Page 1 of 1

[1.5.5] ammo_every <= 0 doesn't work

Posted: Sun Oct 29, 2017 7:56 pm
by minmay
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:

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
reload_counter gets incremented to 1, which ~= 0, so it just keeps getting incremented higher and higher. The check should be

Code: Select all

if ammo.combat.reload_counter >= r then

Re: [1.5.5] ammo_every <= 0 doesn't work

Posted: Mon Oct 30, 2017 1:01 pm
by jenx
+1 - I've had this error in randarts

Re: [1.5.5] ammo_every <= 0 doesn't work

Posted: Mon Oct 30, 2017 3:49 pm
by PseudoLoneWolf
Yep, can confirm, I had a kickass merchant randart bow with -12 turns between reloads once, it did nothing. I was quite disappointed.