Presets now tune shadows, cascades, render scale and anti-aliasing: Low (no shadows, 75%, FXAA), Medium (200 m, 2 cascades, FXAA), High (400 m, 4 cascades, MSAA 2x). GameSettings.apply_to_viewport sets the viewport; MatchView.apply_settings sets the sun's cascades. No preset changes how far props or pieces are drawn, so a lower one never shows a player through cover; a test guards it. When Vulkan can't start, Godot falls back to OpenGL (fallback_to_opengl3) and RendererCheck has the main menu say so. tools/capture.sh gains CAPTURE_RENDERER=no_vulkan, which hides the Vulkan driver and expects the fallback. New scenarios quality_low/medium/high draw a match moment with each preset, reviewed in both renderers. docs/PLAY.md lists the presets, renderers, Wayland and hybrid-GPU notes, and the tested configurations, marking each as software-rendered only or not tested. Closes #55 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
6.0 KiB
GDScript
157 lines
6.0 KiB
GDScript
## Capture scenario for a whole match. It replays the command log `make match` saved
|
|
## to the moment `stage` names, draws that moment with the client's MatchView, and
|
|
## prints what it shows as a caption (Godot's default font; this is a test caption,
|
|
## not the game's HUD).
|
|
##
|
|
## Stages: lobby, barge, glide, landed, built, final, tide (the island just before the
|
|
## end, from where the lobby saw it), results.
|
|
extends Node3D
|
|
|
|
const TICKS: int = Tuning.TICK_RATE_HZ
|
|
## The scripted player's handle.
|
|
const PLAYER: int = 1
|
|
|
|
@export var log_path: String = "res://build/match/match.tclog"
|
|
@export var stage: String = "lobby"
|
|
## H2: a GameSettings quality preset to draw with (-1: the view's defaults).
|
|
@export var quality: int = -1
|
|
|
|
var _replay: MatchReplay
|
|
var _view: MatchView
|
|
|
|
|
|
func _ready() -> void:
|
|
var commands: CommandLog = CommandLog.load_from(log_path)
|
|
if commands == null:
|
|
push_error("match capture: no usable command log at %s; run `make match` first" % log_path)
|
|
return
|
|
_replay = MatchReplay.new(commands)
|
|
var flow: Match = _replay.flow
|
|
var last: int = commands.final_tick
|
|
match stage:
|
|
"lobby":
|
|
pass
|
|
"barge":
|
|
_replay.run_until(func() -> bool: return flow.in_match() and flow.sim.tick >= 2 * TICKS)
|
|
"glide":
|
|
_replay.run_until(func() -> bool: return _player() != null and _player().drop_state == Drop.GLIDING)
|
|
_run_ticks(TICKS)
|
|
"landed":
|
|
_replay.run_until(func() -> bool: return _player() != null and _player().drop_state == Drop.NONE and flow.in_match())
|
|
_run_ticks(4 * TICKS)
|
|
"built":
|
|
_replay.run_until(func() -> bool: return flow.sim.structures.count() >= 2)
|
|
_run_ticks(3 * TICKS)
|
|
"tide":
|
|
_replay.run_until(func() -> bool: return flow.in_match() and flow.sim.tick >= last - 2 * TICKS)
|
|
"final":
|
|
_replay.run_until(func() -> bool: return flow.in_match() and flow.sim.tick > 10 * TICKS and flow.alive().size() <= 3)
|
|
"results":
|
|
_replay.run_to_end()
|
|
_:
|
|
push_error("match capture: unknown stage '%s'" % stage)
|
|
return
|
|
|
|
var sim: Simulation = flow.sim
|
|
var player_id: int = int(flow.entity_of.get(PLAYER, 0))
|
|
_view = MatchView.new()
|
|
_view.setup(sim, player_id)
|
|
add_child(_view)
|
|
if quality >= 0:
|
|
var settings: GameSettings = GameSettings.new()
|
|
settings.quality = quality
|
|
settings.apply_to_viewport(get_viewport())
|
|
_view.apply_settings(settings)
|
|
var watched: int = _watched()
|
|
var who: String = "nobody"
|
|
if stage == "lobby" or stage == "tide":
|
|
_view.overview()
|
|
who = "the island"
|
|
elif stage == "barge":
|
|
var along: Vector3 = (sim.drop.finish - sim.drop.start).normalized()
|
|
var at: Vector3 = sim.drop.barge_position(sim.tick)
|
|
_view.look_from(at - along * 22.0 + Vector3(0.0, 9.0, 0.0) + along.cross(Vector3.UP) * 9.0, at + along * 40.0 - Vector3(0.0, 22.0, 0.0))
|
|
who = "the barge"
|
|
elif watched != 0:
|
|
var entity: SimEntity = sim.entities.find(flow.entity_of[watched])
|
|
var airborne: bool = entity.drop_state != Drop.NONE
|
|
if stage == "built" and sim.structures.count() > 0:
|
|
var piece: StructureSet.Piece = sim.structures.pieces.values()[0]
|
|
_view.frame(entity.id, 7.0, 2.8, piece.boxes[0].get_center())
|
|
elif stage == "results":
|
|
_view.frame(entity.id)
|
|
else:
|
|
_view.follow(entity.id, deg_to_rad(-22.0) if airborne else deg_to_rad(-9.0))
|
|
who = "the player" if watched == PLAYER else "bot %d" % -watched
|
|
else:
|
|
_view.overview()
|
|
_view.settle()
|
|
_caption(_describe(who) + ("" if quality < 0 else "\nquality: %s, renderer: %s" % [GameSettings.QUALITY_NAMES[quality], RenderingServer.get_current_rendering_method()]))
|
|
|
|
|
|
func _player() -> SimEntity:
|
|
var flow: Match = _replay.flow
|
|
if not flow.entity_of.has(PLAYER):
|
|
return null
|
|
return flow.sim.entities.find(flow.entity_of[PLAYER])
|
|
|
|
|
|
func _run_ticks(count: int) -> void:
|
|
for _index: int in count:
|
|
if not _replay.step():
|
|
return
|
|
|
|
|
|
## The handle the camera follows: the player while they stand, then whoever they're
|
|
## spectating, then a winner, then anyone still standing. 0 for nobody.
|
|
func _watched() -> int:
|
|
var flow: Match = _replay.flow
|
|
var living: Array[int] = flow.alive()
|
|
if living.has(PLAYER):
|
|
return PLAYER
|
|
var target: int = flow.spectate_target(PLAYER)
|
|
if target != 0 and flow.entity_of.has(target):
|
|
return target
|
|
if not flow.winners.is_empty():
|
|
return flow.winners[0]
|
|
return living[0] if not living.is_empty() else 0
|
|
|
|
|
|
func _describe(who: String) -> String:
|
|
var flow: Match = _replay.flow
|
|
var sim: Simulation = flow.sim
|
|
var lines: Array[String] = []
|
|
lines.append("%s · %s · seed %d" % [stage.to_upper(), flow.phase_name(), _replay.commands.session_seed])
|
|
if flow.phase == Match.LOBBY or flow.phase == Match.COUNTDOWN:
|
|
lines.append("%d waiting · the match starts in %d s" % [flow.participants.size(), (flow.rules.lobby_ticks + flow.rules.countdown_ticks) / TICKS])
|
|
return "\n".join(lines)
|
|
lines.append("%d:%02d · %d of %d standing · sea %.1f m · tide phase %d" % [
|
|
sim.tick / TICKS / 60, sim.tick / TICKS % 60, flow.alive().size(), flow.summary().size(), sim.sea_level,
|
|
sim.tide.phase_at(sim.tick) + 1 if sim.tide != null else 0])
|
|
var me: SimEntity = _player()
|
|
if me != null:
|
|
lines.append("player: health %d · driftwood %d · %d pieces built · watching %s" % [
|
|
me.health, me.materials[Materials.DRIFTWOOD], sim.structures.count(), who])
|
|
if flow.phase == Match.RESULTS:
|
|
for row: Dictionary in flow.summary():
|
|
if row["place"] <= 3 or row["handle"] == PLAYER:
|
|
lines.append("#%d %s · %d eliminations · %d damage · %d s" % [
|
|
row["place"], "player" if row["handle"] == PLAYER else "bot %d" % -int(row["handle"]),
|
|
row["eliminations"], row["damage_dealt"], roundi(row["survival_seconds"])])
|
|
return "\n".join(lines)
|
|
|
|
|
|
func _caption(text: String) -> void:
|
|
var settings: LabelSettings = LabelSettings.new()
|
|
settings.font_size = 20
|
|
settings.font_color = Color(0.96, 0.94, 0.88)
|
|
settings.outline_size = 6
|
|
settings.outline_color = Color(0.08, 0.09, 0.1)
|
|
var label: Label = Label.new()
|
|
label.label_settings = settings
|
|
label.text = text
|
|
label.position = Vector2(18.0, 14.0)
|
|
var layer: CanvasLayer = CanvasLayer.new()
|
|
layer.add_child(label)
|
|
add_child(layer)
|