Core/Movement: Corrected values sent in knockback packet when speedXY < 0
Port From (https://github.com/TrinityCore/TrinityCore/commit/732a8ee26199d7f04c692fa64f96955db13cf69d)
This commit is contained in:
@@ -325,25 +325,6 @@ namespace Game.Entities
|
|||||||
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(pos.GetPositionX(), pos.GetPositionY()) < width;
|
return Math.Abs(Math.Sin(angle)) * GetExactDist2d(pos.GetPositionX(), pos.GetPositionY()) < width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetSinCos(float x, float y, out float vsin, out float vcos)
|
|
||||||
{
|
|
||||||
float dx = GetPositionX() - x;
|
|
||||||
float dy = GetPositionY() - y;
|
|
||||||
|
|
||||||
if (Math.Abs(dx) < 0.001f && Math.Abs(dy) < 0.001f)
|
|
||||||
{
|
|
||||||
float o = NormalizeOrientation(GetOrientation() - MathF.PI);
|
|
||||||
vcos = MathF.Cos(o);
|
|
||||||
vsin = MathF.Sin(o);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float dist = (float)Math.Sqrt((dx * dx) + (dy * dy));
|
|
||||||
vcos = dx / dist;
|
|
||||||
vsin = dy / dist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"X: {posX} Y: {posY} Z: {posZ} O: {Orientation}";
|
return $"X: {posX} Y: {posY} Z: {posZ} O: {Orientation}";
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ namespace Game.Entities
|
|||||||
GetMotionMaster().LaunchMoveSpline(init, 0, MovementGeneratorPriority.Normal, MovementGeneratorType.Point);
|
GetMotionMaster().LaunchMoveSpline(init, 0, MovementGeneratorPriority.Normal, MovementGeneratorType.Point);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KnockbackFrom(float x, float y, float speedXY, float speedZ, SpellEffectExtraData spellEffectExtraData = null)
|
public void KnockbackFrom(Position origin, float speedXY, float speedZ, SpellEffectExtraData spellEffectExtraData = null)
|
||||||
{
|
{
|
||||||
Player player = ToPlayer();
|
Player player = ToPlayer();
|
||||||
if (!player)
|
if (!player)
|
||||||
@@ -250,11 +250,18 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player)
|
if (!player)
|
||||||
GetMotionMaster().MoveKnockbackFrom(x, y, speedXY, speedZ, spellEffectExtraData);
|
GetMotionMaster().MoveKnockbackFrom(origin, speedXY, speedZ, spellEffectExtraData);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float vcos, vsin;
|
float o = GetPosition() == origin ? GetOrientation() + MathF.PI : origin.GetRelativeAngle(this);
|
||||||
GetSinCos(x, y, out vsin, out vcos);
|
if (speedXY < 0)
|
||||||
|
{
|
||||||
|
speedXY = -speedXY;
|
||||||
|
o = o - MathF.PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
float vcos = MathF.Cos(o);
|
||||||
|
float vsin = MathF.Sin(o);
|
||||||
SendMoveKnockBack(player, speedXY, -speedZ, vcos, vsin);
|
SendMoveKnockBack(player, speedXY, -speedZ, vcos, vsin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -656,7 +656,7 @@ namespace Game.Movement
|
|||||||
init.Launch();
|
init.Launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ, SpellEffectExtraData spellEffectExtraData = null)
|
public void MoveKnockbackFrom(Position origin, float speedXY, float speedZ, SpellEffectExtraData spellEffectExtraData = null)
|
||||||
{
|
{
|
||||||
//This function may make players fall below map
|
//This function may make players fall below map
|
||||||
if (_owner.IsTypeId(TypeId.Player))
|
if (_owner.IsTypeId(TypeId.Player))
|
||||||
@@ -670,7 +670,7 @@ namespace Game.Movement
|
|||||||
float dist = 2 * moveTimeHalf * speedXY;
|
float dist = 2 * moveTimeHalf * speedXY;
|
||||||
float max_height = -MoveSpline.ComputeFallElevation(moveTimeHalf, false, -speedZ);
|
float max_height = -MoveSpline.ComputeFallElevation(moveTimeHalf, false, -speedZ);
|
||||||
|
|
||||||
_owner.GetNearPoint(_owner, out x, out y, out z, dist, _owner.GetAbsoluteAngle(srcX, srcY) + MathFunctions.PI);
|
_owner.GetNearPoint(_owner, out x, out y, out z, dist, _owner.GetAbsoluteAngle(origin) + MathFunctions.PI);
|
||||||
|
|
||||||
MoveSplineInit init = new(_owner);
|
MoveSplineInit init = new(_owner);
|
||||||
init.MoveTo(x, y, z);
|
init.MoveTo(x, y, z);
|
||||||
|
|||||||
@@ -4021,18 +4021,18 @@ namespace Game.Spells
|
|||||||
if (speedxy < 0.01f && speedz < 0.01f)
|
if (speedxy < 0.01f && speedz < 0.01f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float x, y;
|
Position origin;
|
||||||
if (effectInfo.Effect == SpellEffectName.KnockBackDest)
|
if (effectInfo.Effect == SpellEffectName.KnockBackDest)
|
||||||
{
|
{
|
||||||
if (m_targets.HasDst())
|
if (m_targets.HasDst())
|
||||||
destTarget.GetPosition(out x, out y);
|
origin = new(destTarget.GetPosition());
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else //if (GetEffect(i].Effect == SPELL_EFFECT_KNOCK_BACK)
|
else //if (effectInfo.Effect == SPELL_EFFECT_KNOCK_BACK)
|
||||||
m_caster.GetPosition(out x, out y);
|
origin = new(m_caster.GetPosition());
|
||||||
|
|
||||||
unitTarget.KnockbackFrom(x, y, speedxy, speedz);
|
unitTarget.KnockbackFrom(origin, speedxy, speedz);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.LeapBack)]
|
[SpellEffectHandler(SpellEffectName.LeapBack)]
|
||||||
|
|||||||
@@ -1446,7 +1446,7 @@ namespace Scripts.Spells.Generic
|
|||||||
float verticalSpeed = 8.0f;
|
float verticalSpeed = 8.0f;
|
||||||
// This method relies on the Dalaran Sewer map disposition and Water Spout position
|
// This method relies on the Dalaran Sewer map disposition and Water Spout position
|
||||||
// What we do is knock the player from a position exactly behind him and at the end of the pipe
|
// What we do is knock the player from a position exactly behind him and at the end of the pipe
|
||||||
player.KnockbackFrom(target.GetPositionX(), player.GetPositionY(), horizontalSpeed, verticalSpeed);
|
player.KnockbackFrom(target.GetPosition(), horizontalSpeed, verticalSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user