PrimaryAttack()

From Valve Developer Community
Jump to: navigation, search

This is a method to control the primary attack of bullet-based weapons. It exists in CBaseCombatWeapon::PrimaryAttack() form, but it is generally overloaded in specific methods. Half-Life 2 weapons that use PrimaryAttack():

  • 357 Magnum
  • Alyxgun
  • AR2 Machine Gun
  • Pistol
  • Shotgun
  • SMG

Generally the method is concerned with checking ammo for the weapon, calling the FireBullets() method, playing the sound and adding the view kick.


Functions

m_flNextPrimaryAttack = gpGlobals->curtime + 0.75; - (Example taken from weapon_357.cpp) Sets the time until next attack can be made to 3/4 of a second.

Vector vecSrc		= pPlayer->Weapon_ShootPosition();
Vector vecAiming	= pPlayer->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT );

This sets the vectors that will be passed to FireBullets().