Bound individual vessel speed; stop Fleet.stop() accumulating it (#72)
Rotating the fleet and spamming a direction let vessels fall out of sync and fly at wildly high speeds. The pivot cooldown added earlier throttled how often the exploit could be triggered; it never touched the cause. Fleet.stop() did `ship.velocity = ship.velocity + ship.fleet_velocity`, compensating for the fact that Ship.velocity read zero during cruise. The next steer refilled fleet_velocity, so every press-release cycle added a whole cruise velocity to the ship's own, decaying only at `acceleration` in between. Tapping faster than that bled it off stacked them without limit, and ships desynced because each bled off at a rate set by its own distance to its slot. Measured before this change: spamming a direction while pivoting flew the fleet 32737 units in 3s against 784 for simply holding the stick, with a vessel reaching 48x its own top speed. The compensation existed because `velocity` was not the ship's real motion: Ship snapped to its slot every tick and zeroed it, so the truth lived in a second field and anything wanting it had to add the two together. Fixed at that root rather than by clamping the symptom: - fleet_velocity is now fed FORWARD into the steering instead of carried alongside it. The ship aims to travel at its slot's velocity plus a correction closing the gap, so holding formation costs no error and `velocity` is always true world motion. - The snap only applies when the slot is standing still, which is the one case where converging asymptotically would leave a residue. While the slot moves the ship steers continuously - a snap there was the teleport that made `velocity` lie in the first place. - A hard bound on the INTEGRATED result every tick, not merely on the request, so no sequence of commands can leave a vessel over its own top speed. - Fleet.stop() injects nothing; it reports that the slot has halted. tests/test_fleet_speed_bounded.gd covers it, and fails against the previous code with the numbers above: no vessel exceeds its own top speed however hard the direction is spammed, spamming cannot cover more ground than holding the stick, both hold while the formation is pivoting, and the fleet stays together. test_space_time_distorder.gd now clears the asteroid and enemy groups at setup, the same clean-slate idiom test_ship_lab.gd uses. Silencing the spawners was never enough - what Main.tscn had already placed kept moving, and losing the distorder vessel to a rock resets the multiplier correctly, which the test then reported three stages later as a failed scene swap. It also checks it still crews a distorder vessel before relying on that. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
657ca9d035
commit
67cb853397
5 changed files with 274 additions and 34 deletions
|
|
@ -58,6 +58,17 @@ func _process(delta: float) -> bool:
|
|||
return false
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("AsteroidField").set_process(false)
|
||||
# Silencing the spawners is not enough: whatever Main.tscn already
|
||||
# placed keeps moving under its own _physics_process, and this test
|
||||
# flies the fleet several thousand units at up to 3x boost. Losing
|
||||
# the distorder ship to a rock mid-run resets the multiplier -
|
||||
# CORRECTLY, that is what _sync_composition_state is for - and the
|
||||
# test then failed three stages later claiming the multiplier had
|
||||
# not survived a scene swap. Same clean-slate idiom as
|
||||
# test_ship_lab.gd.
|
||||
for hazard in get_nodes_in_group("asteroids") + get_nodes_in_group("enemies"):
|
||||
if is_instance_valid(hazard):
|
||||
hazard.queue_free()
|
||||
|
||||
# --- A. absent, then appears -------------------------------------
|
||||
if fader.visible:
|
||||
|
|
@ -192,6 +203,13 @@ func _process(delta: float) -> bool:
|
|||
# scenario here since this fleet keeps its distorder ship the
|
||||
# whole way across the swap, via GameState.surviving_vessel_types
|
||||
# exactly like every other vessel type).
|
||||
# Check the premise before relying on it. Everything below is about
|
||||
# the multiplier surviving a scene swap, which is only meaningful
|
||||
# while the fleet still crews a distorder vessel - so if the fleet
|
||||
# lost one on the way here, say THAT rather than reporting a reset
|
||||
# multiplier as if the swap were at fault.
|
||||
if not fleet.has_capability("distorder"):
|
||||
return _fail_now("the fleet lost its distorder vessel before the scene swap, so the multiplier reset is expected rather than a bug")
|
||||
game_state.surviving_ship_count = fleet.ships.size()
|
||||
game_state.surviving_vessel_types = fleet.vessel_types()
|
||||
game_state.planet_id = "test_space_time_distorder"
|
||||
|
|
|
|||
Loading…
Reference in a new issue