Ammo quantity upgrade prototype

Not yet tested. Will crash until I also get rate_upgrade_opt up.
This commit is contained in:
Kistaro Windrider 2025-05-03 16:06:16 -07:00
parent 288b7f64c8
commit 7ed305d2d9
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -676,7 +676,8 @@ bullet_base = mknew{ }
gun_base = mknew{ gun_base = mknew{
shoot_ready = -32768, shoot_ready = -32768,
icon = 20 icon = 20,
ammobonus = 1,
} }
-- gun_base subtypes are -- gun_base subtypes are
@ -707,6 +708,38 @@ function gun_base:actually_shoot(x, y)
self.munition.new{}:spawn_at(x, y) self.munition.new{}:spawn_at(x, y)
end end
-- upgrade
function gun_base:small_upgrade_opts()
local ret = {
self:ammo_upgrade_opt(),
self:rate_upgrade_opt(),
}
local s = self.special_upgrade_opt
if (s) add(ret, s(self))
return ret
end
function gun_base:ammo_upgrade_opt()
local a=self.maxammo
local x=a\10+self.ammobonus
return {
icon=self.icon,
hdr=self.hdr,
body=[[----------AMMO
more shots.
is: ]]..tostr(a)..[[
add: ]]..tostr(x)..[[
----------
total: ]]..tostr(a+x),
action=function()
self.maxammo+=x
self.ammo+=x
end,
}
end
function bullet_base:hitship(_) function bullet_base:hitship(_)
self:die() self:die()
return true return true