mirror of
https://github.com/JezuzLizard/BO2-Reimagined.git
synced 2025-06-07 21:59:49 -05:00
Mule Kick: do stowed weapon reload when switching back to weapon (fixes issues with dual wield weapons)
Mule Kick: calculate ammo to add for both clips of dual wield weapons before setting ammo (since setting ammo changes both clips) Mule Kick: make stowed weapon reload activate when perk is acquired
This commit is contained in:
parent
3b6370e01d
commit
0ba7aa0003
@ -2782,9 +2782,13 @@ additionalprimaryweapon_stowed_weapon_refill()
|
||||
|
||||
vars = [];
|
||||
|
||||
self.weapon_last_held_time = [];
|
||||
|
||||
while (1)
|
||||
{
|
||||
vars["string"] = self waittill_any_return("weapon_change", "weapon_change_complete", "specialty_additionalprimaryweapon_stop", "spawned_player");
|
||||
vars["string"] = self waittill_any_return("weapon_change", "weapon_change_complete", "perk_additionalprimaryweapon_activated", "specialty_additionalprimaryweapon_stop", "spawned_player");
|
||||
|
||||
vars["weapon_last_held_time"] = [];
|
||||
|
||||
if (self hasPerk("specialty_additionalprimaryweapon"))
|
||||
{
|
||||
@ -2801,26 +2805,34 @@ additionalprimaryweapon_stowed_weapon_refill()
|
||||
{
|
||||
if (primary != maps\mp\zombies\_zm_weapons::get_nonalternate_weapon(vars["curr_wep"]))
|
||||
{
|
||||
if (vars["string"] != "weapon_change")
|
||||
if (!isdefined(self.weapon_last_held_time[primary]))
|
||||
{
|
||||
self thread refill_after_time(primary);
|
||||
if (vars["string"] != "weapon_change")
|
||||
{
|
||||
vars["weapon_last_held_time"][primary] = getTime();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vars["weapon_last_held_time"][primary] = self.weapon_last_held_time[primary];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self notify(primary + "_reload_stop");
|
||||
if (vars["string"] == "weapon_change")
|
||||
{
|
||||
self additionalprimaryweapon_do_refill(primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.weapon_last_held_time = vars["weapon_last_held_time"];
|
||||
}
|
||||
}
|
||||
|
||||
refill_after_time(primary)
|
||||
additionalprimaryweapon_do_refill(primary)
|
||||
{
|
||||
self endon(primary + "_reload_stop");
|
||||
self endon("specialty_additionalprimaryweapon_stop");
|
||||
self endon("spawned_player");
|
||||
|
||||
vars = [];
|
||||
|
||||
vars["reload_time"] = weaponReloadTime(primary);
|
||||
@ -2846,7 +2858,24 @@ refill_after_time(primary)
|
||||
vars["reload_time"] *= getDvarFloat("perk_weapReloadMultiplier");
|
||||
}
|
||||
|
||||
wait vars["reload_time"];
|
||||
if (!isdefined(self.weapon_last_held_time[primary]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((getTime() - self.weapon_last_held_time[primary]) < (vars["reload_time"] * 1000))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vars["missing_clip_max"] = undefined;
|
||||
|
||||
if (isdefined(vars["reload_amount"]))
|
||||
{
|
||||
vars["reload_segments_num"] = int((getTime() - self.weapon_last_held_time[primary]) / (vars["reload_time"] * 1000));
|
||||
|
||||
vars["missing_clip_max"] = vars["reload_amount"] * vars["reload_segments_num"];
|
||||
}
|
||||
|
||||
vars["ammo_clip"] = self getWeaponAmmoClip(primary);
|
||||
vars["ammo_stock"] = self getWeaponAmmoStock(primary);
|
||||
@ -2857,31 +2886,38 @@ refill_after_time(primary)
|
||||
vars["missing_clip"] = vars["ammo_stock"];
|
||||
}
|
||||
|
||||
if (isDefined(vars["reload_amount"]) && vars["missing_clip"] > vars["reload_amount"])
|
||||
if (isDefined(vars["missing_clip_max"]) && vars["missing_clip"] > vars["missing_clip_max"])
|
||||
{
|
||||
vars["missing_clip"] = vars["reload_amount"];
|
||||
vars["missing_clip"] = vars["missing_clip_max"];
|
||||
}
|
||||
|
||||
self setWeaponAmmoClip(primary, vars["ammo_clip"] + vars["missing_clip"]);
|
||||
self setWeaponAmmoStock(primary, vars["ammo_stock"] - vars["missing_clip"]);
|
||||
vars["ammo_stock"] -= vars["missing_clip"];
|
||||
|
||||
vars["dw_primary"] = weaponDualWieldWeaponName(primary);
|
||||
|
||||
if (vars["dw_primary"] != "none")
|
||||
{
|
||||
vars["ammo_clip"] = self getWeaponAmmoClip(vars["dw_primary"]);
|
||||
vars["ammo_stock"] = self getWeaponAmmoStock(vars["dw_primary"]);
|
||||
vars["missing_clip"] = weaponClipSize(vars["dw_primary"]) - vars["ammo_clip"];
|
||||
vars["dw_ammo_clip"] = self getWeaponAmmoClip(vars["dw_primary"]);
|
||||
vars["dw_missing_clip"] = weaponClipSize(vars["dw_primary"]) - vars["dw_ammo_clip"];
|
||||
|
||||
if (vars["missing_clip"] > vars["ammo_stock"])
|
||||
if (vars["dw_missing_clip"] > vars["ammo_stock"])
|
||||
{
|
||||
vars["missing_clip"] = vars["ammo_stock"];
|
||||
vars["dw_missing_clip"] = vars["ammo_stock"];
|
||||
}
|
||||
|
||||
self setWeaponAmmoClip(vars["dw_primary"], vars["ammo_clip"] + vars["missing_clip"]);
|
||||
self setWeaponAmmoStock(vars["dw_primary"], vars["ammo_stock"] - vars["missing_clip"]);
|
||||
vars["ammo_stock"] -= vars["dw_missing_clip"];
|
||||
}
|
||||
|
||||
// setting dw weapon clip ammo changes both clips ammo so must calculate both left and right ammo before setting ammo
|
||||
self setWeaponAmmoClip(primary, vars["ammo_clip"] + vars["missing_clip"]);
|
||||
|
||||
if (vars["dw_primary"] != "none")
|
||||
{
|
||||
self set_weapon_ammo_clip_left(primary, vars["dw_ammo_clip"] + vars["dw_missing_clip"]);
|
||||
}
|
||||
|
||||
self setWeaponAmmoStock(primary, vars["ammo_stock"]);
|
||||
|
||||
vars["alt_primary"] = weaponAltWeaponName(primary);
|
||||
|
||||
if (vars["alt_primary"] != "none")
|
||||
@ -2898,11 +2934,6 @@ refill_after_time(primary)
|
||||
self setWeaponAmmoClip(vars["alt_primary"], vars["ammo_clip"] + vars["missing_clip"]);
|
||||
self setWeaponAmmoStock(vars["alt_primary"], vars["ammo_stock"] - vars["missing_clip"]);
|
||||
}
|
||||
|
||||
if (isDefined(vars["reload_amount"]) && self getWeaponAmmoStock(primary) > 0 && self getWeaponAmmoClip(primary) < weaponClipSize(primary))
|
||||
{
|
||||
self refill_after_time(primary);
|
||||
}
|
||||
}
|
||||
|
||||
electric_cherry_unlimited()
|
||||
|
@ -787,6 +787,7 @@ give_perk(perk, bought)
|
||||
if (perk == "specialty_additionalprimaryweapon")
|
||||
{
|
||||
self scripts\zm\replaced\_zm::restore_additionalprimaryweapon();
|
||||
self notify("perk_additionalprimaryweapon_activated");
|
||||
}
|
||||
|
||||
if (isDefined(level._custom_perks[perk]) && isDefined(level._custom_perks[perk].player_thread_give))
|
||||
|
Loading…
x
Reference in New Issue
Block a user