Core/Spells: Fix assertion triggered
Port From (https://github.com/TrinityCore/TrinityCore/commit/e71352db6f50d33de54b757a6af3cbe077136d65)
This commit is contained in:
@@ -3763,10 +3763,21 @@ namespace Game.Spells
|
||||
|
||||
// This is a blizzlike mistake: this should be 2D distance according to projectile motion formulas, but Blizzard erroneously used 3D distance.
|
||||
float distXY = unitTarget.GetExactDist(pos);
|
||||
|
||||
// Avoid division by 0
|
||||
if (distXY < 0.001)
|
||||
return;
|
||||
|
||||
float distZ = pos.GetPositionZ() - unitTarget.GetPositionZ();
|
||||
float speedXY = effectInfo.MiscValue != 0 ? effectInfo.MiscValue / 10.0f : 30.0f;
|
||||
float speedZ = (float)((2 * speedXY * speedXY * distZ + MotionMaster.gravity * distXY * distXY) / (2 * speedXY * distXY));
|
||||
|
||||
if (!float.IsFinite(speedZ))
|
||||
{
|
||||
Log.outError(LogFilter.Spells, $"Spell {m_spellInfo.Id} with SPELL_EFFECT_PULL_TOWARDS called with invalid speedZ. {GetDebugInfo()}");
|
||||
return;
|
||||
}
|
||||
|
||||
unitTarget.JumpTo(speedXY, speedZ, true, pos);
|
||||
}
|
||||
|
||||
@@ -3788,11 +3799,22 @@ namespace Game.Spells
|
||||
Position pos = m_targets.GetDstPos();
|
||||
// This is a blizzlike mistake: this should be 2D distance according to projectile motion formulas, but Blizzard erroneously used 3D distance
|
||||
float distXY = unitTarget.GetExactDist(pos);
|
||||
|
||||
// Avoid division by 0
|
||||
if (distXY < 0.001)
|
||||
return;
|
||||
|
||||
float distZ = pos.GetPositionZ() - unitTarget.GetPositionZ();
|
||||
|
||||
float speedXY = effectInfo.MiscValue != 0 ? effectInfo.MiscValue / 10.0f : 30.0f;
|
||||
float speedZ = (float)((2 * speedXY * speedXY * distZ + MotionMaster.gravity * distXY * distXY) / (2 * speedXY * distXY));
|
||||
|
||||
if (!float.IsFinite(speedZ))
|
||||
{
|
||||
Log.outError(LogFilter.Spells, $"Spell {m_spellInfo.Id} with SPELL_EFFECT_PULL_TOWARDS_DEST called with invalid speedZ. {GetDebugInfo()}");
|
||||
return;
|
||||
}
|
||||
|
||||
unitTarget.JumpTo(speedXY, speedZ, true, pos);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user