TrinityCore
boss_kazrogal.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 "hyjal.h"
20#include "hyjal_trash.h"
21#include "InstanceScript.h"
22#include "ObjectAccessor.h"
23#include "SpellAuraEffects.h"
24#include "SpellScript.h"
25
27{
28 SPELL_CLEAVE = 31436,
30 SPELL_MARK = 31447,
31 SPELL_MARK_DAMAGE = 31463
32};
33
35{
39};
40
42{
44};
45
46static constexpr uint32 PATH_ESCORT_KAZROGAL = 143106;
47
49{
50public:
51 boss_kazrogal() : CreatureScript("boss_kazrogal") { }
52
53 CreatureAI* GetAI(Creature* creature) const override
54 {
55 return GetHyjalAI<boss_kazrogalAI>(creature);
56 }
57
59 {
60 boss_kazrogalAI(Creature* creature) : hyjal_trashAI(creature)
61 {
62 Initialize();
63 instance = creature->GetInstanceScript();
64 go = false;
65 }
66
68 {
69 damageTaken = 0;
70 CleaveTimer = 5000;
71 WarStompTimer = 15000;
72 MarkTimer = 45000;
73 MarkTimerBase = 45000;
74 }
75
80 bool go;
81
82 void Reset() override
83 {
84 Initialize();
85
86 if (IsEvent)
88 }
89
90 void JustEngagedWith(Unit* /*who*/) override
91 {
92 if (IsEvent)
95 }
96
97 void KilledUnit(Unit* /*victim*/) override
98 {
100 }
101
102 void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
103 {
104 if (waypointId == 7 && instance)
105 {
107 if (target && target->IsAlive())
108 AddThreat(target, 0.0f);
109 }
110 }
111
112 void JustDied(Unit* killer) override
113 {
115 if (IsEvent)
118 }
119
120 void UpdateAI(uint32 diff) override
121 {
122 if (IsEvent)
123 {
124 //Must update EscortAI
125 EscortAI::UpdateAI(diff);
126 if (!go)
127 {
128 go = true;
130 Start(false);
131 SetDespawnAtEnd(false);
132 }
133 }
134
135 //Return since we have no target
136 if (!UpdateVictim())
137 return;
138
139 if (CleaveTimer <= diff)
140 {
142 CleaveTimer = 6000 + rand32() % 15000;
143 } else CleaveTimer -= diff;
144
145 if (WarStompTimer <= diff)
146 {
148 WarStompTimer = 60000;
149 } else WarStompTimer -= diff;
150
151 if (MarkTimer <= diff)
152 {
154
155 MarkTimerBase -= 5000;
156 if (MarkTimerBase < 5500)
157 MarkTimerBase = 5500;
159 Talk(SAY_MARK);
160 } else MarkTimer -= diff;
161 }
162 };
163
164};
165
167{
168 public:
169 bool operator()(WorldObject* target) const
170 {
171 if (Unit* unit = target->ToUnit())
172 return unit->GetPowerType() != POWER_MANA;
173 return false;
174 }
175};
176
177// 31447 - Mark of Kaz'rogal
179{
180 public:
181 spell_mark_of_kazrogal() : SpellScriptLoader("spell_mark_of_kazrogal") { }
182
184 {
185 void FilterTargets(std::list<WorldObject*>& targets)
186 {
187 targets.remove_if(MarkTargetFilter());
188 }
189
190 void Register() override
191 {
193 }
194 };
195
197 {
198 bool Validate(SpellInfo const* /*spell*/) override
199 {
201 }
202
203 void OnPeriodic(AuraEffect const* aurEff)
204 {
205 Unit* target = GetTarget();
206
207 if (target->GetPower(POWER_MANA) == 0)
208 {
209 target->CastSpell(target, SPELL_MARK_DAMAGE, aurEff);
210 // Remove aura
211 SetDuration(0);
212 }
213 }
214
215 void Register() override
216 {
218 }
219 };
220
221 SpellScript* GetSpellScript() const override
222 {
224 }
225
226 AuraScript* GetAuraScript() const override
227 {
229 }
230};
231
233{
234 new boss_kazrogal();
236}
Texts
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
Spells
Definition: PlayerAI.cpp:32
uint32 rand32()
Definition: Random.cpp:70
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENEMY
@ POWER_MANA
@ SPELL_AURA_PERIODIC_MANA_LEECH
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
Sounds
Definition: boss_beauty.cpp:23
void AddSC_boss_kazrogal()
@ SOUND_ONDEATH
@ SPELL_CLEAVE
@ SPELL_MARK_DAMAGE
@ SPELL_MARK
@ SPELL_WARSTOMP
static constexpr uint32 PATH_ESCORT_KAZROGAL
@ SAY_ONAGGRO
@ SAY_ONSLAY
@ SAY_MARK
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
void SetDuration(int32 duration, bool withMods=false)
Unit * GetTarget() const
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
virtual bool SetBossState(uint32 id, EncounterState state)
virtual ObjectGuid GetGuidData(uint32 type) const override
bool operator()(WorldObject *target) const
static Unit * ToUnit(Object *o)
Definition: Object.h:225
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool IsAlive() const
Definition: Unit.h:1164
int32 GetPower(Powers power) const
Definition: Unit.cpp:9401
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
CreatureAI * GetAI(Creature *creature) const override
void FilterTargets(std::list< WorldObject * > &targets)
SpellScript * GetSpellScript() const override
AuraScript * GetAuraScript() const override
@ DATA_THRALL
Definition: hyjal.h:37
@ DATA_KAZROGAL
Definition: hyjal.h:32
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
void SetDespawnAtEnd(bool despawn)
void LoadPath(uint32 pathId)
void UpdateAI(uint32 diff) override
void DoPlaySoundToSet(WorldObject *source, uint32 soundId)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void WaypointReached(uint32 waypointId, uint32) override
boss_kazrogalAI(Creature *creature)
void KilledUnit(Unit *) override
void JustDied(Unit *killer) override
void JustDied(Unit *) override
uint32 damageTaken
Definition: hyjal_trash.h:43
InstanceScript * instance
Definition: hyjal_trash.h:34