mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/AI: Implemented OnSpellCastInterrupt and OnSuccessfulSpellCast hooks
Ported from:020825902cand1aa42e97a8
This commit is contained in:
@@ -145,6 +145,12 @@ class TC_GAME_API CreatureAI : public UnitAI
|
||||
virtual void SpellHitTarget(Unit* /*target*/, SpellInfo const* /*spellInfo*/) { }
|
||||
virtual void SpellHitTargetGameObject(GameObject* /*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*/) { }
|
||||
|
||||
// Should return true if the NPC is currently being escorted
|
||||
virtual bool IsEscorted() const { return false; }
|
||||
|
||||
|
||||
@@ -3011,6 +3011,9 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi
|
||||
m_currentSpells[spellType] = nullptr;
|
||||
spell->SetReferencedFromCurrent(false);
|
||||
}
|
||||
|
||||
if (GetTypeId() == TYPEID_UNIT && IsAIEnabled())
|
||||
ToCreature()->AI()->OnSpellCastInterrupt(spell->GetSpellInfo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3454,6 +3454,11 @@ void Spell::_cast(bool skipCheck)
|
||||
hitMask |= PROC_HIT_NORMAL;
|
||||
|
||||
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
|
||||
if (Creature* caster = m_originalCaster->ToCreature())
|
||||
if (caster->IsAIEnabled())
|
||||
caster->AI()->OnSuccessfulSpellCast(GetSpellInfo());
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
|
||||
Reference in New Issue
Block a user