TrinityCore
zone_dun_morogh_area_coldridge_valley.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "Containers.h"
19#include "ScriptMgr.h"
20#include "CombatAI.h"
21#include "MotionMaster.h"
22#include "MoveSplineInit.h"
23#include "ObjectAccessor.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "SpellInfo.h"
27#include "SpellScript.h"
28#include "TemporarySummon.h"
29
31{
39};
40
41/*######
42# wounded_coldridge_mountaineer
43######*/
44
46{
47public:
48 npc_wounded_coldridge_mountaineer() : CreatureScript("npc_wounded_coldridge_mountaineer") { }
49
51 {
53
54 void Reset() override
55 {
56 _events.Reset();
58 _tapped = false;
59 }
60
61 void SpellHit(WorldObject* caster, SpellInfo const* spell) override
62 {
63 if (_tapped)
64 return;
65
67 {
68 if (caster->GetTypeId() == TYPEID_PLAYER)
69 {
70 _tapped = true;
71 _playerGUID = caster->GetGUID();
75 }
76 }
77 }
78
79 void UpdateAI(uint32 diff) override
80 {
81 if (!_tapped)
82 return;
83
84 _events.Update(diff);
85
86 while (uint32 eventId = _events.ExecuteEvent())
87 {
88 switch (eventId)
89 {
93 break;
97 break;
99 if (Creature* joren = me->FindNearestCreature(NPC_JOREN_IRONSTOCK, 75.0f, true))
100 me->GetMotionMaster()->MovePoint(0, joren->GetPosition(), true);
102 break;
103 default:
104 break;
105 }
106 }
107 }
108 private:
112 };
113
114 CreatureAI* GetAI(Creature* creature) const override
115 {
116 return new npc_wounded_coldridge_mountaineerAI(creature);
117 }
118};
119
120/*####
121## npc_wounded_milita
122####*/
123
125{
130
132{
133public:
134 npc_wounded_milita() : CreatureScript("npc_wounded_milita") { }
135
137 {
139 {
140 Initialize();
141 }
142
144 {
145 _hitBySpell = false;
146 _percentHP = urand(15, 55);
147 }
148
149 void Reset() override
150 {
151 Initialize();
153 }
154
155 void SpellHit(WorldObject* caster, SpellInfo const* spell) override
156 {
157 if (!_hitBySpell)
158 {
159 _hitBySpell = true;
161 }
162
163 if (spell->Id == SPELL_FLASH_HEAL)
164 if (Player* player = caster->ToPlayer())
165 player->KilledMonsterCredit(QUEST_KILL_CREDIT);
166 }
167
168 void UpdateAI(uint32 diff) override
169 {
170 if (!_hitBySpell)
171 return;
172
173 _events.Update(diff);
174
175 while (uint32 eventId = _events.ExecuteEvent())
176 {
177 switch (eventId)
178 {
181 _hitBySpell = false;
182 break;
183 default:
184 break;
185 }
186 }
187 }
188 private:
192 };
193
194 CreatureAI* GetAI(Creature* creature) const override
195 {
196 return new npc_wounded_militaAI(creature);
197 }
198};
199
200/*######
201## npc_milos_gyro
202######*/
203
205{
206 NPC_MILO = 37518,
226
228{
229 { -6247.328f, 299.5365f, 390.266f },
230 { -6247.328f, 299.5365f, 390.266f },
231 { -6250.934f, 283.5417f, 393.46f },
232 { -6253.335f, 252.7066f, 403.0702f },
233 { -6257.292f, 217.4167f, 424.3807f },
234 { -6224.2f, 159.9861f, 447.0882f },
235 { -6133.597f, 164.3177f, 491.0316f },
236 { -6084.236f, 183.375f, 508.5401f },
237 { -6020.382f, 179.5052f, 521.5396f },
238 { -5973.592f, 161.7396f, 521.5396f },
239 { -5953.665f, 151.6111f, 514.5687f },
240 { -5911.031f, 146.4462f, 482.1806f },
241 { -5886.389f, 124.125f, 445.6252f },
242 { -5852.08f, 55.80903f, 406.7922f },
243 { -5880.707f, 12.59028f, 406.7922f },
244 { -5927.887f, -74.02257f, 406.7922f },
245 { -5988.436f, -152.0174f, 425.6251f },
246 { -6015.274f, -279.467f, 449.528f },
247 { -5936.465f, -454.1875f, 449.528f },
248 { -5862.575f, -468.0504f, 444.3899f },
249 { -5783.58f, -458.6042f, 432.5026f },
250 { -5652.707f, -463.4427f, 415.0308f },
251 { -5603.897f, -466.3438f, 409.8931f },
252 { -5566.957f, -472.5642f, 399.0056f }
253};
254size_t const pathSize = std::extent<decltype(kharanosPath)>::value;
255
257{
258public:
259 npc_milos_gyro() : CreatureScript("npc_milos_gyro") { }
260
262 {
263 npc_milos_gyro_AI(Creature* creature) : VehicleAI(creature), _waitBeforePath(true) { }
264
265 void Reset() override
266 {
267 _events.Reset();
269 _waitBeforePath = true;
270 }
271
272 void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override
273 {
274 if (apply && passenger->GetTypeId() == TYPEID_PLAYER)
275 {
277 {
278 _waitBeforePath = false;
279 _miloGUID = milo->GetGUID();
280 milo->CastSpell(me, SPELL_RIDE_VEHICLE_HARD_CODED);
282 }
283 }
284 }
285
286 void MovementInform(uint32 type, uint32 pointId) override
287 {
288 if (type == EFFECT_MOTION_TYPE && pointId == pathSize)
290 }
291
292 void UpdateAI(uint32 diff) override
293 {
294 if (_waitBeforePath)
295 return;
296
297 _events.Update(diff);
298
300 return;
301
302 while (uint32 eventId = _events.ExecuteEvent())
303 {
304 switch (eventId)
305 {
306 case EVENT_START_PATH:
309 break;
310 case EVENT_MILO_SAY_0:
312 milo->AI()->Talk(SAY_MILO_FLIGHT_1, me);
314 break;
315 case EVENT_MILO_SAY_1:
317 milo->AI()->Talk(SAY_MILO_FLIGHT_2, me);
319 break;
320 case EVENT_MILO_SAY_2:
322 milo->AI()->Talk(SAY_MILO_FLIGHT_3, me);
324 break;
325 case EVENT_MILO_SAY_3:
327 milo->AI()->Talk(SAY_MILO_FLIGHT_4, me);
329 break;
330 case EVENT_MILO_SAY_4:
332 milo->AI()->Talk(SAY_MILO_FLIGHT_5, me);
334 break;
335 case EVENT_MILO_SAY_5:
337 milo->AI()->Talk(SAY_MILO_FLIGHT_6, me);
339 break;
340 case EVENT_MILO_SAY_6:
342 milo->AI()->Talk(SAY_MILO_FLIGHT_7, me);
343 break;
347 milo->DespawnOrUnsummon();
348 _waitBeforePath = true;
349 break;
350 default:
351 break;
352 }
353 }
354 }
355 private:
359 };
360
361 CreatureAI* GetAI(Creature* creature) const override
362 {
363 return new npc_milos_gyro_AI(creature);
364 }
365};
366
367/*######
368# spell_a_trip_to_ironforge_quest_complete
369# 70046 - A Trip to Ironforge - Quest Complete
370######*/
371
373{
374public:
375 spell_a_trip_to_ironforge_quest_complete() : SpellScriptLoader("spell_a_trip_to_ironforge_quest_complete") { }
376
378 {
380 {
381 PreventHitDefaultEffect(effIndex);
382 GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell, true);
383 }
384
385 void Register() override
386 {
388 }
389 };
390
391 SpellScript* GetSpellScript() const override
392 {
394 }
395};
396
397/*######
398# spell_follow_that_gyrocopter_quest_start
399# 70047 - Follow That Gyro-Copter - Quest Start
400######*/
401
403{
404public:
405 spell_follow_that_gyrocopter_quest_start() : SpellScriptLoader("spell_follow_that_gyrocopter_quest_start") { }
406
408 {
410 {
411 PreventHitDefaultEffect(effIndex);
412 GetHitUnit()->CastSpell(GetHitUnit(), GetEffectInfo().TriggerSpell, true);
413 }
414
415 void Register() override
416 {
418 }
419 };
420
421 SpellScript* GetSpellScript() const override
422 {
424 }
425};
426
427/*######
428# spell_low_health
429# 76143 - Low Health
430######*/
431
433{
434public:
435 spell_low_health() : SpellScriptLoader("spell_low_health") { }
436
438 {
440 {
441 if (Creature* target = GetHitCreature())
442 {
443 target->SetRegenerateHealth(false);
444 target->SetHealth(target->CountPctFromMaxHealth(10));
445 }
446 }
447
448 void Register() override
449 {
451 }
452 };
453
454 SpellScript* GetSpellScript() const override
455 {
456 return new spell_low_health_SpellScript();
457 }
458};
459
461{
462 { -6237.6807f, 375.5191f, 385.44696f, 5.168368339538574218f },
463 { -6299.6113f, 347.11978f, 377.25546f, 6.068230628967285156f },
464 { -6208.724f, 354.3229f, 387.3534f, 4.338659286499023437f },
465 { -6261.8228f, 371.06598f, 383.35944f, 5.383506298065185546f },
466 { -6253.722f, 340.1389f, 382.50888f, 5.957066535949707031f },
467 { -6286.6113f, 316.9566f, 376.9441f, 6.195390701293945312f },
468 { -6204.599f, 304.64932f, 388.9596f, 2.362043619155883789f }
469};
470
472{
474
476
477 SPELL_SHOOT = 70014
479
480// 37081 - Joren Ironstock
482{
483 npc_joren_ironstock(Creature* creature) : ScriptedAI(creature) { }
484
485 void EnqueueInvader(Unit* invader, Seconds minTime = 1s, Seconds maxTime = 9s)
486 {
487 _scheduler.Schedule(minTime, maxTime, [this, guid = invader->GetGUID()](TaskContext /*task*/)
488 {
489 _invadersToShoot.push(guid);
490 });
491 }
492
493 void JustAppeared() override
494 {
495 _scheduler.Schedule(1s, [this](TaskContext task)
496 {
498 {
499 if (me->HasInArc(float(M_PI), invader) && !me->IsInCombat())
500 EnqueueInvader(invader, 1s, 3s);
501 else
502 EnqueueInvader(invader, 5s, 8s);
503 invader->AI()->AttackStart(me);
504 }
505 task.Repeat(3s, 20s);
506 });
507
508 _scheduler.Schedule(1s, [this](TaskContext task)
509 {
510 if (!_invadersToShoot.empty())
511 {
512 ObjectGuid guid = _invadersToShoot.front();
513 _invadersToShoot.pop();
514
515 Creature* invader = ObjectAccessor::GetCreature(*me, guid);
516 if (invader && invader->IsAlive())
517 {
518 SpellCastResult result = DoCast(invader, SPELL_SHOOT);
519 if (result == SpellCastResult::SPELL_CAST_OK)
520 {
521 if (roll_chance_i(50))
522 Talk(SAY_SHOOT_ROCKJAW, invader);
523 }
524 else
525 _invadersToShoot.push(guid);
526 }
527 }
528 task.Repeat(1s);
529 });
530 }
531
532 void UpdateAI(uint32 diff) override
533 {
534 _scheduler.Update(diff);
535
536 if (!UpdateVictim())
537 return;
538 }
539
540private:
542 std::queue<ObjectGuid> _invadersToShoot;
543};
544
546{
548 new npc_wounded_milita();
549 new npc_milos_gyro();
552 new spell_low_health();
554}
uint8_t uint8
Definition: Define.h:144
int8_t int8
Definition: Define.h:140
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
@ EFFECT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: ObjectDefines.h:67
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_FORCE_CAST
@ SPELL_EFFECT_APPLY_AURA
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
@ UNIT_STAND_STATE_STAND
Definition: UnitDefines.h:42
@ UNIT_FLAG_IMMUNE_TO_NPC
Definition: UnitDefines.h:153
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
void MoveSmoothPath(uint32 pointId, Position const *pathPoints, size_t pathSize, bool walk=false, bool fly=false)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void Clear()
Definition: ObjectGuid.h:286
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
uint32 const Id
Definition: SpellInfo.h:325
Creature * GetHitCreature() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
TaskContext & Repeat(std::chrono::duration< Rep, Period > duration)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
Definition: Unit.h:627
void SetHealth(uint64 val)
Definition: Unit.cpp:9346
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:10100
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition: Unit.cpp:12671
uint64 CountPctFromMaxHealth(int32 pct) const
Definition: Unit.h:785
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void RemoveAllAuras()
Definition: Unit.cpp:4242
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
SpellScript * GetSpellScript() const override
void apply(T *val)
Definition: ByteConverter.h:41
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
void EnqueueInvader(Unit *invader, Seconds minTime=1s, Seconds maxTime=9s)
void PassengerBoarded(Unit *passenger, int8, bool apply) override
== Fields =======================================
void MovementInform(uint32 type, uint32 pointId) override
void SpellHit(WorldObject *caster, SpellInfo const *spell) override
Position const RockjawInvaderSpawnPoints[7]
Position const kharanosPath[]
void AddSC_dun_morogh_area_coldridge_valley()