|
|
|
@ -625,6 +625,11 @@ void CBasePlayerWeapon::ItemPostFrame( void )
@@ -625,6 +625,11 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|
|
|
|
m_fInReload = FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( !( m_pPlayer->pev->button & IN_ATTACK ) ) |
|
|
|
|
{ |
|
|
|
|
m_flLastFireTime = 0.0f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) |
|
|
|
|
{ |
|
|
|
|
if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) |
|
|
|
@ -963,6 +968,7 @@ BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, i
@@ -963,6 +968,7 @@ BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, i
|
|
|
|
|
|
|
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; |
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; |
|
|
|
|
m_flLastFireTime = 0.0f; |
|
|
|
|
|
|
|
|
|
return TRUE; |
|
|
|
|
} |
|
|
|
@ -1150,6 +1156,37 @@ void CBasePlayerWeapon::RetireWeapon( void )
@@ -1150,6 +1156,37 @@ void CBasePlayerWeapon::RetireWeapon( void )
|
|
|
|
|
g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
|
// GetNextAttackDelay - An accurate way of calcualting the next attack time.
|
|
|
|
|
//=========================================================================
|
|
|
|
|
float CBasePlayerWeapon::GetNextAttackDelay( float delay ) |
|
|
|
|
{ |
|
|
|
|
if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1 ) |
|
|
|
|
{ |
|
|
|
|
// At this point, we are assuming that the client has stopped firing
|
|
|
|
|
// and we are going to reset our book keeping variables.
|
|
|
|
|
m_flLastFireTime = gpGlobals->time; |
|
|
|
|
m_flPrevPrimaryAttack = delay; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// calculate the time between this shot and the previous
|
|
|
|
|
float flTimeBetweenFires = gpGlobals->time - m_flLastFireTime; |
|
|
|
|
float flCreep = 0.0f; |
|
|
|
|
if( flTimeBetweenFires > 0 ) |
|
|
|
|
flCreep = flTimeBetweenFires - m_flPrevPrimaryAttack; // postive or negative
|
|
|
|
|
|
|
|
|
|
// save the last fire time
|
|
|
|
|
m_flLastFireTime = gpGlobals->time; |
|
|
|
|
|
|
|
|
|
float flNextAttack = UTIL_WeaponTimeBase() + delay - flCreep; |
|
|
|
|
// we need to remember what the m_flNextPrimaryAttack time is set to for each shot,
|
|
|
|
|
// store it as m_flPrevPrimaryAttack.
|
|
|
|
|
m_flPrevPrimaryAttack = flNextAttack - UTIL_WeaponTimeBase(); |
|
|
|
|
//char szMsg[256];
|
|
|
|
|
//_snprintf( szMsg, sizeof(szMsg), "next attack time: %0.4f\n", gpGlobals->time + flNextAttack );
|
|
|
|
|
//OutputDebugString( szMsg );
|
|
|
|
|
return flNextAttack; |
|
|
|
|
} |
|
|
|
|
//*********************************************************
|
|
|
|
|
// weaponbox code:
|
|
|
|
|
//*********************************************************
|
|
|
|
|