From e5b8a30cb6ed3cab0427d6e41b8cefc27ced5ca5 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 3 May 2025 16:28:54 -0700 Subject: [PATCH] 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. --- vacuum_gambit.p8 | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 7b02fc5..c0eef2e 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -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