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 /*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
185 }
186
187private:
189};
190
191struct OgreBaseAI : public ScriptedAI
192{
193 OgreBaseAI(Creature* creature) : ScriptedAI(creature), instance(creature->GetInstanceScript()) { }
194
195 void InitializeAI() override
196 {
197 me->SetCorpseDelay(5, true);
199 }
200
201 void Reset() override
202 {
205 {
207 });
208 }
209
210 void JustEngagedWith(Unit* /*who*/) override
211 {
213 }
214
215 virtual void ScheduleEvents() = 0;
216
217 void JustDied(Unit* /*killer*/) override
218 {
219 if (Creature* maulgar = instance->GetCreature(DATA_MAULGAR))
220 maulgar->AI()->DoAction(ACTION_OGRE_DEATH);
221 }
222
223 void UpdateAI(uint32 diff) override
224 {
225 if (!UpdateVictim())
226 return;
227
228 scheduler.Update(diff);
229
231 }
232
233protected:
236};
237
238// 18834 - Olm the Summoner
240{
241 boss_olm_the_summoner(Creature* creature) : OgreBaseAI(creature) { }
242
243 void ScheduleEvents() override
244 {
246 .Schedule(5s, 10s, [this](TaskContext task)
247 {
249 task.Repeat(5s, 10s);
250 })
251 .Schedule(5s, 10s, [this](TaskContext task)
252 {
254 task.Repeat(5s, 15s);
255 })
256 .Schedule(0s, 10s, [this](TaskContext task)
257 {
259 task.Repeat(50s, 60s);
260 });
261 }
262};
263
264// 18835 - Kiggler the Crazed
266{
267 boss_kiggler_the_crazed(Creature* creature) : OgreBaseAI(creature) { }
268
269 void AttackStart(Unit* who) override
270 {
272 }
273
274 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
275 {
276 Unit* unitTarget = target->ToUnit();
277 if (!unitTarget)
278 return;
279
280 if (spellInfo->Id == SPELL_ARCANE_EXPLOSION)
281 ModifyThreatByPercent(unitTarget, -100);
282 }
283
284 void ScheduleEvents() override
285 {
287 .Schedule(0s, [this](TaskContext task)
288 {
290 task.Repeat(2s, 3s);
291 })
292 .Schedule(5s, 10s, [this](TaskContext task)
293 {
296 task.Repeat(10s, 35s);
297 })
298 .Schedule(5s, 15s, [this](TaskContext task)
299 {
301 task.Repeat(5s, 20s);
302 })
303 .Schedule(30s, [this](TaskContext task)
304 {
306 task.Repeat(30s);
307 });
308 }
309};
310
311// 18836 - Blindeye the Seer
313{
314 boss_blindeye_the_seer(Creature* creature) : OgreBaseAI(creature) { }
315
316 void OnSpellCast(SpellInfo const* spellInfo) override
317 {
318 if (spellInfo->Id == SPELL_GREATER_PW_SHIELD)
320 }
321
322 void ScheduleEvents() override
323 {
325 .Schedule(7s, [this](TaskContext task)
326 {
327 if (Unit* target = DoSelectLowestHpFriendly(250.0f))
328 DoCast(target, SPELL_HEAL);
329 task.Repeat(7s);
330 })
331 .Schedule(20s, 30s, [this](TaskContext task)
332 {
334 task.Repeat(15s, 25s);
335 });
336 }
337};
338
339// 18832 - Krosh Firehand
341{
342 boss_krosh_firehand(Creature* creature) : OgreBaseAI(creature) { }
343
344 void ScheduleEvents() override
345 {
347 .Schedule(0s, 5s, [this](TaskContext task)
348 {
350 task.Repeat(2s, 5s);
351 })
352 .Schedule(0s, [this](TaskContext task)
353 {
355 task.Repeat(30s);
356 })
357 .Schedule(10s, 20s, [this](TaskContext task)
358 {
360 task.Repeat(5s, 15s);
361 });
362 }
363};
364
@ EQUIP_UNEQUIP
Definition CreatureAI.h:76
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:31
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
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:82
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:89
Creature * GetCreature(uint32 type)
void Respawn(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
Definition Map.cpp:3105
static Unit * ToUnit(Object *o)
Definition Object.h:192
uint32 Id
Definition SpellInfo.h:289
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
void AttackStartCaster(Unit *victim, float dist)
Definition UnitAI.cpp:48
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
virtual void InitializeAI()
Definition UnitAI.cpp:36
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool IsAlive() const
Definition Unit.h:1234
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
Map * GetMap() const
Definition Object.h:449
virtual uint64 GetData64(uint32) const
Definition ZoneScript.h:51
@ 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
TaskScheduler scheduler
InstanceScript * instance
void JustEngagedWith(Unit *) override
OgreBaseAI(Creature *creature)
virtual void ScheduleEvents()=0
void InitializeAI() override
void UpdateAI(uint32 diff) override
void Reset() override
void JustDied(Unit *) override
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
Unit * DoSelectLowestHpFriendly(float range, uint32 minHPDiff=1)
void ModifyThreatByPercent(Unit *victim, int32 pct, Unit *who=nullptr)
boss_blindeye_the_seer(Creature *creature)
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
boss_kiggler_the_crazed(Creature *creature)
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
boss_krosh_firehand(Creature *creature)
boss_olm_the_summoner(Creature *creature)