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
34
46
51
52// 29315 - Erekem
53// 32226 - Arakkoa Windwalker
54struct boss_erekem : public BossAI
55{
56 boss_erekem(Creature* creature) : BossAI(creature, DATA_EREKEM)
57 {
58 Initialize();
59 }
60
62 {
63 _phase = 0;
64 _addsKilled = 0;
65 }
66
67 void Reset() override
68 {
69 Initialize();
71 me->SetCanDualWield(false);
72 }
73
74 void JustEngagedWith(Unit* who) override
75 {
79 }
80
86
87 void DoAction(int32 actionId) override
88 {
89 switch (actionId)
90 {
92 if (!me->IsAlive())
93 break;
94
95 if (_addsKilled++ == 0)
97 else
99 break;
100 default:
101 break;
102 }
103 }
104
105 void KilledUnit(Unit* victim) override
106 {
107 if (victim->GetTypeId() == TYPEID_PLAYER)
108 Talk(SAY_SLAY);
109 }
110
111 void JustDied(Unit* /*killer*/) override
112 {
114 _JustDied();
115 }
116
117 bool CheckGuardAuras(Creature* guard) const
118 {
119 static uint32 const MechanicImmunityList =
120 (1 << MECHANIC_SNARE)
121 | (1 << MECHANIC_ROOT)
122 | (1 << MECHANIC_FEAR)
123 | (1 << MECHANIC_STUN)
124 | (1 << MECHANIC_SLEEP)
125 | (1 << MECHANIC_CHARM)
126 | (1 << MECHANIC_SAPPED)
127 | (1 << MECHANIC_HORROR)
128 | (1 << MECHANIC_POLYMORPH)
129 | (1 << MECHANIC_DISORIENTED)
130 | (1 << MECHANIC_FREEZE)
131 | (1 << MECHANIC_TURN);
132
133 static std::list<AuraType> const AuraImmunityList =
134 {
140 };
141
142 if (guard->HasAuraWithMechanic(MechanicImmunityList))
143 return true;
144
145 for (AuraType type : AuraImmunityList)
146 if (guard->HasAuraType(type))
147 return true;
148
149 return false;
150 }
151
152 bool CheckGuardAlive() const
153 {
155 {
157 if (guard->IsAlive())
158 return true;
159 }
160
161 return false;
162 }
163
165 {
166 if (HealthBelowPct(85))
167 return me;
168
170 {
172 if (guard->IsAlive() && !guard->HealthAbovePct(75))
173 return guard;
174 }
175
176 return nullptr;
177 }
178
179 void UpdateAI(uint32 diff) override
180 {
181 if (!UpdateVictim())
182 return;
183
184 if (_phase == 0 && !CheckGuardAlive())
185 {
186 _phase = 1;
187 me->SetCanDualWield(true);
188 DoCast(me, SPELL_WINDFURY, true);
189 }
190
191 scheduler.Update(diff, [this]
192 {
193 if (_phase == 1)
195 });
196 }
197
198 void ScheduleTasks() override
199 {
200 scheduler.Schedule(20s, [this](TaskContext& task)
201 {
202 if (Unit* ally = DoSelectLowestHpFriendly(30.0f))
204
205 task.Repeat(20s);
206 });
207
208 scheduler.Schedule(2s, [this](TaskContext& task)
209 {
211 task.Repeat(35s, 45s);
212 });
213
214 scheduler.Schedule(2s, [this](TaskContext& task)
215 {
216 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f))
218
219 task.Repeat(2500ms);
220 });
221
222 scheduler.Schedule(10s, [this](TaskContext& task)
223 {
224 if (Unit* ally = DoSelectLowestHpFriendly(40.0f))
226
227 if (!CheckGuardAlive())
228 task.Repeat(3s);
229 else
230 task.Repeat(8s, 11s);
231 });
232
233 scheduler.Schedule(2s, 8s, [this](TaskContext& task)
234 {
236 task.Repeat(8s, 13s);
237 });
238
239 scheduler.Schedule(0s, [this](TaskContext& task)
240 {
242 {
244
245 if (guard && guard->IsAlive() && CheckGuardAuras(guard))
246 {
248 task.Repeat(10s);
249 return;
250 }
251 }
252 task.Repeat(500ms);
253 });
254 }
255
256private:
259};
260
267
268// 29395 - Erekem Guard
269// 32228 - Arakkoa Talon Guard
271{
272 npc_erekem_guard(Creature* creature) : ScriptedAI(creature)
273 {
275 {
277 });
278 }
279
280 void Reset() override
281 {
283 }
284
285 void JustEngagedWith(Unit* /*who*/) override
286 {
289 }
290
291 void JustDied(Unit* /*killer*/) override
292 {
293 if (InstanceScript* instance = me->GetInstanceScript())
294 if (Creature* erekem = instance->GetCreature(DATA_EREKEM))
295 erekem->AI()->DoAction(ACTION_EREKEM_GUARD_DIED);
296 }
297
298 void UpdateAI(uint32 diff) override
299 {
300 if (!UpdateVictim())
301 return;
302
303 scheduler.Update(diff);
304 }
305
307 {
308 scheduler.Schedule(4s, 8s, [this](TaskContext& task)
309 {
311 task.Repeat(4s, 8s);
312 });
313
314 scheduler.Schedule(8s, 13s, [this](TaskContext& task)
315 {
317 task.Repeat(8s, 13s);
318 });
319
320 scheduler.Schedule(1s, 3s, [this](TaskContext& task)
321 {
323 task.Repeat(7s, 12s);
324 });
325 }
326
327private:
329};
330
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
@ 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
@ UNIT_STATE_CASTING
Definition Unit.h:290
ErekemTexts
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_ADD_KILLED
@ SAY_BOTH_ADDS_KILLED
@ SAY_SLAY
@ SAY_SPAWN
void AddSC_boss_erekem()
GuardSpells
@ SPELL_STRIKE
@ SPELL_HOWLING_SCREECH
@ SPELL_GUSHING_WOUND
ErekemSpells
@ SPELL_WINDFURY
@ SPELL_BLOODLUST
@ SPELL_STORMSTRIKE
@ SPELL_BREAK_BONDS
@ SPELL_CHAIN_HEAL
@ SPELL_EARTH_SHIELD
@ SPELL_LIGHTNING_BOLT
@ SPELL_EARTH_SHOCK
ErekemActions
@ ACTION_EREKEM_GUARD_DIED
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 & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
TaskScheduler & Update()
Update the scheduler to the current time.
bool DoSpellAttackIfReady(uint32 spellId)
Definition UnitAI.cpp:53
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
bool IsAlive() const
Definition Unit.h:1205
bool HasAuraType(AuraType auraType) const
Definition Unit.cpp:4832
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
bool HasAuraWithMechanic(uint64 mechanicMask) const
Definition Unit.cpp:4897
InstanceScript * GetInstanceScript() const
Definition Object.cpp:394
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 DoAction(int32 actionId) override
void Initialize()
npc_erekem_guard(Creature *creature)
TaskScheduler scheduler
void Reset() override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) 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)