Hub character swapping, XP percentage, passive health regeneration
ci / verify (push) Successful in 47s

Character swapping is hub-only, and refused by the SERVER rather than merely
greyed out in the menu. Allowing it inside a dungeon would be an instant,
uninterruptible exit from danger -- strictly better than the one-second escape
channel, which would make that channel pointless. Creating a character in a
dungeon is refused for the same reason. Both are covered by diag_progression.

Health regenerates at 0.5% of MAXIMUM per second. A percentage rather than a
flat rate so it does not become irrelevant at level 15: a capped character
regains 1.2 hp/s against a level 1's 0.5, and both take about 200 seconds to
heal from nothing. No out-of-combat gate -- at this rate it cannot out-heal
anything actually shooting at you, and a trickle that never stops is easier to
reason about than a timer players have to learn. A fractional carry is needed
because a tick heals well under one hit point, so truncating each tick would
heal exactly nothing; there is a test for that specifically.

The XP bar now states the percentage and the level it leads to, since a bar
answers "how far" vaguely and a number answers it exactly.

Recorded the two Stage 3 answers: 4 inventory slots, and the boss's food item
is player-instanced now so the mechanism gets exercised rather than deferred.

Writing the swap guard's test caught my own mistake: the first version created
its spare character through the store, which has no opinion about where you
are, so it bypassed the guard it was meant to prove and left a stray character
behind that broke a later assertion.

200 tests. check.sh, test.sh, smoke.sh and both diagnostics pass.
This commit is contained in:
2026-09-04 00:56:29 +02:00
parent 4765bbce28
commit 7ef972e3b3
14 changed files with 243 additions and 15 deletions
+22
View File
@@ -21,6 +21,10 @@ var alive: bool = true
var fire_cooldown: int = 0
## Ticks of arrival protection left: invulnerable, and unable to shoot.
var spawn_grace: int = 0
## Fractional health carried between ticks. Regeneration is well under one hit
## point per tick, so without this it would round to zero every tick and heal
## nothing at all.
var regen_carry: float = 0.0
## Ticks before a downed player may ask to return to the hub.
var respawn_lockout: int = 0
@@ -68,6 +72,7 @@ func reset_for_instance(spawn: Vector2, grace: int = 0) -> void:
alive = true
spawn_grace = grace
respawn_lockout = 0
regen_carry = 0.0
fire_cooldown = 0
escape_ticks = 0
input_queue.clear()
@@ -86,3 +91,20 @@ func adopt(c: Character) -> void:
colour = c.colour
max_hp = c.max_hp()
hp = mini(hp, max_hp)
## One tick of passive healing. Returns true if the visible hit points changed,
## so the caller can decide whether anything needs announcing.
func regenerate() -> bool:
if not alive or hp >= max_hp:
regen_carry = 0.0
return false
regen_carry += float(max_hp) * (SimConfig.HP_REGEN_PERCENT_PER_SEC / 100.0) \
* SimConfig.TICK_DELTA
if regen_carry < 1.0:
return false
var whole := int(regen_carry)
regen_carry -= float(whole)
var before := hp
hp = mini(hp + whole, max_hp)
return hp != before
+1
View File
@@ -172,6 +172,7 @@ func step() -> void:
func _step_players() -> void:
for p in players.values():
p.regenerate()
if p.spawn_grace > 0:
p.spawn_grace -= 1
if p.fire_cooldown > 0: