TrinityCore
Loading...
Searching...
No Matches
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#include "WaypointDefines.h"
30#include <queue>
31
42
43/*######
44# wounded_coldridge_mountaineer
45######*/
46
48{
49public:
50 npc_wounded_coldridge_mountaineer() : CreatureScript("npc_wounded_coldridge_mountaineer") { }
51
53 {
55
56 void Reset() override
57 {
58 _events.Reset();
60 _tapped = false;
61 }
62
63 void SpellHit(WorldObject* caster, SpellInfo const* spell) override
64 {
65 if (_tapped)
66 return;
67
69 {
70 if (caster->GetTypeId() == TYPEID_PLAYER)
71 {
72 _tapped = true;
73 _playerGUID = caster->GetGUID();
74 me->SetImmuneToNPC(true);
77 }
78 }
79 }
80
81 void UpdateAI(uint32 diff) override
82 {
83 if (!_tapped)
84 return;
85
86 _events.Update(diff);
87
88 while (uint32 eventId = _events.ExecuteEvent())
89 {
90 switch (eventId)
91 {
95 break;
99 break;
101 if (Creature* joren = me->FindNearestCreature(NPC_JOREN_IRONSTOCK, 75.0f, true))
102 me->GetMotionMaster()->MovePoint(0, joren->GetPosition(), true);
104 break;
105 default:
106 break;
107 }
108 }
109 }
110 private:
114 };
115
116 CreatureAI* GetAI(Creature* creature) const override
117 {
118 return new npc_wounded_coldridge_mountaineerAI(creature);
119 }
120};
121
122/*####
123## npc_wounded_milita
124####*/
125
132
134{
135public:
136 npc_wounded_milita() : CreatureScript("npc_wounded_milita") { }
137
139 {
141 {
142 Initialize();
143 }
144
146 {
147 _hitBySpell = false;
148 _percentHP = urand(15, 55);
149 }
150
151 void Reset() override
152 {
153 Initialize();
155 }
156
157 void SpellHit(WorldObject* caster, SpellInfo const* spell) override
158 {
159 if (!_hitBySpell)
160 {
161 _hitBySpell = true;
163 }
164
165 if (spell->Id == SPELL_FLASH_HEAL)
166 if (Player* player = caster->ToPlayer())
167 player->KilledMonsterCredit(QUEST_KILL_CREDIT);
168 }
169
170 void UpdateAI(uint32 diff) override
171 {
172 if (!_hitBySpell)
173 return;
174
175 _events.Update(diff);
176
177 while (uint32 eventId = _events.ExecuteEvent())
178 {
179 switch (eventId)
180 {
183 _hitBySpell = false;
184 break;
185 default:
186 break;
187 }
188 }
189 }
190 private:
194 };
195
196 CreatureAI* GetAI(Creature* creature) const override
197 {
198 return new npc_wounded_militaAI(creature);
199 }
200};
201
202/*######
203## npc_milos_gyro
204######*/
205
229
231{
232 PATH_MILO,
233 {
234 { 0, -6247.328f, 299.5365f, 390.266f },
235 { 1, -6247.328f, 299.5365f, 390.266f },
236 { 2, -6250.934f, 283.5417f, 393.46f },
237 { 3, -6253.335f, 252.7066f, 403.0702f },
238 { 4, -6257.292f, 217.4167f, 424.3807f },
239 { 5, -6224.2f, 159.9861f, 447.0882f },
240 { 6, -6133.597f, 164.3177f, 491.0316f },
241 { 7, -6084.236f, 183.375f, 508.5401f },
242 { 8, -6020.382f, 179.5052f, 521.5396f },
243 { 9, -5973.592f, 161.7396f, 521.5396f },
244 { 10, -5953.665f, 151.6111f, 514.5687f },
245 { 11, -5911.031f, 146.4462f, 482.1806f },
246 { 12, -5886.389f, 124.125f, 445.6252f },
247 { 13, -5852.08f, 55.80903f, 406.7922f },
248 { 14, -5880.707f, 12.59028f, 406.7922f },
249 { 15, -5927.887f, -74.02257f, 406.7922f },
250 { 16, -5988.436f, -152.0174f, 425.6251f },
251 { 17, -6015.274f, -279.467f, 449.528f },
252 { 18, -5936.465f, -454.1875f, 449.528f },
253 { 19, -5862.575f, -468.0504f, 444.3899f },
254 { 20, -5783.58f, -458.6042f, 432.5026f },
255 { 21, -5652.707f, -463.4427f, 415.0308f },
256 { 22, -5603.897f, -466.3438f, 409.8931f },
257 { 23, -5566.957f, -472.5642f, 399.0056f }
258 },
261};
262
264{
265public:
266 npc_milos_gyro() : CreatureScript("npc_milos_gyro") { }
267
269 {
270 npc_milos_gyro_AI(Creature* creature) : VehicleAI(creature), _waitBeforePath(true) { }
271
272 void Reset() override
273 {
274 _events.Reset();
276 _waitBeforePath = true;
277 }
278
279 void PassengerBoarded(Unit* passenger, int8 /*seatId*/, bool apply) override
280 {
281 if (apply && passenger->GetTypeId() == TYPEID_PLAYER)
282 {
284 {
285 _waitBeforePath = false;
286 _miloGUID = milo->GetGUID();
287 milo->CastSpell(me, SPELL_RIDE_VEHICLE_HARD_CODED);
289 }
290 }
291 }
292
293 void WaypointPathEnded(uint32 /*pointId*/, uint32 pathId) override
294 {
295 if (pathId == PATH_MILO)
297 }
298
299 void UpdateAI(uint32 diff) override
300 {
301 if (_waitBeforePath)
302 return;
303
304 _events.Update(diff);
305
307 return;
308
309 while (uint32 eventId = _events.ExecuteEvent())
310 {
311 switch (eventId)
312 {
313 case EVENT_START_PATH:
316 break;
317 case EVENT_MILO_SAY_0:
319 milo->AI()->Talk(SAY_MILO_FLIGHT_1, me);
321 break;
322 case EVENT_MILO_SAY_1:
324 milo->AI()->Talk(SAY_MILO_FLIGHT_2, me);
326 break;
327 case EVENT_MILO_SAY_2:
329 milo->AI()->Talk(SAY_MILO_FLIGHT_3, me);
331 break;
332 case EVENT_MILO_SAY_3:
334 milo->AI()->Talk(SAY_MILO_FLIGHT_4, me);
336 break;
337 case EVENT_MILO_SAY_4:
339 milo->AI()->Talk(SAY_MILO_FLIGHT_5, me);
341 break;
342 case EVENT_MILO_SAY_5:
344 milo->AI()->Talk(SAY_MILO_FLIGHT_6, me);
346 break;
347 case EVENT_MILO_SAY_6:
349 milo->AI()->Talk(SAY_MILO_FLIGHT_7, me);
350 break;
354 milo->DespawnOrUnsummon();
355 _waitBeforePath = true;
356 break;
357 default:
358 break;
359 }
360 }
361 }
362 private:
366 };
367
368 CreatureAI* GetAI(Creature* creature) const override
369 {
370 return new npc_milos_gyro_AI(creature);
371 }
372};
373
374/*######
375# spell_a_trip_to_ironforge_quest_complete
376# 70046 - A Trip to Ironforge - Quest Complete
377######*/
378
403
404/*######
405# spell_follow_that_gyrocopter_quest_start
406# 70047 - Follow That Gyro-Copter - Quest Start
407######*/
408
433
434/*######
435# spell_low_health
436# 76143 - Low Health
437######*/
438
440{
441public:
442 spell_low_health() : SpellScriptLoader("spell_low_health") { }
443
445 {
447 {
448 if (Creature* target = GetHitCreature())
449 {
450 target->SetRegenerateHealth(false);
451 target->SetHealth(target->CountPctFromMaxHealth(10));
452 }
453 }
454
459 };
460
461 SpellScript* GetSpellScript() const override
462 {
463 return new spell_low_health_SpellScript();
464 }
465};
466
468{
469 { -6237.6807f, 375.5191f, 385.44696f, 5.168368339538574218f },
470 { -6299.6113f, 347.11978f, 377.25546f, 6.068230628967285156f },
471 { -6208.724f, 354.3229f, 387.3534f, 4.338659286499023437f },
472 { -6261.8228f, 371.06598f, 383.35944f, 5.383506298065185546f },
473 { -6253.722f, 340.1389f, 382.50888f, 5.957066535949707031f },
474 { -6286.6113f, 316.9566f, 376.9441f, 6.195390701293945312f },
475 { -6204.599f, 304.64932f, 388.9596f, 2.362043619155883789f }
476};
477
486
487// 37081 - Joren Ironstock
489{
490 npc_joren_ironstock(Creature* creature) : ScriptedAI(creature) { }
491
492 void EnqueueInvader(Unit* invader, Seconds minTime = 1s, Seconds maxTime = 9s)
493 {
494 _scheduler.Schedule(minTime, maxTime, [this, guid = invader->GetGUID()](TaskContext const& /*task*/)
495 {
496 _invadersToShoot.push(guid);
497 });
498 }
499
500 void JustAppeared() override
501 {
502 _scheduler.Schedule(1s, [this](TaskContext& task)
503 {
505 {
506 if (me->HasInArc(float(M_PI), invader) && !me->IsInCombat())
507 EnqueueInvader(invader, 1s, 3s);
508 else
509 EnqueueInvader(invader, 5s, 8s);
510 invader->AI()->AttackStart(me);
511 }
512 task.Repeat(3s, 20s);
513 });
514
515 _scheduler.Schedule(1s, [this](TaskContext& task)
516 {
517 if (!_invadersToShoot.empty())
518 {
519 ObjectGuid guid = _invadersToShoot.front();
520 _invadersToShoot.pop();
521
522 Creature* invader = ObjectAccessor::GetCreature(*me, guid);
523 if (invader && invader->IsAlive())
524 {
525 SpellCastResult result = DoCast(invader, SPELL_SHOOT);
526 if (result == SpellCastResult::SPELL_CAST_OK)
527 {
528 if (roll_chance(50))
529 Talk(SAY_SHOOT_ROCKJAW, invader);
530 }
531 else
532 _invadersToShoot.push(guid);
533 }
534 }
535 task.Repeat(1s);
536 });
537 }
538
539 void UpdateAI(uint32 diff) override
540 {
541 _scheduler.Update(diff);
542
543 if (!UpdateVictim())
544 return;
545 }
546
547private:
549 std::queue<ObjectGuid> _invadersToShoot;
550};
551
uint8_t uint8
Definition Define.h:156
int8_t int8
Definition Define.h:152
uint32_t uint32
Definition Define.h:154
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
@ TEMPSUMMON_CORPSE_DESPAWN
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
bool roll_chance(T chance)
Definition Random.h:55
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_FORCE_CAST
@ SPELL_EFFECT_APPLY_AURA
SpellCastResult
@ SPELL_CAST_OK
#define SpellEffectFn(F, I, N)
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:42
@ UNIT_STATE_CASTING
Definition Unit.h:276
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void SetImmuneToNPC(bool apply) override
Definition Creature.h:187
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void Clear()
Definition ObjectGuid.h:329
Player * ToPlayer()
Definition Object.h:126
uint32 const Id
Definition SpellInfo.h:328
Creature * GetHitCreature() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetHealth(uint64 val)
Definition Unit.cpp:9973
uint64 CountPctFromMaxHealth(float pct) const
Definition Unit.h:797
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition Unit.cpp:10731
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition Unit.cpp:13307
bool IsAlive() const
Definition Unit.h:1185
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void RemoveAllAuras()
Definition Unit.cpp:4382
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
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:1398
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1517
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
SpellScript * GetSpellScript() const override
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) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
void EnqueueInvader(Unit *invader, Seconds minTime=1s, Seconds maxTime=9s)
void WaypointPathEnded(uint32, uint32 pathId) override
void PassengerBoarded(Unit *passenger, int8, bool apply) override
== Fields =======================================
void SpellHit(WorldObject *caster, SpellInfo const *spell) override
WaypointPath const kharanosPath
Position const RockjawInvaderSpawnPoints[7]
void AddSC_dun_morogh_area_coldridge_valley()