TrinityCore
Loading...
Searching...
No Matches
boss_anzu.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/*
19 * Timers requires to be revisited
20 * Birds-helpers are NYI
21 */
22
23#include "ScriptMgr.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "ScriptedCreature.h"
27#include "sethekk_halls.h"
28
36
46
60
67
81
83{
84 PATH_BROOD_1 = 1475160,
85 PATH_BROOD_2 = 1475170,
86 NPC_ANZU = 23035,
88};
89
100
101static constexpr std::array<uint32, 3> HelpersSpawnGroupsData =
102{
106};
107
108// 23035 - Anzu
109struct boss_anzu : public BossAI
110{
112
113 void JustAppeared() override
114 {
116 }
117
118 void Reset() override
119 {
120 _Reset();
122 _deadBroodCount = 0;
124 }
125
134
135 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
136 {
137 if (_phase < PHASE_HEALTH_70 && me->HealthBelowPctDamaged(70, damage))
138 {
139 _phase++;
141 }
142
143 if (_phase < PHASE_HEALTH_33 && me->HealthBelowPctDamaged(33, damage))
144 {
145 _phase++;
147 }
148 }
149
150 void DoAction(int32 action) override
151 {
152 if (action == ACTION_INFORM_ANZU)
153 {
155
157 {
159 _deadBroodCount = 0;
160 }
161 }
162 }
163
164 void EnterEvadeMode(EvadeReason why) override
165 {
166 for (uint32 group : BroodSpawnGroupsData)
167 me->GetMap()->SpawnGroupDespawn(group);
168
170 }
171
172 void JustDied(Unit* /*killer*/) override
173 {
174 _JustDied();
175
176 for (uint32 group : HelpersSpawnGroupsData)
177 me->GetMap()->SpawnGroupDespawn(group);
178 }
179
180 void UpdateAI(uint32 diff) override
181 {
182 if (!UpdateVictim())
183 {
184 events.Update(diff);
185
186 while (uint32 eventId = events.ExecuteEvent())
187 {
188 switch (eventId)
189 {
190 case EVENT_INTRO_1:
194 break;
195 case EVENT_INTRO_2:
198 break;
199 case EVENT_INTRO_3:
201 me->SetImmuneToAll(false);
202 for (uint32 group : HelpersSpawnGroupsData)
203 me->GetMap()->SpawnGroupSpawn(group, true);
204 break;
205 default:
206 break;
207 }
208 }
209 return;
210 }
211
212 events.Update(diff);
213
215 return;
216
217 while (uint32 eventId = events.ExecuteEvent())
218 {
219 switch (eventId)
220 {
223 events.Repeat(25s, 35s);
224 break;
225 case EVENT_SPELL_BOMB:
226 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [](Unit const* unit) { return unit && unit->GetPowerType() == POWER_MANA; }))
227 {
228 DoCast(target, SPELL_SPELL_BOMB);
229 Talk(SAY_BOMB, target);
230 }
231 events.Repeat(20s, 30s);
232 break;
236 events.Repeat(20s, 25s);
237 break;
238
239 case EVENT_SUMMON_1:
242
243 _deadBroodCount = 0;
244
245 for (uint32 group : BroodSpawnGroupsData)
246 me->GetMap()->SpawnGroupSpawn(group, true, true);
247
249 break;
250 case EVENT_SUMMON_2:
253 break;
254 default:
255 break;
256 }
257
259 return;
260 }
261
263 }
264
265private:
268};
269
270// 23132 - Brood of Anzu
272{
274
275 void JustAppeared() override
276 {
277 me->SetDisableGravity(true);
279
280 _scheduler.Schedule(0s, 5s, [this](TaskContext /*task*/)
281 {
282 me->GetMotionMaster()->MovePath(RAND(PATH_BROOD_1, PATH_BROOD_2), false);
283 });
284 }
285
286 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
287 {
289 me->SetDisableGravity(false);
291 }
292
293 void JustDied(Unit* /*killer*/) override
294 {
295 if (Creature* anzu = me->FindNearestCreature(NPC_ANZU, 200.0f))
296 anzu->AI()->DoAction(ACTION_INFORM_ANZU);
297 }
298
299 void UpdateAI(uint32 diff) override
300 {
301 _scheduler.Update(diff);
302
303 if (UpdateVictim())
305 }
306
307private:
309};
310
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ POWER_MANA
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
AnzuPhases
Definition boss_anzu.cpp:62
@ PHASE_HEALTH_70
Definition boss_anzu.cpp:64
@ PHASE_NONE
Definition boss_anzu.cpp:63
@ PHASE_HEALTH_33
Definition boss_anzu.cpp:65
AnzuEvents
Definition boss_anzu.cpp:48
@ EVENT_INTRO_1
Definition boss_anzu.cpp:56
@ EVENT_INTRO_2
Definition boss_anzu.cpp:57
@ EVENT_SUMMON_2
Definition boss_anzu.cpp:54
@ EVENT_CYCLONE_OF_FEATHERS
Definition boss_anzu.cpp:51
@ EVENT_PARALYZING_SCREECH
Definition boss_anzu.cpp:49
@ EVENT_SPELL_BOMB
Definition boss_anzu.cpp:50
@ EVENT_SUMMON_1
Definition boss_anzu.cpp:53
@ EVENT_INTRO_3
Definition boss_anzu.cpp:58
AnzuTexts
Definition boss_anzu.cpp:30
@ SAY_INTRO_2
Definition boss_anzu.cpp:32
@ SAY_INTRO_1
Definition boss_anzu.cpp:31
@ SAY_BOMB
Definition boss_anzu.cpp:34
@ SAY_SUMMON
Definition boss_anzu.cpp:33
AnzuSpawnGroups
Definition boss_anzu.cpp:69
@ SPAWN_GROUP_FALCON
Definition boss_anzu.cpp:78
@ SPAWN_GROUP_BROOD_1
Definition boss_anzu.cpp:70
@ SPAWN_GROUP_BROOD_3
Definition boss_anzu.cpp:72
@ SPAWN_GROUP_HAWK
Definition boss_anzu.cpp:77
@ SPAWN_GROUP_BROOD_4
Definition boss_anzu.cpp:73
@ SPAWN_GROUP_BROOD_6
Definition boss_anzu.cpp:75
@ SPAWN_GROUP_EAGLE
Definition boss_anzu.cpp:79
@ SPAWN_GROUP_BROOD_2
Definition boss_anzu.cpp:71
@ SPAWN_GROUP_BROOD_5
Definition boss_anzu.cpp:74
@ SPAWN_GROUP_BROOD_7
Definition boss_anzu.cpp:76
AnzuMisc
Definition boss_anzu.cpp:83
@ ACTION_INFORM_ANZU
Definition boss_anzu.cpp:87
@ PATH_BROOD_2
Definition boss_anzu.cpp:85
@ NPC_ANZU
Definition boss_anzu.cpp:86
@ PATH_BROOD_1
Definition boss_anzu.cpp:84
static constexpr std::array< uint32, 7 > BroodSpawnGroupsData
Definition boss_anzu.cpp:90
void AddSC_boss_anzu()
AnzuSpells
Definition boss_anzu.cpp:38
@ SPELL_SPELL_BOMB
Definition boss_anzu.cpp:42
@ SPELL_SHADOWFORM
Definition boss_anzu.cpp:39
@ SPELL_BANISH_SELF
Definition boss_anzu.cpp:44
@ SPELL_CYCLONE_OF_FEATHERS
Definition boss_anzu.cpp:43
@ SPELL_PARALYZING_SCREECH
Definition boss_anzu.cpp:41
static constexpr std::array< uint32, 3 > HelpersSpawnGroupsData
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void SetReactState(ReactStates st)
Definition Creature.h:128
void SetImmuneToAll(bool apply) override
Definition Creature.h:135
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
Definition Map.cpp:3458
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:783
MotionMaster * GetMotionMaster()
Definition Unit.h:1683
Powers GetPowerType() const
Definition Unit.h:945
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition Unit.cpp:13262
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3807
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
Map * GetMap() const
Definition Object.h:451
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2100
@ DATA_ANZU
#define RegisterSethekkHallsCreatureAI(ai_name)
ScriptedAI(Creature *creature)
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void Reset() override
void JustDied(Unit *) override
void JustAppeared() override
void DoAction(int32 action) override
uint8 _deadBroodCount
boss_anzu(Creature *creature)
void EnterEvadeMode(EvadeReason why) override
uint8 _phase
void JustDied(Unit *) override
void WaypointPathEnded(uint32, uint32) override
void UpdateAI(uint32 diff) override
void JustAppeared() override
TaskScheduler _scheduler