Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_temple_guardian_anhuur.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ObjectMgr.h"
7#include "ScriptMgr.h"
8#include "ScriptedCreature.h"
9#include "SpellScript.h"
10#include "SpellAuraEffects.h"
11#include "GridNotifiers.h"
12#include "Player.h"
14
24
31
50
52{
54 PHASE_FIRST_SHIELD = 1, // Ready to be shielded for the first time
55 PHASE_SECOND_SHIELD = 2, // First shield already happened, ready to be shielded a second time
56 PHASE_FINAL = 3 // Already shielded twice, ready to finish the encounter normally.
57};
58
63
65{
66public:
67 boss_temple_guardian_anhuur() : CreatureScript("boss_temple_guardian_anhuur") { }
68
70 {
72
74 {
75 std::list<Creature*> stalkers;
77 for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
78 {
79 (*itr)->RemoveAurasDueToSpell(SPELL_BEAM_OF_LIGHT_RIGHT);
80 (*itr)->RemoveAurasDueToSpell(SPELL_BEAM_OF_LIGHT_LEFT);
81 }
82 }
83
85 {
88 _beacons = 0;
89 _Reset();
91 me->RemoveAurasDueToSpell(SPELL_SHIELD_OF_LIGHT);
92 events.ScheduleEvent(EVENT_DIVINE_RECKONING, std::rand() % 12000 + 10000);
93 events.ScheduleEvent(EVENT_BURNING_LIGHT, 12000);
94 }
95
96 void DamageTaken(Unit* /*attacker*/, uint32& damage) OVERRIDE
97 {
98 if ((me->HealthBelowPctDamaged(66, damage) && _phase == PHASE_FIRST_SHIELD) ||
99 (me->HealthBelowPctDamaged(33, damage) && _phase == PHASE_SECOND_SHIELD))
100 {
101 _beacons = 2;
102 _phase++; // Increase the phase
104
106
107 me->InterruptNonMeleeSpells(true);
108 me->AttackStop();
110
113
115
116 std::list<Creature*> stalkers;
119
120 stalkers.remove_if(Skyfire::HeightDifferenceCheck(door, 0.0f, false)); // Target only the bottom ones
121 for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
122 {
123 if ((*itr)->GetPositionX() > door->GetPositionX())
124 {
125 (*itr)->CastSpell((*itr), SPELL_SHIELD_VISUAL_LEFT, true);
126 (*itr)->CastSpell((*itr), SPELL_BEAM_OF_LIGHT_LEFT, true);
127 }
128 else
129 {
130 (*itr)->CastSpell((*itr), SPELL_SHIELD_VISUAL_RIGHT, true);
131 (*itr)->CastSpell((*itr), SPELL_BEAM_OF_LIGHT_RIGHT, true);
132 }
133 }
134
136
139 }
140 }
141
143 {
144 if (action == ACTION_DISABLE_BEACON)
145 {
146 --_beacons;
147 if (!_beacons)
148 {
149 me->RemoveAurasDueToSpell(SPELL_SHIELD_OF_LIGHT);
152 }
153 }
154 }
155
156 void EnterCombat(Unit* /*who*/) OVERRIDE
157 {
158 instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me, 1);
160 _EnterCombat();
161 }
162
163 void JustDied(Unit* /*killer*/) OVERRIDE
164 {
165 instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
167 _JustDied();
168 }
169
171 {
172 if (victim->GetTypeId() == TypeID::TYPEID_PLAYER)
173 Talk(SAY_KILL);
174 }
175
177 {
178 instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
181 }
182
184 {
185 if (!UpdateVictim() || !CheckInRoom() || me->GetCurrentSpell(CURRENT_CHANNELED_SPELL) || _phase == PHASE_SHIELDED)
186 return;
187
188 events.Update(diff);
189
190 if (me->HasUnitState(UNIT_STATE_CASTING))
191 return;
192
193 while (uint32 eventId = events.ExecuteEvent())
194 {
195 switch (eventId)
196 {
199 events.ScheduleEvent(EVENT_DIVINE_RECKONING, std::rand() % 12000 + 10000);
200 break;
202 {
204 if (!unit)
205 unit = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true);
207 events.ScheduleEvent(EVENT_SEAR, 2000);
208 events.ScheduleEvent(EVENT_BURNING_LIGHT, 12000);
209 break;
210 }
211 case EVENT_SEAR:
212 {
213 Unit* target = me->FindNearestCreature(NPC_SEARING_LIGHT, 100.0f);
214 if (!target)
215 break;
216
217 std::list<Creature*> stalkers;
219 stalkers.remove_if(Skyfire::HeightDifferenceCheck(ObjectAccessor::GetGameObject(*me, instance->GetData64(DATA_ANHUUR_DOOR)), 5.0f, true));
220
221 if (stalkers.empty())
222 break;
223
224 stalkers.sort(Skyfire::ObjectDistanceOrderPred(target));
225
226 // Get the closest statue face (any of its eyes)
227 Creature* eye1 = stalkers.front();
228 stalkers.remove(eye1); // Remove the eye.
229 stalkers.sort(Skyfire::ObjectDistanceOrderPred(eye1)); // Find the second eye.
230 Creature* eye2 = stalkers.front();
231
232 eye1->CastSpell(eye1, SPELL_SEARING_LIGHT, true);
233 eye2->CastSpell(eye2, SPELL_SEARING_LIGHT, true);
234 break;
235 }
236 }
237 }
238
240 }
241
242 private:
246 };
247
252};
253
255{
256 public:
257 spell_anhuur_shield_of_light() : SpellScriptLoader("spell_anhuur_shield_of_light") { }
258
260 {
262
263 void FilterTargets(std::list<WorldObject*>& targets)
264 {
265 if (InstanceMap* instance = GetCaster()->GetMap()->ToInstanceMap())
266 {
267 if (InstanceScript* const script = instance->GetInstanceScript())
268 {
269 if (GameObject* go = ObjectAccessor::GetGameObject(*GetCaster(), script->GetData64(DATA_ANHUUR_DOOR)))
270 {
271 targets.remove_if(Skyfire::HeightDifferenceCheck(go, 5.0f, false));
272 targets.remove(GetCaster());
274 targets.resize(2);
275 }
276 }
277 }
278 }
279
284 };
285
290};
291
326
353
355{
356public:
357 spell_anhuur_divine_reckoning() : SpellScriptLoader("spell_anhuur_divine_reckoning") { }
358
360 {
362
363 void OnPeriodic(AuraEffect const* aurEff)
364 {
365 if (Unit* caster = GetCaster())
366 {
367 CustomSpellValues values;
369 caster->CastCustomSpell(GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, values, GetTarget());
370 }
371 }
372
377 };
378
383};
384
Actions
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ FAIL
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TYPEID_PLAYER
Definition Object.h:55
void GetCreatureListWithEntryInGrid(std::list< Creature * > &list, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_ACTIVATE_OBJECT
@ TARGET_UNIT_SRC_AREA_ENTRY
@ GO_FLAG_NOT_SELECTABLE
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
@ SPELLVALUE_BASE_POINT0
Definition Unit.h:114
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:1110
@ UNIT_STATE_CASTING
Definition Unit.h:527
@ UNIT_FLAG_UNK_31
Definition Unit.h:656
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ UNIT_FIELD_FLAGS
@ GAMEOBJECT_FIELD_FLAGS
#define SAY_DEATH
#define SAY_AGGRO
#define SAY_KILL
void AddSC_boss_temple_guardian_anhuur()
int32 GetAmount() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
SpellInfo const * GetSpellInfo() const
Unit * GetCaster() const
Unit * GetTarget() const
InstanceScript *const instance
void _JustReachedHome()
bool CheckInRoom()
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
void AddSpellMod(SpellValueMod mod, int32 value)
Definition Unit.h:131
static GameObject * GetGameObject(WorldObject const &u, uint64 guid)
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
HookList< EffectHandler > OnEffectHit
void PreventHitDefaultEffect(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
int32 GetEffectValue()
GameObject * GetHitGObj()
Unit * GetCaster()
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
SpellScriptLoader(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
void DoCastAOE(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:176
Definition Unit.h:1367
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
CreatureAI * GetAI(Creature *creature) const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_anhuur_shield_of_light_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
@ NPC_SEARING_LIGHT
@ NPC_CAVE_IN_STALKER
CreatureAI * GetHallsOfOriginationAI(Creature *creature)
@ DATA_ANHUUR_GUID
@ DATA_TEMPLE_GUARDIAN_ANHUUR
@ DATA_ANHUUR_DOOR
float GetPositionX() const
Definition Object.h:328
Creature * me
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================