From c28f7d11e71d2470e21a842bba897206f0e6014f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 5 Apr 2018 19:16:49 +1000 Subject: [PATCH] Allow mutators to change the ammo to decrease when reducing weapon ammo --- qcsrc/server/mutators/events.qh | 2 ++ qcsrc/server/weapons/weaponsystem.qc | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 202131a22..cc8920800 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -435,6 +435,8 @@ MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged); #define EV_W_DecreaseAmmo(i, o) \ /** actor */ i(entity, MUTATOR_ARGV_0_entity) \ /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \ + /** ammo to take */ i(float, MUTATOR_ARGV_2_float) \ + /**/ o(float, MUTATOR_ARGV_2_float) \ /**/ MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index f9cae87a3..d63c226bc 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -660,9 +660,11 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity) { - if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity))) return; + if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity), ammo_use)) return; if ((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return; + ammo_use = M_ARGV(2, float); + entity w_ent = actor.(weaponentity); // if this weapon is reloadable, decrease its load. Else decrease the player's ammo -- 2.39.2