Core/Spells: unify OnSpellCastInterrupt and OnSuccessfulSpellCast hooks into OnSpellCastFinished
Port From (https://github.com/TrinityCore/TrinityCore/commit/d1594c7295f1ca3f21a63a13895abf371d8bd3e0)
This commit is contained in:
@@ -98,6 +98,13 @@ namespace Framework.Constants
|
||||
Ranged = 2 //hunter range and ranged weapon
|
||||
}
|
||||
|
||||
public enum SpellFinishReason
|
||||
{
|
||||
SuccessfulCast = 0, // spell has sucessfully launched
|
||||
Canceled = 1, // spell has been canceled (interrupts)
|
||||
ChannelingComplete = 2 // spell channeling has been finished
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SpellInterruptFlags
|
||||
{
|
||||
|
||||
@@ -492,11 +492,8 @@ namespace Game.AI
|
||||
// Called when spell hits a target
|
||||
public virtual void SpellHitTarget(WorldObject target, SpellInfo spellInfo) { }
|
||||
|
||||
// Called when a spell cast gets interrupted
|
||||
public virtual void OnSpellCastInterrupt(SpellInfo spell) { }
|
||||
|
||||
// Called when a spell cast has been successfully finished
|
||||
public virtual void OnSuccessfulSpellCast(SpellInfo spell) { }
|
||||
// Called when a spell either finishes, interrupts or cancels a spell cast
|
||||
public virtual void OnSpellCastFinished(SpellInfo spell, SpellFinishReason reason) { }
|
||||
|
||||
// Should return true if the NPC is currently being escorted
|
||||
public virtual bool IsEscorted() { return false; }
|
||||
|
||||
@@ -2422,7 +2422,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
if (IsCreature() && IsAIEnabled())
|
||||
ToCreature().GetAI().OnSpellCastInterrupt(spell.GetSpellInfo());
|
||||
ToCreature().GetAI().OnSpellCastFinished(spell.GetSpellInfo(), SpellFinishReason.Canceled);
|
||||
}
|
||||
}
|
||||
public void UpdateInterruptMask()
|
||||
|
||||
@@ -2904,7 +2904,7 @@ namespace Game.Spells
|
||||
Creature caster = m_originalCaster.ToCreature();
|
||||
if (caster)
|
||||
if (caster.IsAIEnabled())
|
||||
caster.GetAI().OnSuccessfulSpellCast(GetSpellInfo());
|
||||
caster.GetAI().OnSpellCastFinished(GetSpellInfo(), SpellFinishReason.SuccessfulCast);
|
||||
}
|
||||
|
||||
void DoProcessTargetContainer<T>(List<T> targetContainer) where T : TargetInfoBase
|
||||
@@ -3267,6 +3267,12 @@ namespace Game.Spells
|
||||
{
|
||||
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
|
||||
Creature creatureCaster = m_caster.ToCreature();
|
||||
if (creatureCaster != null)
|
||||
if (creatureCaster.IsAIEnabled())
|
||||
creatureCaster.GetAI().OnSpellCastFinished(m_spellInfo, SpellFinishReason.ChannelingComplete);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user