I've made a loop called
Player::RPGPlayerLoop(%this) that implements a check to see when the player was last hit. If they were hit in the last 4 seconds, they cannot run. (This run method will soon be changed to checking their health status because "haha I have 1% of health and I can still run!" is just terrible), but anyway.
The check basically will see if they aren't moving during the running check and if their stamina level is less than 5, they can no longer move. <- In the red area is where it doesn't seem to call it.
Things I have tried:
- Staying still while holding the run button (my jet key) and then leaving, which does not do anything
[0] Moving very very slow
The speed factors are all at 1.
if(getSimTime() - %this.lastHit > 4000)
{
if(%this.RPGStamina() < %this.RPGMaxStamina() && !%this.isRunning)
%cl.RPGData["stamina"] += 0.2;
else if(%this.isRunning)
{
if(vectorLen(%this.getVelocity()) > 1 && %this.RPGStamina() >= 5)
%cl.RPGData["stamina"] --;
else
{
%this.isRunning = 0;
%this.setMaxForwardSpeed(%this.getMaxForwardSpeed() * %this.getSpeedFactor() * %this.RPG_SpeedFactor);
}
if(%this.RPGStamina() > 0)
%usePrint = 1;
}
}There is the running code that makes him directly run, which works perfectly fine.
This checks if the player is moving before they are even able to run, so why jog in place?
Again, the speed factors are at 1.
Packaged function RPGPlayer::onTrigger(%this,%player,%slot,%val)
{
if(%slot == 4)
{
if(%val && %player.RPGStamina() >= 10 && vectorLen(%player.getVelocity()) > 1)
{
%player.setMaxForwardSpeed(%this.maxForwardSpeed * %player.getSpeedFactor() * %player.RPG_SpeedFactor * 1.75);
%player.isRunning = true;
}
else
{
%player.setMaxForwardSpeed(%this.maxForwardSpeed * %player.getSpeedFactor() * %player.RPG_SpeedFactor);
%player.isRunning = false;
}
}
return Parent::onTrigger(%this,%player,%slot,%val);
}