#229, #234: one voice per volley, and gas within reach of the spawn

#229 - a volley got louder for every ship in it.

Every hull owns its gun and asks for its own shot sound, so eight ships
firing on the same cooldown started eight voices playing the SAME sample in
the same frame. Those amplitudes add, so a full fleet was the loudest thing
in the game by a wide margin.

play() now takes a per-sound coalescing window. A volley is one event to the
ear, so it gets one voice. 70ms, which the test checks is inside the fastest
gun's 500ms cooldown - it collapses "six guns at once", never "six shots in
a row". PICKUP and ASTEROID_BREAK get one too: ore arrives in bursts when a
rock breaks and that is one pickup to the ear. Deaths and the boss scream
are left alone deliberately - several things dying together IS several
events.

test_sfx's pool-saturation case was driven by shots, which can no longer
saturate anything by design. It is driven by deaths now, which is what the
pool actually has to absorb, and it gained a case asserting a volley takes
one voice - measured against the real pool rather than the gate.

#234 - gas was not reliably in reach of the opening.

Gas giants are gated behind two independent noise fields, the SPACE biome
AND the planet roll, so whether any sat near the spawn was luck. Measured,
this seed lost: ZERO gas planets within four chunks, the nearest five away
past five rocky ones. Gas is an early need - the burner, ammunition - so the
opening cannot depend on the noise being kind.

SPAWN_GAS_GIANT_CHUNK at (2, -2), authored like OCTOPUS_BIOME_CENTER rather
than found by searching outward: a fixed chunk is reproducible from anywhere
without walking the map, which is what the rest of WorldGen is built on.

The override is applied AFTER every rng draw, for the same reason the dev
planting is - forcing one chunk must not shift what any other chunk rolls.
Confirmed by probe: the five other planets within four chunks are identical
before and after, and the distant gas giants at (-5,-4) and (0,-5) are still
where they were.

Both verified in reverse: without the window, "8 ships firing together
started 8 shot sounds"; without the chunk, "no gas planet within 4 chunks of
the spawn".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
Claude 2026-09-14 10:49:25 -04:00 • committed by Loïc Wisniewski
commit 885f977768
5 changed files with 312 additions and 4 deletions

View file

@ -43,6 +43,19 @@ const RESEARCH_LAB_CHANCE: float = 0.16
# anchor and one shape make the actual rule representable: one multi-chunk
# octopus biome, with its boss at the centre.
const OCTOPUS_BIOME_CENTER: Vector2i = Vector2i(12, -9)
# Forgejo #234: a gas giant the opening is guaranteed to be able to reach.
#
# Gas is gated behind two independent noise fields - the SPACE biome and the
# planet roll - so whether any is in reach of the spawn was luck, and on this
# seed it lost: measured, there were ZERO gas planets within four chunks and
# the nearest sat five away, past five rocky ones. Gas is needed early (the
# burner, ammunition), so the opening cannot depend on the noise being kind.
#
# Authored like OCTOPUS_BIOME_CENTER above rather than found by searching
# outward: a fixed chunk is reproducible from anywhere without walking the
# map, which is the property everything in this file is built on.
const SPAWN_GAS_GIANT_CHUNK: Vector2i = Vector2i(2, -2)
const OCTOPUS_BIOME_OFFSETS: Array[Vector2i] = [
Vector2i(0, 0), Vector2i(-1, 0), Vector2i(1, 0),
Vector2i(0, -1), Vector2i(0, 1),
@ -134,6 +147,8 @@ static func has_planet_at_chunk(chunk: Vector2i) -> bool:
return true
if chunk == OCTOPUS_BIOME_CENTER:
return true
if chunk == SPAWN_GAS_GIANT_CHUNK:
return true
if is_octopus_chunk(chunk):
return false
var n: float = _get_planet_noise().get_noise_2d(float(chunk.x), float(chunk.y))
@ -173,6 +188,11 @@ static func planet_data_at_chunk(chunk: Vector2i) -> Dictionary:
definition_id = PLANET_DEFINITIONS.BLACK_HOLE_ID
elif research_lab_roll < RESEARCH_LAB_CHANCE:
definition_id = PLANET_DEFINITIONS.RESEARCH_LAB_ID
# #234, applied after the rolls for the same reason the dev planting is:
# forcing this chunk must not shift which random values any OTHER chunk
# consumes, or one guaranteed planet would reshuffle the whole map.
if chunk == SPAWN_GAS_GIANT_CHUNK:
definition_id = PLANET_DEFINITIONS.GAS_GIANT_ID
# Dev mode's fixed planting wins over every roll above. Applied last, and
# AFTER all the rng draws, so switching it on cannot shift which random
# values any other chunk consumes - a dev world and a normal one differ