diff --git a/Source/Game/Movement/MotionMaster.cs b/Source/Game/Movement/MotionMaster.cs index 84f85b3a5..232fefc5b 100644 --- a/Source/Game/Movement/MotionMaster.cs +++ b/Source/Game/Movement/MotionMaster.cs @@ -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) diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index f06851a84..cd58382d3 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -480,30 +480,15 @@ namespace Game.Spells void CalculateJumpSpeeds(SpellEffectInfo effInfo, float dist, out float speedXY, out float speedZ) { Unit unitCaster = GetUnitCasterForEffectHandlers(); - float runSpeed = unitCaster.IsControlledByPlayer() ? SharedConst.playerBaseMoveSpeed[(int)UnitMoveType.Run] : SharedConst.baseMoveSpeed[(int)UnitMoveType.Run]; - Creature creature = unitCaster.ToCreature(); - if (creature != null) - runSpeed *= creature.GetCreatureTemplate().SpeedRun; float multiplier = effInfo.Amplitude; if (multiplier <= 0.0f) multiplier = 1.0f; - speedXY = Math.Min(runSpeed * 3.0f * multiplier, Math.Max(28.0f, unitCaster.GetSpeed(UnitMoveType.Run) * 4.0f)); - - float duration = dist / speedXY; - float durationSqr = duration * duration; float minHeight = effInfo.MiscValue != 0 ? effInfo.MiscValue / 10.0f : 0.5f; // Lower bound is blizzlike float maxHeight = effInfo.MiscValueB != 0 ? effInfo.MiscValueB / 10.0f : 1000.0f; // Upper bound is unknown - float height; - if (durationSqr < minHeight * 8 / MotionMaster.gravity) - height = minHeight; - else if (durationSqr > maxHeight * 8 / MotionMaster.gravity) - height = maxHeight; - else - height = (float)(MotionMaster.gravity * durationSqr / 8); - speedZ = MathF.Sqrt((float)(2 * MotionMaster.gravity * height)); + unitCaster.GetMotionMaster().CalculateJumpSpeeds(dist, UnitMoveType.Run, multiplier, minHeight, maxHeight, out speedXY, out speedZ); } [SpellEffectHandler(SpellEffectName.Jump)]