TrinityCore
Loading...
Searching...
No Matches
boss_high_king_maulgar.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 * Timers and targets requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "gruuls_lair.h"
24#include "InstanceScript.h"
25#include "Map.h"
26#include "ScriptedCreature.h"
27#include "SpellInfo.h"
28
37
39{
40 // High King Maulgar
44
45 SPELL_FLURRY = 33232,
46 SPELL_ROAR = 16508,
48
49 // Olm the Summoner
53
54 // Kiggler the Crazed
59
60 // Blindeye the Seer
61 SPELL_HEAL = 33144,
64
65 // Krosh Firehand
68 SPELL_BLAST_WAVE = 33061
69};
70
75
76static constexpr std::array<uint32, 4> OgreData =
77{
82};
83
84// 18831 - High King Maulgar
86{
87 boss_high_king_maulgar(Creature* creature) : BossAI(creature, DATA_MAULGAR), _enraged(false) { }
88
89 void Reset() override
90 {
91 _Reset();
92 _enraged = false;
94
95 for (uint32 data : OgreData)
97 }
98
99 void JustEngagedWith(Unit* who) override
100 {
102
104
106 .Schedule(15s, 20s, [this](TaskContext& task)
107 {
109 task.Repeat(15s, 20s);
110 })
111 .Schedule(55s, 65s, [this](TaskContext& task)
112 {
114 task.Repeat(55s, 60s);
115 })
116 .Schedule(10s, [this](TaskContext& task)
117 {
119 task.Repeat(10s);
120 });
121 }
122
123 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
124 {
125 if (!_enraged && me->HealthBelowPctDamaged(50, damage))
126 {
127 _enraged = true;
128
130 .Schedule(0s, [this](TaskContext const& /*task*/)
131 {
133 })
134 .Schedule(0s, 5s, [this](TaskContext& task)
135 {
137 task.Repeat(40s, 50s);
138 })
139 .Schedule(10s, 15s, [this](TaskContext& task)
140 {
143 task.Repeat(20s);
144 });
145 }
146 }
147
148 void OnSpellCast(SpellInfo const* spellInfo) override
149 {
150 if (spellInfo->Id == SPELL_FLURRY)
151 {
154 }
155 }
156
157 void DoAction(int32 action) override
158 {
159 if (!me->IsAlive())
160 return;
161
162 if (action == ACTION_OGRE_DEATH)
164 }
165
166 void KilledUnit(Unit* /*victim*/) override
167 {
168 Talk(SAY_SLAY);
169 }
170
171 void JustDied(Unit* /*killer*/) override
172 {
173 _JustDied();
175 }
176
177 void UpdateAI(uint32 diff) override
178 {
179 if (!UpdateVictim())
180 return;
181
182 scheduler.Update(diff);
183 }
184
185private:
187};
188
189struct OgreBaseAI : public ScriptedAI
190{
191 OgreBaseAI(Creature* creature) : ScriptedAI(creature), Instance(creature->GetInstanceScript()) { }
192
193 void InitializeAI() override
194 {
195 me->SetCorpseDelay(5, true);
197 }
198
199 void Reset() override
200 {
203 {
205 });
206 }
207
208 void JustEngagedWith(Unit* /*who*/) override
209 {
211 }
212
213 virtual void ScheduleEvents() = 0;
214
215 void JustDied(Unit* /*killer*/) override
216 {
217 if (Creature* maulgar = Instance->GetCreature(DATA_MAULGAR))
218 maulgar->AI()->DoAction(ACTION_OGRE_DEATH);
219 }
220
221 void UpdateAI(uint32 diff) override
222 {
223 if (!UpdateVictim())
224 return;
225
226 Scheduler.Update(diff);
227 }
228
229protected:
232};
233
234// 18834 - Olm the Summoner
236{
238
239 void ScheduleEvents() override
240 {
242 .Schedule(5s, 10s, [this](TaskContext& task)
243 {
245 task.Repeat(5s, 10s);
246 })
247 .Schedule(5s, 10s, [this](TaskContext& task)
248 {
250 task.Repeat(5s, 15s);
251 })
252 .Schedule(0s, 10s, [this](TaskContext& task)
253 {
255 task.Repeat(50s, 60s);
256 });
257 }
258};
259
260// 18835 - Kiggler the Crazed
262{
264
265 void AttackStart(Unit* who) override
266 {
267 if (me->GetDistance(who) > 10.0f)
269 else if (me->GetDistance(who) < 10.0f)
271 }
272
273 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
274 {
275 if (spellInfo->Id == SPELL_ARCANE_EXPLOSION)
276 if (Unit* unit = target->ToUnit())
277 ModifyThreatByPercent(unit, -100);
278 }
279
280 void ScheduleEvents() override
281 {
283 .Schedule(0s, [this](TaskContext& task)
284 {
286 task.Repeat(2s, 3s);
287 })
288 .Schedule(5s, 10s, [this](TaskContext& task)
289 {
292 task.Repeat(10s, 35s);
293 })
294 .Schedule(5s, 15s, [this](TaskContext& task)
295 {
297 task.Repeat(5s, 20s);
298 })
299 .Schedule(30s, [this](TaskContext& task)
300 {
302 task.Repeat(30s);
303 });
304 }
305};
306
307// 18836 - Blindeye the Seer
309{
311
312 void OnSpellCast(SpellInfo const* spellInfo) override
313 {
314 if (spellInfo->Id == SPELL_GREATER_PW_SHIELD)
316 }
317
318 void ScheduleEvents() override
319 {
321 .Schedule(7s, [this](TaskContext& task)
322 {
323 if (Unit* target = DoSelectLowestHpFriendly(250.0f))
324 DoCast(target, SPELL_HEAL);
325 task.Repeat(7s);
326 })
327 .Schedule(20s, 30s, [this](TaskContext& task)
328 {
330 task.Repeat(15s, 25s);
331 });
332 }
333};
334
335// 18832 - Krosh Firehand
337{
339
340 void ScheduleEvents() override
341 {
343 .Schedule(0s, 5s, [this](TaskContext& task)
344 {
346 task.Repeat(2s, 5s);
347 })
348 .Schedule(0s, [this](TaskContext& task)
349 {
351 task.Repeat(30s);
352 })
353 .Schedule(10s, 20s, [this](TaskContext& task)
354 {
356 task.Repeat(5s, 15s);
357 });
358 }
359};
360
@ EQUIP_UNEQUIP
Definition CreatureAI.h:57
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:36
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
void AddSC_boss_high_king_maulgar()
@ SPELL_GREATER_POLYMORPH
@ SPELL_PRAYER_OF_HEALING
@ SPELL_GREATER_PW_SHIELD
@ SPELL_ARCANE_EXPLOSION
@ SPELL_SUMMON_WILD_FELHUNTER
@ SPELL_LIGHTNING_BOLT
@ SPELL_GREATER_FIREBALL
@ SPELL_BERSERKER_CHARGE
static constexpr std::array< uint32, 4 > OgreData
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
TaskScheduler scheduler
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:118
Creature * GetCreature(uint32 type)
void Respawn(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
Definition Map.cpp:2070
Unit * ToUnit()
Definition Object.h:116
uint32 const Id
Definition SpellInfo.h:328
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
TaskScheduler & Update()
Update the scheduler to the current time.
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:47
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void InitializeAI()
Definition UnitAI.cpp:35
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
bool IsAlive() const
Definition Unit.h:1205
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
Map * GetMap() const
Definition Object.h:411
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:430
virtual uint64 GetData64(uint32) const
Definition ZoneScript.h:95
@ DATA_BLINDEYE_THE_SEER
Definition gruuls_lair.h:39
@ DATA_KIGGLER_THE_CRAZED
Definition gruuls_lair.h:38
@ DATA_OLM_THE_SUMMONER
Definition gruuls_lair.h:37
@ DATA_KROSH_FIREHAND
Definition gruuls_lair.h:36
@ DATA_MAULGAR
Definition gruuls_lair.h:30
#define RegisterGruulsLairCreatureAI(ai_name)
Definition gruuls_lair.h:63
void JustEngagedWith(Unit *) override
OgreBaseAI(Creature *creature)
virtual void ScheduleEvents()=0
void InitializeAI() override
void UpdateAI(uint32 diff) override
void Reset() override
InstanceScript * Instance
TaskScheduler Scheduler
void JustDied(Unit *) override
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
Unit * DoSelectLowestHpFriendly(float range, uint32 minHPDiff=1)
void ModifyThreatByPercent(Unit *victim, int32 pct, Unit *who=nullptr)
void OnSpellCast(SpellInfo const *spellInfo) override
void KilledUnit(Unit *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustEngagedWith(Unit *who) override
boss_high_king_maulgar(Creature *creature)
void OnSpellCast(SpellInfo const *spellInfo) override
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override
void AttackStart(Unit *who) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override