TrinityCore
boss_temple_guardian_anhuur.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 "GridNotifiers.h"
21#include "InstanceScript.h"
22#include "ObjectAccessor.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26#include "SpellScript.h"
27
29{
35 SAY_DEATH = 5
36};
37
39{
43};
44
46{
51
54
57
60
62};
63
65{
67 PHASE_FIRST_SHIELD = 1, // Ready to be shielded for the first time
68 PHASE_SECOND_SHIELD = 2, // First shield already happened, ready to be shielded a second time
69 PHASE_FINAL = 3 // Already shielded twice, ready to finish the encounter normally.
70};
71
73{
75};
76
78{
80 {
81 Initialize();
82 }
83
85 {
88 _beacons = 0;
89 }
90
92 {
93 std::list<Creature*> stalkers;
95 for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
96 {
97 (*itr)->RemoveAurasDueToSpell(SPELL_BEAM_OF_LIGHT_RIGHT);
98 (*itr)->RemoveAurasDueToSpell(SPELL_BEAM_OF_LIGHT_LEFT);
99 }
100 }
101
102 void Reset() override
103 {
104 Initialize();
105 _Reset();
110 }
111
112 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
113 {
114 if ((me->HealthBelowPctDamaged(66, damage) && _phase == PHASE_FIRST_SHIELD) ||
116 {
117 _beacons = 2;
118 _phase++; // Increase the phase
120
122
124 me->AttackStop();
126
128
130
132 if (door)
133 {
134 std::list<Creature*> stalkers;
136
137 stalkers.remove_if(Trinity::HeightDifferenceCheck(door, 0.0f, false)); // Target only the bottom ones
138 for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
139 {
140 if ((*itr)->GetPositionX() > door->GetPositionX())
141 {
142 (*itr)->CastSpell((*itr), SPELL_SHIELD_VISUAL_LEFT, true);
143 (*itr)->CastSpell((*itr), SPELL_BEAM_OF_LIGHT_LEFT, true);
144 }
145 else
146 {
147 (*itr)->CastSpell((*itr), SPELL_SHIELD_VISUAL_RIGHT, true);
148 (*itr)->CastSpell((*itr), SPELL_BEAM_OF_LIGHT_RIGHT, true);
149 }
150 }
151 }
152
154
157 }
158 }
159
160 void DoAction(int32 action) override
161 {
162 if (action == ACTION_DISABLE_BEACON)
163 {
164 --_beacons;
165 if (!_beacons)
166 {
170 }
171 }
172 }
173
174 void JustEngagedWith(Unit* who) override
175 {
179 }
180
181 void JustDied(Unit* /*killer*/) override
182 {
185 _JustDied();
186 }
187
188 void KilledUnit(Unit* victim) override
189 {
190 if (victim->GetTypeId() == TYPEID_PLAYER)
191 Talk(SAY_KILL);
192 }
193
194 void JustReachedHome() override
195 {
199 }
200
201 void UpdateAI(uint32 diff) override
202 {
204 return;
205
206 events.Update(diff);
207
209 return;
210
211 while (uint32 eventId = events.ExecuteEvent())
212 {
213 switch (eventId)
214 {
218 break;
220 {
222 if (!unit)
223 unit = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true);
227 break;
228 }
229 case EVENT_SEAR:
230 {
231 Unit* target = me->FindNearestCreature(NPC_SEARING_LIGHT, 100.0f);
232 if (!target)
233 break;
234
235 std::list<Creature*> stalkers;
238
239 if (stalkers.empty())
240 break;
241
242 stalkers.sort(Trinity::ObjectDistanceOrderPred(target));
243
244 // Get the closest statue face (any of its eyes)
245 Creature* eye1 = stalkers.front();
246 stalkers.remove(eye1); // Remove the eye.
247 stalkers.sort(Trinity::ObjectDistanceOrderPred(eye1)); // Find the second eye.
248 Creature* eye2 = stalkers.front();
249
250 eye1->CastSpell(eye1, SPELL_SEARING_LIGHT, true);
251 eye2->CastSpell(eye2, SPELL_SEARING_LIGHT, true);
252 break;
253 }
254 }
255 }
256 }
257
258private:
262};
263
265{
266 void FilterTargets(std::list<WorldObject*>& targets)
267 {
268 if (InstanceScript* const script = GetCaster()->GetInstanceScript())
269 {
270 if (GameObject* go = ObjectAccessor::GetGameObject(*GetCaster(), script->GetGuidData(DATA_ANHUUR_DOOR)))
271 {
272 targets.remove_if(Trinity::HeightDifferenceCheck(go, 5.0f, false));
273 targets.remove(GetCaster());
275 targets.resize(2);
276 }
277 }
278 }
279
280 void Register() override
281 {
283 }
284};
285
287{
288 void HandleScript(SpellEffIndex /*effIndex*/)
289 {
291 }
292
293 void Notify(SpellEffIndex /*index*/)
294 {
295 GameObject* caster = GetGObjCaster();
296 if (!caster)
297 return;
298
299 if (InstanceScript* instance = caster->GetInstanceScript())
300 if (Creature* anhuur = instance->GetCreature(BOSS_TEMPLE_GUARDIAN_ANHUUR))
301 if (CreatureAI* ai = anhuur->AI())
302 ai->DoAction(ACTION_DISABLE_BEACON);
303 }
304
305 void Register() override
306 {
309 }
310};
311
313{
314 void OnPeriodic(AuraEffect const* aurEff)
315 {
316 if (Unit* caster = GetCaster())
317 {
320 caster->CastSpell(GetTarget(), aurEff->GetSpellEffectInfo().TriggerSpell, args);
321 }
322 }
323
324 void Register() override
325 {
327 }
328};
329
331{
336}
Texts
Actions
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ FAIL
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENTRY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELLVALUE_BASE_POINT0
Definition: SpellDefines.h:196
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
DamageEffectType
Definition: UnitDefines.h:131
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:591
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void AddSC_boss_temple_guardian_anhuur()
SpellEffectInfo const & GetSpellEffectInfo() const
int32 GetAmount() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetCaster() const
Unit * GetTarget() const
InstanceScript *const instance
void _JustReachedHome()
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
virtual bool CheckInRoom()
Definition: CreatureAI.cpp:453
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
virtual bool SetBossState(uint32 id, EncounterState state)
virtual ObjectGuid GetGuidData(uint32 type) const override
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
TypeID GetTypeId() const
Definition: Object.h:173
uint32 TriggerSpell
Definition: SpellInfo.h:237
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
GameObject * GetGObjCaster() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
bool AttackStop()
Definition: Unit.cpp:5781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1442
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
void OnPeriodic(AuraEffect const *aurEff)
void FilterTargets(std::list< WorldObject * > &targets)
#define RegisterHallsOfOriginationCreatureAI(ai_name)
@ NPC_SEARING_LIGHT
@ NPC_CAVE_IN_STALKER
@ BOSS_TEMPLE_GUARDIAN_ANHUUR
@ DATA_ANHUUR_DOOR
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)
Definition: SpellDefines.h:474
constexpr float GetPositionX() const
Definition: Position.h:76
void KilledUnit(Unit *victim) override
void DoAction(int32 action) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override