cooldown reduction prototype

I decided to keep cooldown in the same unit as the frame counter,
because the extra math when calculating an upgrade is going to happen
much less frequently than actual cooldown checks and calculations, so
leaving the upgrade logic as the less efficient path seems like the
more appropriate choice.
This commit is contained in:
Kistaro Windrider 2025-05-03 16:28:54 -07:00
parent 7ed305d2d9
commit e5b8a30cb6
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -678,6 +678,11 @@ gun_base = mknew{
shoot_ready = -32768, shoot_ready = -32768,
icon = 20, icon = 20,
ammobonus = 1, ammobonus = 1,
-- fractional frames of
-- cooldown reduction from
-- upgrades, not yet applied
cd_remainder = 0,
} }
-- gun_base subtypes are -- gun_base subtypes are
@ -727,7 +732,9 @@ function gun_base:ammo_upgrade_opt()
hdr=self.hdr, hdr=self.hdr,
body=[[----------AMMO body=[[----------AMMO
more shots. more shots
before you
run out.
is: ]]..tostr(a)..[[ is: ]]..tostr(a)..[[
add: ]]..tostr(x)..[[ add: ]]..tostr(x)..[[
@ -740,6 +747,34 @@ total: ]]..tostr(a+x),
} }
end end
function gun_base:rate_upgrade_opt()
local c=self.cooldown<<16
local rawnewc=0.85*(c-self.cd_remainder)
local newc=ceil(rawnewc)
return {
icon=self.icon,
hdr=self.hdr,
body=[[----------RATE
reduce delay
between shots
in frames.
fractions
add up across
upgrades.
is: ]]..tostr(c)..[[
minus: ]]..tostr(c-newc)..[[
----------
total: ]]..tostr(newc),
action=function()
self.cooldown=newc>>16
self.cd_remainder=newc-rawnewc
end,
}
end
function bullet_base:hitship(_) function bullet_base:hitship(_)
self:die() self:die()
return true return true