Author Topic: [Resource] ::resetMovementSpeed and ::setBaseMovementSpeed  (Read 1062 times)

I'm requesting Badspot to add this into the engine.

void ::resetMovementSpeed - Reset's the object's movement to the datablock's.
float ::setBaseMovementSpeed - Set's the object's main movement.

Code: [Select]
//Reset the speed to their datablock's max speed
function AIPlayer::resetMovementSpeed(%this)
{
%data = %this.getDatablock();
%this.setMaxForwardSpeed(%data.MaxForwardSpeed);
%this.setMaxBackwardSpeed(%data.MaxBackwardSpeed);
%this.setMaxSideSpeed(%data.MaxSideSpeed);
%this.setMaxCrouchForwardSpeed(%data.MaxCrouchForwardSpeed);
%this.setMaxCrouchBackwardSpeed(%data.MaxCrouchBackwardSpeed);
%this.setMaxCrouchSideSpeed(%data.MaxCrouchSideSpeed);
}

//Reset the speed to their datablock's max speed
function Player::resetMovementSpeed(%this)
{
%data = %this.getDatablock();
%this.setMaxForwardSpeed(%data.MaxForwardSpeed);
%this.setMaxBackwardSpeed(%data.MaxBackwardSpeed);
%this.setMaxSideSpeed(%data.MaxSideSpeed);
%this.setMaxCrouchForwardSpeed(%data.MaxCrouchForwardSpeed);
%this.setMaxCrouchBackwardSpeed(%data.MaxCrouchBackwardSpeed);
%this.setMaxCrouchSideSpeed(%data.MaxCrouchSideSpeed);
}

//Set the player's total movement speed
function AIPlayer::setBaseMovementSpeed(%this,%value)
{
if(%value < 0) %value = 0;
if(%value > 200) %value = 200;
%this.setMaxForwardSpeed(%value);
%this.setMaxBackwardSpeed(%value);
%this.setMaxSideSpeed(%value);
%this.setMaxCrouchForwardSpeed(%value);
%this.setMaxCrouchBackwardSpeed(%value);
%this.setMaxCrouchSideSpeed(%value);
}

//Set the player's total movement speed
function Player::setBaseMovementSpeed(%this,%value)
{
if(%value < 0) %value = 0;
if(%value > 200) %value = 200;
%this.setMaxForwardSpeed(%value);
%this.setMaxBackwardSpeed(%value);
%this.setMaxSideSpeed(%value);
%this.setMaxCrouchForwardSpeed(%value);
%this.setMaxCrouchBackwardSpeed(%value);
%this.setMaxCrouchSideSpeed(%value);
}
« Last Edit: January 13, 2015, 10:17:56 PM by Advanced Bot »

Having the left/right/forward/back speeds all the same, which will occur when changing the speed with this, doesn't seem that useful at all. Instead you should have it multiply/divide the speed.

Having the left/right/forward/back speeds all the same, which will occur when changing the speed with this, doesn't seem that useful at all. Instead you should have it multiply/divide the speed.
I could have it make an offset like that for everything else.

Why are you requesting for him to add it if you just implemented it yourself?
« Last Edit: January 14, 2015, 02:23:24 AM by portify »

AiPlayer should inherit from Player so you don't need those.

%value = mClamp(%value, 0, 200);

%value = mClamp(%value, 0, 200);

mClampF - mClamp misbehaves if fed floating-point values.

mClampF - mClamp misbehaves if fed floating-point values.
Didn't know about that bit. Hardly ever use that function - most of the experience I have with it comes from removing it from the damage functions.

mClampF - mClamp misbehaves if fed floating-point values.

Doesn't really "misbehave", just strips away the fractional part.