TrinityCore
boss_infinite_corruptor.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
19#include "InstanceScript.h"
20#include "MotionMaster.h"
21#include "ScriptedCreature.h"
22#include "ScriptMgr.h"
23#include "SpellInfo.h"
24
26{
31};
32
34{
37 SAY_FAIL = 2
38};
39
41{
44};
45
47{
50};
51
52enum Misc
53{
55};
56
58{
59 public:
60 boss_infinite_corruptor() : CreatureScript("boss_infinite_corruptor") { }
61
63 {
65
66 void Reset() override
67 {
68 _Reset();
69 DoCastAOE(SPELL_CORRUPTION_OF_TIME_CHANNEL); // implicitly targets the Guardian
70 }
71
72 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
73 {
74 if (spellInfo->Id == SPELL_CORRUPTION_OF_TIME_CHANNEL)
75 target->CastSpell(target, SPELL_CORRUPTION_OF_TIME_TARGET, true);
76 }
77
78 void JustEngagedWith(Unit* who) override
79 {
84 }
85
86 void JustDied(Unit* /*killer*/) override
87 {
89 _JustDied();
90
91 if (Creature* guardian = me->FindNearestCreature(NPC_GUARDIAN_OF_TIME, 100.0f))
92 {
93 guardian->RemoveAurasDueToSpell(SPELL_CORRUPTION_OF_TIME_TARGET);
94 guardian->DespawnOrUnsummon(5s);
95 }
96
97 if (Creature* rift = me->FindNearestCreature(NPC_TIME_RIFT, 100.0f))
98 rift->DespawnOrUnsummon();
99 }
100
101 void ExecuteEvent(uint32 eventId) override
102 {
103 switch (eventId)
104 {
106 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 60.0f, true))
109 break;
113 break;
114 default:
115 break;
116 }
117 }
118
119 void EnterEvadeMode(EvadeReason why) override
120 {
122 return;
124 }
125
126 void MovementInform(uint32 type, uint32 id) override
127 {
128 if (type == POINT_MOTION_TYPE && id == MOVEMENT_TIME_RIFT)
129 {
132 }
133 }
134
135 void DoAction(int32 action) override
136 {
137 if (action == -ACTION_CORRUPTOR_LEAVE)
138 {
140 Talk(SAY_FAIL);
141 if (Creature* rift = me->FindNearestCreature(NPC_TIME_RIFT, 300.0f))
142 {
143 if (me->IsWithinDist2d(rift, 5.0f))
145 else
146 me->GetMotionMaster()->MovePoint(MOVEMENT_TIME_RIFT, rift->GetPosition()); // @todo offset
147 }
148 else
150 }
151 }
152 };
153
154 CreatureAI* GetAI(Creature* creature) const override
155 {
156 return GetCullingOfStratholmeAI<boss_infinite_corruptorAI>(creature);
157 }
158};
159
161{
163}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
@ FAIL
@ POINT_MOTION_TYPE
Spells
Definition: PlayerAI.cpp:32
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ NPC_GUARDIAN_OF_TIME
@ MOVEMENT_TIME_RIFT
@ SPELL_CORRUPTION_OF_TIME_TARGET
@ SPELL_CORRUPTING_BLIGHT
@ SPELL_CORRUPTION_OF_TIME_CHANNEL
void AddSC_boss_infinite_corruptor()
@ EVENT_CORRUPTING_BLIGHT
Yells
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
bool HasReactState(ReactStates state) const
Definition: Creature.h:162
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
virtual bool SetBossState(uint32 id, EncounterState state)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
uint32 const Id
Definition: SpellInfo.h:325
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsWithinDist2d(float x, float y, float dist) const
Definition: Object.cpp:1132
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
CreatureAI * GetAI(Creature *creature) const override
@ DATA_INFINITE_CORRUPTOR
@ ACTION_CORRUPTOR_LEAVE
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override