mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Movement: various improvements for creature knockbacks
* creature knockbacks will no longer generate a full path but instead only use a destination point to reflect sniff data
* calculate the destination by using a mmap raycast instead of using a mmap path which had the chance of creating weird movements when GetNearPosition failed to get a proper collision point (knocking arround a tree for example or just somewhere it should not go at all)
(cherry picked from commit cfd63c350f)
This commit is contained in:
@@ -744,15 +744,16 @@ void MotionMaster::MoveKnockbackFrom(Position const& origin, float speedXY, floa
|
||||
if (speedXY < 0.01f)
|
||||
return;
|
||||
|
||||
float x, y, z;
|
||||
Position dest = _owner->GetPosition();
|
||||
float moveTimeHalf = speedZ / Movement::gravity;
|
||||
float dist = 2 * moveTimeHalf * speedXY;
|
||||
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
|
||||
|
||||
_owner->GetNearPoint(_owner, x, y, z, dist, _owner->GetAbsoluteAngle(origin) + float(M_PI));
|
||||
// Use a mmap raycast to get a valid destination.
|
||||
_owner->MovePositionToFirstCollision(dest, dist, _owner->GetRelativeAngle(origin) + float(M_PI));
|
||||
|
||||
Movement::MoveSplineInit init(_owner);
|
||||
init.MoveTo(x, y, z);
|
||||
init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
|
||||
init.SetParabolic(max_height, 0);
|
||||
init.SetOrientationFixed(true);
|
||||
init.SetVelocity(speedXY);
|
||||
|
||||
Reference in New Issue
Block a user