ScriptObjectWeapon
Base class of all weapon scripts, associated with a kWeapon actor. Weapon classes are defined in scripts/weapons.txt.
Every weapon is intialized at level start, not just those the player owns.
Ammo is managed by kPlayer, which you can get a reference to with kWeapon::Owner()
.
Inherited Functions
void OnBeginLevel()
seems to be skipped during initialization (other events are called as usual)
void OnTick()
called twice every tick, if it's the current weapon
Weapon Functions
void OnBeginFire()
Called if the fire button is pressed, and the weapon is idle.
The weapon will remain in the firing state until an animation ends (by completing or being stopped manually – interrupting with another animation does not count as "ending" the previous animation), or until anim_weaponIdle
or anim_weaponIdleUnderwater
is playing.
Therefore, if you do not play an animation in this function:
- if an idle anim is playing:
the weapon will not enter the firing state, and
OnBeginFire()
will be called every tick until the player releases the fire button - if the run anim is playing:
the weapon will remain in the firing state until you manually change the anim state (because the run anim is looping, and therefore never ends)
void OnFire()
called every tick, if the weapon is firing
first called one tick after OnBeginFire()
void OnEndFire()
called when the player first releases the fire button while the weapon is firing
void OnRaise()
called at the end of swap-in anim, when changing weapons or after climbing
void OnLower()
called at the end of swap-out anim, when changing weapons
void OnHoldster()
called at the end of swap-out anim, when climbing