Core/AI: OnSpellCast, OnSpellFailed, OnSpellStart hooks

Port From (https://github.com/TrinityCore/TrinityCore/commit/050f55b62fded4cc73b76e42d56d98ea950cc26a)
This commit is contained in:
hondacrx
2022-05-30 15:44:21 -04:00
parent 5575703997
commit 306b0cb227
8 changed files with 80 additions and 14 deletions
@@ -629,6 +629,9 @@ namespace Game.AI
SmartEvents.SceneCancel => 0,
SmartEvents.SceneComplete => 0,
SmartEvents.SummonedUnitDies => Marshal.SizeOf(typeof(SmartEvent.Summoned)),
SmartEvents.OnSpellCast => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
SmartEvents.OnSpellFailed => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
SmartEvents.OnSpellStart => Marshal.SizeOf(typeof(SmartEvent.SpellCast)),
_ => Marshal.SizeOf(typeof(SmartEvent.Raw)),
};
@@ -987,6 +990,17 @@ namespace Game.AI
if (!IsMinMaxValid(e, e.Event.spellHit.cooldownMin, e.Event.spellHit.cooldownMax))
return false;
break;
case SmartEvents.OnSpellCast:
case SmartEvents.OnSpellFailed:
case SmartEvents.OnSpellStart:
{
if (!IsSpellValid(e, e.Event.spellCast.spell))
return false;
if (!IsMinMaxValid(e, e.Event.spellCast.cooldownMin, e.Event.spellCast.cooldownMax))
return false;
break;
}
case SmartEvents.OocLos:
case SmartEvents.IcLos:
if (!IsMinMaxValid(e, e.Event.los.cooldownMin, e.Event.los.cooldownMax))
@@ -2406,6 +2420,9 @@ namespace Game.AI
SmartEvents.SceneCancel => SmartScriptTypeMaskId.Scene,
SmartEvents.SceneComplete => SmartScriptTypeMaskId.Scene,
SmartEvents.SummonedUnitDies => SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject,
SmartEvents.OnSpellCast => SmartScriptTypeMaskId.Creature,
SmartEvents.OnSpellFailed => SmartScriptTypeMaskId.Creature,
SmartEvents.OnSpellStart => SmartScriptTypeMaskId.Creature,
_ => 0,
};
@@ -2589,6 +2606,9 @@ namespace Game.AI
[FieldOffset(16)]
public Counter counter;
[FieldOffset(16)]
public SpellCast spellCast;
[FieldOffset(16)]
public Spell spell;
@@ -2782,6 +2802,12 @@ namespace Game.AI
public uint cooldownMin;
public uint cooldownMax;
}
public struct SpellCast
{
public uint spell;
public uint cooldownMin;
public uint cooldownMax;
}
public struct Spell
{
public uint effIndex;