Core/Movement: Allow setting position or object facing targets for jump movement

Port From (https://github.com/TrinityCore/TrinityCore/commit/ac73edc268bc8d5bbda9f4b05168e3e24c25ca45)
This commit is contained in:
Hondacrx
2024-08-26 16:48:36 -04:00
parent 89587bbd59
commit 7a43203e0c
4 changed files with 28 additions and 22 deletions
+2 -2
View File
@@ -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;
@@ -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;
+20 -9
View File
@@ -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<MovementStopReason> 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<MovementStopReason> 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<MovementStopReason> 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<MovementStopReason> 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<MovementStopReason> 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<MovementStopReason> 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<MovementStopReason> scriptResult = null)
{
var initializer = (MoveSplineInit init) =>
+6 -3
View File
@@ -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)]