| Next revision | Previous revision | ||
|
hpl2:tutorials:script:incremental_running [2013/08/23 20:38] amn created |
hpl2:tutorials:script:incremental_running [2013/08/23 20:40] (current) amn |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | :::::INCREMENTAL RUNNING::::: | + | ====== Incremental Running ====== |
| Line 9: | Line 9: | ||
| <code php>// SPRINT { | <code php>// SPRINT { | ||
| - | + | ||
| + | |||
| void AutoSprintInit () | void AutoSprintInit () | ||
| { AddTimer ( EMPTY, 1.0, "AutoSprintCheck" ); } | { AddTimer ( EMPTY, 1.0, "AutoSprintCheck" ); } | ||
| - | + | ||
| + | |||
| void AutoSprintCheck ( string &in asTimer ) | void AutoSprintCheck ( string &in asTimer ) | ||
| { | { | ||
| float pSpeed = GetPlayerSpeed(); | float pSpeed = GetPlayerSpeed(); | ||
| - | | + | |
| if ( pSpeed < 3.7f ) { AutoSprintNormalize(); } | if ( pSpeed < 3.7f ) { AutoSprintNormalize(); } | ||
| if ( pSpeed >= 3.8f ) { AutoSprintIncrease( pSpeed ); } | if ( pSpeed >= 3.8f ) { AutoSprintIncrease( pSpeed ); } | ||
| - | | + | |
| AddTimer ( EMPTY, 1.0, "AutoSprintCheck" ); | AddTimer ( EMPTY, 1.0, "AutoSprintCheck" ); | ||
| } | } | ||
| - | + | ||
| + | |||
| void AutoSprintIncrease ( float pSpeed ) | void AutoSprintIncrease ( float pSpeed ) | ||
| { | { | ||
| float fBonus = pSpeed * 0.4; | float fBonus = pSpeed * 0.4; | ||
| float fBonusMax = 3; | float fBonusMax = 3; | ||
| - | + | ||
| + | |||
| if ( fBonus > fBonusMax ) { fBonus = fBonusMax; } | if ( fBonus > fBonusMax ) { fBonus = fBonusMax; } | ||
| SetPlayerRunSpeedMul( fBonus ); | SetPlayerRunSpeedMul( fBonus ); | ||
| } | } | ||
| - | + | ||
| + | |||
| void AutoSprintNormalize () | void AutoSprintNormalize () | ||
| { SetPlayerRunSpeedMul( 1.0 ); } | { SetPlayerRunSpeedMul( 1.0 ); } | ||
| - | + | ||
| + | |||
| // } SPRINT | // } SPRINT | ||
| </code> | </code> | ||
| Line 48: | Line 48: | ||
| - | <code php>AutoSprintInit(); | + | <code php> |
| + | AutoSprintInit(); | ||
| </code> | </code> | ||