]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow mutators to change the ammo to decrease when reducing weapon ammo
authorMario <mario@smbclan.net>
Thu, 5 Apr 2018 09:16:49 +0000 (19:16 +1000)
committerMario <mario@smbclan.net>
Thu, 5 Apr 2018 09:16:49 +0000 (19:16 +1000)
qcsrc/server/mutators/events.qh
qcsrc/server/weapons/weaponsystem.qc

index 202131a22c7badb1e3849286c2f4ee389bbdaeb5..cc89208004899f3bca1ffac6ad977781d23ae649 100644 (file)
@@ -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);
 
index f9cae87a3639b8eabb85154f92ea9cabf5d97508..d63c226bc1c6648636639d8dc1c9e853800e9c0f 100644 (file)
@@ -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