[1.5.5] ammo_every <= 0 doesn't work

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
minmay
Wyrmic
Posts: 286
Joined: Fri Sep 07, 2012 1:34 am
Contact:

[1.5.5] ammo_every <= 0 doesn't work

#1 Post 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

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

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

#2 Post by jenx »

+1 - I've had this error in randarts
MADNESS rocks

PseudoLoneWolf
Wyrmic
Posts: 257
Joined: Tue Jan 03, 2017 7:12 pm

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

#3 Post 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.
Let slip the toast of war.

Post Reply