diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 4bfdf1d54..6d30c11cb 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1909,10 +1909,10 @@ namespace Game.AI if (e.Action.jump.Gravity != 0 || e.Action.jump.UseDefaultGravity != 0) { float gravity = e.Action.jump.UseDefaultGravity != 0 ? (float)MotionMaster.gravity : e.Action.jump.Gravity; - _me.GetMotionMaster().MoveJumpWithGravity(pos, e.Action.jump.SpeedXY, gravity, e.Action.jump.PointId, false, null, null, actionResultSetter); + _me.GetMotionMaster().MoveJumpWithGravity(pos, e.Action.jump.SpeedXY, gravity, e.Action.jump.PointId, null, null, null, actionResultSetter); } else - _me.GetMotionMaster().MoveJump(pos, e.Action.jump.SpeedXY, e.Action.jump.SpeedZ, e.Action.jump.PointId, false, null, null, actionResultSetter); + _me.GetMotionMaster().MoveJump(pos, e.Action.jump.SpeedXY, e.Action.jump.SpeedZ, e.Action.jump.PointId, null, null, null, actionResultSetter); mTimedActionWaitEvent = waitEvent; break; diff --git a/Source/Game/Entities/Unit/Unit.Movement.cs b/Source/Game/Entities/Unit/Unit.Movement.cs index ab44ddc6f..a8117ef25 100644 --- a/Source/Game/Entities/Unit/Unit.Movement.cs +++ b/Source/Game/Entities/Unit/Unit.Movement.cs @@ -468,14 +468,6 @@ namespace Game.Entities } } - public void JumpTo(WorldObject obj, float speedZ, bool withOrientation = false) - { - float x, y, z; - obj.GetContactPoint(this, out x, out y, out z); - float speedXY = GetExactDist2d(x, y) * 10.0f / speedZ; - GetMotionMaster().MoveJump(x, y, z, GetAbsoluteAngle(obj), speedXY, speedZ, EventId.Jump, withOrientation); - } - public void UpdateSpeed(UnitMoveType mtype) { int main_speed_mod = 0; diff --git a/Source/Game/Movement/MotionMaster.cs b/Source/Game/Movement/MotionMaster.cs index ebb5127a9..61be03bc7 100644 --- a/Source/Game/Movement/MotionMaster.cs +++ b/Source/Game/Movement/MotionMaster.cs @@ -768,15 +768,15 @@ namespace Game.Movement _owner.GetNearPoint2D(null, out float x, out float y, dist, _owner.GetOrientation() + angle); float z = _owner.GetPositionZ(); _owner.UpdateAllowedPositionZ(x, y, ref z); - MoveJump(x, y, z, 0.0f, speedXY, speedZ); + MoveJump(x, y, z, speedXY, speedZ); } - public void MoveJump(Position pos, float speedXY, float speedZ, uint id = EventId.Jump, bool hasOrientation = false, JumpArrivalCastArgs arrivalCast = null, SpellEffectExtraData spellEffectExtraData = null, ActionResultSetter scriptResult = null) + public void MoveJump(Position pos, float speedXY, float speedZ, uint id = EventId.Jump, object facing = null, JumpArrivalCastArgs arrivalCast = null, SpellEffectExtraData spellEffectExtraData = null, ActionResultSetter scriptResult = null) { - MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), speedXY, speedZ, id, hasOrientation, arrivalCast, spellEffectExtraData, scriptResult); + MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), speedXY, speedZ, id, facing, arrivalCast, spellEffectExtraData, scriptResult); } - public void MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint id = EventId.Jump, bool hasOrientation = false, JumpArrivalCastArgs arrivalCast = null, SpellEffectExtraData spellEffectExtraData = null, ActionResultSetter scriptResult = null) + public void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint id = EventId.Jump, object facing = null, JumpArrivalCastArgs arrivalCast = null, SpellEffectExtraData spellEffectExtraData = null, ActionResultSetter scriptResult = null) { Log.outDebug(LogFilter.Server, "Unit ({0}) jump to point (X: {1} Y: {2} Z: {3})", _owner.GetGUID().ToString(), x, y, z); if (speedXY < 0.01f) @@ -794,8 +794,7 @@ namespace Game.Movement init.MoveTo(x, y, z, false); init.SetParabolic(max_height, 0); init.SetVelocity(speedXY); - if (hasOrientation) - init.SetFacing(o); + MoveSplineInitFacingVisitor(init, facing); if (spellEffectExtraData != null) init.SetSpellEffectExtraData(spellEffectExtraData); }; @@ -814,7 +813,7 @@ namespace Game.Movement Add(movement); } - public void MoveJumpWithGravity(Position pos, float speedXY, float gravity, uint id = EventId.Jump, bool hasOrientation = false, JumpArrivalCastArgs arrivalCast = null, SpellEffectExtraData spellEffectExtraData = null, ActionResultSetter scriptResult = null) + public void MoveJumpWithGravity(Position pos, float speedXY, float gravity, uint id = EventId.Jump, object facing = null, JumpArrivalCastArgs arrivalCast = null, SpellEffectExtraData spellEffectExtraData = null, ActionResultSetter scriptResult = null) { Log.outDebug(LogFilter.Movement, $"MotionMaster.MoveJumpWithGravity: '{_owner.GetGUID()}', jumps to point Id: {id} ({pos})"); if (speedXY < 0.01f) @@ -831,8 +830,7 @@ namespace Game.Movement init.SetUncompressed(); init.SetVelocity(speedXY); init.SetUnlimitedSpeed(); - if (hasOrientation) - init.SetFacing(pos.GetOrientation()); + MoveSplineInitFacingVisitor(init, facing); if (spellEffectExtraData != null) init.SetSpellEffectExtraData(spellEffectExtraData); }; @@ -852,6 +850,19 @@ namespace Game.Movement Add(movement); } + void MoveSplineInitFacingVisitor(MoveSplineInit init, object facing) + { + if (facing == null) + return; + + if (facing is Position pos) + init.SetFacing(pos); + else if (facing is Unit unit) + init.SetFacing(unit); + else if (facing is float angle) + init.SetFacing(angle); + } + public void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, byte stepCount, TimeSpan? duration = null, float? speed = null, MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode.Default, ActionResultSetter scriptResult = null) { var initializer = (MoveSplineInit init) => diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 90c56004d..99ca77cc8 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -534,7 +534,7 @@ namespace Game.Spells JumpArrivalCastArgs arrivalCast = new(); arrivalCast.SpellId = effectInfo.TriggerSpell; arrivalCast.Target = unitTarget.GetGUID(); - unitCaster.GetMotionMaster().MoveJump(unitTarget, speedXY, speedZ, EventId.Jump, false, arrivalCast); + unitCaster.GetMotionMaster().MoveJump(unitTarget, speedXY, speedZ, EventId.Jump, null, arrivalCast); } [SpellEffectHandler(SpellEffectName.JumpDest)] @@ -555,9 +555,12 @@ namespace Game.Spells float speedXY, speedZ; CalculateJumpSpeeds(effectInfo, unitCaster.GetExactDist2d(destTarget), out speedXY, out speedZ); + object facing = null; + if (!m_targets.GetUnitTargetGUID().IsEmpty()) + facing = destTarget.GetOrientation(); JumpArrivalCastArgs arrivalCast = new(); arrivalCast.SpellId = effectInfo.TriggerSpell; - unitCaster.GetMotionMaster().MoveJump(destTarget, speedXY, speedZ, EventId.Jump, !m_targets.GetObjectTargetGUID().IsEmpty(), arrivalCast); + unitCaster.GetMotionMaster().MoveJump(destTarget, speedXY, speedZ, EventId.Jump, facing, arrivalCast); } TeleportToOptions GetTeleportOptions(WorldObject caster, Unit unitTarget, SpellDestination targetDest) @@ -5585,7 +5588,7 @@ namespace Game.Spells effectExtra.ParabolicCurveId = jumpParams.ParabolicCurveId.Value; } - unitCaster.GetMotionMaster().MoveJumpWithGravity(destTarget, speed, jumpParams.JumpGravity, EventId.Jump, false, arrivalCast, effectExtra); + unitCaster.GetMotionMaster().MoveJumpWithGravity(destTarget, speed, jumpParams.JumpGravity, EventId.Jump, null, arrivalCast, effectExtra); } [SpellEffectHandler(SpellEffectName.LearnTransmogSet)]