mirror of https://github.com/FWGS/hlsdk-xash3d
HL 25th anniversary pushable fix. (#427)
This commit is contained in:
parent
1f4a414016
commit
d2a43db7e3
|
@ -928,22 +928,25 @@ void CPushable::Move( CBaseEntity *pOther, int push )
|
|||
|
||||
if( pOther->IsPlayer() )
|
||||
{
|
||||
// g-cont. fix pushable acceleration bug (now implemented as cvar)
|
||||
if (pushablemode.value == 1)
|
||||
{
|
||||
// Allow player push when moving right, left and back too
|
||||
if ( push && !(pevToucher->button & (IN_FORWARD|IN_MOVERIGHT|IN_MOVELEFT|IN_BACK)) )
|
||||
return;
|
||||
// Require player walking back when applying '+use' on pushable
|
||||
if ( !push && !(pevToucher->button & (IN_BACK)) )
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( pushablemode.value == -1 )
|
||||
{
|
||||
// Don't push unless the player is pushing forward and NOT use (pull)
|
||||
if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) )
|
||||
if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE )))
|
||||
return;
|
||||
}
|
||||
// g-cont. fix pushable acceleration bug (now implemented as cvar)
|
||||
else if( pushablemode.value != 0 )
|
||||
{
|
||||
// Allow player push when moving right, left and back too
|
||||
if( push && !( pevToucher->button & ( IN_FORWARD | IN_MOVERIGHT | IN_MOVELEFT | IN_BACK )))
|
||||
return;
|
||||
// Require player walking back when applying '+use' on pushable
|
||||
if( !push && !( pevToucher->button & ( IN_BACK )))
|
||||
return;
|
||||
}
|
||||
// Don't push when +use pressed
|
||||
else if( push && ( pevToucher->button & ( IN_USE )))
|
||||
return;
|
||||
playerTouch = 1;
|
||||
}
|
||||
|
||||
|
@ -964,30 +967,55 @@ void CPushable::Move( CBaseEntity *pOther, int push )
|
|||
else
|
||||
factor = 0.25f;
|
||||
|
||||
// Spirit fix for pushable acceleration
|
||||
if (pushablemode.value == 2)
|
||||
if( pushablemode.value != 0 )
|
||||
{
|
||||
if (!push)
|
||||
factor *= 0.5f;
|
||||
pev->velocity.x += pevToucher->velocity.x * factor;
|
||||
pev->velocity.y += pevToucher->velocity.y * factor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( push )
|
||||
{
|
||||
factor = 0.25f;
|
||||
pev->velocity.x += pevToucher->velocity.x * factor;
|
||||
pev->velocity.y += pevToucher->velocity.y * factor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fix for pushable acceleration
|
||||
if( sv_pushable_fixed_tick_fudge.value >= 0 )
|
||||
factor *= ( sv_pushable_fixed_tick_fudge.value * gpGlobals->frametime );
|
||||
|
||||
pev->velocity.x += pevToucher->velocity.x * factor;
|
||||
pev->velocity.y += pevToucher->velocity.y * factor;
|
||||
if( fabs( pev->velocity.x ) < fabs( pevToucher->velocity.x - pevToucher->velocity.x * factor ))
|
||||
pev->velocity.x += pevToucher->velocity.x * factor;
|
||||
if( fabs( pev->velocity.y ) < fabs( pevToucher->velocity.y - pevToucher->velocity.y * factor ))
|
||||
pev->velocity.y += pevToucher->velocity.y * factor;
|
||||
}
|
||||
}
|
||||
|
||||
float length = sqrt( pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y );
|
||||
if( push && ( length > MaxSpeed() ) )
|
||||
if( ( push && pushablemode.value != 0 )
|
||||
|| pushablemode.value == 0 )
|
||||
{
|
||||
pev->velocity.x = (pev->velocity.x * MaxSpeed() / length );
|
||||
pev->velocity.y = (pev->velocity.y * MaxSpeed() / length );
|
||||
if( length > MaxSpeed())
|
||||
{
|
||||
pev->velocity.x = ( pev->velocity.x * MaxSpeed() / length );
|
||||
pev->velocity.y = ( pev->velocity.y * MaxSpeed() / length );
|
||||
}
|
||||
}
|
||||
|
||||
if( playerTouch )
|
||||
{
|
||||
pevToucher->velocity.x = pev->velocity.x;
|
||||
pevToucher->velocity.y = pev->velocity.y;
|
||||
if( push || pushablemode.value != 0 )
|
||||
{
|
||||
pevToucher->velocity.x = pev->velocity.x;
|
||||
pevToucher->velocity.y = pev->velocity.y;
|
||||
}
|
||||
|
||||
if( ( gpGlobals->time - m_soundTime ) > 0.7f )
|
||||
{
|
||||
m_soundTime = gpGlobals->time;
|
||||
if( length > 0 && FBitSet( pev->flags,FL_ONGROUND ) )
|
||||
if( length > 0 && FBitSet( pev->flags, FL_ONGROUND ))
|
||||
{
|
||||
m_lastSound = RANDOM_LONG( 0, 2 );
|
||||
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, m_soundNames[m_lastSound], 0.5f, ATTN_NORM );
|
||||
|
|
|
@ -457,6 +457,8 @@ cvar_t sk_player_leg3 = { "sk_player_leg3","1" };
|
|||
|
||||
// END Cvars for Skill Level settings
|
||||
|
||||
cvar_t sv_pushable_fixed_tick_fudge = { "sv_pushable_fixed_tick_fudge", "15" };
|
||||
|
||||
// Register your console variables here
|
||||
// This gets called one time when the game is initialied
|
||||
void GameDLLInit( void )
|
||||
|
@ -883,6 +885,8 @@ void GameDLLInit( void )
|
|||
CVAR_REGISTER( &sk_player_leg3 );
|
||||
// END REGISTER CVARS FOR SKILL LEVEL STUFF
|
||||
|
||||
CVAR_REGISTER( &sv_pushable_fixed_tick_fudge );
|
||||
|
||||
SERVER_COMMAND( "exec skill.cfg\n" );
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ extern cvar_t teamoverride;
|
|||
extern cvar_t defaultteam;
|
||||
extern cvar_t allowmonsters;
|
||||
extern cvar_t bhopcap;
|
||||
extern cvar_t sv_pushable_fixed_tick_fudge;
|
||||
|
||||
// Engine Cvars
|
||||
extern cvar_t *g_psv_gravity;
|
||||
|
|
Loading…
Reference in New Issue