Files
tidewall/test/capture/figure_scene.gd
T
claudeandClaude Opus 5.5 aa797580a7 #72: The packet ship, the lifeline mortar and the gull-kite
Eric chose option B on #72. The drop is now the GDD's launch:

- A packet ship sails a seeded straight line past the island, offshore,
  as close in as it can while keeping 45 m of open water from any land
  (eight-way probes; up to 32 headings, then the four world sides).
- Jump fires the lifeline mortar along the look heading. How high the
  player aims sets the charge (-10 to 45 degrees: 16 to 110 m/s over
  the ground; every shot climbs at 75 m/s). The climb can't be steered
  and the kite can't open until the arc tops out. Riders still aboard at
  the end are fired towards the middle of the island.
- Drop.reach() mirrors the fall for both ways down (kite at the top, or
  a fall with the kite opening by itself); bots, the soak and autoplay
  clients and the tutorial pilot aim with Drop.aim_charge().
- Bots fire at their landing spot once abeam of it, when in easy reach
  at their own staggered moment, or just before the route ends, and open
  the kite early only when the spot is beyond the rest of a fall.
- Art: VesselModels.ship() (two-masted packet, tanned square sails, a
  salt-white boot-top, a bowsprit and the mortar on its bed, mirrored to
  face the island), the figure's gull-kite (figure.py), and a lifeline
  cord from the muzzle to each player still climbing.
- Renamed barge to ship and wing-sail to gull-kite throughout code,
  tests, captures, docs and the tutorial text. make match now defaults to
  seed 2, where the scripted player still harvests and builds.

Closes #72

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 12:49:21 -05:00

174 lines
5.6 KiB
GDScript

## Capture scenario for the player figure (A2), on seed 2's island in the real
## MatchView. Each stage stands a row of figures, each frozen at a chosen moment of one
## animation, seen from in front and to their right:
##
## - states: idle, walk, run, crouched, creeping, in the air, skydiving, gliding,
## swimming, downed (M7). (Aboard the ship is the idle with the feet set wider; the deck
## placement would pull it out of the row.)
## - actions: carrying a longgun, a revolver and a tonic, firing each kind, a boathook
## swing, a keg thrown, building, reloading, drinking and a flinch.
## - close: one figure holding the dock carbine, close up, three-quarter front.
extends Node3D
@export var stage: String = "states"
@export var match_seed: int = 2
## [label, item id or "", setup, seconds to run, action or ""]. Setup names a state.
const STATES: Array = [
["idle", "", "ground", 0.6, ""],
["walk", "", "walk", 0.2, ""],
["run", "", "run", 0.15, ""],
["crouch", "", "crouch", 0.8, ""],
["creep", "", "creep", 0.25, ""],
["air", "", "air", 0.5, ""],
["skydive", "", "skydive", 0.8, ""],
["glide", "", "glide", 0.8, ""],
["swim", "", "swim", 0.35, ""],
["downed", "", "downed", 0.5, ""],
]
const ACTIONS: Array = [
["long", "whalers_longgun", "ground", 0.6, ""],
["short", "signal_revolver", "ground", 0.6, ""],
["carry", "brine_tonic", "ground", 0.6, ""],
["fire_long", "dock_carbine", "ground", 0.04, "fire_long"],
["fire_short", "signal_revolver", "ground", 0.04, "fire_short"],
["swing_back", "", "ground", 0.16, "swing"],
["swing", "", "ground", 0.26, "swing"],
["throw", "powder_keg", "ground", 0.2, "throw"],
["build", "", "ground", 0.1, "build"],
["reload", "dock_carbine", "reload", 0.5, ""],
["use", "brine_tonic", "use", 0.5, ""],
["flinch", "dock_carbine", "flinch", 0.06, ""],
]
var sim: Simulation
var view: MatchView
func _ready() -> void:
sim = Simulation.new(match_seed)
var spot: Vector3 = _open_ground()
var rows: Array = STATES if stage == "states" else ACTIONS
if stage == "close":
rows = [["close", "dock_carbine", "ground", 0.6, ""]]
var players: Array[SimEntity] = []
for index: int in rows.size():
players.append(_stand(_at(spot, index, rows.size()), rows[index]))
view = MatchView.new()
view.setup(sim, 0)
add_child(view)
view.entities.animate_live = false
view.sync()
for index: int in rows.size():
_pose(players[index], rows[index])
var middle: Vector3 = _at(spot, (rows.size() - 1) * 0.5 + (1.0 if rows.size() > 1 else 0.0), rows.size())
if stage == "close":
view.look_from(middle + Vector3(-2.0, 1.55, 2.6), middle + Vector3(0.0, 1.0, 0.0))
else:
var back: float = 2.0 + rows.size() * 0.42
view.look_from(middle + Vector3(-back, 1.7, back * 0.3), middle + Vector3(0.0, 1.0, 0.0))
view.settle()
func _at(spot: Vector3, index: float, count: int) -> Vector3:
var at: Vector3 = spot + Vector3(0.0, 0.0, (index - (count - 1) * 0.5) * 1.5 + 1.0)
at.y = sim.ground.terrain_height(at.x, at.z)
return at
func _stand(at: Vector3, row: Array) -> SimEntity:
var player: SimEntity = sim.entities.find(sim.add_player())
player.position = at
player.drop_state = Drop.NONE
player.on_ground = true
player.health = 100
player.yaw = 0
var id: String = row[1]
if id != "":
player.slot_items[0] = ItemCatalog.code_of(id)
player.slot_counts[0] = 1
player.slot_tiers[0] = 2
player.selected = 1
else:
player.selected = 0
match String(row[2]):
"walk":
player.velocity = Vector3(0.0, 0.0, Tuning.WALK_SPEED)
"run":
player.velocity = Vector3(0.0, 0.0, Tuning.SPRINT_SPEED)
"crouch":
player.crouching = true
"creep":
player.crouching = true
player.velocity = Vector3(0.0, 0.0, Tuning.CROUCH_SPEED)
"air":
player.on_ground = false
player.position.y += 0.5
"skydive":
player.drop_state = Drop.FREEFALL
player.on_ground = false
player.position.y += 0.6
"glide":
player.drop_state = Drop.GLIDING
player.on_ground = false
player.position.y += 0.4
"swim":
player.swimming = true
player.on_ground = false
"downed":
player.downed = true
player.crouching = true
player.health = Tuning.DOWNED_HEALTH
"aboard":
player.drop_state = Drop.ABOARD
player.on_ground = false
"reload":
player.reload_ticks = 10
"use":
player.use_ticks = 10
return player
func _pose(player: SimEntity, row: Array) -> void:
var figure: FigureRig = view.entities.figure_of(player.id)
# The ship's deck isn't drawn here: put the passenger back where it stands.
figure.position = player.position
figure.drive(player, 0.0)
figure.drive(player, 1.0)
figure.advance(0.0)
if String(row[2]) == "flinch":
figure.advance(0.4)
player.health = 70
figure.drive(player, 0.0)
if String(row[4]) != "":
figure.advance(0.4)
figure.act(row[4])
var left: float = float(row[3])
while left > 0.0:
var step: float = minf(left, 1.0 / 60.0)
figure.advance(step)
left -= step
## Fairly flat, open ground above the sea near the middle of the island.
func _open_ground() -> Vector3:
var size: float = Tuning.WORLD_SIZE_METRES
var best: Vector3 = Vector3(size * 0.5, 0.0, size * 0.5)
for ring: int in 60:
for step: int in 24:
var angle: float = TAU * step / 24.0
var x: float = size * 0.5 + cos(angle) * ring * 12.0
var z: float = size * 0.5 + sin(angle) * ring * 12.0
var feet: Vector3 = Vector3(x, sim.ground.terrain_height(x, z), z)
if feet.y < sim.sea_level + 3.0 or sim.ground.terrain_normal(x, z).y < 0.985:
continue
if not sim.props.near(feet, 12.0).is_empty():
continue
var level: bool = true
for dz: float in [-7.0, 0.0, 9.0]:
if absf(sim.ground.terrain_height(x - 2.0, z + dz) - feet.y) > 0.8:
level = false
if level:
return feet
return best