TrinityCore
boss_magtheridon.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 "GameObject.h"
20#include "GameObjectAI.h"
21#include "InstanceScript.h"
22#include "magtheridons_lair.h"
23#include "PassiveAI.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "SpellInfo.h"
27#include "TemporarySummon.h"
28#include "SpellScript.h"
29
31{
42};
43
45{
46 // Magtheridon
48 SPELL_CLEAVE = 30619,
52 SPELL_QUAKE = 30657,
54
55 // Player or Manticron Cube
59
60 // Hellfire Raid Trigger
62
63 // HellFire Channeler
70 SPELL_FEAR = 30530,
71
72 // WorldTrigger
74
75 // Magtheridon Room
78
79 // Target Trigger
80 SPELL_BLAZE = 30542
81};
82
84{
85 // Magtheridon
98 // Hellfire Channelers events
105
107{
111 PHASE_3
113
115{
119
121{
123
124 void Reset() override
125 {
126 _Reset();
132 }
133
135 {
140 Talk(SAY_FREE);
142 }
143
144 void EnterEvadeMode(EvadeReason /*why*/) override
145 {
147 events.Reset();
151
153 }
154
155 void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
156 {
158 {
160
161 if (_channelersCount == 0)
162 CombatStart();
163 }
164 }
165
166 void DoAction(int32 action) override
167 {
169 {
178 }
179 }
180
181 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
182 {
183 if (spellInfo->Id == SPELL_SHADOW_CAGE)
185 }
186
187 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
188 {
189 if (me->HealthBelowPctDamaged(30, damage) && !events.IsInPhase(PHASE_3))
190 {
193 me->AttackStop();
198 }
199 }
200
201 void JustDied(Unit* /*killer*/) override
202 {
204 _JustDied();
206 }
207
208 void KilledUnit(Unit* who) override
209 {
210 if (who->GetTypeId() == TYPEID_PLAYER)
211 Talk(SAY_SLAY);
212 }
213
214 void UpdateAI(uint32 diff) override
215 {
217 return;
218
219 events.Update(diff);
220
222 return;
223
224 while (uint32 eventId = events.ExecuteEvent())
225 {
226 switch (eventId)
227 {
228 case EVENT_BERSERK:
230 break;
231 case EVENT_CLEAVE:
233 events.Repeat(Seconds(10));
234 break;
235 case EVENT_BLAZE:
237 events.Repeat(Seconds(20));
238 break;
239 case EVENT_QUAKE:
241 events.Repeat(Seconds(60));
242 break;
244 CombatStart();
245 break;
246 case EVENT_RELEASED:
247 me->SetUninteractible(false);
248 me->SetImmuneToPC(false);
257 break;
258 case EVENT_COLLAPSE:
261 break;
264 {
265 trigger->CastSpell(trigger, SPELL_DEBRIS_KNOCKDOWN, true);
268 }
269 break;
270 case EVENT_DEBRIS:
272 events.Repeat(Seconds(20));
273 break;
276 break;
277 case EVENT_BLAST_NOVA:
280 events.Repeat(Seconds(55));
281 break;
282 case EVENT_TAUNT:
285 break;
286 default:
287 break;
288 }
289
291 return;
292 }
293 }
294
295private:
297};
298
300{
301 npc_hellfire_channeler(Creature* creature) : ScriptedAI(creature), _instance(me->GetInstanceScript()), _canCastDarkMending(true)
302 {
304 }
305
306 void Reset() override
307 {
308 _events.Reset();
311 }
312
313 void JustEngagedWith(Unit* /*who*/) override
314 {
316
317 if (Creature* magtheridon = _instance->GetCreature(DATA_MAGTHERIDON))
318 magtheridon->AI()->DoAction(ACTION_START_CHANNELERS_EVENT);
319
324
325 }
326
327 void JustDied(Unit* /*killer*/) override
328 {
330
331 // Channelers killed by "Hit Kill" need trigger combat event too. It's needed for Cata+
332 if (Creature* magtheridon = _instance->GetCreature(DATA_MAGTHERIDON))
333 magtheridon->AI()->DoAction(ACTION_START_CHANNELERS_EVENT);
334 }
335
336 void JustSummoned(Creature* summon) override
337 {
338 if (Creature* magtheridon = _instance->GetCreature(DATA_MAGTHERIDON))
339 magtheridon->AI()->JustSummoned(summon);
340
341 DoZoneInCombat(summon);
342 }
343
344 void EnterEvadeMode(EvadeReason /*why*/) override
345 {
347 if (Creature* magtheridon = _instance->GetCreature(DATA_MAGTHERIDON))
348 magtheridon->AI()->EnterEvadeMode(EvadeReason::Other);
349 }
350
351 void UpdateAI(uint32 diff) override
352 {
353 if (!UpdateVictim())
354 return;
355
357 return;
358
359 _events.Update(diff);
360
361 while (uint32 eventId = _events.ExecuteEvent())
362 {
363 switch (eventId)
364 {
365 case EVENT_SHADOWBOLT:
367 _events.Repeat(Seconds(15), Seconds(20));
368 break;
369 case EVENT_FEAR:
371 DoCast(target, SPELL_FEAR);
372 _events.Repeat(Seconds(25), Seconds(40));
373 break;
376 {
378 {
379 DoCast(target, SPELL_DARK_MENDING);
380 _canCastDarkMending = false;
382 }
383 }
385 break;
387 _canCastDarkMending = true;
388 break;
389 case EVENT_ABYSSAL:
392 break;
393 default:
394 break;
395 }
396
398 return;
399 }
400 }
401
402private:
406};
407
409{
410 npc_magtheridon_room(Creature* creature) : PassiveAI(creature) { }
411
412 void Reset() override
413 {
415
416 _scheduler.Schedule(Seconds(5), [this](TaskContext /*context*/)
417 {
419 });
420 }
421
422 void UpdateAI(uint32 diff) override
423 {
424 _scheduler.Update(diff);
425 }
426
427private:
429};
430
432{
434
435 bool OnGossipHello(Player* player) override
436 {
438 return true;
439
440 if (Creature* trigger = player->FindNearestCreature(NPC_HELFIRE_RAID_TRIGGER, 10.0f))
441 trigger->CastSpell(nullptr, SPELL_SHADOW_GRASP_VISUAL);
442
443 player->CastSpell(nullptr, SPELL_SHADOW_GRASP, true);
444 return true;
445 }
446};
447
448// 30541 - Blaze
450{
451 bool Validate(SpellInfo const* /*spell*/) override
452 {
453 return ValidateSpellInfo({ SPELL_BLAZE });
454 }
455
457 {
459 }
460
461 void Register() override
462 {
464 }
465};
466
467// 30410 - Shadow Grasp
469{
470 bool Validate(SpellInfo const* /*spell*/) override
471 {
473 }
474
475 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
476 {
478 if (Unit* caster = GetCaster())
479 caster->CastSpell(caster, SPELL_MIND_EXHAUSTION, true);
480 }
481
482 void Register() override
483 {
485 }
486};
487
488// 30166 - Shadow Grasp (Visual Effect)
490{
491 bool Validate(SpellInfo const* /*spell*/) override
492 {
493 return ValidateSpellInfo(
494 {
497 });
498 }
499
500 void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
501 {
502 Unit* target = GetTarget();
503
504 if (target->GetAuraCount(SPELL_SHADOW_GRASP_VISUAL) == 5)
505 target->CastSpell(target, SPELL_SHADOW_CAGE, true);
506 }
507
508 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
509 {
511 }
512
513 void Register() override
514 {
517 }
518};
519
521{
529}
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::minutes Minutes
Minutes shorthand typedef.
Definition: Duration.h:35
@ IN_PROGRESS
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELLVALUE_MAX_TARGETS
Definition: SpellDefines.h:230
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
#define SpellHitFn(F)
Definition: SpellScript.h:854
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_DEFENSIVE
Definition: UnitDefines.h:507
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ ACTION_START_CHANNELERS_EVENT
@ SUMMON_GROUP_CHANNELERS
@ SAY_DEATH
@ EMOTE_BLAST_NOVA
@ SAY_FREE
@ SAY_BANISHED
@ EMOTE_NEARLY_FREE
@ EMOTE_BREAKS_FREE
@ SAY_SLAY
@ SAY_TAUNT
@ EMOTE_WEAKEN
@ SAY_COLLAPSE
@ SPELL_SHADOW_BOLT_VOLLEY
@ SPELL_DEBRIS_SERVERSIDE
@ SPELL_DEBRIS_KNOCKDOWN
@ SPELL_CLEAVE
@ SPELL_SHADOW_CAGE
@ SPELL_QUAKE
@ SPELL_SHADOW_GRASP
@ SPELL_SHADOW_GRASP_C
@ SPELL_DARK_MENDING
@ SPELL_SOUL_TRANSFER
@ SPELL_FEAR
@ SPELL_BLAZE_TARGET
@ SPELL_DEBRIS_DAMAGE
@ SPELL_SHADOW_GRASP_VISUAL
@ SPELL_CAMERA_SHAKE
@ SPELL_SHADOW_CAGE_C
@ SPELL_BURNING_ABYSSAL
@ SPELL_MIND_EXHAUSTION
@ SPELL_DEBRIS_VISUAL
@ SPELL_BLAST_NOVA
@ SPELL_BERSERK
@ SPELL_BLAZE
@ PHASE_BANISH
@ PHASE_3
@ PHASE_2
@ PHASE_1
void AddSC_boss_magtheridon()
@ EVENT_SHADOWBOLT
@ EVENT_START_FIGHT
@ EVENT_RELEASED
@ EVENT_BLAZE
@ EVENT_TAUNT
@ EVENT_DEBRIS
@ EVENT_ABYSSAL
@ EVENT_DARK_MENDING
@ EVENT_NEARLY_EMOTE
@ EVENT_BERSERK
@ EVENT_FEAR
@ EVENT_BLAST_NOVA
@ EVENT_CHECK_FRIEND
@ EVENT_CLEAVE
@ EVENT_QUAKE
@ EVENT_DEBRIS_KNOCKDOWN
@ EVENT_COLLAPSE
Yells
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetCaster() const
Unit * GetTarget() const
InstanceScript *const instance
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void _JustDied()
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void SetBoundary(CreatureBoundary const *boundary, bool negativeBoundaries=false)
Definition: CreatureAI.cpp:446
Creature *const me
Definition: CreatureAI.h:61
void SetImmuneToPC(bool apply) override
Definition: Creature.h:170
void SetReactState(ReactStates st)
Definition: Creature.h:160
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void CancelEvent(uint32 eventId)
Definition: EventMap.cpp:131
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void Reset()
Definition: EventMap.cpp:21
virtual bool SetBossState(uint32 id, EncounterState state)
Creature * GetCreature(uint32 type)
CreatureBoundary const * GetBossBoundary(uint32 id) const
EncounterState GetBossState(uint32 id) const
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
uint32 const Id
Definition: SpellInfo.h:325
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
HookList< HitHandler > OnHit
Definition: SpellScript.h:850
Unit * GetHitUnit() const
void DoZoneInCombat(uint32 entry=0)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
uint32 GetAuraCount(uint32 spellId) const
Definition: Unit.cpp:4648
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
bool AttackStop()
Definition: Unit.cpp:5781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2148
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition: Object.cpp:2131
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
bool Validate(SpellInfo const *) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void OnApply(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
@ NPC_HELLFIRE_CHANNELLER
@ NPC_HELFIRE_RAID_TRIGGER
@ DATA_CALL_WARDERS
@ DATA_COLLAPSE
@ DATA_COLLAPSE_2
@ DATA_WORLD_TRIGGER
@ DATA_MANTICRON_CUBE
@ DATA_MAGTHERIDON
#define RegisterMagtheridonsLairCreatureAI(ai_name)
@ ACTION_ENABLE
@ ACTION_DISABLE
#define RegisterMagtheridonsLairGameObjectAI(ai_name)
Unit * DoSelectBelowHpPctFriendlyWithEntry(uint32 entry, float range, uint8 hpPct=1, bool excludeSelf=true)
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void Reset() override
void DoAction(int32 action) override
boss_magtheridon(Creature *creature)
void EnterEvadeMode(EvadeReason) override
void KilledUnit(Unit *who) override
void UpdateAI(uint32 diff) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void JustDied(Unit *) override
void SummonedCreatureDies(Creature *summon, Unit *) override
bool OnGossipHello(Player *player) override
go_manticron_cube(GameObject *go)
npc_hellfire_channeler(Creature *creature)
void JustEngagedWith(Unit *) override
InstanceScript * _instance
void JustSummoned(Creature *summon) override
void EnterEvadeMode(EvadeReason) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
npc_magtheridon_room(Creature *creature)