TrinityCore
boss_shazzrah.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 "molten_core.h"
21#include "ScriptedCreature.h"
22#include "SpellScript.h"
23
25{
30 SPELL_SHAZZRAH_GATE_DUMMY = 23138, // Teleports to and attacks a random target.
32};
33
35{
42};
43
44struct boss_shazzrah : public BossAI
45{
46 boss_shazzrah(Creature* creature) : BossAI(creature, BOSS_SHAZZRAH) { }
47
48 void JustEngagedWith(Unit* target) override
49 {
56 }
57
58 void UpdateAI(uint32 diff) override
59 {
60 if (!UpdateVictim())
61 return;
62
63 events.Update(diff);
64
66 return;
67
68 while (uint32 eventId = events.ExecuteEvent())
69 {
70 switch (eventId)
71 {
75 break;
76 // Triggered subsequent to using "Gate of Shazzrah".
79 break;
81 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true, -SPELL_SHAZZRAH_CURSE))
84 break;
88 break;
92 break;
99 break;
100 default:
101 break;
102 }
103
105 return;
106 }
107 }
108};
109
110// 23138 - Gate of Shazzrah
112{
113 bool Validate(SpellInfo const* /*spellInfo*/) override
114 {
116 }
117
118 void FilterTargets(std::list<WorldObject*>& targets)
119 {
120 if (targets.empty())
121 return;
122
124 targets.clear();
125 targets.push_back(target);
126 }
127
128 void HandleScript(SpellEffIndex /*effIndex*/)
129 {
130 if (Unit* target = GetHitUnit())
131 {
132 target->CastSpell(GetCaster(), SPELL_SHAZZRAH_GATE, true);
133 if (Creature* creature = GetCaster()->ToCreature())
134 creature->AI()->AttackStart(target); // Attack the target which caster will teleport to.
135 }
136 }
137
138 void Register() override
139 {
142 }
143};
144
146{
149}
uint32_t uint32
Definition: Define.h:142
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_EFFECT_DUMMY
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void AddSC_boss_shazzrah()
@ SPELL_COUNTERSPELL
@ SPELL_ARCANE_EXPLOSION
@ SPELL_SHAZZRAH_GATE_DUMMY
@ SPELL_MAGIC_GROUNDING
@ SPELL_SHAZZRAH_CURSE
@ SPELL_SHAZZRAH_GATE
@ EVENT_COUNTERSPELL
@ EVENT_ARCANE_EXPLOSION_TRIGGERED
@ EVENT_ARCANE_EXPLOSION
@ EVENT_SHAZZRAH_GATE
@ EVENT_SHAZZRAH_CURSE
@ EVENT_MAGIC_GROUNDING
void JustEngagedWith(Unit *who) override
EventMap events
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
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:52
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
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
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
void HandleScript(SpellEffIndex)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
#define RegisterMoltenCoreCreatureAI(ai_name)
Definition: molten_core.h:84
@ BOSS_SHAZZRAH
Definition: molten_core.h:34
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109
void ResetThreatList(Unit *who=nullptr)
void JustEngagedWith(Unit *target) override
void UpdateAI(uint32 diff) override
boss_shazzrah(Creature *creature)