Core/Spells: Fixed spell target selection not being shared by multiple effects when there are targeting scripts that have the same script function
Port From (https://github.com/TrinityCore/TrinityCore/commit/b1d8061a0f848241fe70ab0d718e829836cb5601)
This commit is contained in:
@@ -392,7 +392,12 @@ namespace Game.Scripting
|
|||||||
public Targets GetTarget() { return _targetType; }
|
public Targets GetTarget() { return _targetType; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ObjectAreaTargetSelectHandler : TargetHook
|
public interface ITargetFunction
|
||||||
|
{
|
||||||
|
public virtual bool HasSameTargetFunctionAs<T>(T other) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ObjectAreaTargetSelectHandler : TargetHook, ITargetFunction
|
||||||
{
|
{
|
||||||
SpellObjectAreaTargetSelectFnType _callImpl;
|
SpellObjectAreaTargetSelectFnType _callImpl;
|
||||||
|
|
||||||
@@ -405,9 +410,14 @@ namespace Game.Scripting
|
|||||||
{
|
{
|
||||||
_callImpl(targets);
|
_callImpl(targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasSameTargetFunctionAs(ObjectAreaTargetSelectHandler other)
|
||||||
|
{
|
||||||
|
return _callImpl.Method == other._callImpl.Method || _callImpl.Target == other._callImpl.Target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ObjectTargetSelectHandler : TargetHook
|
public class ObjectTargetSelectHandler : TargetHook, ITargetFunction
|
||||||
{
|
{
|
||||||
SpellObjectTargetSelectFnType _callImpl;
|
SpellObjectTargetSelectFnType _callImpl;
|
||||||
|
|
||||||
@@ -420,6 +430,11 @@ namespace Game.Scripting
|
|||||||
{
|
{
|
||||||
_callImpl(ref target);
|
_callImpl(ref target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasSameTargetFunctionAs(ObjectTargetSelectHandler other)
|
||||||
|
{
|
||||||
|
return _callImpl.Method == other._callImpl.Method || _callImpl.Target == other._callImpl.Target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DestinationTargetSelectHandler : TargetHook
|
public class DestinationTargetSelectHandler : TargetHook
|
||||||
|
|||||||
+23
-10
@@ -8194,21 +8194,34 @@ namespace Game.Spells
|
|||||||
|
|
||||||
bool CheckScriptEffectImplicitTargets(uint effIndex, uint effIndexToCheck)
|
bool CheckScriptEffectImplicitTargets(uint effIndex, uint effIndexToCheck)
|
||||||
{
|
{
|
||||||
// Skip if there are not any script
|
bool allEffectTargetScriptsAreShared<T>(List<T> hooks, SpellInfo spellInfo, uint effIndex, uint effIndexToCheck) where T : SpellScript.EffectHook, SpellScript.ITargetFunction
|
||||||
if (m_loadedScripts.Empty())
|
{
|
||||||
|
foreach (var hook in hooks)
|
||||||
|
{
|
||||||
|
if (!hook.IsEffectAffected(spellInfo, effIndex))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool otherEffectHasSameTargetFunction = hooks.Any(other => other.IsEffectAffected(spellInfo, effIndexToCheck) && hook.HasSameTargetFunctionAs(other));
|
||||||
|
if (!otherEffectHasSameTargetFunction)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
foreach (var script in m_loadedScripts)
|
foreach (var script in m_loadedScripts)
|
||||||
{
|
{
|
||||||
foreach (var hook in script.OnObjectTargetSelect)
|
if (!allEffectTargetScriptsAreShared(script.OnObjectTargetSelect, m_spellInfo, effIndex, effIndexToCheck))
|
||||||
if ((hook.IsEffectAffected(m_spellInfo, effIndex) && !hook.IsEffectAffected(m_spellInfo, effIndexToCheck)) ||
|
return false;
|
||||||
(!hook.IsEffectAffected(m_spellInfo, effIndex) && hook.IsEffectAffected(m_spellInfo, effIndexToCheck)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
foreach (var hook in script.OnObjectAreaTargetSelect)
|
if (!allEffectTargetScriptsAreShared(script.OnObjectTargetSelect, m_spellInfo, effIndexToCheck, effIndex))
|
||||||
if ((hook.IsEffectAffected(m_spellInfo, effIndex) && !hook.IsEffectAffected(m_spellInfo, effIndexToCheck)) ||
|
return false;
|
||||||
(!hook.IsEffectAffected(m_spellInfo, effIndex) && hook.IsEffectAffected(m_spellInfo, effIndexToCheck)))
|
|
||||||
return false;
|
if (!allEffectTargetScriptsAreShared(script.OnObjectAreaTargetSelect, m_spellInfo, effIndex, effIndexToCheck))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!allEffectTargetScriptsAreShared(script.OnObjectAreaTargetSelect, m_spellInfo, effIndexToCheck, effIndex))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user