#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:
+120
-30
@@ -1,6 +1,7 @@
|
||||
extends TestCase
|
||||
|
||||
## The drop from issue W7: the sky barge's route, leaping, freefall, the wing-sail,
|
||||
## The drop from issues W7 and #72: the packet ship's route offshore, the lifeline
|
||||
## mortar's charge and arc, freefall, the gull-kite,
|
||||
## steering, landing and the forced ejection at the end of the route.
|
||||
|
||||
const SECOND: int = Tuning.TICK_RATE_HZ
|
||||
@@ -20,27 +21,92 @@ func _command(sim: Simulation, move: Vector2, yaw: float, buttons: int = 0) -> P
|
||||
return PlayerCommand.from_input(sim.tick, move, yaw, 0.0, buttons)
|
||||
|
||||
|
||||
func test_routes_always_cross_land() -> void:
|
||||
# 60 seeds: every route starts and ends inside the world, flies at barge altitude, and
|
||||
# spends a good stretch over dry land, so every player can reach the island.
|
||||
func test_routes_pass_offshore_and_every_shore_is_in_reach() -> void:
|
||||
# 60 seeds: every route starts and ends inside the world at deck height, sails only
|
||||
# over open sea, passes close to the coast, and no land is further from the route
|
||||
# than the mortar's full charge carries, so every player can reach anywhere.
|
||||
var full: float = Drop.reach(1.0, true)
|
||||
for seed_value: int in range(1, 61):
|
||||
var island: Island = Island.generate(seed_value)
|
||||
var drop: Drop = Drop.plan(island.ground, SimRng.new(seed_value), 0)
|
||||
var size: float = Tuning.WORLD_SIZE_METRES
|
||||
for end: Vector3 in [drop.start, drop.finish]:
|
||||
assert_true(end.x >= 0.0 and end.x <= size and end.z >= 0.0 and end.z <= size, "seed %d route leaves the world" % seed_value)
|
||||
assert_eq(end.y, Tuning.BARGE_ALTITUDE)
|
||||
var land: int = 0
|
||||
var samples: PackedVector2Array = drop.route_samples(4.0)
|
||||
for point: Vector2 in samples:
|
||||
if island.ground.terrain_height(point.x, point.y) > Tuning.ISLAND_BEACH_TOP:
|
||||
land += 1
|
||||
var land_metres: float = land * 4.0
|
||||
assert_true(land_metres >= Tuning.BARGE_MIN_LAND_METRES, "seed %d route crosses only %.0f m of land" % [seed_value, land_metres])
|
||||
assert_eq(end.y, Tuning.SHIP_DECK_HEIGHT)
|
||||
for point: Vector2 in drop.route_samples(4.0):
|
||||
assert_true(island.ground.terrain_height(point.x, point.y) < Tuning.SEA_LEVEL_START, "seed %d: the ship runs aground at %s" % [seed_value, point])
|
||||
var a: Vector2 = Vector2(drop.start.x, drop.start.z)
|
||||
var b: Vector2 = Vector2(drop.finish.x, drop.finish.z)
|
||||
var nearest: float = INF
|
||||
var farthest: float = 0.0
|
||||
var x: float = 8.0
|
||||
while x < size:
|
||||
var z: float = 8.0
|
||||
while z < size:
|
||||
if island.ground.terrain_height(x, z) > Tuning.ISLAND_BEACH_TOP:
|
||||
var at: Vector2 = Vector2(x, z)
|
||||
var gap: float = at.distance_to(Geometry2D.get_closest_point_to_segment(at, a, b))
|
||||
nearest = minf(nearest, gap)
|
||||
farthest = maxf(farthest, gap)
|
||||
z += 16.0
|
||||
x += 16.0
|
||||
assert_true(nearest >= 15.0 and nearest <= 140.0, "seed %d: the ship passes %.0f m from land" % [seed_value, nearest])
|
||||
assert_true(farthest <= full - 50.0, "seed %d: land %.0f m off, the mortar carries %.0f m" % [seed_value, farthest, full])
|
||||
var seconds: float = float(drop.duration_ticks) / SECOND
|
||||
assert_true(seconds >= 20.0 and seconds <= 75.0, "seed %d route takes %.1f s" % [seed_value, seconds])
|
||||
|
||||
|
||||
func test_charge_follows_the_aim_and_reach_grows_with_it() -> void:
|
||||
assert_eq(Drop.charge_for_pitch(deg_to_rad(-30.0)), 0.0)
|
||||
assert_eq(Drop.charge_for_pitch(deg_to_rad(80.0)), 1.0)
|
||||
for charge: float in [0.0, 0.3, 0.7, 1.0]:
|
||||
assert_near(Drop.charge_for_pitch(Drop.pitch_for_charge(charge)), charge, 0.0001)
|
||||
for kite: bool in [false, true]:
|
||||
var last: float = 0.0
|
||||
for step: int in 11:
|
||||
var reach: float = Drop.reach(step / 10.0, kite)
|
||||
assert_true(reach > last, "reach should grow with the charge")
|
||||
last = reach
|
||||
for distance: float in [450.0, 600.0, 750.0]:
|
||||
assert_near(Drop.reach(Drop.charge_for_distance(distance, kite), kite), distance, 2.0)
|
||||
assert_eq(Drop.charge_for_distance(10.0, kite), 0.0)
|
||||
assert_eq(Drop.charge_for_distance(5000.0, kite), 1.0)
|
||||
# The kite opened at the top carries further than a fall, and aim_charge falls when
|
||||
# a fall carries far enough.
|
||||
assert_true(Drop.reach(1.0, true) > Drop.reach(1.0) + 100.0)
|
||||
assert_eq(Drop.aim_charge(600.0), Drop.charge_for_distance(600.0))
|
||||
var far: float = Drop.reach(1.0) + 50.0
|
||||
assert_eq(Drop.aim_charge(far), Drop.charge_for_distance(far, true))
|
||||
|
||||
|
||||
func test_shots_land_where_reach_says() -> void:
|
||||
# On flat ground: fire straight along +z and hold forward, either opening the kite as
|
||||
# soon as the climb ends or letting it open by itself. The landing must match
|
||||
# Drop.reach(), which bots aim by.
|
||||
for case: int in 6:
|
||||
var charge: float = [0.0, 0.5, 1.0][case % 3]
|
||||
var kite: bool = case >= 3
|
||||
var sim: Simulation = _flat_sim()
|
||||
var id: int = sim.add_player()
|
||||
sim.start_drop()
|
||||
var player: SimEntity = sim.entities.find(id)
|
||||
player.position = Vector3(10.0, Tuning.SHIP_DECK_HEIGHT, 10.0)
|
||||
sim.drop.start = player.position
|
||||
sim.drop.finish = player.position
|
||||
sim.submit_command(id, PlayerCommand.from_input(sim.tick, Vector2.ZERO, 0.0, Drop.pitch_for_charge(charge), PlayerCommand.BUTTON_JUMP))
|
||||
sim.step()
|
||||
var from: Vector3 = player.position
|
||||
for _i: int in SECOND * 120:
|
||||
var buttons: int = PlayerCommand.BUTTON_JUMP if kite and player.drop_state == Drop.FREEFALL else 0
|
||||
sim.submit_command(id, PlayerCommand.from_input(sim.tick, Vector2(0.0, 1.0), 0.0, 0.0, buttons))
|
||||
sim.step()
|
||||
if player.drop_state == Drop.NONE:
|
||||
break
|
||||
var travelled: float = player.position.z - from.z
|
||||
assert_near(travelled, Drop.reach(charge, kite), Drop.reach(charge, kite) * 0.03, "charge %.1f, kite at the top %s" % [charge, kite])
|
||||
assert_near(player.position.x, from.x, 0.01)
|
||||
|
||||
|
||||
func test_route_is_seeded() -> void:
|
||||
var island: Island = Island.generate(5)
|
||||
var a: Drop = Drop.plan(island.ground, SimRng.new(5), 0)
|
||||
@@ -51,7 +117,7 @@ func test_route_is_seeded() -> void:
|
||||
assert_ne(a.start, c.start)
|
||||
|
||||
|
||||
func test_players_ride_the_barge_until_they_leap() -> void:
|
||||
func test_players_ride_the_ship_until_the_mortar_fires_them_up_the_arc() -> void:
|
||||
var sim: Simulation = _flat_sim()
|
||||
var id: int = sim.add_player()
|
||||
sim.start_drop()
|
||||
@@ -62,30 +128,50 @@ func test_players_ride_the_barge_until_they_leap() -> void:
|
||||
sim.submit_command(id, _command(sim, Vector2(1.0, 1.0), 0.3, PlayerCommand.BUTTON_SPRINT | PlayerCommand.BUTTON_CROUCH))
|
||||
sim.step()
|
||||
assert_eq(player.drop_state, Drop.ABOARD)
|
||||
assert_true(player.position.distance_to(sim.drop.barge_position(sim.tick)) < 0.001, "rider isn't on the barge")
|
||||
sim.submit_command(id, _command(sim, Vector2.ZERO, 0.0, PlayerCommand.BUTTON_JUMP))
|
||||
assert_true(player.position.distance_to(sim.drop.ship_position(sim.tick)) < 0.001, "rider isn't on the ship")
|
||||
var yaw: float = 0.8
|
||||
sim.submit_command(id, PlayerCommand.from_input(sim.tick, Vector2.ZERO, yaw, deg_to_rad(20.0), PlayerCommand.BUTTON_JUMP))
|
||||
sim.step()
|
||||
assert_eq(player.drop_state, Drop.FREEFALL)
|
||||
var height: float = player.position.y
|
||||
for _i: int in SECOND:
|
||||
var launch: Vector3 = Drop.launch_velocity(yaw, Drop.charge_for_pitch(deg_to_rad(20.0)))
|
||||
assert_true(player.velocity.distance_to(launch) < 0.05, "launched at %s, wanted %s" % [player.velocity, launch])
|
||||
# The climb: steering and jump (the kite) do nothing until the arc tops out.
|
||||
var flat: Vector2 = Vector2(launch.x, launch.z)
|
||||
var top: float = player.position.y
|
||||
for _i: int in SECOND * 3:
|
||||
sim.submit_command(id, _command(sim, Vector2(1.0, -1.0), 2.5, PlayerCommand.BUTTON_JUMP))
|
||||
sim.step()
|
||||
assert_true(player.position.y < height - 10.0, "freefall too slow: %.1f to %.1f" % [height, player.position.y])
|
||||
# Freefall tops out at its terminal speed.
|
||||
for _i: int in SECOND * 2:
|
||||
top = maxf(top, player.position.y)
|
||||
assert_eq(player.drop_state, Drop.FREEFALL, "the kite opened during the climb")
|
||||
assert_true(Vector2(player.velocity.x, player.velocity.z).distance_to(flat) < 0.05, "steered during the climb")
|
||||
while player.velocity.y > 0.0:
|
||||
sim.step()
|
||||
top = maxf(top, player.position.y)
|
||||
var apex: float = Tuning.SHIP_DECK_HEIGHT + Tuning.MORTAR_RISE_SPEED * Tuning.MORTAR_RISE_SPEED / (2.0 * Tuning.GRAVITY)
|
||||
assert_near(top, apex, 3.0, "the top of the arc")
|
||||
# Then freefall, which tops out at its terminal speed.
|
||||
for _i: int in SECOND * 4:
|
||||
sim.step()
|
||||
assert_true(player.velocity.y < -20.0, "should be falling fast, at %s" % player.velocity)
|
||||
assert_true(-player.velocity.y <= Tuning.FREEFALL_MAX_SPEED + 0.001)
|
||||
|
||||
|
||||
func test_wing_sail_slows_the_fall_and_steers() -> void:
|
||||
func _over_the_top(sim: Simulation, player: SimEntity) -> void:
|
||||
while player.velocity.y > 0.0:
|
||||
sim.step()
|
||||
|
||||
|
||||
func test_gull_kite_slows_the_fall_and_steers() -> void:
|
||||
var sim: Simulation = _flat_sim()
|
||||
var id: int = sim.add_player()
|
||||
sim.start_drop()
|
||||
var player: SimEntity = sim.entities.find(id)
|
||||
sim.submit_command(id, _command(sim, Vector2.ZERO, 0.0, PlayerCommand.BUTTON_JUMP))
|
||||
sim.step()
|
||||
_over_the_top(sim, player)
|
||||
for _i: int in SECOND:
|
||||
sim.step()
|
||||
# Open the sail by hand, high up.
|
||||
# Open the kite by hand, high up.
|
||||
sim.submit_command(id, _command(sim, Vector2.ZERO, 0.0, PlayerCommand.BUTTON_JUMP))
|
||||
sim.step()
|
||||
assert_eq(player.drop_state, Drop.GLIDING)
|
||||
@@ -118,14 +204,14 @@ func test_wing_sail_slows_the_fall_and_steers() -> void:
|
||||
sim.step()
|
||||
var p4: Vector2 = Vector2(player.position.x, player.position.z)
|
||||
assert_near((p4 - p3).dot(right), Tuning.GLIDE_SPEED, 0.1, "glide speed to the right")
|
||||
# Letting go stops the sail drifting.
|
||||
# Letting go stops the kite drifting.
|
||||
for _i: int in SECOND:
|
||||
sim.step()
|
||||
assert_near(Vector2(player.velocity.x, player.velocity.z).length(), 0.0, 0.01)
|
||||
assert_eq(player.drop_state, Drop.GLIDING)
|
||||
|
||||
|
||||
func test_sail_opens_by_itself_near_the_ground_and_landing_is_safe() -> void:
|
||||
func test_kite_opens_by_itself_near_the_ground_and_landing_is_safe() -> void:
|
||||
var sim: Simulation = _flat_sim()
|
||||
var id: int = sim.add_player()
|
||||
sim.start_drop()
|
||||
@@ -139,8 +225,8 @@ func test_sail_opens_by_itself_near_the_ground_and_landing_is_safe() -> void:
|
||||
opened_at = player.position.y
|
||||
if player.on_ground:
|
||||
break
|
||||
assert_true(opened_at > 0.0, "the sail never opened")
|
||||
assert_true(opened_at <= Tuning.WING_AUTO_DEPLOY_HEIGHT + 0.001 and opened_at > Tuning.WING_AUTO_DEPLOY_HEIGHT - 2.0, "opened at %.1f m" % opened_at)
|
||||
assert_true(opened_at > 0.0, "the kite never opened")
|
||||
assert_true(opened_at <= Tuning.KITE_AUTO_DEPLOY_HEIGHT + 0.001 and opened_at > Tuning.KITE_AUTO_DEPLOY_HEIGHT - 2.0, "opened at %.1f m" % opened_at)
|
||||
assert_true(player.on_ground, "never landed, at %s" % player.position)
|
||||
assert_eq(player.drop_state, Drop.NONE)
|
||||
assert_eq(player.health, Tuning.PLAYER_MAX_HEALTH)
|
||||
@@ -169,8 +255,8 @@ func test_gliding_into_the_sea_ends_in_the_water_unhurt() -> void:
|
||||
assert_eq(player.health, Tuning.PLAYER_MAX_HEALTH)
|
||||
|
||||
|
||||
func test_riders_are_thrown_off_at_the_end_of_the_route() -> void:
|
||||
var sim: Simulation = _flat_sim()
|
||||
func test_riders_are_fired_inland_at_the_end_of_the_route() -> void:
|
||||
var sim: Simulation = _sim(11)
|
||||
var id: int = sim.add_player()
|
||||
sim.start_drop()
|
||||
var player: SimEntity = sim.entities.find(id)
|
||||
@@ -181,12 +267,16 @@ func test_riders_are_thrown_off_at_the_end_of_the_route() -> void:
|
||||
sim.step()
|
||||
assert_eq(player.drop_state, Drop.FREEFALL, "still aboard after the route ended")
|
||||
assert_true(sim.drop.finished)
|
||||
assert_true(player.position.distance_to(sim.drop.finish) < Tuning.FREEFALL_MAX_SPEED)
|
||||
assert_true(player.velocity.y > 0.0, "fired up the arc")
|
||||
var centre: Vector2 = Vector2.ONE * Tuning.WORLD_SIZE_METRES * 0.5
|
||||
var to_centre: Vector2 = (centre - Vector2(sim.drop.finish.x, sim.drop.finish.z)).normalized()
|
||||
var heading: Vector2 = Vector2(player.velocity.x, player.velocity.z).normalized()
|
||||
assert_true(heading.dot(to_centre) > 0.999, "fired towards the middle of the island")
|
||||
|
||||
|
||||
func test_forced_landing_brings_every_player_down_alive() -> void:
|
||||
# A full drop on a real island: 24 players, a third leaping early, a third steering
|
||||
# and opening their sails high, the rest never pressing anything and thrown off at
|
||||
# and opening their kites high, the rest never pressing anything and fired off at
|
||||
# the end. Everyone must reach the ground or the water, unhurt, before the route
|
||||
# time plus a generous fall.
|
||||
var sim: Simulation = _sim(11)
|
||||
|
||||
Reference in New Issue
Block a user