[1.5.5] ammo_every <= 0 doesn't work
Posted: Sun Oct 29, 2017 7:56 pm
It's pretty easy to get ammo_every of 0 or below due to stacking sentry/self-loading egos on randarts. When you do, however, it prevents the property from working entirely:
reload_counter gets incremented to 1, which ~= 0, so it just keeps getting incremented higher and higher. The check should be
Code: Select all
function _M:regenAmmo()
local ammo = self:hasAmmo()
local r = (ammo and ammo.combat and ammo.combat.ammo_every)
if not r then return end
if ammo.combat.shots_left >= ammo.combat.capacity then ammo.combat.shots_left = ammo.combat.capacity return end
ammo.combat.reload_counter = (ammo.combat.reload_counter or 0) + 1
if ammo.combat.reload_counter == r then
ammo.combat.reload_counter = 0
ammo.combat.shots_left = util.bound(ammo.combat.shots_left + 1, 0, ammo.combat.capacity)
end
end
Code: Select all
if ammo.combat.reload_counter >= r then