class CGlock : public CBasePlayerWeapon{public: void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 2; } int GetItemInfo(ItemInfo *p); void PrimaryAttack( void ); void SecondaryAttack( void ); void GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ); BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); BOOL TriggerReleased; // This declares the TriggerReleased boolean....
BOOL CGlock::Deploy( ){ TriggerReleased = FALSE; return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", UseDecrement() ? 1 : 0, pev->body ); }
void CGlock::PrimaryAttack( void ){ if (!TriggerReleased ) return; GlockFire( 0.01, 0.3, TRUE ); TriggerReleased = FALSE;}
void CGlock::WeaponIdle( void ){ TriggerReleased = TRUE; ResetEmptySound( ); m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return;...
void CBasePlayerWeapon::ItemPostFrame( void ){ if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmm_iPrimaryAmmoType]); // Add them to the clip m_iClip += j; m_pPlayer->m_rgAmmm_iPrimaryAmmoType] -= j; m_pPlayer->TabulateAmmo(); m_fInReload = FALSE; } if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) { if ( pszAmmo2() && !m_pPlayer->m_rgAmmSecondaryAmmoIndex()] ) { m_fFireOnEmpty = TRUE; } m_pPlayer->TabulateAmmo(); SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) ){ if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmPrimaryAmmoIndex()] ) ) { m_fFireOnEmpty = TRUE; } m_pPlayer->TabulateAmmo(); PrimaryAttack();}else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload();}else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) ) { // no fire buttons down m_fFireOnEmpty = FALSE; if ( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) { // weapon isn't useable, switch. if ( !(iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) { m_flNextPrimaryAttack = ( UseDecrement() ? 0.0 : gpGlobals->time ) + 0.3; return; } } else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) { Reload(); return; }}WeaponIdle( );return;} // catch allif ( ShouldWeaponIdle() ){ WeaponIdle();}}
You must log in to post a comment. You can login or register a new account.