TrinityCore
Loading...
Searching...
No Matches
boss_anubrekhan.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 "Containers.h"
20#include "InstanceScript.h"
21#include "ObjectAccessor.h"
22#include "naxxramas.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25
27{
31
32 EMOTE_LOCUST = 3
33};
34
41
43{
44 EVENT_IMPALE = 1, // Cast Impale on a random target
45 EVENT_LOCUST, // Begin channeling Locust Swarm
46 EVENT_LOCUST_ENDS, // Locust swarm dissipates
47 EVENT_SPAWN_GUARD, // 10-man only - crypt guard has delayed spawn; also used for the locust swarm crypt guard in both modes
48 EVENT_SCARABS, // spawn corpse scarabs
49 EVENT_BERSERK // Berserk
50};
51
53{
54 SPELL_IMPALE = 28783, // 25-man: 56090
55 SPELL_LOCUST_SWARM = 28785, // 25-man: 54021
56 SPELL_SUMMON_CORPSE_SCARABS_PLR = 29105, // This spawns 5 corpse scarabs on top of player
57 SPELL_SUMMON_CORPSE_SCARABS_MOB = 28864, // This spawns 10 corpse scarabs on top of dead guards
58 SPELL_BERSERK = 27680
59};
60
66
67enum Misc
68{
70};
71
77
78struct boss_anubrekhan : public BossAI
79{
80 boss_anubrekhan(Creature* creature) : BossAI(creature, BOSS_ANUBREKHAN) { }
81
87
88 void InitializeAI() override
89 {
91 {
92 Reset();
94 }
95 }
96
97 void Reset() override
98 {
99 _Reset();
100 guardCorpses.clear();
101 }
102
103 void JustReachedHome() override
104 {
106 SummonGuards();
107 }
108
109 void JustSummoned(Creature* summon) override
110 {
111 BossAI::JustSummoned(summon);
112
113 if (me->IsInCombat())
114 if (summon->GetEntry() == NPC_CRYPT_GUARD)
115 summon->AI()->Talk(EMOTE_SPAWN, me);
116 }
117
118 void SummonedCreatureDies(Creature* summon, Unit* killer) override
119 {
120 BossAI::SummonedCreatureDies(summon, killer);
121
122 if (summon->GetEntry() == NPC_CRYPT_GUARD)
123 guardCorpses.insert(summon->GetGUID());
124 }
125
126 void SummonedCreatureDespawn(Creature* summon) override
127 {
129
130 if (summon->GetEntry() == NPC_CRYPT_GUARD)
131 guardCorpses.erase(summon->GetGUID());
132 }
133
134 void KilledUnit(Unit* victim) override
135 {
136 if (victim->GetTypeId() == TYPEID_PLAYER)
138
139 Talk(SAY_SLAY);
140 }
141
142 void JustDied(Unit* /*killer*/) override
143 {
144 _JustDied();
145
146 // start achievement timer (kill Maexna within 20 min)
148 }
149
166
167 void UpdateAI(uint32 diff) override
168 {
169 if (!UpdateVictim())
170 return;
171
172 events.Update(diff);
173
174 while (uint32 eventId = events.ExecuteEvent())
175 {
176 switch (eventId)
177 {
178 case EVENT_IMPALE:
180 break; // don't chain impale tank -> locust swarm
182 DoCast(target, SPELL_IMPALE);
183 else
185
187 break;
188 case EVENT_SCARABS:
189 if (!guardCorpses.empty())
190 {
192 {
193 creatureTarget->CastSpell(creatureTarget, SPELL_SUMMON_CORPSE_SCARABS_MOB, me->GetGUID());
194 creatureTarget->AI()->Talk(EMOTE_SCARAB);
195 creatureTarget->DespawnOrUnsummon();
196 }
197 }
199 break;
200 case EVENT_LOCUST:
204
208 break;
213 break;
216 break;
217 case EVENT_BERSERK:
218 DoCast(me, SPELL_BERSERK, true);
220 break;
221 }
222 }
223
226 }
227 private:
229};
230
232{
233 public:
234 at_anubrekhan_entrance() : OnlyOnceAreaTriggerScript("at_anubrekhan_entrance") { }
235
236 bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
237 {
238 InstanceScript* instance = player->GetInstanceScript();
239 if (!instance || instance->GetBossState(BOSS_ANUBREKHAN) != NOT_STARTED)
240 return true;
241
242 if (Creature* anub = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_ANUBREKHAN)))
243 anub->AI()->Talk(SAY_GREET);
244
245 return true;
246 }
247};
248
@ ACHIEVEMENT_TIMED_TYPE_EVENT
Definition DBCEnums.h:122
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
std::chrono::minutes Minutes
Minutes shorthand typedef.
Definition Duration.h:30
@ DONE
@ NOT_STARTED
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:260
Spells
Definition PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition Random.cpp:62
void AddSC_boss_anubrekhan()
@ ACHIEV_TIMED_START_EVENT
@ EMOTE_SCARAB
@ EMOTE_FRENZY
@ EMOTE_SPAWN
@ GROUP_SINGLE_SPAWN
@ GROUP_INITIAL_25M
@ SAY_AGGRO
@ SAY_GREET
@ EMOTE_LOCUST
@ SAY_SLAY
@ SPELL_SUMMON_CORPSE_SCARABS_MOB
@ SPELL_SUMMON_CORPSE_SCARABS_PLR
@ SPELL_LOCUST_SWARM
@ SPELL_BERSERK
@ SPELL_IMPALE
@ PHASE_SWARM
@ PHASE_NORMAL
@ EVENT_LOCUST
@ EVENT_LOCUST_ENDS
@ EVENT_SCARABS
@ EVENT_BERSERK
@ EVENT_SPAWN_GUARD
@ EVENT_IMPALE
InstanceScript *const instance
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summon) override
SummonList summons
EventMap events
void SummonedCreatureDespawn(Creature *summon) override
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
virtual void SummonedCreatureDies(Creature *, Unit *)
Definition CreatureAI.h:140
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
CreatureAI * AI() const
Definition Creature.h:154
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
Milliseconds GetTimeUntilEvent(EventId eventId) const
Definition EventMap.cpp:179
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
virtual ObjectGuid GetGuidData(uint32 type) const override
EncounterState GetBossState(uint32 id) const
void DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void DoZoneInCombat(uint32 entry=0)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
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:769
bool IsInCombat() const
Definition Unit.h:1144
bool isDead() const
Definition Unit.h:1236
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:2082
bool TryHandleOnce(Player *player, AreaTriggerEntry const *) override
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:108
@ NPC_CRYPT_GUARD
Definition naxxramas.h:104
@ BOSS_ANUBREKHAN
Definition naxxramas.h:30
@ DATA_ANUBREKHAN
Definition naxxramas.h:63
#define RegisterNaxxramasCreatureAI(ai_name)
Definition naxxramas.h:221
T const & RAID_MODE(T const &normal10, T const &normal25) const
bool Is25ManRaid() const
void JustReachedHome() override
void Reset() override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void SummonedCreatureDespawn(Creature *summon) override
void SummonedCreatureDies(Creature *summon, Unit *killer) override
void JustSummoned(Creature *summon) override
void KilledUnit(Unit *victim) override
void JustEngagedWith(Unit *who) override
void InitializeAI() override
boss_anubrekhan(Creature *creature)