void CWeaponMP5::PrimaryAttack( void ) { const CSDKWeaponInfo &pWeaponInfo = GetSDKWpnData(); CSDKPlayer *pPlayer = GetPlayerOwner(); float flCycleTime = pWeaponInfo.m_flCycleTime; bool bPrimaryMode = true; float flSpread = 0.01f; // more spread when jumping if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) ) flSpread = 0.05f; pPlayer->m_iShotsFired++; // Out of ammo? if ( m_iClip1 <= 0 ) { if (m_bFireOnEmpty) { PlayEmptySound(); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; } } SendWeaponAnim( ACT_VM_PRIMARYATTACK ); m_iClip1--; // player "shoot" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); FX_FireBullets( pPlayer->entindex(), pPlayer->Weapon_ShootPosition(), pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), GetWeaponID(), bPrimaryMode?Primary_Mode:Secondary_Mode, CBaseEntity::GetPredictionRandomSeed() & 255, flSpread ); pPlayer->DoMuzzleFlash(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + flCycleTime; if (!m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0); } // start idle animation in 5 seconds SetWeaponIdleTime( gpGlobals->curtime + 5.0 ); }
void CWeaponShotgun::PrimaryAttack() { CSDKPlayer *pPlayer = GetPlayerOwner(); if ( !pPlayer ) return; // don't fire underwater if (pPlayer->GetWaterLevel() == 3) { PlayEmptySound( ); m_flNextPrimaryAttack = gpGlobals->curtime + 0.15; return; } // Out of ammo? if ( m_iClip1 <= 0 ) { Reload(); if ( m_iClip1 == 0 ) { PlayEmptySound(); m_flNextPrimaryAttack = gpGlobals->curtime + 0.2; } return; } SendWeaponAnim( ACT_VM_PRIMARYATTACK ); m_iClip1--; pPlayer->DoMuzzleFlash(); // player "shoot" animation pPlayer->SetAnimation( PLAYER_ATTACK1 ); // Dispatch the FX right away with full accuracy. FX_FireBullets( pPlayer->entindex(), pPlayer->Weapon_ShootPosition(), pPlayer->EyeAngles() + 2.0f * pPlayer->GetPunchAngle(), GetWeaponID(), Primary_Mode, CBaseEntity::GetPredictionRandomSeed() & 255, // wrap it for network traffic so it's the same between client and server 0.0675 ); if (!m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0) { // HEV suit - indicate out of ammo condition pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0); } if (m_iClip1 != 0) m_flPumpTime = gpGlobals->curtime + 0.5; m_flNextPrimaryAttack = gpGlobals->curtime + 0.875; m_flNextSecondaryAttack = gpGlobals->curtime + 0.875; if (m_iClip1 != 0) SetWeaponIdleTime( gpGlobals->curtime + 2.5 ); else SetWeaponIdleTime( gpGlobals->curtime + 0.875 ); m_fInSpecialReload = 0; // Update punch angles. QAngle angle = pPlayer->GetPunchAngle(); if ( pPlayer->GetFlags() & FL_ONGROUND ) { angle.x -= SharedRandomInt( "ShotgunPunchAngleGround", 4, 6 ); } else { angle.x -= SharedRandomInt( "ShotgunPunchAngleAir", 8, 11 ); } pPlayer->SetPunchAngle( angle ); }