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:
parent
7ed305d2d9
commit
e5b8a30cb6
@ -678,6 +678,11 @@ gun_base = mknew{
|
||||
shoot_ready = -32768,
|
||||
icon = 20,
|
||||
ammobonus = 1,
|
||||
|
||||
-- fractional frames of
|
||||
-- cooldown reduction from
|
||||
-- upgrades, not yet applied
|
||||
cd_remainder = 0,
|
||||
}
|
||||
|
||||
-- gun_base subtypes are
|
||||
@ -727,7 +732,9 @@ function gun_base:ammo_upgrade_opt()
|
||||
hdr=self.hdr,
|
||||
body=[[----------AMMO
|
||||
|
||||
more shots.
|
||||
more shots
|
||||
before you
|
||||
run out.
|
||||
|
||||
is: ]]..tostr(a)..[[
|
||||
add: ]]..tostr(x)..[[
|
||||
@ -740,6 +747,34 @@ total: ]]..tostr(a+x),
|
||||
}
|
||||
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(_)
|
||||
self:die()
|
||||
return true
|
||||
|
Loading…
x
Reference in New Issue
Block a user