surive at 0hp and adjust hp values to match

Instead of doing a special case for 1HP, 0HP is survivable, ships die
at negative HP instead. all ship health is adjusted to match, assuming
the weakest shot is 0.5hp, which is currently true. the "real" game will
totally rebalance all ships and weapons anyway.

we're getting close to when I have to stop dawdling and implement the
real game, the engine is _there._
This commit is contained in:
Kistaro Windrider 2024-08-18 14:57:29 -07:00
parent 6b8efe3438
commit cc1e7ea5b7
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -339,15 +339,15 @@ function drawhud()
inset(120,66,125,125)
-- 57 px vertically
local mxs, cs, mxh, ch = primary_ship.maxshield, primary_ship.shield, primary_ship.maxhp, primary_ship.hp
if (mxs > 0) and (mxh > 1) then
local split = 57 * (mxs / (mxs + mxh-1)) \ 1 + 66
if (mxs > 0) and (mxh > 0) then
local split = 57 * (mxs / (mxs + mxh)) \ 1 + 66
line(121, split, 124, split, 0xba)
vertmeter(121,67,124,split-1,cs, mxs,shlcols)
vertmeter(121,split+1,124,124,ch-1, mxh-1, hpcols)
vertmeter(121,split+1,124,124,ch, mxh, hpcols)
elseif mxs > 0 then
vertmeter(121,67,124,124,cs,mxs,shlcols)
elseif mxh > 1 then
vertmeter(121,67,124,124,ch-1,mxh-1,hpcols)
elseif mxh > 0 then
vertmeter(121,67,124,124,ch,mxh,hpcols)
else
print("!", 122, 94, 9)
print("!", 121, 93, 8)
@ -441,7 +441,7 @@ mknew(ship_m)
function ship_m:die()
self.dead = true
if (self.hp <= 0) boom(self.x+self.size*4, self.y+self.size*4,12*self.size, self.boss)
if (self.hp < 0) boom(self.x+self.size*4, self.y+self.size*4,12*self.size, self.boss)
end
function ship_m:calc_velocity(v0, t)
@ -551,7 +551,7 @@ function ship_m:hitsomething(dmg)
dmg -= self.shield
self.shield = 0
self.hp -= dmg
if self.hp <= 0 then
if self.hp < 0 then
self:die()
return true
end
@ -916,11 +916,10 @@ player = ship_m.new{
mknew(player,
function(p)
p.main_gun = zap_gun.new()
-- ONE HIT MODE: max hp is
-- minimum nonzero value.
-- ONE HIT MODE
--
-- p.hp = 0x0.0001
-- p.maxhp = 0x0.0001
-- p.hp = 0
-- p.maxhp = 0
-- p.shield = 0
-- p.maxshield = 0
end
@ -940,7 +939,7 @@ frownie = ship_m.new{
sparkodds = 8,
-- health and power
hp = 1, -- enemy ships need no max hp
hp = 0.5, -- enemy ships need no max hp
-- position
x=60, -- x and y are for upper left corner
@ -962,7 +961,7 @@ mknew(frownie)
blocky = frownie.new{
sprite = 10,
hp = 2,
hp = 1.5,
hurt = {
x_off = 0,
y_off = 0,
@ -971,7 +970,7 @@ blocky = frownie.new{
},
ow = function(self)
if self.hp <= 1 then
if self.hp < 1 then
self.sprite = 11
else
self.sprite = 10
@ -990,7 +989,7 @@ spewy = frownie.new{
width=8,
height=5
},
hp=1,
hp=0.5,
maxpower=70,
generator=0.5,
fire_off_x=4,
@ -1015,7 +1014,7 @@ chasey = ship_m.new{
},
sparks = smokespark,
sparkodds = 8,
hp = 2,
hp = 1.5,
shield = 1,
maxshield = 1,
shieldcost = 180,
@ -1047,7 +1046,7 @@ xl_chasey=chasey.new{
width = 12,
height = 10
},
hp = 20,
hp = 19.5,
shield = 5,
boss = true,
slip = false,