From Valve Developer Community
Revision as of 21:01, 24 May 2012 by Nacimota (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.


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().