TrinityCore
boss_erekem.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 "InstanceScript.h"
20#include "MotionMaster.h"
21#include "ObjectAccessor.h"
22#include "ScriptedCreature.h"
23#include "violet_hold.h"
24
26{
34 SPELL_WINDFURY = 54493
35};
36
38{
45};
46
47struct boss_erekem : public BossAI
48{
49 boss_erekem(Creature* creature) : BossAI(creature, DATA_EREKEM)
50 {
51 Initialize();
52 }
53
55 {
56 _phase = 0;
57 }
58
59 void Reset() override
60 {
61 Initialize();
63 me->SetCanDualWield(false);
64 }
65
66 void JustEngagedWith(Unit* who) override
67 {
71 }
72
73 void MovementInform(uint32 type, uint32 pointId) override
74 {
75 if (type == EFFECT_MOTION_TYPE && pointId == POINT_INTRO)
76 me->SetFacingTo(4.921828f);
77 }
78
79 void JustReachedHome() override
80 {
83 }
84
85 void KilledUnit(Unit* victim) override
86 {
87 if (victim->GetTypeId() == TYPEID_PLAYER)
89 }
90
91 void JustDied(Unit* /*killer*/) override
92 {
94 _JustDied();
95 }
96
97 bool CheckGuardAuras(Creature* guard) const
98 {
99 static uint32 const MechanicImmunityList =
100 (1 << MECHANIC_SNARE)
101 | (1 << MECHANIC_ROOT)
102 | (1 << MECHANIC_FEAR)
103 | (1 << MECHANIC_STUN)
104 | (1 << MECHANIC_SLEEP)
105 | (1 << MECHANIC_CHARM)
106 | (1 << MECHANIC_SAPPED)
107 | (1 << MECHANIC_HORROR)
108 | (1 << MECHANIC_POLYMORPH)
109 | (1 << MECHANIC_DISORIENTED)
110 | (1 << MECHANIC_FREEZE)
111 | (1 << MECHANIC_TURN);
112
113 static std::list<AuraType> const AuraImmunityList =
114 {
120 };
121
122 if (guard->HasAuraWithMechanic(MechanicImmunityList))
123 return true;
124
125 for (AuraType type : AuraImmunityList)
126 if (guard->HasAuraType(type))
127 return true;
128
129 return false;
130 }
131
132 bool CheckGuardAlive() const
133 {
135 {
137 if (guard->IsAlive())
138 return true;
139 }
140
141 return false;
142 }
143
145 {
146 if (HealthBelowPct(85))
147 return me;
148
150 {
152 if (guard->IsAlive() && !guard->HealthAbovePct(75))
153 return guard;
154 }
155
156 return nullptr;
157 }
158
159 void UpdateAI(uint32 diff) override
160 {
161 if (!UpdateVictim())
162 return;
163
164 if (_phase == 0 && !CheckGuardAlive())
165 {
166 _phase = 1;
167 me->SetCanDualWield(true);
168 DoCast(me, SPELL_WINDFURY, true);
169 }
170
171 scheduler.Update(diff, [this]
172 {
173 if (_phase == 1)
175 });
176 }
177
178 void ScheduleTasks() override
179 {
180 scheduler.Schedule(Seconds(20), [this](TaskContext task)
181 {
182 if (Unit* ally = DoSelectLowestHpFriendly(30.0f))
184
185 task.Repeat(Seconds(20));
186 });
187
188 scheduler.Schedule(Seconds(2), [this](TaskContext task)
189 {
191 task.Repeat(Seconds(35), Seconds(45));
192 });
193
194 scheduler.Schedule(Seconds(2), [this](TaskContext task)
195 {
196 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f))
198
199 task.Repeat(Milliseconds(2500));
200 });
201
202 scheduler.Schedule(Seconds(10), [this](TaskContext task)
203 {
204 if (Unit* ally = DoSelectLowestHpFriendly(40.0f))
206
207 if (!CheckGuardAlive())
208 task.Repeat(Seconds(3));
209 else
210 task.Repeat(Seconds(8), Seconds(11));
211 });
212
213 scheduler.Schedule(Seconds(2), Seconds(8), [this](TaskContext task)
214 {
216 task.Repeat(Seconds(8), Seconds(13));
217 });
218
219 scheduler.Schedule(0s, [this](TaskContext task)
220 {
222 {
224
225 if (guard && guard->IsAlive() && CheckGuardAuras(guard))
226 {
228 task.Repeat(Seconds(10));
229 return;
230 }
231 }
232 task.Repeat(Milliseconds(500));
233 });
234 }
235
236private:
238};
239
241{
244 SPELL_STRIKE = 14516
246
248{
249 npc_erekem_guard(Creature* creature) : ScriptedAI(creature) { }
250
251 void Reset() override
252 {
254 }
255
256 void JustEngagedWith(Unit* /*who*/) override
257 {
259 }
260
261 void UpdateAI(uint32 diff) override
262 {
263 if (!UpdateVictim())
264 return;
265
266 scheduler.Update(diff);
267 }
268
270 {
271 scheduler.Schedule(Seconds(4), Seconds(8), [this](TaskContext task)
272 {
274 task.Repeat(Seconds(4), Seconds(8));
275 });
276
277 scheduler.Schedule(Seconds(8), Seconds(13), [this](TaskContext task)
278 {
280 task.Repeat(Seconds(8), Seconds(13));
281 });
282
283 scheduler.Schedule(Seconds(1), Seconds(3), [this](TaskContext task)
284 {
286 task.Repeat(Seconds(7), Seconds(12));
287 });
288 }
289
290private:
292};
293
295{
298}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ EFFECT_MOTION_TYPE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
@ MECHANIC_FEAR
@ MECHANIC_DISORIENTED
@ MECHANIC_CHARM
@ MECHANIC_TURN
@ MECHANIC_STUN
@ MECHANIC_FREEZE
@ MECHANIC_ROOT
@ MECHANIC_SLEEP
@ MECHANIC_POLYMORPH
@ MECHANIC_SNARE
@ MECHANIC_SAPPED
@ MECHANIC_HORROR
AuraType
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_MOD_ROOT
@ SPELL_AURA_MOD_DECREASE_SPEED
@ SPELL_AURA_MOD_CONFUSE
@ SPELL_AURA_MOD_STUN
@ SAY_DEATH
Definition: boss_erekem.cpp:41
@ SAY_AGGRO
Definition: boss_erekem.cpp:39
@ SAY_ADD_KILLED
Definition: boss_erekem.cpp:43
@ SAY_BOTH_ADDS_KILLED
Definition: boss_erekem.cpp:44
@ SAY_SLAY
Definition: boss_erekem.cpp:40
@ SAY_SPAWN
Definition: boss_erekem.cpp:42
@ SPELL_WINDFURY
Definition: boss_erekem.cpp:34
@ SPELL_BLOODLUST
Definition: boss_erekem.cpp:27
@ SPELL_STORMSTRIKE
Definition: boss_erekem.cpp:33
@ SPELL_BREAK_BONDS
Definition: boss_erekem.cpp:28
@ SPELL_CHAIN_HEAL
Definition: boss_erekem.cpp:29
@ SPELL_EARTH_SHIELD
Definition: boss_erekem.cpp:30
@ SPELL_LIGHTNING_BOLT
Definition: boss_erekem.cpp:32
@ SPELL_EARTH_SHOCK
Definition: boss_erekem.cpp:31
void AddSC_boss_erekem()
GuardSpells
@ SPELL_STRIKE
@ SPELL_HOWLING_SCREECH
@ SPELL_GUSHING_WOUND
Yells
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
void JustReachedHome() override
void Reset() override
void _JustDied()
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetCanDualWield(bool value) override
Definition: Creature.cpp:1940
virtual ObjectGuid GetGuidData(uint32 type) const override
TypeID GetTypeId() const
Definition: Object.h:173
TaskContext & Repeat(std::chrono::duration< Rep, Period > duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
bool DoSpellAttackIfReady(uint32 spellId)
Definition: UnitAI.cpp:61
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
bool IsAlive() const
Definition: Unit.h:1164
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4674
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
bool HasAuraWithMechanic(uint64 mechanicMask) const
Definition: Unit.cpp:4739
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Unit * DoSelectLowestHpFriendly(float range, uint32 minHPDiff=1)
bool HealthBelowPct(uint32 pct) const
bool CheckGuardAlive() const
void JustEngagedWith(Unit *who) override
Definition: boss_erekem.cpp:66
boss_erekem(Creature *creature)
Definition: boss_erekem.cpp:49
void JustReachedHome() override
Definition: boss_erekem.cpp:79
void Reset() override
Definition: boss_erekem.cpp:59
Unit * GetChainHealTarget() const
void UpdateAI(uint32 diff) override
bool CheckGuardAuras(Creature *guard) const
Definition: boss_erekem.cpp:97
void ScheduleTasks() override
void JustDied(Unit *) override
Definition: boss_erekem.cpp:91
void KilledUnit(Unit *victim) override
Definition: boss_erekem.cpp:85
void Initialize()
Definition: boss_erekem.cpp:54
void MovementInform(uint32 type, uint32 pointId) override
Definition: boss_erekem.cpp:73
npc_erekem_guard(Creature *creature)
TaskScheduler scheduler
void Reset() override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
@ DATA_HANDLE_CELLS
Definition: violet_hold.h:87
@ DATA_EREKEM_GUARD_2
Definition: violet_hold.h:71
@ DATA_EREKEM
Definition: violet_hold.h:55
@ DATA_EREKEM_GUARD_1
Definition: violet_hold.h:70
#define RegisterVioletHoldCreatureAI(ai_name)
Definition: violet_hold.h:164
@ POINT_INTRO
Definition: zulaman.cpp:64