Core/Movement: Refactor jump speed calculation out of spell code
Port From (https://github.com/TrinityCore/TrinityCore/commit/705d5701bf17f1787d2646c55c994b0404659991)
This commit is contained in:
@@ -1036,6 +1036,28 @@ namespace Game.Movement
|
||||
Add(movement);
|
||||
}
|
||||
|
||||
public void CalculateJumpSpeeds(float dist, UnitMoveType moveType, float speedMultiplier, float minHeight, float maxHeight, out float speedXY, out float speedZ)
|
||||
{
|
||||
float baseSpeed = _owner.IsControlledByPlayer() ? SharedConst.playerBaseMoveSpeed[(int)moveType] : SharedConst.baseMoveSpeed[(int)moveType];
|
||||
Creature creature = _owner.ToCreature();
|
||||
if (creature != null)
|
||||
baseSpeed *= creature.GetCreatureTemplate().SpeedRun;
|
||||
|
||||
speedXY = Math.Min(baseSpeed * 3.0f * speedMultiplier, Math.Max(28.0f, _owner.GetSpeed(moveType) * 4.0f));
|
||||
|
||||
float duration = dist / speedXY;
|
||||
float durationSqr = duration * duration;
|
||||
float height;
|
||||
if (durationSqr < minHeight * 8 / gravity)
|
||||
height = minHeight;
|
||||
else if (durationSqr > maxHeight * 8 / gravity)
|
||||
height = maxHeight;
|
||||
else
|
||||
height = (float)(gravity * durationSqr / 8);
|
||||
|
||||
speedZ = (float)Math.Sqrt(2 * gravity * height);
|
||||
}
|
||||
|
||||
void ResolveDelayedActions()
|
||||
{
|
||||
while (_delayedActions.Count != 0)
|
||||
|
||||
Reference in New Issue
Block a user