Skip to content

Commit 51e04b6

Browse files
committed
Print jump heights for splines with spell effects
1 parent e032465 commit 51e04b6

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

WowPacketParser/Parsing/Parsers/MovementHandler.cs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -343,35 +343,40 @@ public static void PrintComputedSplineMovementParams(Packet packet, double dista
343343
packet.AddValue("Computed Distance", distance, indexes);
344344
packet.AddValue("Computed Speed", (distance / monsterMove.MoveTime) * 1000, indexes);
345345
if (monsterMove.Jump != null && monsterMove.Flags.HasAnyFlag(UniversalSplineFlag.Parabolic))
346-
{
347-
const double defaultGravity = 19.29110336303710937;
346+
PrintComputedSplineMovementJumpHeight(packet, monsterMove.MoveTime, monsterMove.Jump.Gravity, indexes);
347+
else if (monsterMove.SpellEffect != null && monsterMove.SpellEffect.JumpGravity > 0)
348+
PrintComputedSplineMovementJumpHeight(packet, monsterMove.MoveTime, monsterMove.SpellEffect.JumpGravity, indexes);
349+
}
348350

349-
static double ComputeFallElevation(double timePassed, double startVelocity, double gravity)
350-
{
351-
const double termVel = 60.148003;
351+
private static void PrintComputedSplineMovementJumpHeight(Packet packet, uint moveTime, float jumpGravity, params object[] indexes)
352+
{
353+
const double defaultGravity = 19.29110336303710937;
352354

353-
if (startVelocity > termVel)
354-
startVelocity = termVel;
355+
static double ComputeFallElevation(double timePassed, double startVelocity, double gravity)
356+
{
357+
const double termVel = 60.148003;
355358

356-
var terminalTime = (termVel - startVelocity) / gravity; // the time that needed to reach terminalVelocity
359+
if (startVelocity > termVel)
360+
startVelocity = termVel;
357361

358-
if (timePassed > terminalTime)
359-
return termVel * (timePassed - terminalTime) +
360-
startVelocity * terminalTime +
361-
gravity * terminalTime * terminalTime * 0.5f;
362+
var terminalTime = (termVel - startVelocity) / gravity; // the time that needed to reach terminalVelocity
362363

363-
return timePassed * (startVelocity + timePassed * gravity * 0.5f);
364-
}
364+
if (timePassed > terminalTime)
365+
return termVel * (timePassed - terminalTime) +
366+
startVelocity * terminalTime +
367+
gravity * terminalTime * terminalTime * 0.5f;
368+
369+
return timePassed * (startVelocity + timePassed * gravity * 0.5f);
370+
}
365371

366-
var speedZ = monsterMove.MoveTime * monsterMove.Jump.Gravity / 2.0 / 1000.0;
367-
var height = -ComputeFallElevation(monsterMove.MoveTime / 2.0 / 1000.0, -speedZ, monsterMove.Jump.Gravity);
372+
var speedZ = moveTime * jumpGravity / 2.0 / 1000.0;
373+
var height = -ComputeFallElevation(moveTime / 2.0 / 1000.0, -speedZ, jumpGravity);
368374

369-
var speedZWithDefaultGravity = monsterMove.MoveTime * defaultGravity / 2.0 / 1000.0;
370-
var heightWithDefaultGravity = -ComputeFallElevation(monsterMove.MoveTime / 2.0 / 1000.0, -speedZWithDefaultGravity, defaultGravity);
375+
var speedZWithDefaultGravity = moveTime * defaultGravity / 2.0 / 1000.0;
376+
var heightWithDefaultGravity = -ComputeFallElevation(moveTime / 2.0 / 1000.0, -speedZWithDefaultGravity, defaultGravity);
371377

372-
packet.AddValue("Computed Jump Height", height, indexes);
373-
packet.AddValue("Computed Jump Height (with default gravity)", heightWithDefaultGravity, indexes);
374-
}
378+
packet.AddValue("Computed Jump Height", height, indexes);
379+
packet.AddValue("Computed Jump Height (with default gravity)", heightWithDefaultGravity, indexes);
375380
}
376381

377382
private static void ReadSplineMovement510(Packet packet, Vector3 pos)

0 commit comments

Comments
 (0)