From 990defbdd8e4d4e7833911ce8d195630f784d879 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 4 Apr 2018 02:19:45 +0200 Subject: [PATCH] Core/Creature: move MakeInterruptable helper to creature class to make it accessible from all places with no multiple definitions --- src/server/game/Entities/Creature/Creature.cpp | 6 ++++++ src/server/game/Entities/Creature/Creature.h | 2 ++ .../Kalimdor/HallsOfOrigination/boss_rajh.cpp | 18 ++++++------------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 6331ff1886c..c7569365ed1 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2953,3 +2953,9 @@ bool Creature::IsAllowedToRepostionAgainst(Unit* target) const && !IsDungeonBoss() // 6. Creature is a dungeon boss && !isWorldBoss(); // 7. Creature is a world boss } + +void Creature::MakeInterruptable(bool apply) +{ + ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPT, !apply); + ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, !apply); +} diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 4cc774ef2cb..3bcc6620044 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -328,6 +328,8 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma bool CanGiveExperience() const; bool IsAllowedToRepostionAgainst(Unit* target) const; + void MakeInterruptable(bool apply); + protected: bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 entry, CreatureData const* data = nullptr, uint32 vehId = 0); bool InitEntry(uint32 entry, CreatureData const* data = nullptr); diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp index 53cc8f47808..071d4d1c192 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_rajh.cpp @@ -105,7 +105,7 @@ public: _achievementEnabled = true; me->SetReactState(REACT_PASSIVE); me->SetPower(POWER_ENERGY, 100); - MakeInterruptable(false); + me->MakeInterruptable(false); } void JustEngagedWith(Unit* /*who*/) override @@ -127,7 +127,7 @@ public: if (summon->GetEntry() == NPC_INFERNO_LEAP) { - MakeInterruptable(true); + me->MakeInterruptable(true); events.ScheduleEvent(EVENT_INFERNO_LEAP, 1); events.ScheduleEvent(EVENT_APPLY_IMMUNITY, Seconds(1) + Milliseconds(500)); } @@ -150,22 +150,16 @@ public: { _EnterEvadeMode(); summons.DespawnAll(); - MakeInterruptable(false); instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); _DespawnAtEvade(); } + void OnSpellCastInterrupt(SpellInfo const* /*spell*/) override { - MakeInterruptable(false); + me->MakeInterruptable(false); events.CancelEvent(EVENT_APPLY_IMMUNITY); } - void MakeInterruptable(bool apply) - { - me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPT, !apply); - me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, !apply); - } - uint32 GetData(uint32 type) const override { switch (type) @@ -225,7 +219,7 @@ public: DoCastSelf(SPELL_SOLAR_WINDS_SUMMON); break; case EVENT_SUMMON_SUN_ORB: - MakeInterruptable(true); + me->MakeInterruptable(true); me->StopMoving(); DoCastSelf(SPELL_SUMMON_SUN_ORB); events.Repeat(_randomTimerCase == 0 ? Seconds(35), Seconds(36) : Seconds(31), Seconds(37)); @@ -237,7 +231,7 @@ public: events.Repeat(_randomTimerCase == 0 ? Seconds(35) : Seconds(27)); break; case EVENT_APPLY_IMMUNITY: - MakeInterruptable(false); + me->MakeInterruptable(false); break; case EVENT_MOVE_TO_MIDDLE: events.Reset();