diff --git a/src/shared/NSWeapon.h b/src/shared/NSWeapon.h index 94abfe7f..76cd8331 100644 --- a/src/shared/NSWeapon.h +++ b/src/shared/NSWeapon.h @@ -142,6 +142,9 @@ public: /** Overridable: Called once when the weapon stopped firing. */ virtual void WeaponStoppedFiring(void); + /** Returns whether the weapon is being actively fired by the owner. */ + nonvirtual bool WeaponIsFiring(void); + /** Overridable: Controls def_onFire event. */ virtual void FiredWeaponAttack(string); /** Overridable: Controls def_onRelease event. */ @@ -167,6 +170,8 @@ private: nonvirtual void _SwitchedFromCallback(void); /** Called to cache some entityDef values. */ nonvirtual void _CacheWeaponDefVariables(void); + nonvirtual void _WeaponStartedFiring(void); + nonvirtual void _WeaponStoppedFiring(void); #ifdef SERVER nonvirtual void _ReloadFinished(void); diff --git a/src/shared/NSWeapon.qc b/src/shared/NSWeapon.qc index 2cce97c0..8847ee61 100644 --- a/src/shared/NSWeapon.qc +++ b/src/shared/NSWeapon.qc @@ -1092,11 +1092,11 @@ NSWeapon::_WeaponStartedFiring(void) } /* hasn't been fired yet. */ - if (!(vv_flags & VFL_FIRING)) { + if (!(owner.vv_flags & VFL_FIRING)) { WeaponStartedFiring(); } - vv_flags |= VFL_FIRING; + owner.vv_flags |= VFL_FIRING; } void @@ -1107,11 +1107,17 @@ NSWeapon::_WeaponStoppedFiring(void) } /* was still registed as firing */ - if (vv_flags & VFL_FIRING) { + if (owner.vv_flags & VFL_FIRING) { WeaponStoppedFiring(); } - vv_flags &= ~VFL_FIRING; + owner.vv_flags &= ~VFL_FIRING; +} + +bool +NSWeapon::WeaponIsFiring(void) +{ + return (owner.vv_flags & VFL_FIRING) ? (true) : (false); } void