TrinityCore
Loading...
Searching...
No Matches
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
36
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
78
79 void KilledUnit(Unit* victim) override
80 {
81 if (victim->GetTypeId() == TYPEID_PLAYER)
83 }
84
85 void JustDied(Unit* /*killer*/) override
86 {
88 _JustDied();
89 }
90
91 bool CheckGuardAuras(Creature* guard) const
92 {
93 static uint32 const MechanicImmunityList =
94 (1 << MECHANIC_SNARE)
95 | (1 << MECHANIC_ROOT)
96 | (1 << MECHANIC_FEAR)
97 | (1 << MECHANIC_STUN)
98 | (1 << MECHANIC_SLEEP)
99 | (1 << MECHANIC_CHARM)
100 | (1 << MECHANIC_SAPPED)
101 | (1 << MECHANIC_HORROR)
102 | (1 << MECHANIC_POLYMORPH)
103 | (1 << MECHANIC_DISORIENTED)
104 | (1 << MECHANIC_FREEZE)
105 | (1 << MECHANIC_TURN);
106
107 static std::list<AuraType> const AuraImmunityList =
108 {
114 };
115
116 if (guard->HasAuraWithMechanic(MechanicImmunityList))
117 return true;
118
119 for (AuraType type : AuraImmunityList)
120 if (guard->HasAuraType(type))
121 return true;
122
123 return false;
124 }
125
126 bool CheckGuardAlive() const
127 {
129 {
131 if (guard->IsAlive())
132 return true;
133 }
134
135 return false;
136 }
137
139 {
140 if (HealthBelowPct(85))
141 return me;
142
144 {
146 if (guard->IsAlive() && !guard->HealthAbovePct(75))
147 return guard;
148 }
149
150 return nullptr;
151 }
152
153 void UpdateAI(uint32 diff) override
154 {
155 if (!UpdateVictim())
156 return;
157
158 if (_phase == 0 && !CheckGuardAlive())
159 {
160 _phase = 1;
161 me->SetCanDualWield(true);
162 DoCast(me, SPELL_WINDFURY, true);
163 }
164
165 scheduler.Update(diff, [this]
166 {
167 if (_phase == 1)
169 });
170 }
171
172 void ScheduleTasks() override
173 {
174 scheduler.Schedule(Seconds(20), [this](TaskContext& task)
175 {
176 if (Unit* ally = DoSelectLowestHpFriendly(30.0f))
178
179 task.Repeat(Seconds(20));
180 });
181
182 scheduler.Schedule(Seconds(2), [this](TaskContext& task)
183 {
185 task.Repeat(Seconds(35), Seconds(45));
186 });
187
188 scheduler.Schedule(Seconds(2), [this](TaskContext& task)
189 {
190 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f))
192
193 task.Repeat(Milliseconds(2500));
194 });
195
196 scheduler.Schedule(Seconds(10), [this](TaskContext& task)
197 {
198 if (Unit* ally = DoSelectLowestHpFriendly(40.0f))
200
201 if (!CheckGuardAlive())
202 task.Repeat(Seconds(3));
203 else
204 task.Repeat(Seconds(8), Seconds(11));
205 });
206
207 scheduler.Schedule(Seconds(2), Seconds(8), [this](TaskContext& task)
208 {
210 task.Repeat(Seconds(8), Seconds(13));
211 });
212
213 scheduler.Schedule(0s, [this](TaskContext& task)
214 {
216 {
218
219 if (guard && guard->IsAlive() && CheckGuardAuras(guard))
220 {
222 task.Repeat(Seconds(10));
223 return;
224 }
225 }
226 task.Repeat(Milliseconds(500));
227 });
228 }
229
230private:
232};
233
240
242{
243 npc_erekem_guard(Creature* creature) : ScriptedAI(creature) { }
244
245 void Reset() override
246 {
248 }
249
250 void JustEngagedWith(Unit* /*who*/) override
251 {
253 }
254
255 void UpdateAI(uint32 diff) override
256 {
257 if (!UpdateVictim())
258 return;
259
260 scheduler.Update(diff);
261 }
262
264 {
265 scheduler.Schedule(Seconds(4), Seconds(8), [this](TaskContext& task)
266 {
268 task.Repeat(Seconds(4), Seconds(8));
269 });
270
271 scheduler.Schedule(Seconds(8), Seconds(13), [this](TaskContext& task)
272 {
274 task.Repeat(Seconds(8), Seconds(13));
275 });
276
277 scheduler.Schedule(Seconds(1), Seconds(3), [this](TaskContext& task)
278 {
280 task.Repeat(Seconds(7), Seconds(12));
281 });
282 }
283
284private:
286};
287
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
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
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_MOD_ROOT
@ SPELL_AURA_MOD_DECREASE_SPEED
@ SPELL_AURA_MOD_CONFUSE
@ SPELL_AURA_MOD_STUN
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_ADD_KILLED
@ SAY_BOTH_ADDS_KILLED
@ SAY_SLAY
@ SAY_SPAWN
@ SPELL_WINDFURY
@ SPELL_BLOODLUST
@ SPELL_STORMSTRIKE
@ SPELL_BREAK_BONDS
@ SPELL_CHAIN_HEAL
@ SPELL_EARTH_SHIELD
@ SPELL_LIGHTNING_BOLT
@ SPELL_EARTH_SHOCK
void AddSC_boss_erekem()
GuardSpells
@ SPELL_STRIKE
@ SPELL_HOWLING_SCREECH
@ SPELL_GUSHING_WOUND
Yells
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
void JustReachedHome() override
void Reset() override
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetCanDualWield(bool value) override
virtual ObjectGuid GetGuidData(uint32 type) const override
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
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:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
bool IsAlive() const
Definition Unit.h:1185
bool HasAuraType(AuraType auraType) const
Definition Unit.cpp:4814
bool HasAuraWithMechanic(uint64 mechanicMask) const
Definition Unit.cpp:4879
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
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
boss_erekem(Creature *creature)
void JustReachedHome() override
void Reset() override
Unit * GetChainHealTarget() const
void UpdateAI(uint32 diff) override
bool CheckGuardAuras(Creature *guard) const
void ScheduleTasks() override
void JustDied(Unit *) override
void KilledUnit(Unit *victim) override
void Initialize()
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)