From: Mario Date: Thu, 5 Apr 2018 09:16:49 +0000 (+1000) Subject: Allow mutators to change the ammo to decrease when reducing weapon ammo X-Git-Tag: xonotic-v0.8.5~2202 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c28f7d11e71d2470e21a842bba897206f0e6014f;p=xonotic%2Fxonotic-data.pk3dir.git Allow mutators to change the ammo to decrease when reducing weapon ammo --- 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