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
81 void MovementInform(uint32 type, uint32 pointId) override
82 {
83 if (type == EFFECT_MOTION_TYPE && pointId == POINT_INTRO)
84 me->SetFacingTo(4.921828f);
85 }
86
92
93 void DoAction(int32 actionId) override
94 {
95 switch (actionId)
96 {
98 if (!me->IsAlive())
99 break;
100
101 if (_addsKilled++ == 0)
103 else
105 break;
106 default:
107 break;
108 }
109 }
110
111 void KilledUnit(Unit* victim) override
112 {
113 if (victim->GetTypeId() == TYPEID_PLAYER)
114 Talk(SAY_SLAY);
115 }
116
117 void JustDied(Unit* /*killer*/) override
118 {
120 _JustDied();
121 }
122
123 bool CheckGuardAuras(Creature* guard) const
124 {
125 static uint32 const MechanicImmunityList =
126 (1 << MECHANIC_SNARE)
127 | (1 << MECHANIC_ROOT)
128 | (1 << MECHANIC_FEAR)
129 | (1 << MECHANIC_STUN)
130 | (1 << MECHANIC_SLEEP)
131 | (1 << MECHANIC_CHARM)
132 | (1 << MECHANIC_SAPPED)
133 | (1 << MECHANIC_HORROR)
134 | (1 << MECHANIC_POLYMORPH)
135 | (1 << MECHANIC_DISORIENTED)
136 | (1 << MECHANIC_FREEZE)
137 | (1 << MECHANIC_TURN);
138
139 static std::list<AuraType> const AuraImmunityList =
140 {
146 };
147
148 if (guard->HasAuraWithMechanic(MechanicImmunityList))
149 return true;
150
151 for (AuraType type : AuraImmunityList)
152 if (guard->HasAuraType(type))
153 return true;
154
155 return false;
156 }
157
158 bool CheckGuardAlive() const
159 {
161 {
163 if (guard->IsAlive())
164 return true;
165 }
166
167 return false;
168 }
169
171 {
172 if (HealthBelowPct(85))
173 return me;
174
176 {
178 if (guard->IsAlive() && !guard->HealthAbovePct(75))
179 return guard;
180 }
181
182 return nullptr;
183 }
184
185 void UpdateAI(uint32 diff) override
186 {
187 if (!UpdateVictim())
188 return;
189
190 if (_phase == 0 && !CheckGuardAlive())
191 {
192 _phase = 1;
193 me->SetCanDualWield(true);
194 DoCast(me, SPELL_WINDFURY, true);
195 }
196
197 scheduler.Update(diff, [this]
198 {
199 if (_phase == 1)
201 else
203 });
204 }
205
206 void ScheduleTasks() override
207 {
208 scheduler.Schedule(20s, [this](TaskContext task)
209 {
210 if (Unit* ally = DoSelectLowestHpFriendly(30.0f))
212
213 task.Repeat(20s);
214 });
215
216 scheduler.Schedule(2s, [this](TaskContext task)
217 {
219 task.Repeat(35s, 45s);
220 });
221
222 scheduler.Schedule(2s, [this](TaskContext task)
223 {
224 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f))
226
227 task.Repeat(2500ms);
228 });
229
230 scheduler.Schedule(10s, [this](TaskContext task)
231 {
232 if (Unit* ally = DoSelectLowestHpFriendly(40.0f))
234
235 if (!CheckGuardAlive())
236 task.Repeat(3s);
237 else
238 task.Repeat(8s, 11s);
239 });
240
241 scheduler.Schedule(2s, 8s, [this](TaskContext task)
242 {
244 task.Repeat(8s, 13s);
245 });
246
247 scheduler.Schedule(0s, [this](TaskContext task)
248 {
250 {
252
253 if (guard && guard->IsAlive() && CheckGuardAuras(guard))
254 {
256 task.Repeat(10s);
257 return;
258 }
259 }
260 task.Repeat(500ms);
261 });
262 }
263
264private:
267};
268
275
276// 29395 - Erekem Guard
277// 32228 - Arakkoa Talon Guard
279{
280 npc_erekem_guard(Creature* creature) : ScriptedAI(creature)
281 {
283 {
285 });
286 }
287
288 void Reset() override
289 {
291 }
292
293 void JustEngagedWith(Unit* /*who*/) override
294 {
297 }
298
299 void JustDied(Unit* /*killer*/) override
300 {
301 if (InstanceScript* instance = me->GetInstanceScript())
302 if (Creature* erekem = instance->GetCreature(DATA_EREKEM))
303 erekem->AI()->DoAction(ACTION_EREKEM_GUARD_DIED);
304 }
305
306 void UpdateAI(uint32 diff) override
307 {
308 if (!UpdateVictim())
309 return;
310
311 scheduler.Update(diff,
312 std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
313 }
314
316 {
317 scheduler.Schedule(4s, 8s, [this](TaskContext task)
318 {
320 task.Repeat(4s, 8s);
321 });
322
323 scheduler.Schedule(8s, 13s, [this](TaskContext task)
324 {
326 task.Repeat(8s, 13s);
327 });
328
329 scheduler.Schedule(1s, 3s, [this](TaskContext task)
330 {
332 task.Repeat(7s, 12s);
333 });
334 }
335
336private:
338};
339
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ EFFECT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ 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:235
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
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
void JustReachedHome() override
void Reset() override
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetCanDualWield(bool value) override
virtual ObjectGuid GetGuidData(uint32 type) const override
TypeID GetTypeId() const
Definition Object.h:93
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
bool DoSpellAttackIfReady(uint32 spell)
Definition UnitAI.cpp:78
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool HasAuraWithMechanic(uint32 mechanicMask) const
Definition Unit.cpp:4602
bool IsAlive() const
Definition Unit.h:1234
bool HasAuraType(AuraType auraType) const
Definition Unit.cpp:4542
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void SetFacingTo(float ori, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13250
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
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()
void MovementInform(uint32 type, uint32 pointId) override
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:86
@ DATA_EREKEM_GUARD_2
Definition violet_hold.h:70
@ DATA_EREKEM
Definition violet_hold.h:54
@ DATA_EREKEM_GUARD_1
Definition violet_hold.h:69
#define RegisterVioletHoldCreatureAI(ai_name)
@ POINT_INTRO