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
83
84static constexpr std::array<uint32, 4> OgreSpawnGroupsData =
85{
90};
91
92// 18831 - High King Maulgar
94{
95 boss_high_king_maulgar(Creature* creature) : BossAI(creature, DATA_MAULGAR), _enraged(false) { }
96
97 void Reset() override
98 {
99 _Reset();
100 _enraged = false;
101 SetEquipmentSlots(true);
102
103 for (uint32 group : OgreSpawnGroupsData)
104 me->GetMap()->SpawnGroupSpawn(group, true);
105 }
106
107 void JustEngagedWith(Unit* who) override
108 {
110
112
114 .Schedule(15s, 20s, [this](TaskContext task)
115 {
117 task.Repeat(15s, 20s);
118 })
119 .Schedule(55s, 65s, [this](TaskContext task)
120 {
122 task.Repeat(55s, 60s);
123 })
124 .Schedule(10s, [this](TaskContext task)
125 {
127 task.Repeat(10s);
128 });
129 }
130
131 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
132 {
133 if (!_enraged && me->HealthBelowPctDamaged(50, damage))
134 {
135 _enraged = true;
136
138 .Schedule(0s, [this](TaskContext /*task*/)
139 {
141 })
142 .Schedule(0s, 5s, [this](TaskContext task)
143 {
145 task.Repeat(40s, 50s);
146 })
147 .Schedule(10s, 15s, [this](TaskContext task)
148 {
151 task.Repeat(20s);
152 });
153 }
154 }
155
156 void OnSpellCast(SpellInfo const* spellInfo) override
157 {
158 if (spellInfo->Id == SPELL_FLURRY)
159 {
162 }
163 }
164
165 void DoAction(int32 action) override
166 {
167 if (!me->IsAlive())
168 return;
169
170 if (action == ACTION_OGRE_DEATH)
172 }
173
174 void KilledUnit(Unit* /*victim*/) override
175 {
176 Talk(SAY_SLAY);
177 }
178
179 void JustDied(Unit* /*killer*/) override
180 {
181 _JustDied();
183 }
184
185 void UpdateAI(uint32 diff) override
186 {
187 if (!UpdateVictim())
188 return;
189
190 scheduler.Update(diff);
191
193 }
194
195private:
197};
198
199struct OgreBaseAI : public ScriptedAI
200{
201 OgreBaseAI(Creature* creature) : ScriptedAI(creature), Instance(creature->GetInstanceScript()) { }
202
203 void InitializeAI() override
204 {
205 me->SetCorpseDelay(5, true);
207 }
208
209 void Reset() override
210 {
213 {
215 });
216 }
217
218 void JustEngagedWith(Unit* /*who*/) override
219 {
221 }
222
223 virtual void ScheduleEvents() = 0;
224
225 void JustDied(Unit* /*killer*/) override
226 {
227 if (Creature* maulgar = Instance->GetCreature(DATA_MAULGAR))
228 maulgar->AI()->DoAction(ACTION_OGRE_DEATH);
229 }
230
231 void UpdateAI(uint32 diff) override
232 {
233 if (!UpdateVictim())
234 return;
235
236 Scheduler.Update(diff);
237
239 }
240
241protected:
244};
245
246// 18834 - Olm the Summoner
248{
250
251 void ScheduleEvents() override
252 {
254 .Schedule(5s, 10s, [this](TaskContext task)
255 {
257 task.Repeat(5s, 10s);
258 })
259 .Schedule(5s, 10s, [this](TaskContext task)
260 {
262 task.Repeat(5s, 15s);
263 })
264 .Schedule(0s, 10s, [this](TaskContext task)
265 {
267 task.Repeat(50s, 60s);
268 });
269 }
270};
271
272// 18835 - Kiggler the Crazed
274{
276
277 void AttackStart(Unit* who) override
278 {
279 if (me->GetDistance(who) > 10.0f)
281 else if (me->GetDistance(who) < 10.0f)
283 }
284
285 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
286 {
287 if (spellInfo->Id == SPELL_ARCANE_EXPLOSION)
288 if (Unit* unit = target->ToUnit())
289 ModifyThreatByPercent(unit, -100);
290 }
291
292 void ScheduleEvents() override
293 {
295 .Schedule(0s, [this](TaskContext task)
296 {
298 task.Repeat(2s, 3s);
299 })
300 .Schedule(5s, 10s, [this](TaskContext task)
301 {
304 task.Repeat(10s, 35s);
305 })
306 .Schedule(5s, 15s, [this](TaskContext task)
307 {
309 task.Repeat(5s, 20s);
310 })
311 .Schedule(30s, [this](TaskContext task)
312 {
314 task.Repeat(30s);
315 });
316 }
317};
318
319// 18836 - Blindeye the Seer
321{
323
324 void OnSpellCast(SpellInfo const* spellInfo) override
325 {
326 if (spellInfo->Id == SPELL_GREATER_PW_SHIELD)
328 }
329
330 void ScheduleEvents() override
331 {
333 .Schedule(7s, [this](TaskContext task)
334 {
335 if (Unit* target = DoSelectLowestHpFriendly(250.0f))
336 DoCast(target, SPELL_HEAL);
337 task.Repeat(7s);
338 })
339 .Schedule(20s, 30s, [this](TaskContext task)
340 {
342 task.Repeat(15s, 25s);
343 });
344 }
345};
346
347// 18832 - Krosh Firehand
349{
351
352 void ScheduleEvents() override
353 {
355 .Schedule(0s, 5s, [this](TaskContext task)
356 {
358 task.Repeat(2s, 5s);
359 })
360 .Schedule(0s, [this](TaskContext task)
361 {
363 task.Repeat(30s);
364 })
365 .Schedule(10s, 20s, [this](TaskContext task)
366 {
368 task.Repeat(5s, 15s);
369 });
370 }
371};
372
@ EQUIP_UNEQUIP
Definition CreatureAI.h:76
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
@ SPAWN_GROUP_KIGGLER
@ SPAWN_GROUP_BLINDEYE
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 > OgreSpawnGroupsData
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:98
Creature * GetCreature(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
static Unit * ToUnit(Object *o)
Definition Object.h:195
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:783
bool IsAlive() const
Definition Unit.h:1247
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:932
Map * GetMap() const
Definition Object.h:451
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1124
@ DATA_MAULGAR
Definition gruuls_lair.h:30
#define RegisterGruulsLairCreatureAI(ai_name)
Definition gruuls_lair.h:51
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
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