Core/AI: refactor SpellHit and SpellHitTarget.
Port From (https://github.com/TrinityCore/TrinityCore/commit/3171cd3fa9dbcec43f5d70b74ab2f54a2aa44173)
This commit is contained in:
@@ -486,12 +486,10 @@ namespace Game.AI
|
||||
public virtual void JustUnregisteredAreaTrigger(AreaTrigger areaTrigger) { }
|
||||
|
||||
// Called when hit by a spell
|
||||
public virtual void SpellHit(Unit caster, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHitByGameObject(GameObject caster, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHit(WorldObject caster, SpellInfo spellInfo) { }
|
||||
|
||||
// Called when spell hits a target
|
||||
public virtual void SpellHitTarget(Unit target, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHitTargetGameObject(GameObject target, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHitTarget(WorldObject target, SpellInfo spellInfo) { }
|
||||
|
||||
// Called when a spell cast gets interrupted
|
||||
public virtual void OnSpellCastInterrupt(SpellInfo spell) { }
|
||||
|
||||
@@ -95,12 +95,10 @@ namespace Game.AI
|
||||
public virtual void EventInform(uint eventId) { }
|
||||
|
||||
// Called when hit by a spell
|
||||
public virtual void SpellHit(Unit caster, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHitByGameObject(GameObject caster, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHit(WorldObject caster, SpellInfo spellInfo) { }
|
||||
|
||||
// Called when spell hits a target
|
||||
public virtual void SpellHitTarget(Unit target, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHitTargetGameObject(GameObject target, SpellInfo spellInfo) { }
|
||||
public virtual void SpellHitTarget(WorldObject target, SpellInfo spellInfo) { }
|
||||
|
||||
// Called when the gameobject summon successfully other creature
|
||||
public virtual void JustSummoned(Creature summon) { }
|
||||
|
||||
@@ -664,24 +664,14 @@ namespace Game.AI
|
||||
}
|
||||
}
|
||||
|
||||
public override void SpellHit(Unit caster, SpellInfo spellInfo)
|
||||
public override void SpellHit(WorldObject caster, SpellInfo spellInfo)
|
||||
{
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHit, caster, 0, 0, false, spellInfo);
|
||||
}
|
||||
|
||||
public override void SpellHitByGameObject(GameObject obj, SpellInfo spellInfo)
|
||||
{
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHit, null, 0, 0, false, spellInfo, obj);
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHit, caster.ToUnit(), 0, 0, false, spellInfo, caster.ToGameObject());
|
||||
}
|
||||
|
||||
public override void SpellHitTarget(Unit target, SpellInfo spellInfo)
|
||||
public override void SpellHitTarget(WorldObject target, SpellInfo spellInfo)
|
||||
{
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHitTarget, target, 0, 0, false, spellInfo);
|
||||
}
|
||||
|
||||
public override void SpellHitTargetGameObject(GameObject target, SpellInfo spellInfo)
|
||||
{
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHitTarget, null, 0, 0, false, spellInfo, target);
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHitTarget, target.ToUnit(), 0, 0, false, spellInfo, target.ToGameObject());
|
||||
}
|
||||
|
||||
public override void DamageTaken(Unit attacker, ref uint damage)
|
||||
@@ -1199,9 +1189,9 @@ namespace Game.AI
|
||||
GetScript().ProcessEventsFor(SmartEvents.GoEventInform, null, eventId);
|
||||
}
|
||||
|
||||
public override void SpellHit(Unit unit, SpellInfo spellInfo)
|
||||
public override void SpellHit(WorldObject caster, SpellInfo spellInfo)
|
||||
{
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHit, unit, 0, 0, false, spellInfo);
|
||||
GetScript().ProcessEventsFor(SmartEvents.SpellHit, caster.ToUnit(), 0, 0, false, spellInfo);
|
||||
}
|
||||
|
||||
public override void JustSummoned(Creature creature)
|
||||
|
||||
@@ -8226,12 +8226,7 @@ namespace Game.Spells
|
||||
{
|
||||
CreatureAI hitTargetAI = cHitTarget.GetAI();
|
||||
if (hitTargetAI != null)
|
||||
{
|
||||
if (spell.GetCaster().IsGameObject())
|
||||
hitTargetAI.SpellHitByGameObject(spell.GetCaster().ToGameObject(), spell.m_spellInfo);
|
||||
else
|
||||
hitTargetAI.SpellHit(spell.GetCaster().ToUnit(), spell.m_spellInfo);
|
||||
}
|
||||
hitTargetAI.SpellHit(spell.GetCaster(), spell.m_spellInfo);
|
||||
}
|
||||
|
||||
if (spell.GetCaster().IsCreature() && spell.GetCaster().ToCreature().IsAIEnabled())
|
||||
@@ -8285,17 +8280,12 @@ namespace Game.Spells
|
||||
|
||||
//AI functions
|
||||
if (go.GetAI() != null)
|
||||
{
|
||||
if (spell.GetCaster().IsGameObject())
|
||||
go.GetAI().SpellHitByGameObject(spell.GetCaster().ToGameObject(), spell.m_spellInfo);
|
||||
else
|
||||
go.GetAI().SpellHit(spell.GetCaster().ToUnit(), spell.m_spellInfo);
|
||||
}
|
||||
go.GetAI().SpellHit(spell.GetCaster(), spell.m_spellInfo);
|
||||
|
||||
if (spell.GetCaster().IsCreature() && spell.GetCaster().ToCreature().IsAIEnabled())
|
||||
spell.GetCaster().ToCreature().GetAI().SpellHitTargetGameObject(go, spell.m_spellInfo);
|
||||
spell.GetCaster().ToCreature().GetAI().SpellHitTarget(go, spell.m_spellInfo);
|
||||
else if (spell.GetCaster().IsGameObject() && spell.GetCaster().ToGameObject().GetAI() != null)
|
||||
spell.GetCaster().ToGameObject().GetAI().SpellHitTargetGameObject(go, spell.m_spellInfo);
|
||||
spell.GetCaster().ToGameObject().GetAI().SpellHitTarget(go, spell.m_spellInfo);
|
||||
|
||||
spell.CallScriptOnHitHandlers();
|
||||
spell.CallScriptAfterHitHandlers();
|
||||
|
||||
Reference in New Issue
Block a user