//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponAR2::AddViewKick( void ) { #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 8.0f //Degrees #define SLIDE_LIMIT 5.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (!pPlayer) return; float flDuration = m_fFireDuration; if( g_pGameRules->GetAutoAimMode() == AUTOAIM_ON_CONSOLE ) { // On the 360 (or in any configuration using the 360 aiming scheme), don't let the // AR2 progressive into the late, highly inaccurate stages of its kick. Just // spoof the time to make it look (to the kicking code) like we haven't been // firing for very long. flDuration = MIN( flDuration, 0.75f ); } DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, flDuration, SLIDE_LIMIT ); }
void CWeaponM249::AddViewKick( void ) { CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) return; #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 7.5f // in degrees #define SLIDE_LIMIT 1.0f // in seconds DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); }
void CWeaponUzi::PrimaryAttack( void ) { BaseClass::PrimaryAttack(); m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate(); //BP muzzlefash de la mort /*Vector vecShootOrigin; QAngle angShootDir; GetAttachment(LookupAttachment("muzzle"), vecShootOrigin, angShootDir); DispatchParticleEffect("muzzleflash_final_uzi", vecShootOrigin, angShootDir);*/ /*if(!GetOwner()->IsAlive()) ToBasePlayer( GetOwner() )->DoMuzzleFlash();*/ #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 1.0f //Degrees #define SLIDE_LIMIT 2.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; //pPlayer->DoMuzzleFlash(); Vector vForward, vRight, vUp; pPlayer->EyeVectors( &vForward, &vRight, &vUp ); Vector vecShootOrigin; QAngle angShootDir; GetAttachment(LookupAttachment("muzzle"), vecShootOrigin, angShootDir); #ifdef CLIENT_DLL Vector muzzlePoint = pPlayer->Weapon_ShootPosition() + vForward * 18.0f + vRight * 6.0f + vUp * -3.0f; #else Vector muzzlePoint = vecShootOrigin; #endif DispatchParticleEffect("muzzleflash_final_uzi", muzzlePoint, angShootDir); #ifdef CLIENT_DLL dlight_t *el = effects->CL_AllocDlight( LIGHT_INDEX_MUZZLEFLASH + index ); el->origin = muzzlePoint; el->radius = random->RandomInt( 32, 64 ); el->decay = el->radius / 0.05f; el->die = gpGlobals->curtime + 0.2f; el->color.r = 255; el->color.g = 192; el->color.b = 64; el->color.exponent = 5; #endif DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponSMG1::AddViewKick( void ) { #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 1.0f //Degrees #define SLIDE_LIMIT 2.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); }
void CWeaponSubMachineGun::AddViewKick( void ) { #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 1.0f //Degrees #define SLIDE_LIMIT 2.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); // Add a view punch too QAngle viewPunch; viewPunch.x = SharedRandomFloat( "smg1pax", BALANCE_VALUE( Float, lfm_smg1_vx_min ), BALANCE_VALUE( Float, lfm_smg1_vx_max ) ); viewPunch.y = SharedRandomFloat( "smg1pay", BALANCE_VALUE( Float, lfm_smg1_vy_min ), BALANCE_VALUE( Float, lfm_smg1_vy_max ) ); viewPunch.z = 0.0f; pPlayer->ViewPunch( viewPunch ); }
void CWeaponTranquilizer::PrimaryAttack( void ) { if(m_flNextPrimaryAttack > gpGlobals->curtime) return; FireBolt(); SetWeaponIdleTime( gpGlobals->curtime + FIRE_DELAY ); m_flNextPrimaryAttack = m_flNextSecondaryAttack = m_fSecondRefire = gpGlobals->curtime + FIRE_DELAY; #define EASY_DAMPEN 0.5f #define MAX_VERTICAL_KICK 1.0f //Degrees #define SLIDE_LIMIT 2.0f //Seconds //Get the view kick CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( pPlayer == NULL ) return; DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT ); }
//----------------------------------------------------------------------------- // Purpose: // // //----------------------------------------------------------------------------- void CWeaponSMG1::PrimaryAttack( void ) { // Only the player fires this way so we can cast CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if (!pPlayer) return; // Abort here to handle burst and auto fire modes if ( (UsesClipsForAmmo1() && m_iClip1 == 0) || ( !UsesClipsForAmmo1() && !pPlayer->GetAmmoCount(m_iPrimaryAmmoType) ) ) return; m_nShotsFired++; pPlayer->DoMuzzleFlash(); // To make the firing framerate independent, we may have to fire more than one bullet here on low-framerate systems, // especially if the weapon we're firing has a really fast rate of fire. int iBulletsToFire = 0; float fireRate = GetFireRate(); // MUST call sound before removing a round from the clip of a CHLMachineGun while ( m_flNextPrimaryAttack <= gpGlobals->curtime ) { WeaponSound(SINGLE, m_flNextPrimaryAttack); m_flNextPrimaryAttack = m_flNextPrimaryAttack + fireRate; iBulletsToFire++; } // Make sure we don't fire more than the amount in the clip, if this weapon uses clips if ( UsesClipsForAmmo1() ) { if ( iBulletsToFire > m_iClip1 ) iBulletsToFire = m_iClip1; m_iClip1 -= iBulletsToFire; } m_iPrimaryAttacks++; gamestats->Event_WeaponFired( pPlayer, true, GetClassname() ); // Fire the bullets FireBulletsInfo_t info; info.m_iShots = iBulletsToFire; info.m_vecSrc = pPlayer->Weapon_ShootPosition( ); info.m_vecDirShooting = pPlayer->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT ); info.m_vecSpread = pPlayer->GetAttackSpread( this ); info.m_flDistance = MAX_TRACE_LENGTH; info.m_iAmmoType = m_iPrimaryAmmoType; info.m_iTracerFreq = 2; FireBullets( info ); //Factor in the view kick if( IsIronsighted() ) { DoMachineGunKick( pPlayer, 0.5, 5.0, 0.5, 3.0 ); } else { DoMachineGunKick( pPlayer, 0.5, 10.0, 0.5, 3.0 ); } CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_MACHINEGUN, 0.2, pPlayer ); SendWeaponAnim( GetPrimaryAttackActivity() ); pPlayer->SetAnimation( PLAYER_ATTACK1 ); // Register a muzzleflash for the AI pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 ); }