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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
return $"X: {posX} Y: {posY} Z: {posZ} O: {Orientation}";
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Game.Entities
|
||||
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();
|
||||
if (!player)
|
||||
@@ -250,11 +250,18 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
if (!player)
|
||||
GetMotionMaster().MoveKnockbackFrom(x, y, speedXY, speedZ, spellEffectExtraData);
|
||||
GetMotionMaster().MoveKnockbackFrom(origin, speedXY, speedZ, spellEffectExtraData);
|
||||
else
|
||||
{
|
||||
float vcos, vsin;
|
||||
GetSinCos(x, y, out vsin, out vcos);
|
||||
float o = GetPosition() == origin ? GetOrientation() + MathF.PI : origin.GetRelativeAngle(this);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user