From 70ea7b3522614d4433d708e95d8d30216763f2d6 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Sun, 23 Jan 2022 00:58:58 -0800 Subject: [PATCH] Mule Kick: stowed weapons refill ammo from stock --- README.md | 5 +- scripts/zm/_zm_reimagined.gsc | 97 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ef0082a..2c68ea8c 100644 --- a/README.md +++ b/README.md @@ -188,13 +188,14 @@ * Move faster (normally only sprint faster) ### Deadshot Daiquiri -* Double headshot damage +* Increases headshot damage by 100% * Move faster while aiming -* Decreased sprint recovery time +* Decreases sprint recovery time ### Mule Kick * Added additional weapon indicator * Additional weapon is given back when perk is repurchased +* Stowed weapons refill ammo from stock over time ### Tombstone Soda * Added in solo diff --git a/scripts/zm/_zm_reimagined.gsc b/scripts/zm/_zm_reimagined.gsc index c8678165..0bac934c 100644 --- a/scripts/zm/_zm_reimagined.gsc +++ b/scripts/zm/_zm_reimagined.gsc @@ -139,6 +139,7 @@ onplayerspawned() self thread additionalprimaryweapon_save_weapons(); self thread additionalprimaryweapon_restore_weapons(); self thread additionalprimaryweapon_indicator(); + self thread additionalprimaryweapon_stowed_weapon_refill(); self thread whos_who_spawn_changes(); @@ -4324,6 +4325,102 @@ additionalprimaryweapon_indicator() } } +additionalprimaryweapon_stowed_weapon_refill() +{ + self endon("disconnect"); + + while (1) + { + self waittill_any("weapon_change", "specialty_additionalprimaryweapon_stop", "spawned_player"); + + if(self hasPerk("specialty_additionalprimaryweapon")) + { + curr_wep = self getCurrentWeapon(); + if(curr_wep == "none") + { + continue; + } + + primaries = self getWeaponsListPrimaries(); + foreach(primary in primaries) + { + if(primary != maps/mp/zombies/_zm_weapons::get_nonalternate_weapon(curr_wep)) + { + self thread refill_after_time(primary); + } + else + { + self notify(primary + "_reload_stop"); + } + } + } + } +} + +refill_after_time(primary) +{ + self endon(primary + "_reload_stop"); + self endon("specialty_additionalprimaryweapon_stop"); + self endon("spawned_player"); + + reload_time = weaponReloadTime(primary); + if(reload_time < 1) + { + reload_time = 1; + } + + if(self hasPerk("specialty_fastreload")) + { + reload_time *= getDvarFloat("perk_weapReloadMultiplier"); + } + + wait reload_time; + + ammo_clip = self getWeaponAmmoClip(primary); + ammo_stock = self getWeaponAmmoStock(primary); + + missing_clip = weaponClipSize(primary) - ammo_clip; + if(missing_clip > ammo_stock) + { + missing_clip = ammo_stock; + } + + self setWeaponAmmoClip(primary, ammo_clip + missing_clip); + self setWeaponAmmoStock(primary, ammo_stock - missing_clip); + + dw_primary = weaponDualWieldWeaponName(primary); + if(dw_primary != "none") + { + ammo_clip = self getWeaponAmmoClip(dw_primary); + ammo_stock = self getWeaponAmmoStock(dw_primary); + + missing_clip = weaponClipSize(dw_primary) - ammo_clip; + if(missing_clip > ammo_stock) + { + missing_clip = ammo_stock; + } + + self setWeaponAmmoClip(dw_primary, ammo_clip + missing_clip); + self setWeaponAmmoStock(dw_primary, ammo_stock - missing_clip); + } + + alt_primary = weaponAltWeaponName(primary); + if(alt_primary != "none") + { + ammo_clip = self getWeaponAmmoClip(alt_primary); + ammo_stock = self getWeaponAmmoStock(alt_primary); + + missing_clip = weaponClipSize(alt_primary) - ammo_clip; + if(missing_clip > ammo_stock) + { + missing_clip = ammo_stock; + } + + self setWeaponAmmoClip(alt_primary, ammo_clip + missing_clip); + self setWeaponAmmoStock(alt_primary, ammo_stock - missing_clip); + } +} + whos_who_spawn_changes() { self endon( "disconnect" );