Page MenuHomeFeedback Tracker

PlayerBase.IsSprinting does not return true when player is sprinting
Assigned, UrgentPublic

Description

The PlayerBase.IsSprinting method always seems to return false, even if the player is actually sprinting.

Tested on DayZ version 1.14.154258.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
21H1
Category
General
Steps To Reproduce

Create a mod that prints the return value of PlayerBase.IsSprinting on every tick. For example:

modded class PlayerBase
{
    override void OnTick()
    {
        super.OnTick();

        PrintFormat(
            "%1 :: IsSprinting=%2 :: m_iMovement=%3",
            this, IsSprinting(), m_MovementState.m_iMovement);
    }
};

Load this mod on a server and connect to it.

When the player is standing still, a line similar to the following will be printed to the script log:

SCRIPT       : SurvivorBase<a0b90210> :: IsSprinting=0 :: m_iMovement=0

When the player is running but not sprinting, a line similar to the following will be printed:

SCRIPT       : SurvivorBase<a0b90210> :: IsSprinting=0 :: m_iMovement=2

When the player is sprinting, a line similar to the following will be printed:

SCRIPT       : SurvivorBase<a0b90210> :: IsSprinting=0 :: m_iMovement=3
Additional Information

The following replacement implementation of PlayerBase.IsSprinting appears to work correctly:

bool IsSprinting()
{
    return m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT;
}

The following patch appears to fix the issue:

--- scripts/4_World/Entities/ManBase/PlayerBase.c.original	2021-11-09 18:45:04.589091000 -0600
+++ scripts/4_World/Entities/ManBase/PlayerBase.c	2021-11-09 18:52:43.798113700 -0600
@@ -4714,7 +4714,7 @@
 	
 	bool IsSprinting()
 	{
-		return m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENT_SPRINT);
+		return m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT;
 	}
 
 	bool CanSprint()

Note that the 1.14.154258 implementation contains an errant trailing ) character. DayZ experimental version 1.15.154306 contains the same broken implementation.

Event Timeline

tjensen created this task.Nov 10 2021, 1:57 AM
tjensen edited Additional Information. (Show Details)Nov 10 2021, 2:01 AM
Geez changed the task status from New to Assigned.Nov 11 2021, 11:15 AM