Scripts/Spells: Implement OnPrecast scripting hook for spell scripts
Port From (https://github.com/TrinityCore/TrinityCore/commit/12d00e2e5f7e2cc7efe1ea8d126f9408055c05f8)
This commit is contained in:
@@ -44,7 +44,8 @@ namespace Framework.Constants
|
||||
OnCast,
|
||||
OnResistAbsorbCalculation,
|
||||
AfterCast,
|
||||
CalcCritChance
|
||||
CalcCritChance,
|
||||
OnPrecast
|
||||
}
|
||||
|
||||
// AuraScript interface - enum used for runtime checks of script function calls
|
||||
|
||||
@@ -502,6 +502,8 @@ namespace Game.Scripting
|
||||
|| m_currentScriptState == (byte)SpellScriptHookType.EffectSuccessfulDispel;
|
||||
}
|
||||
|
||||
public virtual void OnPrecast() { }
|
||||
|
||||
Spell m_spell;
|
||||
uint m_hitPreventEffectMask;
|
||||
uint m_hitPreventDefaultEffectMask;
|
||||
|
||||
@@ -2413,6 +2413,8 @@ namespace Game.Spells
|
||||
// set timer base at cast time
|
||||
ReSetTimer();
|
||||
|
||||
CallScriptOnPrecastHandler();
|
||||
|
||||
Log.outDebug(LogFilter.Spells, "Spell.prepare: spell id {0} source {1} caster {2} customCastFlags {3} mask {4}", m_spellInfo.Id, m_caster.GetEntry(), m_originalCaster != null ? (int)m_originalCaster.GetEntry() : -1, _triggeredCastFlags, m_targets.GetTargetMask());
|
||||
|
||||
if (m_spellInfo.HasAttribute(SpellAttr12.StartCooldownOnCastStart))
|
||||
@@ -7131,6 +7133,16 @@ namespace Game.Spells
|
||||
}
|
||||
}
|
||||
|
||||
void CallScriptOnPrecastHandler()
|
||||
{
|
||||
foreach (var script in m_loadedScripts)
|
||||
{
|
||||
script._PrepareScriptCall(SpellScriptHookType.OnPrecast);
|
||||
script.OnPrecast();
|
||||
script._FinishScriptCall();
|
||||
}
|
||||
}
|
||||
|
||||
void CallScriptBeforeCastHandlers()
|
||||
{
|
||||
foreach (var script in m_loadedScripts)
|
||||
|
||||
Reference in New Issue
Block a user