TweakSpeeds
Jump to navigation
Jump to search
virtual double, double TweakSpeeds (double forward, double side)
Usage
A virtual function defined in the PlayerPawn class. Called from MovePlayer to modify incoming input.
By default, it simply checks whether incoming input (the values passed from PlayerPawn's UserCmd) are meant to trigger walking or running and returns the output accordingly. Additionallly, it applies speed modifiers from powerups (such as PowerSpeed).
Arguments
- double forward
- Forward movement input passed from UserCmd
- double side
- Side movement input passed from UserCmd
Return values
- double - modified forward movement value
- double - modified side movement value
ZScript defintion
| Note: The ZScript definition below is for reference and may be different in the current version of UZDoom. The most up-to-date version of this code can be found on UZDoom GitHub. |
virtual double, double TweakSpeeds (double forward, double side)
{
// Strife's player can't run when its health is below 10
if (health <= RunHealth)
{
forward = clamp(forward, -gameinfo.normforwardmove[0]*256, gameinfo.normforwardmove[0]*256);
side = clamp(side, -gameinfo.normsidemove[0]*256, gameinfo.normsidemove[0]*256);
}
// [GRB]
if (abs(forward) < 0x3200)
{
forward *= ForwardMove1;
}
else
{
forward *= ForwardMove2;
}
if (abs(side) < 0x2800)
{
side *= SideMove1;
}
else
{
side *= SideMove2;
}
if (!Alternative)
{
double factor = 1.;
for(let it = Inv; it != null; it = it.Inv)
{
factor *= it.GetSpeedFactor ();
}
forward *= factor;
side *= factor;
}
return forward, side;
}