diff options
-rw-r--r-- | src/server/game/AI/CreatureAI.h | 8 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 7 | ||||
-rw-r--r-- | src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp | 6 | ||||
-rw-r--r-- | src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp | 7 |
6 files changed, 25 insertions, 14 deletions
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 05e615631b7..54b5d8c15af 100644 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -33,6 +33,7 @@ class PlayerAI; class WorldObject; struct Position; enum class QuestGiverStatus : uint32; +enum SpellFinishReason : uint8; typedef std::vector<AreaBoundary const*> CreatureBoundary; @@ -139,11 +140,8 @@ class TC_GAME_API CreatureAI : public UnitAI // Called when spell hits a target virtual void SpellHitTarget(WorldObject* /*target*/, SpellInfo const* /*spellInfo*/) { } - // Called when a spell cast gets interrupted - virtual void OnSpellCastInterrupt(SpellInfo const* /*spell*/) { } - - // Called when a spell cast has been successfully finished - virtual void OnSuccessfulSpellCast(SpellInfo const* /*spell*/) { } + // Called when a spell either finishes, interrupts or cancels a spell cast + virtual void OnSpellCastFinished(SpellInfo const* /*spell*/, SpellFinishReason /*reason*/) { } // Should return true if the NPC is currently being escorted virtual bool IsEscorted() const { return false; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 25f3c5ca404..94ad263d2fa 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2879,7 +2879,7 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi } if (GetTypeId() == TYPEID_UNIT && IsAIEnabled()) - ToCreature()->AI()->OnSpellCastInterrupt(spell->GetSpellInfo()); + ToCreature()->AI()->OnSpellCastFinished(spell->GetSpellInfo(), SPELL_FINISHED_CANCELED); } } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index ae5665d53a2..f1203d70e3d 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3724,10 +3724,10 @@ void Spell::_cast(bool skipCheck) Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr); - // Call CreatureAI hook OnSuccessfulSpellCast + // Call CreatureAI hook OnSpellCastFinished if (Creature* caster = m_originalCaster->ToCreature()) if (caster->IsAIEnabled()) - caster->AI()->OnSuccessfulSpellCast(GetSpellInfo()); + caster->AI()->OnSpellCastFinished(GetSpellInfo(), SPELL_FINISHED_SUCCESSFUL_CAST); } template <class Container> @@ -4086,6 +4086,11 @@ void Spell::update(uint32 difftime) { SendChannelUpdate(0); finish(); + + // We call the hook here instead of in Spell::finish because we only want to call it for completed channeling. Everything else is handled by interrupts + if (Creature* creatureCaster = m_caster->ToCreature()) + if (creatureCaster->IsAIEnabled()) + creatureCaster->AI()->OnSpellCastFinished(m_spellInfo, SPELL_FINISHED_CHANNELING_COMPLETE); } break; } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 76cba756fd0..bbe87563654 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -152,6 +152,13 @@ enum SpellRangeFlag SPELL_RANGE_RANGED = 2 //hunter range and ranged weapon }; +enum SpellFinishReason : uint8 +{ + SPELL_FINISHED_SUCCESSFUL_CAST = 0, // spell has sucessfully launched + SPELL_FINISHED_CANCELED = 1, // spell has been canceled (interrupts) + SPELL_FINISHED_CHANNELING_COMPLETE = 2 // spell channeling has been finished +}; + struct SpellLogEffectPowerDrainParams { ObjectGuid Victim; diff --git a/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp b/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp index b8c45975ff8..aa6f2630ddf 100644 --- a/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp +++ b/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp @@ -24,6 +24,7 @@ #include "ObjectAccessor.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" +#include "Spell.h" #include "SpellAuras.h" #include "SpellScript.h" #include "SpellAuraEffects.h" @@ -246,8 +247,11 @@ struct boss_garothi_worldbreaker : public BossAI instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); } - void OnSuccessfulSpellCast(SpellInfo const* spell) override + void OnSpellCastFinished(SpellInfo const* spell, SpellFinishReason reason) override { + if (reason != SPELL_FINISHED_SUCCESSFUL_CAST) + return; + switch (spell->Id) { case SPELL_APOCALYPSE_DRIVE_FINAL_DAMAGE: diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 3d676b29f7c..0a86b71d03c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1321,12 +1321,9 @@ struct npc_shambling_horror_icc : public ScriptedAI DoMeleeAttackIfReady(); } - void OnSpellCastInterrupt(SpellInfo const* spell) override + void OnSpellCastFinished(SpellInfo const* spell, SpellFinishReason reason) override { - ScriptedAI::OnSpellCastInterrupt(spell); - - // When enrage is interrupted, reschedule the event - if (spell->Id == ENRAGE) + if (reason == SPELL_FINISHED_CANCELED && spell->Id == ENRAGE) _events.RescheduleEvent(EVENT_ENRAGE, 1s); } |