TrinityCore
Loading...
Searching...
No Matches
zone_hellfire_peninsula.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 "ScriptMgr.h"
19#include "CellImpl.h"
20#include "Containers.h"
21#include "GridNotifiersImpl.h"
22#include "Log.h"
23#include "MotionMaster.h"
24#include "ObjectAccessor.h"
25#include "Player.h"
26#include "ScriptedEscortAI.h"
27#include "ScriptedGossip.h"
28#include "SpellScript.h"
29#include "TemporarySummon.h"
30
41
59
61{
62 { -707.123f, 2751.686f, 101.592f, 4.577416f }, //Barada Waypoint-1 0
63 { -710.731f, 2749.075f, 101.592f, 1.513286f }, //Barada Cast position 1
64 { -710.332f, 2754.394f, 102.948f, 3.207566f }, //Jules 2
65 { -714.261f, 2747.754f, 103.391f, 0.0f }, //Jules Waypoint-1 3
66 { -713.113f, 2750.194f, 103.391f, 0.0f }, //Jules Waypoint-2 4
67 { -710.385f, 2750.896f, 103.391f, 0.0f }, //Jules Waypoint-3 5
68 { -708.309f, 2750.062f, 103.391f, 0.0f }, //Jules Waypoint-4 6
69 { -707.401f, 2747.696f, 103.391f, 0.0f }, //Jules Waypoint-5 7
70 { -708.591f, 2745.266f, 103.391f, 0.0f }, //Jules Waypoint-6 8
71 { -710.597f, 2744.035f, 103.391f, 0.0f }, //Jules Waypoint-7 9
72 { -713.089f, 2745.302f, 103.391f, 0.0f }, //Jules Waypoint-8 10
73};
74
90
92{
95
96 //Colonel Jules
98};
99
100/*######
101## npc_colonel_jules
102######*/
103
105{
106public:
107 npc_colonel_jules() : CreatureScript("npc_colonel_jules") { }
108
110 {
112 {
113 Initialize();
114 }
115
117 {
118 point = 3;
119 wpreached = false;
120 success = false;
121 }
122
123 void Reset() override
124 {
125 events.Reset();
126
128 Initialize();
129 }
130
132
133 void DoAction(int32 action) override
134 {
135 switch (action)
136 {
140
141 me->SetFacingTo(3.207566f);
142 me->GetMotionMaster()->MovePoint(11, exorcismPos[2], false, {}, 1.25f);
143
144 success = false;
145
147 break;
150
153
154 wpreached = true;
156 break;
158 wpreached = false;
159 me->SetSpeedRate(MOVE_RUN, 1.0f);
161
163 break;
164 }
165 }
166
167 void JustSummoned(Creature* summon) override
168 {
169 summons.Summon(summon);
170 summon->GetMotionMaster()->MoveRandom(10.0f);
171 }
172
173 void MovementInform(uint32 type, uint32 id) override
174 {
175 if (type != POINT_MOTION_TYPE)
176 return;
177
178 if (id < 10)
179 wpreached = true;
180
181 if (id == 8)
182 {
183 for (uint8 i = 0; i < 2; i++)
185 }
186
187 if (id == 10)
188 {
189 wpreached = true;
190 point = 3;
191 }
192 }
193
194 void UpdateAI(uint32 diff) override
195 {
196 if (wpreached)
197 {
199 point++;
200 wpreached = false;
201 }
202
203 events.Update(diff);
204
205 while (uint32 eventId = events.ExecuteEvent())
206 {
207 switch (eventId)
208 {
210 uint8 summonCount = urand(1, 3);
211
212 for (uint8 i = 0; i < summonCount; i++)
214
216 break;
217 }
218 }
219 }
220
221 bool OnGossipHello(Player* player) override
222 {
223 if (success)
225
226 SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID());
227 return true;
228 }
229
230 private:
233
235
237 };
238
239 CreatureAI* GetAI(Creature* creature) const override
240 {
241 return new npc_colonel_julesAI(creature);
242 }
243};
244
245/*######
246## npc_barada
247######*/
248
250{
251public:
252 npc_barada() : CreatureScript("npc_barada") { }
253
254 struct npc_baradaAI : public ScriptedAI
255 {
256 npc_baradaAI(Creature* creature) : ScriptedAI(creature)
257 {
258 Initialize();
259 }
260
262 {
263 step = 0;
264 }
265
266 void Reset() override
267 {
268 events.Reset();
269 Initialize();
270
274 }
275
276 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
277 {
278 ClearGossipMenuFor(player);
279 switch (gossipListId)
280 {
281 case 1:
282 CloseGossipMenuFor(player);
283 me->AI()->Talk(SAY_BARADA_1);
286 break;
287 default:
288 break;
289 }
290 return false;
291 }
292
293 void DoAction(int32 action) override
294 {
295 if (action == ACTION_START_EVENT)
296 {
297 if (Creature* jules = me->FindNearestCreature(NPC_COLONEL_JULES, 20.0f, true))
298 {
299 julesGUID = jules->GetGUID();
300 jules->AI()->Talk(SAY_JULES_1);
301 }
302
305
307 }
308 }
309
310 void MovementInform(uint32 type, uint32 id) override
311 {
312 if (type != POINT_MOTION_TYPE)
313 return;
314
315 if (id == 0)
317
318 if (id == 1)
320 }
321
322 void JustDied(Unit* /*killer*/) override
323 {
325 {
326 jules->AI()->DoAction(ACTION_JULES_MOVE_HOME);
327 jules->RemoveAllAuras();
328 }
329 }
330
331 void UpdateAI(uint32 diff) override
332 {
333 events.Update(diff);
334
335 while (uint32 eventId = events.ExecuteEvent())
336 {
337 switch (eventId)
338 {
340 switch (step)
341 {
342 case 0:
343 me->SetFacingTo(1.513286f);
344
347 step++;
348 break;
349 case 1:
352 step++;
353 break;
354 case 2:
357 step++;
358 break;
359 case 3:
361 jules->AI()->Talk(SAY_JULES_2);
362
364 step++;
365 break;
366 case 4:
369
371 jules->AI()->DoAction(ACTION_JULES_HOVER);
372
374 step++;
375 break;
376 case 5:
378 jules->AI()->Talk(SAY_JULES_3);
379
381 step++;
382 break;
383 case 6:
386 step++;
387 break;
388 case 7:
390 jules->AI()->Talk(SAY_JULES_3);
391
393 step++;
394 break;
395 case 8:
398 step++;
399 break;
400 case 9:
402 jules->AI()->Talk(SAY_JULES_4);
403
405 step++;
406 break;
407 case 10:
410 step++;
411 break;
412 case 11:
414 jules->AI()->DoAction(ACTION_JULES_FLIGHT);
415
417 step++;
418 break;
419 case 12:
421 jules->AI()->Talk(SAY_JULES_4);
422
424 step++;
425 break;
426 case 13:
429 step++;
430 break;
431 case 14:
433 jules->AI()->Talk(SAY_JULES_4);
434
436 step++;
437 break;
438 case 15:
441 step++;
442 break;
443 case 16:
445 jules->AI()->Talk(SAY_JULES_5);
446
448 step++;
449 break;
450 case 17:
453 step++;
454 break;
455 case 18:
457 jules->AI()->Talk(SAY_JULES_3);
458
460 step++;
461 break;
462 case 19:
465 step++;
466 break;
467 case 20:
469 {
470 jules->AI()->DoAction(ACTION_JULES_MOVE_HOME);
471 jules->RemoveAura(SPELL_JULES_VOMITS_AURA);
472 }
473
475 step++;
476 break;
477 case 21:
478 //End
480 {
481 ENSURE_AI(npc_colonel_jules::npc_colonel_julesAI, jules->AI())->success = true;
482 jules->RemoveAllAuras();
483 }
484
487
492 break;
493 }
494 break;
495 case EVENT_RESET:
497 ENSURE_AI(npc_colonel_jules::npc_colonel_julesAI, jules->AI())->success = false;
498 break;
499 }
500 }
501 }
502
503 private:
508 };
509
510 CreatureAI* GetAI(Creature* creature) const override
511 {
512 return new npc_baradaAI(creature);
513 }
514};
515
528
530{
531public:
532 npc_magister_aledis() : CreatureScript("npc_magister_aledis") { }
533
535 {
536 npc_magister_aledisAI(Creature* creature) : ScriptedAI(creature) { }
537
538 void StartFight(Player* player)
539 {
540 me->Dismount();
541 me->SetFacingToObject(player);
543 _playerGUID = player->GetGUID();
545 }
546
547 void Reset() override
548 {
552 me->SetImmuneToPC(true);
553 }
554
555 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
556 {
557 if (damage > me->GetHealth() || me->HealthBelowPctDamaged(20, damage))
558 {
559 damage = 0;
560
561 _events.Reset();
564 me->CombatStop(true);
567 me->SetImmuneToPC(true);
569
571 }
572 }
573
574 void UpdateAI(uint32 diff) override
575 {
576 _events.Update(diff);
577
578 while (uint32 eventId = _events.ExecuteEvent())
579 {
580 switch (eventId)
581 {
582 case EVENT_TALK:
585 break;
586 case EVENT_ATTACK:
587 me->SetImmuneToPC(false);
590 me->EngageWithTarget(player);
593 break;
594 case EVENT_FIREBALL:
597 break;
598 case EVENT_FROSTNOVA:
601 break;
602 case EVENT_EVADE:
604 break;
605 }
606 }
607
608 if (!UpdateVictim())
609 return;
610 }
611
612 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 /*gossipListId*/) override
613 {
614 CloseGossipMenuFor(player);
615 me->StopMoving();
616 StartFight(player);
617 return true;
618 }
619
620 private:
623 };
624
625 CreatureAI* GetAI(Creature* creature) const override
626 {
627 return new npc_magister_aledisAI(creature);
628 }
629};
630
646
648{
650
651 void OnGameEvent(bool start, uint16 eventId) override
652 {
653 if (eventId == GAME_EVENT_HELLFIRE && start)
654 {
655 _events.Reset();
657 }
658 }
659
660 void UpdateAI(uint32 diff) override
661 {
662 _events.Update(diff);
663
664 while (uint32 eventId = _events.ExecuteEvent())
665 {
666 switch (eventId)
667 {
668 case EVENT_START:
669 {
672
673 std::list<Creature*> dummies;
675 {
678 Cell::VisitAllObjects(me, searcher, 500.0f);
679 }
680
681 for (Creature* dummy : dummies)
682 if (dummy->GetCreatureData()->movementType == 0)
683 dummy->AI()->SetData(EVENT_START, 0);
684 break;
685 }
686 }
687 }
688
689 if (!UpdateVictim())
690 return;
691 }
692
693private:
695};
696
698{
700
701 void SetData(uint32 type, uint32 /*data*/) override
702 {
703 if (type != EVENT_START)
704 return;
705
709 }
710
712 {
713 _targets.clear();
714
715 std::vector<Creature*> others;
718 Cell::VisitAllObjects(me, searcher, 500.0f);
719 for (Creature* other : others)
720 if (other->GetCreatureData()->movementType == 2)
721 _targets.push_back(other->GetGUID());
722 }
723
724 void UpdateAI(uint32 diff) override
725 {
726 _events.Update(diff);
727
728 while (uint32 eventId = _events.ExecuteEvent())
729 {
730 switch (eventId)
731 {
732 case EVENT_CAST:
733 {
735 {
738 me->CastSpell(target, SPELL_INFERNAL_RAIN, args);
739 }
740
741 _events.Repeat(1s, 2s);
742 break;
743 }
744 case EVENT_END:
745 _events.Reset();
746 break;
747 }
748 }
749 }
750
751 private:
753 std::vector<ObjectGuid> _targets;
754};
755
757{
758 npc_fear_controller(Creature* creature) : ScriptedAI(creature) { }
759
760 void SetData(uint32 type, uint32 /*data*/) override
761 {
762 if (type != EVENT_START)
763 return;
764
767 }
768
769 void UpdateAI(uint32 diff) override
770 {
771 _events.Update(diff);
772
773 while (uint32 eventId = _events.ExecuteEvent())
774 {
775 switch (eventId)
776 {
777 case EVENT_CAST:
779 _events.Repeat(10s);
780 break;
781 case EVENT_END:
782 _events.Reset();
783 break;
784 }
785 }
786 }
787
788 private:
790};
791
792/*######
793## Quest 10909: Fel Spirits
794######*/
795
801
802// 39190 - Send Vengeance
804{
805 bool Validate(SpellInfo const* /*spellInfo*/) override
806 {
808 }
809
810 void HandleScript(SpellEffIndex /*effIndex*/)
811 {
812 if (TempSummon* target = GetHitUnit()->ToTempSummon())
813 if (Unit* summoner = target->GetSummonerUnit())
814 target->CastSpell(summoner, SPELL_SEND_VENGEANCE_TO_PLAYER, true);
815 }
816
821};
822
823// 39202 - Send Vengeance to Player
841
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
@ TEMPSUMMON_MANUAL_DESPAWN
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void ClearGossipMenuFor(Player *player)
void CloseGossipMenuFor(Player *player)
SpellEffIndex
@ EFFECT_0
@ EMOTE_ONESHOT_KNEEL
@ EMOTE_STAND_STATE_NONE
@ EMOTE_ONESHOT_SHOUT
@ SPELL_EFFECT_SCRIPT_EFFECT
@ FACTION_MONSTER_2
@ SPELLVALUE_MAX_TARGETS
#define SpellEffectFn(F, I, N)
#define ENSURE_AI(a, b)
Definition UnitAI.h:30
@ MOVE_RUN
@ UNIT_NPC_FLAG_GOSSIP
@ UNIT_NPC_FLAG_QUESTGIVER
DamageEffectType
@ UNIT_FLAG_PACIFIED
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
void EngagementOver()
void SetImmuneToPC(bool apply) override
Definition Creature.h:184
CreatureAI * AI() const
Definition Creature.h:228
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void CancelEvent(uint32 eventId)
Definition EventMap.cpp:135
void Reset()
Definition EventMap.cpp:25
void MoveRandom(float wanderDistance=0.0f, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::ForceWalk, MovementSlot slot=MOTION_SLOT_DEFAULT, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
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 MoveTargetedHome()
static ObjectGuid const Empty
Definition ObjectGuid.h:314
void Clear()
Definition ObjectGuid.h:329
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition Player.cpp:16679
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition Player.cpp:14269
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void Summon(Creature const *summon)
virtual void DoAction(int32 param)
Definition UnitAI.h:73
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition Unit.cpp:6012
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3828
void RestoreFaction()
Definition Unit.cpp:12048
void SetFaction(uint32 faction) override
Definition Unit.h:872
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void Dismount()
Definition Unit.cpp:8317
void SetFacingToObject(WorldObject const *object, bool force=true)
Definition Unit.cpp:13307
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:12249
void StopMoving()
Definition Unit.cpp:10680
void RemoveNpcFlag(NPCFlags flags)
Definition Unit.h:998
uint64 GetHealth() const
Definition Unit.h:788
void SetNpcFlag(NPCFlags flags)
Definition Unit.h:997
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
void EngageWithTarget(Unit *who)
Definition Unit.cpp:8494
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition Unit.cpp:8942
void SetFacingTo(float const ori, bool force=true)
Definition Unit.cpp:13289
void RemoveAllAuras()
Definition Unit.cpp:4382
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition Unit.cpp:1657
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:847
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
TC_GAME_API Player * GetPlayer(Map 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
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:203
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetPositionZ() const
Definition Position.h:89
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
void MovementInform(uint32 type, uint32 id) override
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override
void MovementInform(uint32 type, uint32 id) override
void SetData(uint32 type, uint32) override
void UpdateAI(uint32 diff) override
npc_fear_controller(Creature *creature)
npc_infernal_rain_hellfire(Creature *creature)
std::vector< ObjectGuid > _targets
void SetData(uint32 type, uint32) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
bool OnGossipSelect(Player *player, uint32, uint32) override
void OnGameEvent(bool start, uint16 eventId) override
void UpdateAI(uint32 diff) override
npc_watch_commander_leonus(Creature *creature)
@ ACTION_JULES_MOVE_HOME
@ QUEST_THE_EXORCISM_OF_COLONEL_JULES
@ NPC_DARKNESS_RELEASED
@ BARADAS_GOSSIP_MESSAGE
@ SPELL_JULES_THREATENS_AURA
@ SPELL_JULES_GOES_PRONE
@ SPELL_JULES_VOMITS_AURA
@ SPELL_BARADAS_COMMAND
@ SPELL_JULES_GOES_UPRIGHT
@ SPELL_SEND_VENGEANCE_TO_PLAYER
@ SPELL_SUMMON_FEL_SPIRIT
Position const exorcismPos[11]
void AddSC_hellfire_peninsula()