TrinityCore
Loading...
Searching...
No Matches
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/*
19 * Combat timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "hyjal.h"
24#include "MotionMaster.h"
25#include "ScriptedCreature.h"
26#include "SpellAuraEffects.h"
27#include "SpellInfo.h"
28#include "SpellScript.h"
29
36
46
54
56{
57 SOUND_DEATH = 11018
58};
59
60// 17888 - Kaz'rogal
61struct boss_kazrogal : public BossAI
62{
63 boss_kazrogal(Creature* creature) : BossAI(creature, DATA_KAZROGAL), _markCount(0), _markTimer(0) { }
64
65 void JustAppeared() override
66 {
69 }
70
71 void Reset() override
72 {
73 _Reset();
74 _markCount = 0;
75 _markTimer = 45s;
76 }
77
87
88 void OnSpellCast(SpellInfo const* spellInfo) override
89 {
90 if (spellInfo->Id == SPELL_MARK_OF_KAZROGAL)
92 }
93
94 // Do not reset SetActive, we want boss to be active all the time
95 void JustReachedHome() override { }
96
97 void KilledUnit(Unit* victim) override
98 {
99 if (victim->GetTypeId() == TYPEID_PLAYER)
100 Talk(SAY_SLAY);
101 }
102
103 void JustDied(Unit* /*killer*/) override
104 {
105 _JustDied();
107 }
108
109 void UpdateAI(uint32 diff) override
110 {
111 if (!UpdateVictim())
112 return;
113
114 events.Update(diff);
115
117 return;
118
119 while (uint32 eventId = events.ExecuteEvent())
120 {
121 switch (eventId)
122 {
125 events.Repeat(6s, 12s);
126 break;
127 case EVENT_WAR_STOMP:
129 events.Repeat(15s, 25s);
130 break;
131 case EVENT_CRIPPLE:
132 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f))
133 DoCast(target, SPELL_CRIPPLE);
134 events.Repeat(15s, 25s);
135 break;
138 ++_markCount;
139 if (_markCount <= 7)
140 _markTimer -= 5s;
142 break;
143 default:
144 break;
145 }
146
148 return;
149 }
150 }
151
152private:
155};
156
158{
159 public:
160 bool operator()(WorldObject* target) const
161 {
162 if (Unit* unit = target->ToUnit())
163 return unit->GetPowerType() != POWER_MANA;
164 return true;
165 }
166};
167
168// 31447 - Mark of Kaz'rogal
170{
171 void FilterTargets(std::list<WorldObject*>& targets)
172 {
173 targets.remove_if(MarkTargetFilter());
174 }
175
180};
181
183{
184 bool Validate(SpellInfo const* /*spellInfo*/) override
185 {
187 }
188
189 void OnPeriodic(AuraEffect const* aurEff)
190 {
191 Unit* target = GetTarget();
192
193 if (target->GetPower(POWER_MANA) < aurEff->GetAmountAsInt())
194 {
195 target->CastSpell(target, SPELL_MARK_OF_KAZROGAL_DMG, aurEff);
196 Remove();
197 }
198 }
199
204};
205
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
#define RegisterSpellAndAuraScriptPair(script_1, script_2)
Definition ScriptMgr.h:1381
@ EFFECT_0
@ TARGET_UNIT_SRC_AREA_ENEMY
@ POWER_MANA
@ SPELL_AURA_PERIODIC_MANA_LEECH
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:290
void AddSC_boss_kazrogal()
KazrogalEvents
@ EVENT_MALEVOLENT_CLEAVE
@ EVENT_CRIPPLE
@ EVENT_WAR_STOMP
@ EVENT_MARK_OF_KAZROGAL
KazrogalTexts
@ SAY_SLAY
@ SAY_MARK
@ SAY_INTRO
KazrogalSpells
@ SPELL_CRIPPLE
@ SPELL_MALEVOLENT_CLEAVE
@ SPELL_WAR_STOMP
@ SPELL_MARK_OF_KAZROGAL_DMG
@ SPELL_MARK_OF_KAZROGAL
KazrogalMisc
@ SOUND_DEATH
int32 GetAmountAsInt() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
TypeID GetTypeId() const
Definition BaseEntity.h:166
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
bool operator()(WorldObject *target) const
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Unit * ToUnit()
Definition Object.h:116
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
int32 GetPower(Powers power) const
Definition Unit.cpp:10096
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void OnPeriodic(AuraEffect const *aurEff)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
@ PATH_HORDE_BOSS
Definition hyjal.h:115
@ DATA_KAZROGAL
Definition hyjal.h:32
#define RegisterHyjalCreatureAI(ai_name)
Definition hyjal.h:126
void DoPlaySoundToSet(WorldObject *source, uint32 soundId)
boss_kazrogal(Creature *creature)
void JustEngagedWith(Unit *who) override
Milliseconds _markTimer
void JustDied(Unit *) override
void OnSpellCast(SpellInfo const *spellInfo) override
void JustReachedHome() override
void KilledUnit(Unit *victim) override
void UpdateAI(uint32 diff) override
void Reset() override
void JustAppeared() override