void CWeaponScout::SCOUTFire( float flSpread ) { CCSPlayer *pPlayer = GetPlayerOwner(); if (pPlayer == NULL) { Assert(pPlayer != NULL); return; } // If we are not zoomed in, or we have very recently zoomed and are still transitioning, the bullet diverts more. if (pPlayer->GetFOV() == pPlayer->GetDefaultFOV() || (gpGlobals->curtime < m_zoomFullyActiveTime)) { flSpread += 0.025; } if (pPlayer->GetFOV() != pPlayer->GetDefaultFOV()) { pPlayer->m_bResumeZoom = true; pPlayer->m_iLastZoom = pPlayer->GetFOV(); #ifndef CLIENT_DLL pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.05f ); #endif } if ( !CSBaseGunFire( flSpread, GetCSWpnData().m_flCycleTime, true ) ) return; QAngle angle = pPlayer->GetPunchAngle(); angle.x -= 2; pPlayer->SetPunchAngle( angle ); }
void CWeaponCSBaseGun::ItemPostFrame() { CCSPlayer *pPlayer = GetPlayerOwner(); if ( !pPlayer ) return; //GOOSEMAN : Return zoom level back to previous zoom level before we fired a shot. This is used only for the AWP. // And Scout. if ( (m_flNextPrimaryAttack <= gpGlobals->curtime) && (pPlayer->m_bResumeZoom == TRUE) ) { #ifndef CLIENT_DLL pPlayer->SetFOV( pPlayer, pPlayer->m_iLastZoom, 0.05f ); m_zoomFullyActiveTime = gpGlobals->curtime + 0.05f;// Make sure we think that we are zooming on the server so we don't get instant acc bonus if ( pPlayer->GetFOV() == pPlayer->m_iLastZoom ) { // return the fade level in zoom. pPlayer->m_bResumeZoom = false; } #endif } BaseClass::ItemPostFrame(); }
bool CWeaponCSBaseGun::Reload() { CCSPlayer *pPlayer = GetPlayerOwner(); if ( !pPlayer ) return false; if (pPlayer->GetAmmoCount( GetPrimaryAmmoType() ) <= 0) return false; int iResult = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD ); if ( !iResult ) return false; pPlayer->SetAnimation( PLAYER_RELOAD ); #ifndef CLIENT_DLL if ((iResult) && (pPlayer->GetFOV() != pPlayer->GetDefaultFOV())) { pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV() ); } #endif m_flAccuracy = 0.2; pPlayer->m_iShotsFired = 0; m_bDelayFire = false; pPlayer->SetShieldDrawnState( false ); return true; }
void CWeaponG3SG1::G3SG1Fire( float flSpread, float flCycleTime, bool fUseAutoAim ) { CCSPlayer *pPlayer = GetPlayerOwner(); if ( pPlayer->GetFOV() == 90 ) flSpread += 0.025; // Mark the time of this shot and determine the accuracy modifier based on the last shot fired... if (m_flLastFire == 0) { m_flLastFire = gpGlobals->curtime; } else { m_flAccuracy = 0.55 + (0.3) * (gpGlobals->curtime - m_flLastFire); if (m_flAccuracy > 0.98) m_flAccuracy = 0.98; m_flLastFire = gpGlobals->curtime; } if ( !CSBaseGunFire( flSpread, flCycleTime ) ) return; // Adjust the punch angle. QAngle angle = pPlayer->GetPunchAngle(); angle.x -= SHARED_RANDOMFLOAT( 2.75, 3.25) + ( angle.x / 4 ); angle.y += SHARED_RANDOMFLOAT( -1.25, 1.5); pPlayer->SetPunchAngle( angle ); }
float CWeaponSG552::GetMaxSpeed() const { CCSPlayer *pPlayer = GetPlayerOwner(); if ( pPlayer->GetFOV() == 90 ) return BaseClass::GetMaxSpeed(); else return 200; // zoomed in. }
void CWeaponScout::SecondaryAttack() { #ifndef CLIENT_DLL CCSPlayer *pPlayer = GetPlayerOwner(); if (pPlayer == NULL) { Assert(pPlayer != NULL); return; } if (pPlayer->GetFOV() == pPlayer->GetDefaultFOV()) { pPlayer->SetFOV( pPlayer, 40, 0.15f ); } else if (pPlayer->GetFOV() == 40) { pPlayer->SetFOV( pPlayer, 15, 0.05 ); } else if (pPlayer->GetFOV() == 15) { pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.05f ); } pPlayer->ResetMaxSpeed(); #endif m_flNextSecondaryAttack = gpGlobals->curtime + 0.3; m_zoomFullyActiveTime = gpGlobals->curtime + 0.15; // The worst zoom time from above. #ifndef CLIENT_DLL // If this isn't guarded, the sound will be emitted twice, once by the server and once by the client. // Let the server play it since if only the client plays it, it's liable to get played twice cause of // a prediction error. joy. EmitSound( "Default.Zoom" ); // zoom sound // let the bots hear the rifle zoom IGameEvent * event = gameeventmanager->CreateEvent( "weapon_zoom" ); if( event ) { event->SetInt( "userid", pPlayer->GetUserID() ); gameeventmanager->FireEvent( event ); } #endif }
void CWeaponSG552::SecondaryAttack() { #ifndef CLIENT_DLL CCSPlayer *pPlayer = GetPlayerOwner(); if (pPlayer->GetFOV() == 90) { pPlayer->SetFOV( 55 ); } else if (pPlayer->GetFOV() == 55) { pPlayer->SetFOV( 90 ); } else { pPlayer->SetFOV( 90 ); } #endif m_flNextSecondaryAttack = gpGlobals->curtime + 0.3; }
void CWeaponSG552::PrimaryAttack() { CCSPlayer *pPlayer = GetPlayerOwner(); if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) ) SG552Fire( 0.035 + (0.45) * (m_flAccuracy), 0.0825 ); else if (pPlayer->GetAbsVelocity().Length2D() > 140) SG552Fire( 0.035 + (0.075) * (m_flAccuracy), 0.0825 ); else if (pPlayer->GetFOV() == 90) SG552Fire( (0.02) * (m_flAccuracy), 0.0825 ); else SG552Fire( (0.02) * (m_flAccuracy), 0.135 ); }
float CWeaponScout::GetMaxSpeed() const { CCSPlayer *pPlayer = GetPlayerOwner(); if (pPlayer == NULL) { Assert(pPlayer != NULL); return BaseClass::GetMaxSpeed(); } if ( pPlayer->GetFOV() == pPlayer->GetDefaultFOV() ) return BaseClass::GetMaxSpeed(); else return 220; // zoomed in. }
void CWeaponG3SG1::SecondaryAttack() { #ifndef CLIENT_DLL CCSPlayer *pPlayer = GetPlayerOwner(); if ( pPlayer->GetFOV() == 90 ) { pPlayer->SetFOV( 40 ); } else if (pPlayer->GetFOV() == 40) { pPlayer->SetFOV( 15 ); } else if (pPlayer->GetFOV() == 15) { pPlayer->SetFOV( 90 ); } pPlayer->ResetMaxSpeed(); WeaponSound( SPECIAL3 ); // zoom sound #endif m_flNextSecondaryAttack = gpGlobals->curtime + 0.3; }
void CWeaponCSBase::ItemPostFrame() { CCSPlayer *pPlayer = GetPlayerOwner(); //GOOSEMAN : Return zoom level back to previous zoom level before we fired a shot. This is used only for the AWP. if ( (m_flNextPrimaryAttack <= gpGlobals->curtime) && (pPlayer->m_bResumeZoom == TRUE) ) { #ifndef CLIENT_DLL pPlayer->SetFOV( pPlayer->m_iLastZoom ); if ( pPlayer->GetFOV() == pPlayer->m_iLastZoom ) { // return the fade level in zoom. pPlayer->m_bResumeZoom = false; } #endif } //GOOSEMAN : Delayed shell ejection code.. if ( (pPlayer->m_flEjectBrass != 0.0) && (pPlayer->m_flEjectBrass <= gpGlobals->curtime ) ) { pPlayer->m_flEjectBrass = 0.0; EjectBrassLate(); } if ((m_bInReload) && (pPlayer->m_flNextAttack <= gpGlobals->curtime)) { // complete the reload. int j = min( GetMaxClip1() - m_iClip1, pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) ); // Add them to the clip m_iClip1 += j; pPlayer->RemoveAmmo( j, m_iPrimaryAmmoType ); m_bInReload = false; } if ((pPlayer->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime)) { if ( m_iClip2 != -1 && !pPlayer->GetAmmoCount( GetSecondaryAmmoType() ) ) { m_bFireOnEmpty = TRUE; } SecondaryAttack(); pPlayer->m_nButtons &= ~IN_ATTACK2; } else if ((pPlayer->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime )) { if ( (m_iClip1 == 0/* && pszAmmo1()*/) || (GetMaxClip1() == -1 && !pPlayer->GetAmmoCount( GetPrimaryAmmoType() ) ) ) { m_bFireOnEmpty = TRUE; } // Can't shoot during the freeze period // Ken: Always allow firing in single player //--- if ( !CSGameRules()->IsFreezePeriod() && !pPlayer->m_bIsDefusing && pPlayer->State_Get() == STATE_JOINED ) { PrimaryAttack(); } //--- } else if ( pPlayer->m_nButtons & IN_RELOAD && GetMaxClip1() != WEAPON_NOCLIP && !m_bInReload && m_flNextPrimaryAttack < gpGlobals->curtime) { // reload when reload is pressed, or if no buttons are down and weapon is empty. //MIKETODO: add code for shields... //if ( !FBitSet( m_iWeaponState, WPNSTATE_SHIELD_DRAWN ) ) Reload(); } else if ( !(pPlayer->m_nButtons & (IN_ATTACK|IN_ATTACK2) ) ) { // no fire buttons down // The following code prevents the player from tapping the firebutton repeatedly // to simulate full auto and retaining the single shot accuracy of single fire if (m_bDelayFire == TRUE) { m_bDelayFire = FALSE; if (m_iShotsFired > 15) m_iShotsFired = 15; m_flDecreaseShotsFired = gpGlobals->curtime + 0.4; } m_bFireOnEmpty = FALSE; // if it's a pistol then set the shots fired to 0 after the player releases a button if ( IsPistol() ) { m_iShotsFired = 0; } else { if ( (m_iShotsFired > 0) && (m_flDecreaseShotsFired < gpGlobals->curtime) ) { m_flDecreaseShotsFired = gpGlobals->curtime + 0.0225; m_iShotsFired--; } } #ifndef CLIENT_DLL if ( !IsUseable() && m_flNextPrimaryAttack < gpGlobals->curtime ) { // Intentionally blank -- used to switch weapons here } else #endif { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing if ( m_iClip1 == 0 && !(GetFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < gpGlobals->curtime ) { Reload(); return; } } WeaponIdle( ); return; } }