TrinityCore
Loading...
Searching...
No Matches
boss_heigan.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 "GameObject.h"
20#include "InstanceScript.h"
21#include "Map.h"
22#include "naxxramas.h"
23#include "ObjectAccessor.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "SpellScript.h"
27
29{
30 SPELL_DECREPIT_FEVER = 29998, // 25-man: 55011
34};
35
46
55
61
62enum Misc
63{
64 DATA_SAFETY_DANCE = 19962139
65};
66
67static const uint32 firstEruptionDBGUID = 84980;
68static const uint8 numSections = 4;
69static const uint8 numEruptions[numSections] = { // count of sequential GO DBGUIDs in the respective section of the room
70 15,
71 25,
72 23,
73 13
74};
75
76struct boss_heigan : public BossAI
77{
78 boss_heigan(Creature* creature) : BossAI(creature, BOSS_HEIGAN), _safeSection(0), _danceDirection(false), _safetyDance(false) { }
79
80 void Reset() override
81 {
83 _Reset();
84 }
85
86 void KilledUnit(Unit* who) override
87 {
88 if (who->GetTypeId() == TYPEID_PLAYER)
89 {
91 _safetyDance = false;
92 }
93 }
94
95 uint32 GetData(uint32 type) const override
96 {
97 return (type == DATA_SAFETY_DANCE && _safetyDance) ? 1u : 0u;
98 }
99
100 void JustDied(Unit* /*killer*/) override
101 {
102 _JustDied();
104 }
105
106 void JustEngagedWith(Unit* who) override
107 {
110
111 _safeSection = 0;
116
117 _safetyDance = true;
118
119 // figure out the current GUIDs of our eruption tiles and which segment they belong in
120 std::unordered_multimap<uint32, GameObject*> const& mapGOs = me->GetMap()->GetGameObjectBySpawnIdStore();
121 uint32 spawnId = firstEruptionDBGUID;
122 for (uint8 section = 0; section < numSections; ++section)
123 {
124 _eruptTiles[section].clear();
125 for (uint8 i = 0; i < numEruptions[section]; ++i)
126 {
127 auto tileIt = mapGOs.equal_range(spawnId++);
128 for (auto it = tileIt.first; it != tileIt.second; ++it)
129 _eruptTiles[section].push_back(it->second->GetGUID());
130 }
131 }
132 }
133
134 void UpdateAI(uint32 diff) override
135 {
136 if (!UpdateVictim())
137 return;
138
139 events.Update(diff);
140
141 while (uint32 eventId = events.ExecuteEvent())
142 {
143 switch (eventId)
144 {
145 case EVENT_DISRUPT:
147 events.Repeat(Seconds(11));
148 break;
149 case EVENT_FEVER:
152 break;
153 case EVENT_DANCE:
157 _safeSection = 0;
159 me->AttackStop();
160 me->StopMoving();
165 break;
166 case EVENT_DANCE_END:
169 _safeSection = 0;
174 me->CastStop();
177 break;
178 case EVENT_ERUPT:
180 for (uint8 section = 0; section < numSections; ++section)
181 if (section != _safeSection)
182 for (ObjectGuid tileGUID : _eruptTiles[section])
183 if (GameObject* tile = ObjectAccessor::GetGameObject(*me, tileGUID))
184 {
185 tile->SendCustomAnim(0);
187 args.OriginalCaster = me->GetGUID();
188 tile->CastSpell(tile, tile->GetGOInfo()->trap.spellId, args);
189 }
190
191 if (_safeSection == 0)
192 _danceDirection = true;
193 else if (_safeSection == numSections-1)
194 _danceDirection = false;
195
197
199 break;
200 }
201 }
202
204 }
205
206 private:
207 std::vector<ObjectGuid> _eruptTiles[numSections]; // populated on encounter start
208
209 uint32 _safeSection; // 0 is next to the entrance
210 bool _danceDirection; // true is counter-clockwise, false is clock-wise
211 bool _safetyDance; // is achievement still possible? (= no player deaths yet)
212};
213
214// 29371 - Eruption
216{
218
220 {
221 Unit* caster = GetCaster();
222 if (!caster || !GetHitUnit())
223 return;
224
225 if (GetHitDamage() >= int32(GetHitUnit()->GetHealth()))
226 if (InstanceScript* instance = caster->GetInstanceScript())
227 if (Creature* Heigan = ObjectAccessor::GetCreature(*caster, instance->GetGuidData(DATA_HEIGAN)))
228 Heigan->AI()->KilledUnit(GetHitUnit());
229 }
230
235};
236
238{
239 public:
240 achievement_safety_dance() : AchievementCriteriaScript("achievement_safety_dance") { }
241
242 bool OnCheck(Player* /*player*/, Unit* target) override
243 {
244 if (!target)
245 return false;
246
247 if (Creature* Heigan = target->ToCreature())
248 if (Heigan->AI()->GetData(DATA_SAFETY_DANCE))
249 return true;
250
251 return false;
252 }
253};
254
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
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
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
Milliseconds randtime(Milliseconds min, Milliseconds max)
Definition Random.cpp:62
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCHOOL_DAMAGE
#define SpellEffectFn(F, I, N)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ DATA_SAFETY_DANCE
@ SAY_DEATH
@ EMOTE_DANCE
@ SAY_AGGRO
@ EMOTE_DANCE_END
@ SAY_SLAY
@ SAY_TAUNT
static const uint8 numEruptions[numSections]
void AddSC_boss_heigan()
@ SPELL_SPELL_DISRUPTION
@ SPELL_TELEPORT_SELF
@ SPELL_PLAGUE_CLOUD
@ SPELL_DECREPIT_FEVER
@ PHASE_FIGHT
@ PHASE_DANCE
static const uint32 firstEruptionDBGUID
static const uint8 numSections
@ EVENT_DANCE_END
@ EVENT_ERUPT
@ EVENT_FEVER
@ EVENT_DISRUPT
@ EVENT_DANCE
Yells
void JustEngagedWith(Unit *who) override
void TeleportCheaters()
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:496
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
int32 GetHitDamage() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void CastStop(uint32 except_spellid=0)
Definition Unit.cpp:988
void StopMoving(bool force=false)
Definition Unit.cpp:10312
bool AttackStop()
Definition Unit.cpp:5645
Map * GetMap() const
Definition Object.h:449
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
bool OnCheck(Player *, Unit *target) override
PrepareSpellScript(spell_heigan_eruption)
void HandleScript(SpellEffIndex)
void Register() override
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ BOSS_HEIGAN
Definition naxxramas.h:34
@ DATA_HEIGAN
Definition naxxramas.h:73
#define RegisterNaxxramasCreatureAI(ai_name)
Definition naxxramas.h:221
ObjectGuid OriginalCaster
void Reset() override
void UpdateAI(uint32 diff) override
boss_heigan(Creature *creature)
void KilledUnit(Unit *who) override
void JustEngagedWith(Unit *who) override
uint32 GetData(uint32 type) const override
uint32 _safeSection
std::vector< ObjectGuid > _eruptTiles[numSections]
void JustDied(Unit *) override