TrinityCore
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
36{
39 EMOTE_SCARAB = 2
40};
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_SUMMON_CORPSE_SCARABS_PLR = 29105, // This spawns 5 corpse scarabs on top of player
55 SPELL_SUMMON_CORPSE_SCARABS_MOB = 28864, // This spawns 10 corpse scarabs on top of dead guards
56 SPELL_BERSERK = 27680
57};
58
59#define SPELL_IMPALE RAID_MODE(28783, 56090)
60#define SPELL_LOCUST_SWARM RAID_MODE(28785, 54021)
61
63{
66};
67
68enum Misc
69{
71};
72
74{
77};
78
79struct boss_anubrekhan : public BossAI
80{
81 boss_anubrekhan(Creature* creature) : BossAI(creature, BOSS_ANUBREKHAN) { }
82
84 {
85 if (Is25ManRaid())
87 }
88
89 void InitializeAI() override
90 {
92 {
93 Reset();
95 }
96 }
97
98 void Reset() override
99 {
100 _Reset();
101 guardCorpses.clear();
102 me->SetCanMelee(true);
103 }
104
105 void JustReachedHome() override
106 {
108 SummonGuards();
109 }
110
111 void JustSummoned(Creature* summon) override
112 {
113 BossAI::JustSummoned(summon);
114
115 if (me->IsInCombat())
116 if (summon->GetEntry() == NPC_CRYPT_GUARD)
117 summon->AI()->Talk(EMOTE_SPAWN, me);
118 }
119
120 void SummonedCreatureDies(Creature* summon, Unit* killer) override
121 {
122 BossAI::SummonedCreatureDies(summon, killer);
123
124 if (summon->GetEntry() == NPC_CRYPT_GUARD)
125 guardCorpses.insert(summon->GetGUID());
126 }
127
128 void SummonedCreatureDespawn(Creature* summon) override
129 {
131
132 if (summon->GetEntry() == NPC_CRYPT_GUARD)
133 guardCorpses.erase(summon->GetGUID());
134 }
135
136 void KilledUnit(Unit* victim) override
137 {
138 if (victim->GetTypeId() == TYPEID_PLAYER)
140 .SetOriginalCaster(me->GetGUID()));
141
142 Talk(SAY_SLAY);
143 }
144
145 void JustDied(Unit* /*killer*/) override
146 {
147 _JustDied();
148
149 // start achievement timer (kill Maexna within 20 min)
151 }
152
153 void JustEngagedWith(Unit* who) override
154 {
157
159
165
166 if (!Is25ManRaid())
168 }
169
170 void UpdateAI(uint32 diff) override
171 {
172 if (!UpdateVictim())
173 return;
174
175 events.Update(diff);
176
177 while (uint32 eventId = events.ExecuteEvent())
178 {
179 switch (eventId)
180 {
181 case EVENT_IMPALE:
183 break; // don't chain impale tank -> locust swarm
185 DoCast(target, SPELL_IMPALE);
186 else
188
190 break;
191 case EVENT_SCARABS:
192 if (!guardCorpses.empty())
193 {
195 {
196 creatureTarget->CastSpell(creatureTarget, SPELL_SUMMON_CORPSE_SCARABS_MOB, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
197 .SetOriginalCaster(me->GetGUID()));
198 creatureTarget->AI()->Talk(EMOTE_SCARAB);
199 creatureTarget->DespawnOrUnsummon();
200 }
201 }
203 break;
204 case EVENT_LOCUST:
208 me->SetCanMelee(false);
209
213 break;
216 me->SetCanMelee(true);
219 break;
222 break;
223 case EVENT_BERSERK:
224 DoCast(me, SPELL_BERSERK, true);
226 break;
227 }
228 }
229 }
230 private:
232};
233
235{
236 public:
237 at_anubrekhan_entrance() : OnlyOnceAreaTriggerScript("at_anubrekhan_entrance") { }
238
239 bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
240 {
241 InstanceScript* instance = player->GetInstanceScript();
242 if (!instance || instance->GetBossState(BOSS_ANUBREKHAN) != NOT_STARTED)
243 return true;
244
245 if (Creature* anub = ObjectAccessor::GetCreature(*player, instance->GetGuidData(DATA_ANUBREKHAN)))
246 anub->AI()->Talk(SAY_GREET);
247
248 return true;
249 }
250};
251
253{
255
257}
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::minutes Minutes
Minutes shorthand typedef.
Definition: Duration.h:35
@ DONE
@ NOT_STARTED
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:393
Spells
Definition: PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition: Random.cpp:62
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
#define SPELL_LOCUST_SWARM
void AddSC_boss_anubrekhan()
@ ACHIEV_TIMED_START_EVENT
GuardSays
@ EMOTE_SCARAB
@ EMOTE_FRENZY
@ EMOTE_SPAWN
@ GROUP_SINGLE_SPAWN
@ GROUP_INITIAL_25M
AnubSays
@ SAY_AGGRO
@ SAY_GREET
@ EMOTE_LOCUST
@ SAY_SLAY
@ SPELL_SUMMON_CORPSE_SCARABS_MOB
@ SPELL_SUMMON_CORPSE_SCARABS_PLR
@ SPELL_BERSERK
@ PHASE_SWARM
@ PHASE_NORMAL
#define SPELL_IMPALE
@ 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 _JustDied()
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
virtual void SummonedCreatureDies(Creature *, Unit *)
Definition: CreatureAI.h:115
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
Milliseconds GetTimeUntilEvent(uint32 eventId) const
Definition: EventMap.cpp:175
virtual ObjectGuid GetGuidData(uint32 type) const override
EncounterState GetBossState(uint32 id) const
void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr) override
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
void DoZoneInCombat(uint32 entry=0)
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 DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool IsInCombat() const
Definition: Unit.h:1043
bool isDead() const
Definition: Unit.h:1166
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition: Object.cpp:2131
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:109
@ 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)