User Tools

Site Tools


Sidebar

hpl2:tutorials:script:incremental_running

Incremental Running

This code will allow the player to run faster over time until he stops.

Add all this code to your script file:

// SPRINT {
 
 
void AutoSprintInit ()
{    AddTimer ( EMPTY, 1.0, "AutoSprintCheck" ); }
 
 
void AutoSprintCheck ( string &in asTimer )
{
    float pSpeed = GetPlayerSpeed();
 
    if ( pSpeed < 3.7f ) { AutoSprintNormalize(); }
    if ( pSpeed >= 3.8f ) { AutoSprintIncrease( pSpeed ); }
 
    AddTimer ( EMPTY, 1.0, "AutoSprintCheck" );
}
 
 
void AutoSprintIncrease ( float pSpeed )
{    
    float fBonus = pSpeed * 0.4;
    float fBonusMax = 3;
 
 
    if ( fBonus > fBonusMax ) { fBonus = fBonusMax; }
    SetPlayerRunSpeedMul( fBonus );
}
 
 
void AutoSprintNormalize ()
{ SetPlayerRunSpeedMul( 1.0 ); }
 
 
// } SPRINT

Then add this line to your OnStart()

AutoSprintInit();

Try your map and start running.

Amn.-

hpl2/tutorials/script/incremental_running.txt · Last modified: 2013/08/23 20:40 by amn