#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>
This commit is contained in:
@@ -296,7 +296,7 @@ func _show(delta: float) -> void:
|
||||
if view == null:
|
||||
return
|
||||
view.entities.local_id = mirror.own_id if mirror.own_id != 0 else view.entities.local_id
|
||||
view.entities.barge_at = mirror.barge_at
|
||||
view.entities.ship_at = mirror.ship_at
|
||||
view.rig.update_aim(input.aiming() and mirror.own_id != 0, delta)
|
||||
view.sync()
|
||||
var fresh: int = mini(game.fx_received - _fx_seen, game.fx.size())
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@
|
||||
## the FX the server sends) and moves on when each step is done, so it judges what the
|
||||
## player actually did, through the same door as any match.
|
||||
##
|
||||
## The steps: leave the barge, glide down, walk and jump, cut materials with the
|
||||
## The steps: fire yourself off the ship, glide down, walk and jump, cut materials with the
|
||||
## boathook, place a wall, aim and fire the carbine you start with, and get above the
|
||||
## line the tide will reach. Every instruction names the player's own key bindings.
|
||||
##
|
||||
@@ -22,7 +22,7 @@ const TIDE: int = 6
|
||||
const DONE: int = 7
|
||||
const STEP_NAMES: Array[String] = ["leap", "glide", "move", "harvest", "build", "fire", "tide", "done"]
|
||||
const TITLES: Array[String] = [
|
||||
"Leave the barge", "Glide down", "Find your feet", "Gather materials",
|
||||
"Leave the ship", "Glide down", "Find your feet", "Gather materials",
|
||||
"Build a wall", "Aim and fire", "Beat the tide", "Ready to set out",
|
||||
]
|
||||
|
||||
@@ -132,9 +132,9 @@ static func tide_line(tide: Tide, tick: int) -> float:
|
||||
func instruction() -> String:
|
||||
match step:
|
||||
LEAP:
|
||||
return "You're aboard the barge, high over the island. When it's over land, press %s to leap." % _key("jump")
|
||||
return "You're aboard the packet ship, off the coast. Face the island and look up to charge the lifeline mortar: the higher you aim, the farther it throws you. Press %s to fire." % _key("jump")
|
||||
GLIDE:
|
||||
return "Steer with %s as you fall. Press %s to open your sail, or it opens by itself near the ground. Aim for open ground." % [
|
||||
return "Steer with %s as you fall. Once you're over the top of the arc, press %s to open your gull-kite, or it opens by itself near the ground. Aim for open ground." % [
|
||||
_moves(), _key("jump")]
|
||||
MOVE:
|
||||
return "Walk with %s and look with the %s. %s to sprint, press %s to jump." % [
|
||||
|
||||
@@ -53,7 +53,11 @@ func command(tick: int, game: ClientGame) -> PlayerCommand:
|
||||
match tutorial.step:
|
||||
Tutorial.LEAP:
|
||||
_face_centre(me)
|
||||
if tick > 3 * TICKS and world.ground.terrain_height(me.position.x, me.position.z) > Tuning.ISLAND_BEACH_TOP + 4.0:
|
||||
if tick > 3 * TICKS:
|
||||
# Fire the mortar most of the way to the middle of the island.
|
||||
var centre: Vector2 = Vector2.ONE * Tuning.WORLD_SIZE_METRES * 0.5
|
||||
var gap: float = centre.distance_to(Vector2(me.position.x, me.position.z))
|
||||
input.pitch = Drop.pitch_for_charge(Drop.aim_charge(gap * 0.7))
|
||||
input.buttons = PlayerCommand.BUTTON_JUMP
|
||||
Tutorial.GLIDE:
|
||||
_face_centre(me)
|
||||
|
||||
@@ -463,7 +463,8 @@ func _stop() -> void:
|
||||
|
||||
# The drop
|
||||
|
||||
## Rides the barge to within reach of a loot marker near its route, then glides to it.
|
||||
## Rides the ship until it is abeam of a loot marker within the mortar's reach, fires
|
||||
## itself at it and glides there.
|
||||
func _drop(sim: Simulation, grid: NavGrid, world: BotWorld) -> PlayerCommand:
|
||||
state = "drop"
|
||||
var rider: SimEntity = sim.entities.find(player_id)
|
||||
@@ -481,7 +482,7 @@ func _drop(sim: Simulation, grid: NavGrid, world: BotWorld) -> PlayerCommand:
|
||||
for index: int in world.markers.size():
|
||||
var at: Vector2 = Vector2(world.markers[index].x, world.markers[index].z)
|
||||
var closest: Vector2 = Geometry2D.get_closest_point_to_segment(at, a, b)
|
||||
if at.distance_to(closest) <= 120.0 and world.markers[index].y > sim.sea_level + 1.0:
|
||||
if at.distance_to(closest) <= Tuning.BOT_LANDING_REACH_METRES and world.markers[index].y > sim.sea_level + 1.0:
|
||||
near.append(index)
|
||||
if near.is_empty():
|
||||
_landing = rng.randi_range(0, world.markers.size() - 1)
|
||||
|
||||
+35
-11
@@ -36,7 +36,7 @@ var _stuck_ticks: int = 0
|
||||
var _stuck_tries: int = 0
|
||||
var _jump_next: bool = false
|
||||
var _leap_tick: int = -1
|
||||
## How far the goal was from the barge last tick, while riding.
|
||||
## How far the goal was from the ship last tick, while riding.
|
||||
var _ride_gap: float = INF
|
||||
var _rng: RandomNumberGenerator = null
|
||||
var _rng_seed: int = 0
|
||||
@@ -87,8 +87,8 @@ func think(sim: Simulation, grid: NavGrid) -> PlayerCommand:
|
||||
if player.drop_state == Drop.ABOARD:
|
||||
return _ride(sim, player)
|
||||
if player.drop_state != Drop.NONE:
|
||||
# Gliding down: head for the goal.
|
||||
return _steer(sim, player, goal, 0)
|
||||
# Coming down: head for the goal.
|
||||
return _descend(sim, player)
|
||||
if status != MOVING:
|
||||
return PlayerCommand.from_input(sim.tick, Vector2.ZERO, deg_to_rad(player.yaw * 360.0 / PlayerCommand.YAW_STEPS), 0.0)
|
||||
if not _needs_plan and (sim.tick + player_id) % Tuning.BOT_PATH_CHECK_TICKS == 0:
|
||||
@@ -175,21 +175,45 @@ func _steer(sim: Simulation, player: SimEntity, target: Vector3, buttons: int) -
|
||||
return PlayerCommand.from_input(sim.tick, Vector2(0.0, 1.0), atan2(to.x, to.y), 0.0, buttons)
|
||||
|
||||
|
||||
## Aboard the barge: leap once the goal is within gliding reach, or once the barge
|
||||
## starts drawing away from it; with no goal, at a time set by the player ID. The end of the route puts everyone off anyway.
|
||||
## Aboard the ship: with a goal, fire the mortar at it with the charge that reaches it,
|
||||
## once the ship has come abeam of it and starts drawing away, or sooner if it is in
|
||||
## easy reach at a time set by the player ID; with no goal, at that time, towards the
|
||||
## middle of the island. The end of the route
|
||||
## fires everyone still aboard anyway.
|
||||
func _ride(sim: Simulation, player: SimEntity) -> PlayerCommand:
|
||||
if _leap_tick < 0 and sim.drop != null:
|
||||
_leap_tick = sim.drop.began_tick + Tuning.TICK_RATE_HZ * 2 + (player_id * 53) % (Tuning.TICK_RATE_HZ * 20)
|
||||
var leap: bool = sim.tick >= _leap_tick
|
||||
var target: Vector2 = Vector2.ONE * Tuning.WORLD_SIZE_METRES * 0.5
|
||||
var reach: float = 0.7
|
||||
if status == MOVING:
|
||||
# With somewhere to land, wait until it's in gliding reach, or until the barge
|
||||
# has passed it and is drawing away (H3: bots used to leap on the timer and land
|
||||
# hundreds of metres short).
|
||||
var gap: float = Vector2(goal.x - player.position.x, goal.z - player.position.z).length()
|
||||
leap = gap < 0.6 * (player.position.y - goal.y) or gap > _ride_gap + 0.01
|
||||
target = Vector2(goal.x, goal.z)
|
||||
reach = 1.0
|
||||
var gap: float = target.distance_to(Vector2(player.position.x, player.position.z))
|
||||
# Abeam of the goal; or in easy reach of it once this bot's own moment has come,
|
||||
# so riders don't all fire together; or about to be fired off at the end of the
|
||||
# route anyway, which aims at the middle of the island instead of the goal.
|
||||
leap = gap > _ride_gap + 0.01 or (sim.drop != null and sim.drop.is_over(sim.tick + 2)) \
|
||||
or (leap and gap <= Tuning.BOT_LANDING_REACH_METRES)
|
||||
_ride_gap = gap
|
||||
var to: Vector2 = target - Vector2(player.position.x, player.position.z)
|
||||
var buttons: int = PlayerCommand.BUTTON_JUMP if leap else 0
|
||||
return PlayerCommand.from_input(sim.tick, Vector2.ZERO, 0.0, 0.0, buttons)
|
||||
var pitch: float = Drop.pitch_for_charge(Drop.aim_charge(to.length() * reach)) if leap else 0.0
|
||||
return PlayerCommand.from_input(sim.tick, Vector2.ZERO, atan2(to.x, to.y), pitch, buttons)
|
||||
|
||||
|
||||
## Coming down: steer for the goal, and once over the top of the mortar's arc, open the
|
||||
## kite if the goal is further off than the rest of a fall would carry (a fall covers
|
||||
## well under the kite's glide of about two metres across for each one down).
|
||||
func _descend(sim: Simulation, player: SimEntity) -> PlayerCommand:
|
||||
var buttons: int = 0
|
||||
if player.drop_state == Drop.FREEFALL and player.velocity.y <= 0.0:
|
||||
var gap: float = Vector2(goal.x - player.position.x, goal.z - player.position.z).length()
|
||||
var carry: float = Vector2(player.velocity.x, player.velocity.z).length()
|
||||
var coast: float = maxf(carry * carry - Tuning.GLIDE_SPEED * Tuning.GLIDE_SPEED, 0.0) / (2.0 * Tuning.DROP_STEER_ACCEL)
|
||||
if gap - coast > (player.position.y - goal.y) * 1.6:
|
||||
buttons = PlayerCommand.BUTTON_JUMP
|
||||
return _steer(sim, player, goal, buttons)
|
||||
|
||||
|
||||
## A random open dry point within ROAM_RANGE that a path reaches, from the bot's own
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## The script a soak-test client plays by. It only sees what a network client sees: its
|
||||
## own predicted player and its copy of the island. It leaps from the barge over land,
|
||||
## own predicted player and its copy of the island. It fires itself off the ship at the summit,
|
||||
## glides, heads for the island's highest ground (where the tide leaves people last),
|
||||
## swings the boathook at whatever is in front of it, which harvests trees and crates,
|
||||
## and every few seconds tries to put up a wall. So a soak match has movement, world
|
||||
@@ -40,9 +40,10 @@ func command(tick: int, me: SimEntity, world: Simulation) -> PlayerCommand:
|
||||
var to_top: Vector2 = _top - Vector2(me.position.x, me.position.z)
|
||||
var yaw: float = atan2(to_top.x, to_top.y)
|
||||
if me.drop_state == Drop.ABOARD:
|
||||
# Fire the mortar at the summit after a wait of a few seconds.
|
||||
var wait: int = (3 + number % 8) * TICKS
|
||||
var over_land: bool = world.ground.terrain_height(me.position.x, me.position.z) > Tuning.ISLAND_BEACH_TOP + 2.0
|
||||
return PlayerCommand.from_input(tick, Vector2.ZERO, yaw, 0.0, PlayerCommand.BUTTON_JUMP if tick > wait and over_land else 0)
|
||||
var pitch: float = Drop.pitch_for_charge(Drop.aim_charge(to_top.length()))
|
||||
return PlayerCommand.from_input(tick, Vector2.ZERO, yaw, pitch, PlayerCommand.BUTTON_JUMP if tick > wait else 0)
|
||||
if me.drop_state != Drop.NONE:
|
||||
return PlayerCommand.from_input(tick, Vector2(0.0, 1.0), yaw, 0.0)
|
||||
var phase: int = (tick + number * 11) % (6 * TICKS)
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
## A gamepad works alongside them, in PadInput's fixed layout (A13), with AimAssist
|
||||
## on its right stick when the setting is on.
|
||||
##
|
||||
## With `autoplay` on, a simple script plays instead: it leaps from the barge over
|
||||
## land, glides, and walks about. That is for tests and for checking a connection with
|
||||
## With `autoplay` on, a simple script plays instead: it fires itself off the ship
|
||||
## towards the middle of the island, glides, and walks about. That is for tests and for checking a connection with
|
||||
## nobody at the keyboard.
|
||||
class_name ClientInput
|
||||
extends RefCounted
|
||||
@@ -172,8 +172,11 @@ func autoplay_command(tick: int, me: SimEntity, ground: SimGround) -> PlayerComm
|
||||
move = Vector2.ZERO
|
||||
buttons = 0
|
||||
if me.drop_state == Drop.ABOARD:
|
||||
# Over dry land, with a moment to look about first.
|
||||
if tick > 3 * Tuning.TICK_RATE_HZ and ground.terrain_height(me.position.x, me.position.z) > Tuning.ISLAND_BEACH_TOP + 2.0:
|
||||
# With a moment to look about first, fire the mortar most of the way to the
|
||||
# middle of the island.
|
||||
if tick > 3 * Tuning.TICK_RATE_HZ:
|
||||
var gap: float = Vector2(centre - me.position.x, centre - me.position.z).length()
|
||||
pitch = Drop.pitch_for_charge(Drop.aim_charge(gap * 0.7))
|
||||
buttons = PlayerCommand.BUTTON_JUMP
|
||||
elif me.drop_state != Drop.NONE:
|
||||
move = Vector2(0.0, 1.0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Draws what moves in a match: players with what they hold, the sky barge while it
|
||||
## Draws what moves in a match: players with what they hold, the packet ship while it
|
||||
## crosses, items lying in the world, thrown kegs and sea chests. `sync()` matches everything to the
|
||||
## simulation as it is now, and `animate()` steps the players' figures.
|
||||
##
|
||||
@@ -6,8 +6,9 @@
|
||||
## simulation replicates about them, with shots, swings and building played from FX
|
||||
## records through hear(). Held and lying items are the models of A4 (ItemModels): a
|
||||
## held one sits with its grip in the figure's right hand and points where its player
|
||||
## looks. The barge and the sea chests are VesselModels, generated in code. Nothing
|
||||
## here is ever used for collision.
|
||||
## looks. The ship and the sea chests are VesselModels, generated in code. The ship's
|
||||
## lifeline mortar faces the island, and a player it has just fired trails a line from
|
||||
## its muzzle until the arc tops out. Nothing here is ever used for collision.
|
||||
class_name EntityView
|
||||
extends Node3D
|
||||
|
||||
@@ -21,7 +22,7 @@ const SKIN: Color = Palette.SKIN
|
||||
## shows darker, its paint dulled.
|
||||
const CHEST_SHUT: Color = Color.WHITE
|
||||
const CHEST_OPEN: Color = Palette.OPENED_DULL
|
||||
## How far apart passengers stand on the barge's deck, in metres. The simulation
|
||||
## How far apart passengers stand on the ship's deck, in metres. The simulation
|
||||
## carries them all at one point; this only spreads them out to be seen.
|
||||
const DECK_SPACING: float = 1.3
|
||||
const DECK_ROWS: int = 4
|
||||
@@ -30,16 +31,19 @@ const PICKUP_SCALE: float = 1.4
|
||||
|
||||
## The entity drawn in the brightest oilskin, or 0.
|
||||
var local_id: int = 0
|
||||
## Where to draw the barge, when its owner knows better than the simulation's tick: a
|
||||
## Where to draw the ship, when its owner knows better than the simulation's tick: a
|
||||
## network client, which draws between ticks. Vector3.INF leaves it to the tick.
|
||||
var barge_at: Vector3 = Vector3.INF
|
||||
var ship_at: Vector3 = Vector3.INF
|
||||
|
||||
var _sim: Simulation
|
||||
## Entity ID -> its FigureRig.
|
||||
var _figures: Dictionary = {}
|
||||
## Whether _process steps the figures. Captures that pose figures exactly turn it off.
|
||||
var animate_live: bool = true
|
||||
var _barge: Node3D
|
||||
var _ship: Node3D
|
||||
## One line from the mortar to each player still climbing the arc, reused.
|
||||
var _lifelines: Array[MeshInstance3D] = []
|
||||
var _lifeline_mesh: ArrayMesh
|
||||
## Items lying in the world: one MultiMeshInstance3D per item model and tier.
|
||||
var _pickups: Node3D
|
||||
var _pickup_fields: Dictionary = {}
|
||||
@@ -48,9 +52,9 @@ var _chests: MultiMeshInstance3D
|
||||
|
||||
func setup(sim: Simulation) -> void:
|
||||
_sim = sim
|
||||
_barge = _build_barge()
|
||||
_barge.visible = false
|
||||
add_child(_barge)
|
||||
_ship = _build_ship()
|
||||
_ship.visible = false
|
||||
add_child(_ship)
|
||||
_pickups = Node3D.new()
|
||||
_pickups.name = "Pickups"
|
||||
add_child(_pickups)
|
||||
@@ -68,8 +72,8 @@ func figure_of(entity_id: int) -> FigureRig:
|
||||
return _figures.get(entity_id)
|
||||
|
||||
|
||||
func barge() -> Node3D:
|
||||
return _barge
|
||||
func ship() -> Node3D:
|
||||
return _ship
|
||||
|
||||
|
||||
## Items drawn lying in the world.
|
||||
@@ -106,10 +110,15 @@ func sync() -> void:
|
||||
if drop != null:
|
||||
var along: Vector3 = drop.finish - drop.start
|
||||
heading = atan2(along.x, along.z)
|
||||
_barge.visible = crossing
|
||||
_ship.visible = crossing
|
||||
if crossing:
|
||||
_barge.position = barge_at if barge_at != Vector3.INF else drop.barge_position(_sim.tick)
|
||||
_barge.rotation.y = heading
|
||||
_ship.position = ship_at if ship_at != Vector3.INF else drop.ship_position(_sim.tick)
|
||||
_ship.rotation.y = heading
|
||||
# The model's mortar faces its +x: mirror it if the island lies the other way.
|
||||
var starboard: Vector2 = Vector2(cos(heading), -sin(heading))
|
||||
var centre: Vector2 = Vector2.ONE * Tuning.WORLD_SIZE_METRES * 0.5
|
||||
_ship.scale.x = 1.0 if (centre - Vector2(drop.start.x, drop.start.z)).dot(starboard) >= 0.0 else -1.0
|
||||
var lines: int = 0
|
||||
|
||||
var seen: Dictionary = {}
|
||||
var aboard: int = 0
|
||||
@@ -133,7 +142,12 @@ func sync() -> void:
|
||||
figure.position += offset.rotated(Vector3.UP, heading)
|
||||
figure.rotation.y = heading
|
||||
aboard += 1
|
||||
elif crossing and entity.drop_state == Drop.FREEFALL and entity.velocity.y > 0.0 and not entity.eliminated:
|
||||
_draw_lifeline(lines, _ship.transform * VesselModels.muzzle(), entity.position + Vector3(0.0, 1.0, 0.0))
|
||||
lines += 1
|
||||
_hold(figure, entity)
|
||||
for index: int in range(lines, _lifelines.size()):
|
||||
_lifelines[index].visible = false
|
||||
for entity_id: int in _figures.keys():
|
||||
if not seen.has(entity_id):
|
||||
_figures[entity_id].queue_free()
|
||||
@@ -176,7 +190,7 @@ func hear(records: Array[Dictionary]) -> void:
|
||||
|
||||
|
||||
## Puts the held item's model in the figure's hand; the figure points it where the
|
||||
## player looks. Nothing is held aboard the barge, falling, gliding, swimming or down.
|
||||
## player looks. Nothing is held aboard the ship, falling, gliding, swimming or down.
|
||||
func _hold(figure: FigureRig, entity: SimEntity) -> void:
|
||||
var busy: bool = entity.drop_state != Drop.NONE or entity.swimming or entity.eliminated or entity.downed
|
||||
figure.hand().visible = not busy
|
||||
@@ -248,6 +262,35 @@ func _item_field(key: String) -> MultiMeshInstance3D:
|
||||
return field
|
||||
|
||||
|
||||
## Shows lifeline `index` from `from` to `to`, making it if there aren't enough yet.
|
||||
func _draw_lifeline(index: int, from: Vector3, to: Vector3) -> void:
|
||||
if _lifeline_mesh == null:
|
||||
_lifeline_mesh = VesselModels.lifeline()
|
||||
while _lifelines.size() <= index:
|
||||
var line: MeshInstance3D = MeshInstance3D.new()
|
||||
line.name = "Lifeline%d" % _lifelines.size()
|
||||
line.mesh = _lifeline_mesh
|
||||
line.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(line)
|
||||
_lifelines.append(line)
|
||||
var line: MeshInstance3D = _lifelines[index]
|
||||
var length: float = from.distance_to(to)
|
||||
line.visible = length > 0.5
|
||||
if not line.visible:
|
||||
return
|
||||
var up: Vector3 = Vector3.UP if absf((to - from).normalized().y) < 0.99 else Vector3.RIGHT
|
||||
line.transform = Transform3D(Basis.looking_at(to - from, up) * Basis.from_scale(Vector3(1.0, 1.0, length)), (from + to) * 0.5)
|
||||
|
||||
|
||||
## Lifelines drawn now, for tests.
|
||||
func lifeline_count() -> int:
|
||||
var count: int = 0
|
||||
for line: MeshInstance3D in _lifelines:
|
||||
if line.visible:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
func _build_figure(entity_id: int) -> FigureRig:
|
||||
var coat: Color = OILSKINS[0] if entity_id == local_id else OILSKINS[1 + entity_id % (OILSKINS.size() - 1)]
|
||||
var figure: FigureRig = FigureRig.new(coat)
|
||||
@@ -255,13 +298,13 @@ func _build_figure(entity_id: int) -> FigureRig:
|
||||
return figure
|
||||
|
||||
|
||||
## The barge (VesselModels): a hull hung under a canvas envelope. Its deck is at the
|
||||
## origin, where the simulation carries the passengers.
|
||||
func _build_barge() -> Node3D:
|
||||
var barge: MeshInstance3D = MeshInstance3D.new()
|
||||
barge.name = "Barge"
|
||||
barge.mesh = VesselModels.barge()
|
||||
return barge
|
||||
## The packet ship (VesselModels). Its deck is at the origin, where the simulation
|
||||
## carries the passengers.
|
||||
func _build_ship() -> Node3D:
|
||||
var ship: MeshInstance3D = MeshInstance3D.new()
|
||||
ship.name = "Ship"
|
||||
ship.mesh = VesselModels.ship()
|
||||
return ship
|
||||
|
||||
|
||||
func _chest_field() -> MultiMeshInstance3D:
|
||||
|
||||
@@ -188,7 +188,7 @@ static func _clips() -> Dictionary:
|
||||
[0.4, over(air, {"shoulder_r": Vector3(-20, 0, -46), "shoulder_l": Vector3(-20, 0, 46)})],
|
||||
]]
|
||||
|
||||
# Falling from the barge, belly down, spread out.
|
||||
# Climbing the mortar's arc and falling from it, belly down, spread out.
|
||||
var skydive: Dictionary = {
|
||||
"hips": Vector3(72, 0, 0), "waist": Vector3(6, 0, 0), "neck": Vector3(-55, 0, 0),
|
||||
"shoulder_r": Vector3(-70, 0, -70), "shoulder_l": Vector3(-70, 0, 70),
|
||||
@@ -201,7 +201,7 @@ static func _clips() -> Dictionary:
|
||||
[0.5, over(skydive, {"shoulder_r": Vector3(-74, 0, -64), "shoulder_l": Vector3(-74, 0, 64), "knee_r": Vector3(48, 0, 0), "knee_l": Vector3(34, 0, 0)})],
|
||||
]]
|
||||
|
||||
# Hanging under the wing-sail, both hands up on its lines.
|
||||
# Hanging under the gull-kite, both hands up on its lines.
|
||||
var glide: Dictionary = {
|
||||
"hips": Vector3(12, 0, 0), "waist": Vector3(-4, 0, 0), "neck": Vector3(10, 0, 0),
|
||||
"shoulder_r": Vector3(-158, 0, -16), "shoulder_l": Vector3(-158, 0, 16),
|
||||
|
||||
@@ -36,7 +36,7 @@ const ANIMATED: Array[String] = [
|
||||
const PARENT: Dictionary = {
|
||||
"hips": "", "waist": "hips", "spine": "waist", "neck": "spine",
|
||||
"shoulder_r": "spine", "elbow_r": "shoulder_r", "shoulder_l": "spine", "elbow_l": "shoulder_l",
|
||||
"hip_r": "hips", "knee_r": "hip_r", "hip_l": "hips", "knee_l": "hip_l", "sail": "",
|
||||
"hip_r": "hips", "knee_r": "hip_r", "hip_l": "hips", "knee_l": "hip_l", "kite": "",
|
||||
}
|
||||
## Part model -> the joint pivot it hangs on.
|
||||
const PART_JOINT: Dictionary = {
|
||||
@@ -44,7 +44,7 @@ const PART_JOINT: Dictionary = {
|
||||
"upper_arm_r": "shoulder_r", "forearm_r": "elbow_r",
|
||||
"upper_arm_l": "shoulder_l", "forearm_l": "elbow_l",
|
||||
"thigh_r": "hip_r", "shin_r": "knee_r", "thigh_l": "hip_l", "shin_l": "knee_l",
|
||||
"sail": "sail",
|
||||
"kite": "kite",
|
||||
}
|
||||
## Material names in the part models -> Palette colours. COAT and COAT_DARK are the
|
||||
## player's own oilskin.
|
||||
@@ -52,6 +52,7 @@ const COLOURS: Dictionary = {
|
||||
"TAR": Palette.TAR, "TAR_WEATHERED": Palette.TAR_WEATHERED, "SKIN": Palette.SKIN,
|
||||
"INK": Palette.INK, "BARK": Palette.BARK, "CANVAS": Palette.CANVAS, "GILT": Palette.GILT,
|
||||
"PLANK": Palette.PLANK, "OCHRE_RED": Palette.OCHRE_RED, "TANNED_SAIL": Palette.TANNED_SAIL,
|
||||
"SALT": Palette.SALT,
|
||||
}
|
||||
const COAT_SHADE: float = 0.28
|
||||
## The states of `move`, in input order.
|
||||
@@ -88,7 +89,7 @@ var speed: float = 0.0
|
||||
|
||||
var _hand: Node3D
|
||||
var _held: MeshInstance3D
|
||||
var _sail: Node3D
|
||||
var _kite: Node3D
|
||||
var _pitch: float = 0.0
|
||||
var _holding: bool = true
|
||||
var _airborne: float = 0.0
|
||||
@@ -124,8 +125,8 @@ func _init(coat_colour: Color = Palette.OILSKIN) -> void:
|
||||
instance.name = part
|
||||
instance.mesh = mesh
|
||||
(joints[PART_JOINT[part]] as Node3D).add_child(instance)
|
||||
_sail = joints["sail"]
|
||||
_sail.visible = false
|
||||
_kite = joints["kite"]
|
||||
_kite.visible = false
|
||||
_hand = Node3D.new()
|
||||
_hand.name = "hand_r"
|
||||
_hand.position = _vector(layout.get("hand_r", [-0.24, 0.86, 0.03])) - _vector(at.get("elbow_r", [0, 0, 0]))
|
||||
@@ -163,7 +164,7 @@ static func part_mesh(part: String, coat_colour: Color) -> ArrayMesh:
|
||||
|
||||
## H1: one surface per finish instead of one per colour, with each Palette colour
|
||||
## carried as a vertex colour. The model's surfaces are separate draw calls in every
|
||||
## pass, and 24 figures crowded on the barge passed the draw-call budget; merged, a
|
||||
## pass, and 24 figures crowded on the ship passed the draw-call budget; merged, a
|
||||
## figure costs a third of the draws and looks the same. Each surface is named after
|
||||
## its finish: FINISH_COAT, FINISH_GILT or FINISH_PLAIN.
|
||||
static func _merged(source: Mesh, coat_colour: Color) -> ArrayMesh:
|
||||
@@ -256,8 +257,8 @@ func held() -> MeshInstance3D:
|
||||
return _held
|
||||
|
||||
|
||||
func sail() -> Node3D:
|
||||
return _sail
|
||||
func kite() -> Node3D:
|
||||
return _kite
|
||||
|
||||
|
||||
## Sets the tree from an entity's replicated state. `delta` is the time since the last
|
||||
@@ -283,7 +284,7 @@ func drive(entity: SimEntity, delta: float) -> void:
|
||||
flinch()
|
||||
_last_health = entity.health
|
||||
_pitch = float(entity.pitch) / PlayerCommand.PITCH_MAX * (PI * 0.5)
|
||||
_sail.visible = state == "glide"
|
||||
_kite.visible = state == "glide"
|
||||
_hand.visible = _holding
|
||||
tree.set("parameters/move/transition_request", state)
|
||||
tree.set("parameters/ground/blend_position", speed)
|
||||
|
||||
@@ -1,31 +1,42 @@
|
||||
## Generated meshes for the drop barge and the sea chests, built in code from Palette
|
||||
## Generated meshes for the packet ship and the sea chests, built in code from Palette
|
||||
## colours (no imported art):
|
||||
##
|
||||
## - the barge: a tarred, lofted hull with a sheer and pointed ends, a planked deck,
|
||||
## rails, mooring lines, and a gored canvas envelope with tanned stripes and an ochre
|
||||
## band, in the folk-art manner of docs/STYLE.md. Its deck top is at the origin, where
|
||||
## the simulation carries the passengers; it points along +z;
|
||||
## - the packet ship (#72): a tarred, lofted hull with a sheer, an ochre rubbing strake
|
||||
## and a salt-white boot-top at the waterline, a planked deck, rails, two masts with
|
||||
## tanned square sails on yards, a bowsprit, shrouds, and the lifeline mortar on its
|
||||
## timber bed, in the folk-art manner of docs/STYLE.md. Its deck top is at the origin,
|
||||
## where the simulation carries the passengers, and the waterline SHIP_DECK_HEIGHT
|
||||
## below it; it points along +z, and the mortar faces +x;
|
||||
## - a sea chest: a painted box with a lid, tarred iron bands, a salt-white border and a
|
||||
## gilt hasp, its base at the origin.
|
||||
class_name VesselModels
|
||||
extends RefCounted
|
||||
|
||||
## Hull half-length, half-breadth at the deck, and depth amidships, in metres.
|
||||
const HULL_HALF_LENGTH: float = 5.5
|
||||
const HULL_HALF_BREADTH: float = 3.4
|
||||
const HULL_DEPTH: float = 1.6
|
||||
## Envelope centre height above the deck and its semi-axes (x, y, z), in metres.
|
||||
const ENVELOPE_HEIGHT: float = 10.5
|
||||
const ENVELOPE_AXES: Vector3 = Vector3(5.2, 3.8, 9.0)
|
||||
const ENVELOPE_RINGS: int = 14
|
||||
const ENVELOPE_SIDES: int = 20
|
||||
## Hull half-length, half-breadth at the deck, and depth amidships, in metres. The keel
|
||||
## sits HULL_DEPTH under the deck, below the waterline.
|
||||
const HULL_HALF_LENGTH: float = 12.0
|
||||
const HULL_HALF_BREADTH: float = 3.8
|
||||
const HULL_DEPTH: float = Tuning.SHIP_DECK_HEIGHT + 1.8
|
||||
## Masts: where along the deck (z), and how tall above it.
|
||||
const MASTS: Array[Vector2] = [Vector2(6.6, 17.0), Vector2(-5.8, 14.5)]
|
||||
## Where the mortar stands on the deck: forward of the passengers, aft of the foremast,
|
||||
## pointing out to +x.
|
||||
const MORTAR_AT: Vector3 = Vector3(1.4, 0.0, 4.7)
|
||||
|
||||
## The mortar's barrel: its breech above MORTAR_AT, the way it points, and its length.
|
||||
const MORTAR_BREECH: Vector3 = Vector3(-0.15, 0.55, 0.0)
|
||||
const MORTAR_AIM: Vector3 = Vector3(0.62, 0.78, 0.0)
|
||||
const MORTAR_LENGTH: float = 1.25
|
||||
|
||||
## The lifeline cord's thickness, in metres.
|
||||
const LIFELINE_WIDTH: float = 0.07
|
||||
|
||||
## Chest size (x, y, z), in metres; its lid is the top LID share of its height.
|
||||
const CHEST_SIZE: Vector3 = Vector3(0.9, 0.55, 0.6)
|
||||
const LID: float = 0.3
|
||||
|
||||
|
||||
static func barge() -> ArrayMesh:
|
||||
static func ship() -> ArrayMesh:
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
tool.set_smooth_group(-1)
|
||||
@@ -43,30 +54,117 @@ static func barge() -> ArrayMesh:
|
||||
x += 0.32
|
||||
index += 1
|
||||
# Rails follow the sheer on stanchions at every station.
|
||||
var rail: Vector3 = Vector3(0.0, 0.65, 0.0)
|
||||
for side: int in [0, 4]:
|
||||
var rail: Vector3 = Vector3(0.0, 0.8, 0.0)
|
||||
for side: int in [0, 6]:
|
||||
var inward: Vector3 = Vector3(0.12 if side == 0 else -0.12, 0.0, 0.0)
|
||||
for station: int in rings.size():
|
||||
var at: Vector3 = rings[station][side] + inward
|
||||
_line(tool, at, at + rail, 0.1, Palette.TAR)
|
||||
if station + 1 < rings.size():
|
||||
_line(tool, at + rail, rings[station + 1][side] + inward + rail, 0.1, Palette.TAR)
|
||||
for side: float in [-1.0, 1.0]:
|
||||
# Mooring lines from the rail to the envelope's belly.
|
||||
for end: float in [-1.0, 1.0]:
|
||||
var foot: Vector3 = Vector3(side * (HULL_HALF_BREADTH - 0.35), 0.6, end * 3.6)
|
||||
var hx: float = 0.55
|
||||
var hz: float = 0.5
|
||||
var under: float = ENVELOPE_AXES.y * sqrt(1.0 - hx * hx - hz * hz)
|
||||
var head: Vector3 = Vector3(side * ENVELOPE_AXES.x * hx, ENVELOPE_HEIGHT - under + 0.15, end * ENVELOPE_AXES.z * hz)
|
||||
_line(tool, foot, head, 0.05, Palette.PLANK.darkened(0.3))
|
||||
_envelope(tool)
|
||||
# Bowsprit, raking up from the bow.
|
||||
var bow: Vector3 = Vector3(0.0, _sheer(1.0) + 0.3, HULL_HALF_LENGTH - 0.4)
|
||||
var sprit_end: Vector3 = bow + Vector3(0.0, 2.4, 6.0)
|
||||
_line(tool, bow, sprit_end, 0.28, Palette.PLANK.darkened(0.15))
|
||||
for mast: Vector2 in MASTS:
|
||||
_mast(tool, mast.x, mast.y, sprit_end if mast == MASTS[0] else Vector3.INF)
|
||||
_mortar(tool)
|
||||
tool.generate_normals()
|
||||
var mesh: ArrayMesh = tool.commit()
|
||||
mesh.surface_set_material(0, _material(0.85))
|
||||
return mesh
|
||||
|
||||
|
||||
## Height of the sheer at `t`, from -1 (stern) to 1 (bow).
|
||||
static func _sheer(t: float) -> float:
|
||||
return 0.9 * t * t
|
||||
|
||||
|
||||
## A mast at `z` rising `height` above the deck: a tarred pole, two yards with tanned
|
||||
## square sails between them, an ochre band on the lower sail, and shrouds to the rails.
|
||||
## A forestay runs to `stay_to` unless it is Vector3.INF.
|
||||
static func _mast(tool: SurfaceTool, z: float, height: float, stay_to: Vector3) -> void:
|
||||
var foot: Vector3 = Vector3(0.0, 0.0, z)
|
||||
var top: Vector3 = Vector3(0.0, height, z)
|
||||
_line(tool, foot, top, 0.36, Palette.PLANK.darkened(0.25))
|
||||
var yards: Array[float] = [height * 0.36, height * 0.66, height * 0.92]
|
||||
var spans: Array[float] = [4.6, 3.8, 2.8]
|
||||
for level: int in yards.size():
|
||||
var y: float = yards[level]
|
||||
var half: float = spans[level]
|
||||
_line(tool, Vector3(-half, y, z + 0.3), Vector3(half, y, z + 0.3), 0.2, Palette.TAR)
|
||||
for level: int in 2:
|
||||
var y_top: float = yards[level + 1]
|
||||
var y_foot: float = yards[level] + 0.25
|
||||
var half_top: float = spans[level + 1]
|
||||
var half_foot: float = spans[level]
|
||||
# The sail bellies forward in the middle: three panels across, the middle one
|
||||
# further out.
|
||||
var columns: int = 4
|
||||
for column: int in columns:
|
||||
var u0: float = float(column) / columns * 2.0 - 1.0
|
||||
var u1: float = float(column + 1) / columns * 2.0 - 1.0
|
||||
var belly0: float = 0.55 + 0.9 * (1.0 - u0 * u0)
|
||||
var belly1: float = 0.55 + 0.9 * (1.0 - u1 * u1)
|
||||
var colour: Color = Palette.TANNED_SAIL if column % 2 == 0 else Palette.TANNED_SAIL.lightened(0.08)
|
||||
_quad(tool,
|
||||
Vector3(u0 * half_top, y_top, z + 0.45), Vector3(u1 * half_top, y_top, z + 0.45),
|
||||
Vector3(u1 * half_foot, y_foot, z + belly1), Vector3(u0 * half_foot, y_foot, z + belly0), colour)
|
||||
if level == 0:
|
||||
# An ochre band across the lower sail, a little above its foot.
|
||||
var yb: float = lerpf(y_foot, y_top, 0.2)
|
||||
var yb2: float = lerpf(y_foot, y_top, 0.3)
|
||||
var hb: float = lerpf(half_foot, half_top, 0.2)
|
||||
var hb2: float = lerpf(half_foot, half_top, 0.3)
|
||||
_quad(tool, Vector3(-hb2, yb2, z + 1.42), Vector3(hb2, yb2, z + 1.42), Vector3(hb, yb, z + 1.47), Vector3(-hb, yb, z + 1.47), Palette.OCHRE_RED)
|
||||
# Shrouds from the top of the lower sail to each rail.
|
||||
for side: float in [-1.0, 1.0]:
|
||||
for step: float in [-0.8, 0.0, 0.8]:
|
||||
_line(tool, Vector3(side * (HULL_HALF_BREADTH - 0.3), 0.7, z + step - 0.6), Vector3(0.0, yards[1], z), 0.05, Palette.TAR)
|
||||
if stay_to != Vector3.INF:
|
||||
_line(tool, top, stay_to, 0.06, Palette.TAR)
|
||||
|
||||
|
||||
## The lifeline mortar: a squat tarred barrel with gilt bands on a timber bed, cocked up
|
||||
## towards +x, and a coil of line beside it.
|
||||
static func _mortar(tool: SurfaceTool) -> void:
|
||||
var at: Vector3 = MORTAR_AT
|
||||
PieceMesher.add_box(tool, AABB(at + Vector3(-0.8, 0.0, -0.7), Vector3(1.6, 0.45, 1.4)), Palette.PLANK.darkened(0.2))
|
||||
var breech: Vector3 = at + MORTAR_BREECH
|
||||
var aim: Vector3 = MORTAR_AIM.normalized()
|
||||
_line(tool, breech, breech + aim * MORTAR_LENGTH, 0.72, Palette.TAR)
|
||||
for band: float in [0.25, 0.95]:
|
||||
_line(tool, breech + aim * band, breech + aim * (band + 0.12), 0.8, Palette.GILT)
|
||||
# A coil of line on the deck behind it, as a ring of short segments.
|
||||
var coil: Vector3 = at + Vector3(-1.6, 0.18, 0.9)
|
||||
for turn: int in 3:
|
||||
var radius: float = 0.55 - turn * 0.1
|
||||
var segments: int = 10
|
||||
for segment: int in segments:
|
||||
var a0: float = TAU * segment / segments
|
||||
var a1: float = TAU * (segment + 1) / segments
|
||||
var p0: Vector3 = coil + Vector3(cos(a0) * radius, turn * 0.07, sin(a0) * radius)
|
||||
var p1: Vector3 = coil + Vector3(cos(a1) * radius, turn * 0.07, sin(a1) * radius)
|
||||
_line(tool, p0, p1, 0.09, Palette.CANVAS.darkened(0.15))
|
||||
|
||||
|
||||
## The middle of the mortar's muzzle, in the ship model's own space.
|
||||
static func muzzle() -> Vector3:
|
||||
return MORTAR_AT + MORTAR_BREECH + MORTAR_AIM.normalized() * MORTAR_LENGTH
|
||||
|
||||
|
||||
## A length of lifeline: a square cord LIFELINE_WIDTH thick and one metre long along
|
||||
## -z, centred on the origin, for EntityView to stretch between the mortar and a player.
|
||||
static func lifeline() -> ArrayMesh:
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
_line(tool, Vector3(0.0, 0.0, 0.5), Vector3(0.0, 0.0, -0.5), LIFELINE_WIDTH, Palette.CANVAS.darkened(0.15))
|
||||
tool.generate_normals()
|
||||
var mesh: ArrayMesh = tool.commit()
|
||||
mesh.surface_set_material(0, _material(0.9))
|
||||
return mesh
|
||||
|
||||
|
||||
static func chest() -> ArrayMesh:
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
@@ -89,65 +187,56 @@ static func chest() -> ArrayMesh:
|
||||
return mesh
|
||||
|
||||
|
||||
## The hull as rings of five points (rail, bilge, keel, bilge, rail) along z. Returns
|
||||
## the rings, for the rails.
|
||||
## The hull as rings of seven points along z: rail, boot-top, waterline, keel and back
|
||||
## up the other side (indices 0 to 6), with the deck at y = 0 and the sea at
|
||||
## -SHIP_DECK_HEIGHT. Returns the rings, for the rails.
|
||||
static func _hull(tool: SurfaceTool) -> Array[PackedVector3Array]:
|
||||
var stations: int = 12
|
||||
var stations: int = 16
|
||||
var water: float = -Tuning.SHIP_DECK_HEIGHT
|
||||
var rings: Array[PackedVector3Array] = []
|
||||
for station: int in stations + 1:
|
||||
var t: float = float(station) / stations * 2.0 - 1.0
|
||||
var z: float = t * HULL_HALF_LENGTH
|
||||
var breadth: float = HULL_HALF_BREADTH * sqrt(maxf(1.0 - pow(absf(t), 4.0), 0.015))
|
||||
var keel: float = -HULL_DEPTH * (1.0 - 0.55 * pow(absf(t), 3.0))
|
||||
var sheer: float = 0.25 * t * t
|
||||
var breadth: float = HULL_HALF_BREADTH * sqrt(maxf(1.0 - pow(absf(t), 3.0), 0.01))
|
||||
var keel: float = -HULL_DEPTH * (1.0 - 0.3 * pow(absf(t), 3.0))
|
||||
var sheer: float = _sheer(t)
|
||||
var ring: PackedVector3Array = PackedVector3Array([
|
||||
Vector3(-breadth, sheer, z), Vector3(-breadth * 0.8, keel * 0.6, z), Vector3(0.0, keel, z),
|
||||
Vector3(breadth * 0.8, keel * 0.6, z), Vector3(breadth, sheer, z),
|
||||
Vector3(-breadth, sheer, z),
|
||||
Vector3(-breadth * 0.97, water + 0.6, z),
|
||||
Vector3(-breadth * 0.93, water, z),
|
||||
Vector3(0.0, keel, z),
|
||||
Vector3(breadth * 0.93, water, z),
|
||||
Vector3(breadth * 0.97, water + 0.6, z),
|
||||
Vector3(breadth, sheer, z),
|
||||
])
|
||||
rings.append(ring)
|
||||
for station: int in stations:
|
||||
for side: int in 4:
|
||||
var colour: Color = Palette.TAR if side == 1 or side == 2 else Palette.TAR_WEATHERED
|
||||
# A painted strake under the rail, every other station a shade lighter.
|
||||
if side == 0 or side == 3:
|
||||
for side: int in 6:
|
||||
var colour: Color = Palette.TAR_WEATHERED
|
||||
if side == 1 or side == 4:
|
||||
colour = Palette.SALT
|
||||
elif side == 2 or side == 3:
|
||||
colour = Palette.TAR
|
||||
else:
|
||||
# The topsides, a painted strake every other station a shade lighter.
|
||||
colour = PieceMesher.tint(colour, station * 7 + side)
|
||||
_quad(tool, rings[station][side], rings[station][side + 1], rings[station + 1][side + 1], rings[station + 1][side], colour)
|
||||
# Transom and stem: close the ends.
|
||||
for end: int in [0, stations]:
|
||||
var ring: PackedVector3Array = rings[end]
|
||||
for side: int in 3:
|
||||
_quad(tool, ring[side], ring[side + 1], ring[5 - side], ring[6 - side], Palette.TAR)
|
||||
# Rubbing strake: an ochre band along the top of the hull.
|
||||
for station: int in stations:
|
||||
for side: int in [0, 4]:
|
||||
for side: int in [0, 6]:
|
||||
var a: Vector3 = rings[station][side]
|
||||
var b: Vector3 = rings[station + 1][side]
|
||||
var out: float = 0.04 * signf(a.x) if absf(a.x) > 0.01 else 0.0
|
||||
var drop: Vector3 = Vector3(0.0, -0.22, 0.0)
|
||||
_quad(tool, a + Vector3(out, 0.0, 0.0), b + Vector3(out, 0.0, 0.0), b + drop + Vector3(out, 0.0, 0.0), a + drop + Vector3(out, 0.0, 0.0), Palette.OCHRE_RED)
|
||||
var out: Vector3 = Vector3(0.04 * signf(a.x), 0.0, 0.0)
|
||||
var drop: Vector3 = Vector3(0.0, -0.3, 0.0)
|
||||
_quad(tool, a + out, b + out, b + drop + out, a + drop + out, Palette.OCHRE_RED)
|
||||
return rings
|
||||
|
||||
|
||||
## The envelope: an ellipsoid of gores along z, alternately canvas and tanned, with an
|
||||
## ochre band round its middle.
|
||||
static func _envelope(tool: SurfaceTool) -> void:
|
||||
var centre: Vector3 = Vector3(0.0, ENVELOPE_HEIGHT, 0.0)
|
||||
var rings: Array[PackedVector3Array] = []
|
||||
for ring: int in ENVELOPE_RINGS + 1:
|
||||
var phi: float = PI * float(ring) / ENVELOPE_RINGS
|
||||
var z: float = -cos(phi) * ENVELOPE_AXES.z
|
||||
var r: float = sin(phi)
|
||||
var points: PackedVector3Array = PackedVector3Array()
|
||||
for side: int in ENVELOPE_SIDES + 1:
|
||||
var theta: float = TAU * float(side) / ENVELOPE_SIDES
|
||||
points.append(centre + Vector3(cos(theta) * r * ENVELOPE_AXES.x, sin(theta) * r * ENVELOPE_AXES.y, z))
|
||||
rings.append(points)
|
||||
var middle: int = ENVELOPE_RINGS / 2
|
||||
tool.set_smooth_group(1)
|
||||
for ring: int in ENVELOPE_RINGS:
|
||||
for side: int in ENVELOPE_SIDES:
|
||||
var colour: Color = Palette.CANVAS if (side / 2) % 2 == 0 else Palette.TANNED_SAIL.lightened(0.15)
|
||||
if ring == middle or ring == middle - 1:
|
||||
colour = Palette.OCHRE_RED
|
||||
_quad(tool, rings[ring][side], rings[ring][side + 1], rings[ring + 1][side + 1], rings[ring + 1][side], colour)
|
||||
tool.set_smooth_group(-1)
|
||||
|
||||
|
||||
## A square line `width` thick from `a` to `b`.
|
||||
static func _line(tool: SurfaceTool, a: Vector3, b: Vector3, width: float, colour: Color) -> void:
|
||||
var along: Vector3 = (b - a).normalized()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## The island as a hand-drawn nautical chart (A11): paper land with ink contours every
|
||||
## CONTOUR_METRES, a heavier coastline, the sea in the sea's ink, place names, the
|
||||
## barge's route, the player's own mark, and the tide forecast: land the coming tide
|
||||
## ship's route, the player's own mark, and the tide forecast: land the coming tide
|
||||
## will flood is hatched, and land the sea has already taken is washed with the sea.
|
||||
##
|
||||
## The forecast comes from the client's own Flood (Flood.forecast), the same spreading
|
||||
@@ -28,7 +28,7 @@ var mode: Mode = Mode.FULL
|
||||
var world: Simulation = null
|
||||
## Place names and where they are, in world metres (x, z).
|
||||
var places: Array[Dictionary] = []
|
||||
## The barge's route ends, in world metres (x, z), or empty when there's no drop.
|
||||
## The ship's route ends, in world metres (x, z), or empty when there's no drop.
|
||||
var route: PackedVector2Array = PackedVector2Array()
|
||||
## The player: position (x, z) in metres, facing (radians, the simulation's yaw), and
|
||||
## whether to draw them.
|
||||
@@ -54,7 +54,7 @@ func _init(chart_mode: Mode = Mode.FULL) -> void:
|
||||
|
||||
|
||||
## Draws the chart of `simulation`'s island and names its places from `match_seed`.
|
||||
## `drop` is the match's barge route, or null. `share` is another ChartMap already set
|
||||
## `drop` is the match's ship route, or null. `share` is another ChartMap already set
|
||||
## up for the same world, whose paper and contours are used rather than drawn again.
|
||||
func setup(simulation: Simulation, match_seed: int, drop: Drop = null, share: ChartMap = null) -> void:
|
||||
world = simulation
|
||||
|
||||
@@ -122,7 +122,7 @@ func follow(entity_id: int, pitch: float = NAN, look_yaw: float = NAN) -> bool:
|
||||
return false
|
||||
var yaw: float = look_yaw if not is_nan(look_yaw) else float(player.yaw) / PlayerCommand.YAW_STEPS * TAU
|
||||
var look_pitch: float = pitch if not is_nan(pitch) else float(player.pitch) / PlayerCommand.PITCH_MAX * (PI * 0.5)
|
||||
# Where the figure is drawn: on the barge's deck that is its own place, not the
|
||||
# Where the figure is drawn: on the ship's deck that is its own place, not the
|
||||
# one point the simulation carries every passenger at.
|
||||
var feet: Vector3 = player.position
|
||||
var figure: Node3D = entities.figure_of(entity_id)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
## packets to receive() and sends whatever advance() leaves in `outbox`.
|
||||
##
|
||||
## The client generates the match's island itself from the seed in the MATCH notice
|
||||
## (`world`, a Simulation that is never stepped) and plans the same barge route, so it
|
||||
## (`world`, a Simulation that is never stepped) and plans the same ship route, so it
|
||||
## can run the same movement code as the server on the same ground. WORLD messages keep
|
||||
## that world's built pieces, props, chests and tide in line with the server's, and OWN
|
||||
## messages say what the player carries (`replica`, a ClientWorld). Pieces the player
|
||||
@@ -322,7 +322,7 @@ func _take_snapshot() -> void:
|
||||
_recent.clear()
|
||||
return
|
||||
if not prediction.active:
|
||||
# The barge's route is drawn from the seed alone, at the match's first tick.
|
||||
# The ship's route is drawn from the seed alone, at the match's first tick.
|
||||
prediction.begin(world.ground, Drop.plan(world.ground, SimRng.new(world_seed), 0))
|
||||
clock.start(receiver.sim_tick)
|
||||
clock.observe(receiver.sim_tick, receiver.command_tick)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
## pieces, props, chests and tide in line with the server. This adds the rest of the
|
||||
## picture, afresh every frame: every entity the server has told this client about,
|
||||
## where it is being drawn now (everyone else from the recent past, the client's own
|
||||
## player where it was predicted), the barge, the clock and the sea level. Nothing
|
||||
## player where it was predicted), the ship, the clock and the sea level. Nothing
|
||||
## here is authoritative, and nothing reads it back but views and the client's own
|
||||
## check before placing a piece.
|
||||
class_name ClientMirror
|
||||
@@ -16,8 +16,8 @@ extends RefCounted
|
||||
var watched_id: int = 0
|
||||
## The client's own player while it is in the match, or 0.
|
||||
var own_id: int = 0
|
||||
## Where the barge is being drawn, or Vector3.INF when it isn't crossing.
|
||||
var barge_at: Vector3 = Vector3.INF
|
||||
## Where the ship is being drawn, or Vector3.INF when it isn't crossing.
|
||||
var ship_at: Vector3 = Vector3.INF
|
||||
## The moment being drawn, in simulation ticks.
|
||||
var time: float = 0.0
|
||||
|
||||
@@ -35,7 +35,7 @@ func sync(game: ClientGame) -> void:
|
||||
var world: Simulation = game.world
|
||||
watched_id = 0
|
||||
own_id = 0
|
||||
barge_at = Vector3.INF
|
||||
ship_at = Vector3.INF
|
||||
if world == null:
|
||||
return
|
||||
var receiver: SnapshotReceiver = game.receiver
|
||||
@@ -60,7 +60,7 @@ func sync(game: ClientGame) -> void:
|
||||
_drop.finished = _drop.is_over(world.tick)
|
||||
world.drop = _drop
|
||||
if not _drop.finished:
|
||||
barge_at = _drop.barge_position(world.tick).lerp(_drop.barge_position(world.tick + 1), time - floorf(time))
|
||||
ship_at = _drop.ship_position(world.tick).lerp(_drop.ship_position(world.tick + 1), time - floorf(time))
|
||||
else:
|
||||
world.drop = null
|
||||
|
||||
@@ -154,8 +154,8 @@ func _show_player(entity: SimEntity, record: PackedInt32Array, shown: Dictionary
|
||||
entity.use_ticks = 1 if flags & NetSnapshot.FLAG_USING != 0 else 0
|
||||
# What is in the player's hands, for whoever draws it: the item's code, or -1.
|
||||
entity.item = record[NetSnapshot.R_HELD] - 1
|
||||
if entity.drop_state == Drop.ABOARD and barge_at != Vector3.INF:
|
||||
entity.position = barge_at
|
||||
if entity.drop_state == Drop.ABOARD and ship_at != Vector3.INF:
|
||||
entity.position = ship_at
|
||||
|
||||
|
||||
## The client's own player: where and how it was predicted, not where the server last
|
||||
@@ -172,5 +172,5 @@ func _show_own(entity: SimEntity, game: ClientGame) -> void:
|
||||
entity.velocity = me.velocity
|
||||
entity.reload_ticks = me.reload_ticks
|
||||
entity.use_ticks = me.use_ticks
|
||||
if me.drop_state == Drop.ABOARD and barge_at != Vector3.INF:
|
||||
entity.position = barge_at
|
||||
if me.drop_state == Drop.ABOARD and ship_at != Vector3.INF:
|
||||
entity.position = ship_at
|
||||
|
||||
@@ -157,7 +157,7 @@ func _run(tick: int) -> void:
|
||||
return
|
||||
_drop.ride(player, command, tick)
|
||||
if player.drop_state == Drop.ABOARD and _drop.is_over(tick + 1):
|
||||
_drop.leap(player, tick + 1)
|
||||
_drop.fire_at_end(player, tick + 1)
|
||||
return
|
||||
var water: float = _water_at(player.position)
|
||||
Movement.step(player, command, _ground, water)
|
||||
|
||||
@@ -47,7 +47,7 @@ func _init(match_seed: int, human_players: int, bot_count: int, rules: MatchRule
|
||||
for handle: int in range(1, human_players + 1):
|
||||
match_flow.join(handle)
|
||||
if rules.lobby_ticks == 0 and rules.countdown_ticks == 0:
|
||||
# Every match starts on the sky barge, on the first tick.
|
||||
# Every match starts on the packet ship, on the first tick.
|
||||
_advance()
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ extends RefCounted
|
||||
|
||||
enum Result {
|
||||
OK,
|
||||
## Dead, swimming, aboard the barge or falling.
|
||||
## Dead, swimming, aboard the ship or falling.
|
||||
NOT_ALLOWED,
|
||||
## Unknown piece kind or material.
|
||||
BAD_REQUEST,
|
||||
|
||||
+181
-45
@@ -1,78 +1,128 @@
|
||||
## The start of a match: a sky barge drifts across the island on a seeded straight route,
|
||||
## carrying every player. Each one leaps when they choose, falls, opens a wing-sail
|
||||
## (by hand, or automatically near the ground) and steers down. Anyone still aboard
|
||||
## when the barge reaches the end of its route is thrown off.
|
||||
## The start of a match (#72): a packet ship sails a seeded straight line past the
|
||||
## island, offshore, carrying every player. Each one fires themselves inland by lifeline
|
||||
## mortar when they choose: the look direction sets the heading, and how high they aim
|
||||
## sets the charge, so a level aim lands near the shore and an aim up high carries to
|
||||
## the far side. They ride the mortar's arc up, then fall, open a gull-kite (by hand,
|
||||
## or by itself near the ground) and steer down. Anyone still aboard when the ship
|
||||
## reaches the end of its route is fired towards the middle of the island.
|
||||
##
|
||||
## The route is drawn from the "drop" stream: a heading, and a point near the island's
|
||||
## middle that the route passes through, so it always crosses land. Movement handles
|
||||
## falling and gliding; this owns the barge, boarding and leaping.
|
||||
## The route is drawn from the "drop" stream: a heading, and the side of the island the
|
||||
## ship passes on. It passes as close in as it can while keeping SHIP_COAST_CLEARANCE
|
||||
## of open water between itself and any land. Movement handles the arc, falling and gliding;
|
||||
## this owns the ship, boarding and firing.
|
||||
class_name Drop
|
||||
extends RefCounted
|
||||
|
||||
## Player drop states, in SimEntity.drop_state.
|
||||
## Player drop states, in SimEntity.drop_state. FREEFALL covers the mortar's climb
|
||||
## (rising, with no steering) as well as the fall.
|
||||
const NONE: int = 0
|
||||
const ABOARD: int = 1
|
||||
const FREEFALL: int = 2
|
||||
const GLIDING: int = 3
|
||||
|
||||
## Where the route starts and ends, at barge altitude.
|
||||
## Where the route starts and ends, at deck height.
|
||||
var start: Vector3 = Vector3.ZERO
|
||||
var finish: Vector3 = Vector3.ZERO
|
||||
## Ticks the barge takes from start to finish.
|
||||
## Ticks the ship takes from start to finish.
|
||||
var duration_ticks: int = 0
|
||||
## Simulation tick the drop began on.
|
||||
var began_tick: int = 0
|
||||
## True once the barge has reached the end and thrown everyone off.
|
||||
## True once the ship has reached the end and fired everyone still aboard.
|
||||
var finished: bool = false
|
||||
|
||||
|
||||
## Plans the route for `island` from the simulation's "drop" stream.
|
||||
## Plans the route past `island_ground` from the simulation's "drop" stream.
|
||||
static func plan(island_ground: SimGround, rng: SimRng, tick: int) -> Drop:
|
||||
var drop: Drop = Drop.new()
|
||||
var stream: RandomNumberGenerator = rng.stream("drop")
|
||||
var size: float = Tuning.WORLD_SIZE_METRES
|
||||
var centre: Vector2 = Vector2(size, size) * 0.5
|
||||
var heading: float = stream.randf() * TAU
|
||||
var jitter_angle: float = stream.randf() * TAU
|
||||
var jitter: float = sqrt(stream.randf()) * Tuning.BARGE_CENTRE_JITTER
|
||||
var through: Vector2 = centre + Vector2(cos(jitter_angle), sin(jitter_angle)) * jitter
|
||||
# Pull the crossing point onto land if the jitter put it over water.
|
||||
var tries: int = 0
|
||||
while island_ground.terrain_height(through.x, through.y) <= Tuning.ISLAND_BEACH_TOP and tries < 16:
|
||||
through = through.lerp(centre, 0.5)
|
||||
tries += 1
|
||||
var direction: Vector2 = Vector2(cos(heading), sin(heading))
|
||||
var margin: float = Tuning.BARGE_ROUTE_MARGIN
|
||||
var back: float = _distance_to_edge(through, -direction, margin, size)
|
||||
var ahead: float = _distance_to_edge(through, direction, margin, size)
|
||||
var a: Vector2 = through - direction * back
|
||||
var b: Vector2 = through + direction * ahead
|
||||
drop.start = Vector3(a.x, Tuning.BARGE_ALTITUDE, a.y)
|
||||
drop.finish = Vector3(b.x, Tuning.BARGE_ALTITUDE, b.y)
|
||||
drop.duration_ticks = maxi(ceili(a.distance_to(b) / Tuning.BARGE_SPEED * Tuning.TICK_RATE_HZ), 1)
|
||||
var margin: float = Tuning.SHIP_ROUTE_MARGIN
|
||||
var best_a: Vector2 = Vector2.ZERO
|
||||
var best_b: Vector2 = Vector2.ZERO
|
||||
var found: bool = false
|
||||
for _try: int in Tuning.SHIP_ROUTE_TRIES:
|
||||
var heading: float = stream.randf() * TAU
|
||||
var side: float = 1.0 if stream.randf() < 0.5 else -1.0
|
||||
var direction: Vector2 = Vector2(cos(heading), sin(heading))
|
||||
# Away from the island, on the chosen side.
|
||||
var outward: Vector2 = Vector2(-direction.y, direction.x) * side
|
||||
var offset: float = Tuning.SHIP_OFFSET_MIN
|
||||
while offset <= Tuning.SHIP_OFFSET_MAX:
|
||||
var through: Vector2 = centre + outward * offset
|
||||
var a: Vector2 = through - direction * _distance_to_edge(through, -direction, margin, size)
|
||||
var b: Vector2 = through + direction * _distance_to_edge(through, direction, margin, size)
|
||||
if a.distance_to(b) < Tuning.SHIP_MIN_ROUTE_METRES:
|
||||
break
|
||||
if not found:
|
||||
# The fallback, should no route anywhere stay clear: the farthest one out.
|
||||
best_a = a
|
||||
best_b = b
|
||||
if _clear_of_land(island_ground, a, b):
|
||||
best_a = a
|
||||
best_b = b
|
||||
found = true
|
||||
break
|
||||
offset += Tuning.SHIP_OFFSET_STEP
|
||||
if found:
|
||||
break
|
||||
if not found:
|
||||
# Nothing on the drawn headings stayed clear: try the four routes along the
|
||||
# world's sides, as far out as routes go, which are the longest.
|
||||
var sides: Array[Vector2] = [Vector2.DOWN, Vector2.UP, Vector2.LEFT, Vector2.RIGHT]
|
||||
for outward: Vector2 in sides:
|
||||
var direction: Vector2 = Vector2(outward.y, -outward.x)
|
||||
var through: Vector2 = centre + outward * Tuning.SHIP_OFFSET_MAX
|
||||
var a: Vector2 = through - direction * _distance_to_edge(through, -direction, margin, size)
|
||||
var b: Vector2 = through + direction * _distance_to_edge(through, direction, margin, size)
|
||||
if _clear_of_land(island_ground, a, b):
|
||||
best_a = a
|
||||
best_b = b
|
||||
break
|
||||
drop.start = Vector3(best_a.x, Tuning.SHIP_DECK_HEIGHT, best_a.y)
|
||||
drop.finish = Vector3(best_b.x, Tuning.SHIP_DECK_HEIGHT, best_b.y)
|
||||
drop.duration_ticks = maxi(ceili(best_a.distance_to(best_b) / Tuning.SHIP_SPEED * Tuning.TICK_RATE_HZ), 1)
|
||||
drop.began_tick = tick
|
||||
return drop
|
||||
|
||||
|
||||
## How far along the route the barge is at `tick`, from 0 to 1.
|
||||
## True if the route from `a` to `b` is open sea with no land within
|
||||
## SHIP_COAST_CLEARANCE of it, probed in eight directions at half and full clearance.
|
||||
static func _clear_of_land(island_ground: SimGround, a: Vector2, b: Vector2) -> bool:
|
||||
var count: int = maxi(ceili(a.distance_to(b) / Tuning.SHIP_CLEARANCE_STEP), 1)
|
||||
var limit: float = Tuning.SEA_LEVEL_START - Tuning.SHIP_DRAUGHT
|
||||
for index: int in count + 1:
|
||||
var point: Vector2 = a.lerp(b, float(index) / count)
|
||||
if island_ground.terrain_height(point.x, point.y) > limit:
|
||||
return false
|
||||
for direction: int in 8:
|
||||
var angle: float = TAU * direction / 8.0
|
||||
for radius: float in [Tuning.SHIP_COAST_CLEARANCE * 0.5, Tuning.SHIP_COAST_CLEARANCE]:
|
||||
var probe: Vector2 = point + Vector2(cos(angle), sin(angle)) * radius
|
||||
if island_ground.terrain_height(probe.x, probe.y) > limit:
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
## How far along the route the ship is at `tick`, from 0 to 1.
|
||||
func progress(tick: int) -> float:
|
||||
return clampf(float(tick - began_tick) / duration_ticks, 0.0, 1.0)
|
||||
|
||||
|
||||
func barge_position(tick: int) -> Vector3:
|
||||
func ship_position(tick: int) -> Vector3:
|
||||
return start.lerp(finish, progress(tick))
|
||||
|
||||
|
||||
func barge_velocity() -> Vector3:
|
||||
func ship_velocity() -> Vector3:
|
||||
return (finish - start) / (float(duration_ticks) / Tuning.TICK_RATE_HZ)
|
||||
|
||||
|
||||
## True once the barge is at the end of its route.
|
||||
## True once the ship is at the end of its route.
|
||||
func is_over(tick: int) -> bool:
|
||||
return tick - began_tick >= duration_ticks
|
||||
|
||||
|
||||
## Points along the route every `step` metres, at ground level, for tests and maps.
|
||||
## Points along the route every `step` metres, at sea level, for tests and maps.
|
||||
func route_samples(step: float) -> PackedVector2Array:
|
||||
var points: PackedVector2Array = PackedVector2Array()
|
||||
var a: Vector2 = Vector2(start.x, start.z)
|
||||
@@ -83,7 +133,7 @@ func route_samples(step: float) -> PackedVector2Array:
|
||||
return points
|
||||
|
||||
|
||||
## Puts a player aboard: carried with the barge, not moving on their own.
|
||||
## Puts a player aboard: carried with the ship, not moving on their own.
|
||||
static func board(player: SimEntity, at: Vector3) -> void:
|
||||
player.drop_state = ABOARD
|
||||
player.position = at
|
||||
@@ -92,25 +142,111 @@ static func board(player: SimEntity, at: Vector3) -> void:
|
||||
player.swimming = false
|
||||
|
||||
|
||||
## Throws a player off the barge into freefall, keeping some of the barge's speed.
|
||||
func leap(player: SimEntity, tick: int) -> void:
|
||||
# The lifeline mortar
|
||||
|
||||
## The mortar's charge, 0 to 1, for a look pitch in radians: level or lower is the
|
||||
## least, MORTAR_PITCH_HIGH_DEGREES or higher the most.
|
||||
static func charge_for_pitch(pitch_radians: float) -> float:
|
||||
var low: float = deg_to_rad(Tuning.MORTAR_PITCH_LOW_DEGREES)
|
||||
var high: float = deg_to_rad(Tuning.MORTAR_PITCH_HIGH_DEGREES)
|
||||
return clampf((pitch_radians - low) / (high - low), 0.0, 1.0)
|
||||
|
||||
|
||||
## The look pitch, in radians, that gives `charge`.
|
||||
static func pitch_for_charge(charge: float) -> float:
|
||||
var low: float = deg_to_rad(Tuning.MORTAR_PITCH_LOW_DEGREES)
|
||||
var high: float = deg_to_rad(Tuning.MORTAR_PITCH_HIGH_DEGREES)
|
||||
return lerpf(low, high, clampf(charge, 0.0, 1.0))
|
||||
|
||||
|
||||
## The launch velocity for a heading (yaw, radians, as PlayerCommand measures it) and
|
||||
## a charge.
|
||||
static func launch_velocity(yaw_radians: float, charge: float) -> Vector3:
|
||||
var speed: float = lerpf(Tuning.MORTAR_MIN_SPEED, Tuning.MORTAR_MAX_SPEED, clampf(charge, 0.0, 1.0))
|
||||
return Vector3(sin(yaw_radians) * speed, Tuning.MORTAR_RISE_SPEED, cos(yaw_radians) * speed)
|
||||
|
||||
|
||||
## Fires a player off the ship by mortar, along `yaw_radians` with `charge`.
|
||||
func fire(player: SimEntity, tick: int, yaw_radians: float, charge: float) -> void:
|
||||
player.drop_state = FREEFALL
|
||||
player.position = barge_position(tick)
|
||||
var carried: Vector3 = barge_velocity() * Tuning.LEAP_CARRY
|
||||
player.velocity = Vector3(carried.x, 0.0, carried.z)
|
||||
player.position = ship_position(tick)
|
||||
player.velocity = launch_velocity(yaw_radians, charge)
|
||||
player.on_ground = false
|
||||
|
||||
|
||||
## A tick aboard the barge: jump leaps off, anything else rides along. The server and a
|
||||
## client predicting its own player both come through here.
|
||||
## How far over level ground a shot with `charge` carries while the player keeps
|
||||
## steering straight on: with `kite_at_top`, opening the kite as soon as the climb ends
|
||||
## (the furthest a shot can carry, and the slowest way down); without, falling until
|
||||
## the kite opens by itself. Mirrors Movement._fall_from_ship(); bots and the forced
|
||||
## shot pick their charge with it.
|
||||
static func reach(charge: float, kite_at_top: bool = false) -> float:
|
||||
var dt: float = 1.0 / Tuning.TICK_RATE_HZ
|
||||
var launch: Vector3 = launch_velocity(0.0, charge)
|
||||
var flat: float = launch.z
|
||||
var rise: float = launch.y
|
||||
var height: float = Tuning.SHIP_DECK_HEIGHT
|
||||
var travelled: float = 0.0
|
||||
var gliding: bool = false
|
||||
for _tick: int in Tuning.TICK_RATE_HZ * 120:
|
||||
if rise > 0.0:
|
||||
rise -= Tuning.GRAVITY * dt
|
||||
else:
|
||||
gliding = gliding or kite_at_top or height <= Tuning.KITE_AUTO_DEPLOY_HEIGHT
|
||||
if gliding:
|
||||
flat = move_toward(flat, Tuning.GLIDE_SPEED, Tuning.DROP_STEER_ACCEL * dt)
|
||||
rise = move_toward(rise, -Tuning.GLIDE_FALL_SPEED, Tuning.GLIDE_BRAKE * dt)
|
||||
else:
|
||||
flat = move_toward(flat, Tuning.FREEFALL_STEER_SPEED, Tuning.DROP_STEER_ACCEL * dt)
|
||||
rise = maxf(rise - Tuning.GRAVITY * dt, -Tuning.FREEFALL_MAX_SPEED)
|
||||
travelled += flat * dt
|
||||
height += rise * dt
|
||||
if height <= 0.0:
|
||||
break
|
||||
return travelled
|
||||
|
||||
|
||||
## The least charge whose reach() is at least `distance`, or 1 if none is.
|
||||
static func charge_for_distance(distance: float, kite_at_top: bool = false) -> float:
|
||||
if reach(0.0, kite_at_top) >= distance:
|
||||
return 0.0
|
||||
if reach(1.0, kite_at_top) <= distance:
|
||||
return 1.0
|
||||
var low: float = 0.0
|
||||
var high: float = 1.0
|
||||
for _step: int in 12:
|
||||
var middle: float = (low + high) * 0.5
|
||||
if reach(middle, kite_at_top) < distance:
|
||||
low = middle
|
||||
else:
|
||||
high = middle
|
||||
return high
|
||||
|
||||
|
||||
## The charge that carries `distance` with the quickest way down: a fall if one carries
|
||||
## that far, otherwise a full charge with the kite opened at the top.
|
||||
static func aim_charge(distance: float) -> float:
|
||||
return charge_for_distance(distance) if reach(1.0) >= distance else charge_for_distance(distance, true)
|
||||
|
||||
|
||||
## A tick aboard the ship: jump fires the mortar, anything else rides along. The
|
||||
## server and a client predicting its own player both come through here.
|
||||
func ride(player: SimEntity, command: PlayerCommand, tick: int) -> void:
|
||||
if command != null:
|
||||
player.yaw = command.yaw
|
||||
player.pitch = command.pitch
|
||||
if command.is_pressed(PlayerCommand.BUTTON_JUMP):
|
||||
leap(player, tick)
|
||||
fire(player, tick, command.yaw_radians(), charge_for_pitch(command.pitch_radians()))
|
||||
return
|
||||
player.position = barge_position(tick + 1)
|
||||
player.position = ship_position(tick + 1)
|
||||
|
||||
|
||||
## The end of the route: fires a player still aboard towards the middle of the island,
|
||||
## with the charge that carries there.
|
||||
func fire_at_end(player: SimEntity, tick: int) -> void:
|
||||
var at: Vector3 = ship_position(tick)
|
||||
var centre: Vector2 = Vector2(Tuning.WORLD_SIZE_METRES, Tuning.WORLD_SIZE_METRES) * 0.5
|
||||
var to: Vector2 = centre - Vector2(at.x, at.z)
|
||||
fire(player, tick, atan2(to.x, to.y), aim_charge(to.length() * Tuning.MORTAR_FORCED_REACH))
|
||||
|
||||
|
||||
## Distance from `from` along unit `direction` to the square [margin, size - margin].
|
||||
|
||||
+2
-2
@@ -125,7 +125,7 @@ func in_match() -> bool:
|
||||
## Adds a participant. Returns false if the handle is already here or the lobby is
|
||||
## full. During a match they wait for the next one.
|
||||
func join(handle: int, bot: bool = false) -> bool:
|
||||
# Once the barge has left, newcomers watch (see watch()) until the next lobby.
|
||||
# Once the ship has left, newcomers watch (see watch()) until the next lobby.
|
||||
if in_match() or phase == RESULTS:
|
||||
return false
|
||||
if participants.has(handle) or watchers.has(handle) or participants.size() >= rules.max_players:
|
||||
@@ -239,7 +239,7 @@ func _enter(next: int) -> void:
|
||||
phase_ticks = 0
|
||||
|
||||
|
||||
## Fills empty places with bots, puts every participant on the barge and places loot.
|
||||
## Fills empty places with bots, puts every participant on the ship and places loot.
|
||||
func _start() -> void:
|
||||
if rules.fill_with_bots:
|
||||
while participants.size() < rules.max_players:
|
||||
|
||||
@@ -31,7 +31,7 @@ static func immediate() -> MatchRules:
|
||||
return rules
|
||||
|
||||
|
||||
## Rules for the tutorial (A12): one player alone, straight onto the barge, with a
|
||||
## Rules for the tutorial (A12): one player alone, straight onto the ship, with a
|
||||
## weapon to learn on, and no ending until the tide's own.
|
||||
static func tutorial() -> MatchRules:
|
||||
var rules: MatchRules = MatchRules.immediate()
|
||||
|
||||
+16
-12
@@ -28,10 +28,10 @@ static func step(player: SimEntity, command: PlayerCommand, ground: SimGround, s
|
||||
wish = wish.limit_length(Tuning.DOWNED_CRAWL_SPEED)
|
||||
|
||||
if player.drop_state == Drop.ABOARD:
|
||||
# Riders move with the barge; Simulation places them.
|
||||
# Riders move with the ship; Simulation places them.
|
||||
return
|
||||
if player.drop_state != Drop.NONE:
|
||||
_fall_from_barge(player, command, ground, sea_level)
|
||||
_fall_from_ship(player, command, ground, sea_level)
|
||||
return
|
||||
|
||||
if player.swimming:
|
||||
@@ -268,15 +268,18 @@ static func _swim(player: SimEntity, command: PlayerCommand, ground: SimGround,
|
||||
player.on_ground = false
|
||||
|
||||
|
||||
## One tick of the drop after leaping: freefall, then the wing-sail. Players steer with
|
||||
## the move keys relative to where they look; jump opens the sail, and it opens by itself
|
||||
## WING_AUTO_DEPLOY_HEIGHT above the ground or water. Near the bottom the sail folds and
|
||||
## ordinary falling (or the water) takes over, slow enough to do no damage.
|
||||
static func _fall_from_barge(player: SimEntity, command: PlayerCommand, ground: SimGround, sea_level: float) -> void:
|
||||
## One tick of the drop after the mortar fires: the climb, freefall, then the gull-kite.
|
||||
## While the shot is still climbing nothing steers it and the kite can't open. Then
|
||||
## players steer with the move keys relative to where they look; jump opens the kite,
|
||||
## and it opens by itself KITE_AUTO_DEPLOY_HEIGHT above the ground or water. Near the
|
||||
## bottom the kite folds and ordinary falling (or the water) takes over, slow enough to
|
||||
## do no damage.
|
||||
static func _fall_from_ship(player: SimEntity, command: PlayerCommand, ground: SimGround, sea_level: float) -> void:
|
||||
var below: float = _drop_floor(player, ground, sea_level, player.position.y)
|
||||
if player.drop_state == Drop.FREEFALL:
|
||||
var climbing: bool = player.drop_state == Drop.FREEFALL and player.velocity.y > 0.0
|
||||
if player.drop_state == Drop.FREEFALL and not climbing:
|
||||
var opens: bool = command != null and command.is_pressed(PlayerCommand.BUTTON_JUMP)
|
||||
if opens or player.position.y - below <= Tuning.WING_AUTO_DEPLOY_HEIGHT:
|
||||
if opens or player.position.y - below <= Tuning.KITE_AUTO_DEPLOY_HEIGHT:
|
||||
player.drop_state = Drop.GLIDING
|
||||
var gliding: bool = player.drop_state == Drop.GLIDING
|
||||
|
||||
@@ -290,9 +293,10 @@ static func _fall_from_barge(player: SimEntity, command: PlayerCommand, ground:
|
||||
var right: Vector3 = Vector3(-cos(angle), 0.0, sin(angle))
|
||||
wish = (right * input.x + forward * input.y) * (Tuning.GLIDE_SPEED if gliding else Tuning.FREEFALL_STEER_SPEED)
|
||||
var velocity: Vector3 = player.velocity
|
||||
var flat: Vector3 = Vector3(velocity.x, 0.0, velocity.z).move_toward(wish, Tuning.DROP_STEER_ACCEL * DT)
|
||||
velocity.x = flat.x
|
||||
velocity.z = flat.z
|
||||
if not climbing:
|
||||
var flat: Vector3 = Vector3(velocity.x, 0.0, velocity.z).move_toward(wish, Tuning.DROP_STEER_ACCEL * DT)
|
||||
velocity.x = flat.x
|
||||
velocity.z = flat.z
|
||||
if gliding:
|
||||
velocity.y = move_toward(velocity.y, -Tuning.GLIDE_FALL_SPEED, Tuning.GLIDE_BRAKE * DT)
|
||||
else:
|
||||
|
||||
@@ -35,7 +35,7 @@ var tide: Tide = null
|
||||
var flood: Flood = null
|
||||
## Every built piece. Their boxes are part of `ground`.
|
||||
var structures: StructureSet = StructureSet.new()
|
||||
## The sky barge, from start_drop() on. Null in matches and tests that start on foot.
|
||||
## The packet ship, from start_drop() on. Null in matches and tests that start on foot.
|
||||
var drop: Drop = null
|
||||
|
||||
## Floor loot, sea chests and crate contents. Empty until place_loot().
|
||||
@@ -103,7 +103,7 @@ func add_player() -> int:
|
||||
Water.reset(player)
|
||||
Inventory.reset(player)
|
||||
if drop != null and not drop.finished:
|
||||
Drop.board(player, drop.barge_position(tick))
|
||||
Drop.board(player, drop.ship_position(tick))
|
||||
_players.append(player.id)
|
||||
_pending[player.id] = {}
|
||||
return player.id
|
||||
@@ -174,11 +174,11 @@ func submit_command(player_id: int, command: PlayerCommand) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
## Starts the match's drop: plans the barge's route and puts every player aboard.
|
||||
## Starts the match's drop: plans the ship's route and puts every player aboard.
|
||||
func start_drop() -> void:
|
||||
drop = Drop.plan(ground, rng, tick)
|
||||
for player_id: int in _players:
|
||||
Drop.board(entities.find(player_id), drop.barge_position(tick))
|
||||
Drop.board(entities.find(player_id), drop.ship_position(tick))
|
||||
|
||||
|
||||
## Rolls the match's loot from the "loot" stream and puts the floor loot in the world.
|
||||
@@ -256,11 +256,11 @@ func step() -> void:
|
||||
_spill_broken_crates()
|
||||
_check_eliminations()
|
||||
if drop != null and not drop.finished and drop.is_over(tick + 1):
|
||||
# The end of the route: everyone still aboard goes over the side.
|
||||
# The end of the route: the mortar fires everyone still aboard inland.
|
||||
for player_id: int in _players:
|
||||
var player: SimEntity = entities.find(player_id)
|
||||
if player.drop_state == Drop.ABOARD:
|
||||
drop.leap(player, tick + 1)
|
||||
drop.fire_at_end(player, tick + 1)
|
||||
drop.finished = true
|
||||
tick += 1
|
||||
|
||||
|
||||
+40
-17
@@ -145,29 +145,49 @@ const SWIM_SPRINT_STAMINA_COST: int = 3
|
||||
const STAMINA_RECOVERY_RATE: int = 3
|
||||
const BREATH_RECOVERY_RATE: int = 4
|
||||
|
||||
# The drop, in metres and seconds. The sky barge crosses the island on a straight
|
||||
# seeded route through a point within BARGE_CENTRE_JITTER of the middle.
|
||||
const BARGE_ALTITUDE: float = 150.0
|
||||
const BARGE_SPEED: float = 24.0
|
||||
# The drop (#72), in metres and seconds. The packet ship sails a straight seeded line
|
||||
# past the island, offshore, and players fire themselves inland by lifeline mortar.
|
||||
## The deck the players ride on, above the starting sea level.
|
||||
const SHIP_DECK_HEIGHT: float = 4.0
|
||||
const SHIP_SPEED: float = 16.0
|
||||
## The route starts and ends this far inside the world's edge.
|
||||
const BARGE_ROUTE_MARGIN: float = 40.0
|
||||
const BARGE_CENTRE_JITTER: float = 140.0
|
||||
## Every route crosses at least this much dry land.
|
||||
const BARGE_MIN_LAND_METRES: float = 250.0
|
||||
## Fraction of the barge's speed a leaping player keeps.
|
||||
const LEAP_CARRY: float = 0.4
|
||||
const SHIP_ROUTE_MARGIN: float = 40.0
|
||||
## The route keeps this much open water between itself and the coast. The planner tries
|
||||
## routes from SHIP_OFFSET_MIN to SHIP_OFFSET_MAX from the middle of the world, in
|
||||
## SHIP_OFFSET_STEP steps, and takes the first that is clear, for up to SHIP_ROUTE_TRIES
|
||||
## headings. Sea counts as open where the bottom is SHIP_DRAUGHT under the water.
|
||||
const SHIP_COAST_CLEARANCE: float = 45.0
|
||||
const SHIP_DRAUGHT: float = 1.0
|
||||
const SHIP_OFFSET_MIN: float = 300.0
|
||||
const SHIP_OFFSET_MAX: float = 465.0
|
||||
const SHIP_OFFSET_STEP: float = 6.0
|
||||
const SHIP_CLEARANCE_STEP: float = 6.0
|
||||
const SHIP_ROUTE_TRIES: int = 32
|
||||
## A route shorter than this (one cutting a corner of the world) isn't used.
|
||||
const SHIP_MIN_ROUTE_METRES: float = 420.0
|
||||
## The lifeline mortar: every shot climbs at MORTAR_RISE_SPEED; its speed over the
|
||||
## ground runs from MORTAR_MIN_SPEED to MORTAR_MAX_SPEED with the charge, which comes
|
||||
## from how high the player aims, from MORTAR_PITCH_LOW_DEGREES to ..._HIGH_DEGREES.
|
||||
const MORTAR_RISE_SPEED: float = 75.0
|
||||
const MORTAR_MIN_SPEED: float = 16.0
|
||||
const MORTAR_MAX_SPEED: float = 110.0
|
||||
const MORTAR_PITCH_LOW_DEGREES: float = -10.0
|
||||
const MORTAR_PITCH_HIGH_DEGREES: float = 45.0
|
||||
## Riders fired at the end of the route are sent this fraction of the way to the middle
|
||||
## of the island, so they land inland without all landing on one spot.
|
||||
const MORTAR_FORCED_REACH: float = 0.8
|
||||
const FREEFALL_MAX_SPEED: float = 32.0
|
||||
## Horizontal speed a falling player can steer to, before and after the sail opens.
|
||||
## Horizontal speed a falling player can steer to, before and after the kite opens.
|
||||
const FREEFALL_STEER_SPEED: float = 9.0
|
||||
const GLIDE_SPEED: float = 13.0
|
||||
## How fast horizontal speed changes while steering a fall, in metres per second squared.
|
||||
const DROP_STEER_ACCEL: float = 20.0
|
||||
## Sink rate under an open wing-sail, and how hard opening it brakes the fall.
|
||||
## Sink rate under an open gull-kite, and how hard opening it brakes the fall.
|
||||
const GLIDE_FALL_SPEED: float = 5.5
|
||||
const GLIDE_BRAKE: float = 60.0
|
||||
## The sail opens by itself this high above the ground or water.
|
||||
const WING_AUTO_DEPLOY_HEIGHT: float = 40.0
|
||||
## Within this height of the ground or water, the sail folds and the player drops the rest.
|
||||
## The kite opens by itself this high above the ground or water.
|
||||
const KITE_AUTO_DEPLOY_HEIGHT: float = 40.0
|
||||
## Within this height of the ground or water, the kite folds and the player drops the rest.
|
||||
const DROP_LAND_HANDOFF: float = 1.0
|
||||
|
||||
# The island. Worldgen fills the whole world square; the island is about a kilometre
|
||||
@@ -319,7 +339,10 @@ const BOT_ENGAGE_METRES: float = 30.0
|
||||
## away from its opponent, and won't break off again until as long again has passed.
|
||||
const BOT_RETREAT_SECONDS: float = 6.0
|
||||
const BOT_RETREAT_METRES: float = 30.0
|
||||
## A bot weighs this many landing spots near the barge's line and takes the one with
|
||||
## A bot lands at a loot marker no further than this from the ship's line (#72: within
|
||||
## the lifeline mortar's reach).
|
||||
const BOT_LANDING_REACH_METRES: float = 600.0
|
||||
## A bot weighs this many landing spots near the ship's line and takes the one with
|
||||
## the fewest other bots' landings within BOT_LANDING_SPREAD_METRES.
|
||||
const BOT_LANDING_CHOICES: int = 8
|
||||
const BOT_LANDING_SPREAD_METRES: float = 60.0
|
||||
@@ -608,7 +631,7 @@ const LOOT_SCATTER_METRES: float = 0.7
|
||||
# Balance targets (H3), judged by `make balance` over bot-only matches; see docs/BALANCE.md.
|
||||
## The pass needs at least this many matches.
|
||||
const BALANCE_MIN_MATCHES: int = 200
|
||||
## The median match, from the barge leaving to the last player standing, lasts this
|
||||
## The median match, from the ship leaving to the last player standing, lasts this
|
||||
## many minutes.
|
||||
const BALANCE_MEDIAN_MINUTES_MIN: float = 12.0
|
||||
const BALANCE_MEDIAN_MINUTES_MAX: float = 18.0
|
||||
|
||||
Reference in New Issue
Block a user