Core/Spells: fix logic error causing near teleports to drop combat for players
Port From (https://github.com/TrinityCore/TrinityCore/commit/8c379e920ca184d520c81ada26c42c5dfeac770d)
This commit is contained in:
@@ -34,7 +34,7 @@ namespace Framework.Constants
|
|||||||
EffectHitTarget,
|
EffectHitTarget,
|
||||||
EffectSuccessfulDispel,
|
EffectSuccessfulDispel,
|
||||||
BeforeHit,
|
BeforeHit,
|
||||||
OnHit,
|
Hit,
|
||||||
AfterHit,
|
AfterHit,
|
||||||
ObjectAreaTargetSelect,
|
ObjectAreaTargetSelect,
|
||||||
ObjectTargetSelect,
|
ObjectTargetSelect,
|
||||||
|
|||||||
@@ -447,16 +447,33 @@ namespace Game.Scripting
|
|||||||
case SpellScriptHookType.EffectHitTarget:
|
case SpellScriptHookType.EffectHitTarget:
|
||||||
case SpellScriptHookType.EffectSuccessfulDispel:
|
case SpellScriptHookType.EffectSuccessfulDispel:
|
||||||
case SpellScriptHookType.BeforeHit:
|
case SpellScriptHookType.BeforeHit:
|
||||||
case SpellScriptHookType.OnHit:
|
case SpellScriptHookType.Hit:
|
||||||
case SpellScriptHookType.AfterHit:
|
case SpellScriptHookType.AfterHit:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsInModifiableHook()
|
||||||
|
{
|
||||||
|
// after hit hook executed after damage/healing is already done
|
||||||
|
// modifying it at this point has no effect
|
||||||
|
switch ((SpellScriptHookType)m_currentScriptState)
|
||||||
|
{
|
||||||
|
case SpellScriptHookType.LaunchTarget:
|
||||||
|
case SpellScriptHookType.EffectHitTarget:
|
||||||
|
case SpellScriptHookType.BeforeHit:
|
||||||
|
case SpellScriptHookType.Hit:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsInHitPhase()
|
public bool IsInHitPhase()
|
||||||
{
|
{
|
||||||
return (m_currentScriptState >= (byte)SpellScriptHookType.EffectHit && m_currentScriptState < (byte)SpellScriptHookType.AfterHit + 1);
|
return (m_currentScriptState >= (byte)SpellScriptHookType.EffectHit && m_currentScriptState < (byte)SpellScriptHookType.AfterHit + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInEffectHook()
|
public bool IsInEffectHook()
|
||||||
{
|
{
|
||||||
return (m_currentScriptState >= (byte)SpellScriptHookType.Launch && m_currentScriptState <= (byte)SpellScriptHookType.EffectHitTarget)
|
return (m_currentScriptState >= (byte)SpellScriptHookType.Launch && m_currentScriptState <= (byte)SpellScriptHookType.EffectHitTarget)
|
||||||
@@ -675,7 +692,7 @@ namespace Game.Scripting
|
|||||||
}
|
}
|
||||||
public void SetHitDamage(int damage)
|
public void SetHitDamage(int damage)
|
||||||
{
|
{
|
||||||
if (!IsInTargetHook())
|
if (!IsInModifiableHook())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Scripts, "Script: `{0}` Spell: `{1}`: function SpellScript.SetHitDamage was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
|
Log.outError(LogFilter.Scripts, "Script: `{0}` Spell: `{1}`: function SpellScript.SetHitDamage was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
|
||||||
return;
|
return;
|
||||||
@@ -696,7 +713,7 @@ namespace Game.Scripting
|
|||||||
}
|
}
|
||||||
public void SetHitHeal(int heal)
|
public void SetHitHeal(int heal)
|
||||||
{
|
{
|
||||||
if (!IsInTargetHook())
|
if (!IsInModifiableHook())
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Scripts, "Script: `{0}` Spell: `{1}`: function SpellScript.SetHitHeal was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
|
Log.outError(LogFilter.Scripts, "Script: `{0}` Spell: `{1}`: function SpellScript.SetHitHeal was called, but function has no effect in current hook!", m_scriptName, m_scriptSpellId);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7132,7 +7132,7 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
foreach (var script in m_loadedScripts)
|
foreach (var script in m_loadedScripts)
|
||||||
{
|
{
|
||||||
script._PrepareScriptCall(SpellScriptHookType.OnHit);
|
script._PrepareScriptCall(SpellScriptHookType.Hit);
|
||||||
|
|
||||||
foreach (var hook in script.OnHit)
|
foreach (var hook in script.OnHit)
|
||||||
hook.Call();
|
hook.Call();
|
||||||
|
|||||||
Reference in New Issue
Block a user