Core/AI: Implement OnAuraApplied and OnAuraRemoved hooks
Port From (https://github.com/TrinityCore/TrinityCore/commit/d1e07ac6553c7ae1e3296fc044247f0d0f95d267)
This commit is contained in:
@@ -232,6 +232,8 @@ namespace Framework.Constants
|
|||||||
OnDespawn = 86, // NONE
|
OnDespawn = 86, // NONE
|
||||||
SendEventTrigger = 87, // NONE
|
SendEventTrigger = 87, // NONE
|
||||||
AreatriggerExit = 88, // None
|
AreatriggerExit = 88, // None
|
||||||
|
OnAuraApplied = 89, // SpellID, CooldownMin, CooldownMax
|
||||||
|
OnAuraRemoved = 90, // SpellID, CooldownMin, CooldownMax
|
||||||
|
|
||||||
End
|
End
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,6 +494,12 @@ namespace Game.AI
|
|||||||
// Called when a channeled spell finishes
|
// Called when a channeled spell finishes
|
||||||
public virtual void OnChannelFinished(SpellInfo spell) { }
|
public virtual void OnChannelFinished(SpellInfo spell) { }
|
||||||
|
|
||||||
|
// Called when aura is applied
|
||||||
|
public virtual void OnAuraApplied(AuraApplication aurApp) { }
|
||||||
|
|
||||||
|
// Called when aura is removed
|
||||||
|
public virtual void OnAuraRemoved(AuraApplication aurApp) { }
|
||||||
|
|
||||||
// Should return true if the NPC is currently being escorted
|
// Should return true if the NPC is currently being escorted
|
||||||
public virtual bool IsEscorted() { return false; }
|
public virtual bool IsEscorted() { return false; }
|
||||||
|
|
||||||
|
|||||||
@@ -642,6 +642,16 @@ namespace Game.AI
|
|||||||
GetScript().ProcessEventsFor(SmartEvents.OnSpellStart, null, 0, 0, false, spellInfo);
|
GetScript().ProcessEventsFor(SmartEvents.OnSpellStart, null, 0, 0, false, spellInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnAuraApplied(AuraApplication aurApp)
|
||||||
|
{
|
||||||
|
GetScript().ProcessEventsFor(SmartEvents.OnAuraApplied, null, 0, 0, false, aurApp.GetBase().GetSpellInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnAuraRemoved(AuraApplication aurApp)
|
||||||
|
{
|
||||||
|
GetScript().ProcessEventsFor(SmartEvents.OnAuraRemoved, null, 0, 0, false, aurApp.GetBase().GetSpellInfo());
|
||||||
|
}
|
||||||
|
|
||||||
public override void DamageTaken(Unit attacker, ref uint damage, DamageEffectType damageType, SpellInfo spellInfo = null)
|
public override void DamageTaken(Unit attacker, ref uint damage, DamageEffectType damageType, SpellInfo spellInfo = null)
|
||||||
{
|
{
|
||||||
GetScript().ProcessEventsFor(SmartEvents.Damaged, attacker, damage);
|
GetScript().ProcessEventsFor(SmartEvents.Damaged, attacker, damage);
|
||||||
|
|||||||
@@ -628,6 +628,8 @@ namespace Game.AI
|
|||||||
SmartEvents.OnSpellCast => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
SmartEvents.OnSpellCast => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
||||||
SmartEvents.OnSpellFailed => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
SmartEvents.OnSpellFailed => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
||||||
SmartEvents.OnSpellStart => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
SmartEvents.OnSpellStart => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
||||||
|
SmartEvents.OnAuraApplied => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
||||||
|
SmartEvents.OnAuraRemoved => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
|
||||||
SmartEvents.OnDespawn => 0,
|
SmartEvents.OnDespawn => 0,
|
||||||
SmartEvents.SendEventTrigger => 0,
|
SmartEvents.SendEventTrigger => 0,
|
||||||
SmartEvents.AreatriggerExit => 0,
|
SmartEvents.AreatriggerExit => 0,
|
||||||
@@ -1056,6 +1058,8 @@ namespace Game.AI
|
|||||||
case SmartEvents.OnSpellCast:
|
case SmartEvents.OnSpellCast:
|
||||||
case SmartEvents.OnSpellFailed:
|
case SmartEvents.OnSpellFailed:
|
||||||
case SmartEvents.OnSpellStart:
|
case SmartEvents.OnSpellStart:
|
||||||
|
case SmartEvents.OnAuraApplied:
|
||||||
|
case SmartEvents.OnAuraRemoved:
|
||||||
{
|
{
|
||||||
if (!IsSpellValid(e, e.Event.spellCast.spell))
|
if (!IsSpellValid(e, e.Event.spellCast.spell))
|
||||||
return false;
|
return false;
|
||||||
@@ -2587,6 +2591,8 @@ namespace Game.AI
|
|||||||
SmartEvents.OnDespawn => SmartScriptTypeMaskId.Creature,
|
SmartEvents.OnDespawn => SmartScriptTypeMaskId.Creature,
|
||||||
SmartEvents.SendEventTrigger => SmartScriptTypeMaskId.Event,
|
SmartEvents.SendEventTrigger => SmartScriptTypeMaskId.Event,
|
||||||
SmartEvents.AreatriggerExit => SmartScriptTypeMaskId.Areatrigger + SmartScriptTypeMaskId.AreatrigggerEntity,
|
SmartEvents.AreatriggerExit => SmartScriptTypeMaskId.Areatrigger + SmartScriptTypeMaskId.AreatrigggerEntity,
|
||||||
|
SmartEvents.OnAuraApplied => SmartScriptTypeMaskId.Creature,
|
||||||
|
SmartEvents.OnAuraRemoved => SmartScriptTypeMaskId.Creature,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3500,6 +3500,8 @@ namespace Game.AI
|
|||||||
case SmartEvents.OnSpellCast:
|
case SmartEvents.OnSpellCast:
|
||||||
case SmartEvents.OnSpellFailed:
|
case SmartEvents.OnSpellFailed:
|
||||||
case SmartEvents.OnSpellStart:
|
case SmartEvents.OnSpellStart:
|
||||||
|
case SmartEvents.OnAuraApplied:
|
||||||
|
case SmartEvents.OnAuraRemoved:
|
||||||
{
|
{
|
||||||
if (spell == null)
|
if (spell == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1486,6 +1486,19 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Creature creature = target.ToCreature();
|
||||||
|
if (creature != null)
|
||||||
|
{
|
||||||
|
var ai = creature.GetAI();
|
||||||
|
if (ai != null)
|
||||||
|
{
|
||||||
|
if (apply)
|
||||||
|
ai.OnAuraApplied(aurApp);
|
||||||
|
else
|
||||||
|
ai.OnAuraRemoved(aurApp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanBeAppliedOn(Unit target)
|
bool CanBeAppliedOn(Unit target)
|
||||||
|
|||||||
Reference in New Issue
Block a user