feat(packages): ludic.vehicles - each player's boat and horse: called to four berths or four bays, made the first time and fetched after, owner and rider, mounting (a hungry horse will not go), riding a horse on stamina and a boat on the wind with steering by signed speed, the swell at the edge, getting off onto the rider's own safe spot, a player leaving; the world and the rider through ports; mounted, dismounted, no landing, moved, swell and hunger as facts; this player's own saved by kind
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fdf9866e88
commit
6e2212de7b
13 changed files with 877 additions and 0 deletions
81
packages/ludic.vehicles/places.ludic
Normal file
81
packages/ludic.vehicles/places.ludic
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# places.ludic - four berths off the pier head and four bays at the trough. Nobody's boat waits in
|
||||
# one: a player calls theirs into a place that is empty. A place is taken while a boat lies in it or
|
||||
# a horse is tied at it, and frees itself the moment it is rowed or ridden away.
|
||||
export function vehicles_dock_at(x: float, z: float, yaw: float) -> void {
|
||||
ve_dock_x = x
|
||||
ve_dock_z = z
|
||||
ve_dock_yaw = yaw
|
||||
ve_have_dock = true
|
||||
}
|
||||
|
||||
export function vehicles_rail_at(x: float, z: float, yaw: float) -> void {
|
||||
ve_rail_x = x
|
||||
ve_rail_z = z
|
||||
ve_rail_yaw = yaw
|
||||
}
|
||||
|
||||
# which way the pier head faces, for the posts a game stands on it
|
||||
export function vehicles_dock_yaw() -> float { return ve_dock_yaw }
|
||||
|
||||
function ve_across(k: int) -> float { return -3.3 + float(k) * 2.2 }
|
||||
|
||||
# a berth: 90 cm off the pier head's outer edge, bow out; its post on the deck above it
|
||||
export function vehicle_berth_x(k: int) -> float { return ve_dock_x - Math.sin(ve_dock_yaw) * 7.25 + Math.cos(ve_dock_yaw) * ve_across(k) }
|
||||
export function vehicle_berth_z(k: int) -> float { return ve_dock_z - Math.cos(ve_dock_yaw) * 7.25 - Math.sin(ve_dock_yaw) * ve_across(k) }
|
||||
export function vehicle_post_x(k: int) -> float { return ve_dock_x - Math.sin(ve_dock_yaw) * 6.15 + Math.cos(ve_dock_yaw) * ve_across(k) }
|
||||
export function vehicle_post_z(k: int) -> float { return ve_dock_z - Math.cos(ve_dock_yaw) * 6.15 - Math.sin(ve_dock_yaw) * ve_across(k) }
|
||||
|
||||
# a bay: off the trough's long side, a trough's length apart - four horses at a feeding trough
|
||||
# stand shoulder to shoulder along it
|
||||
function ve_bay_across(k: int) -> float { return -1.44 + float(k) * 0.96 }
|
||||
export function vehicle_bay_x(k: int) -> float { return ve_rail_x - Math.sin(ve_rail_yaw) * 1.4 + Math.cos(ve_rail_yaw) * ve_bay_across(k) }
|
||||
export function vehicle_bay_z(k: int) -> float { return ve_rail_z - Math.cos(ve_rail_yaw) * 1.4 - Math.sin(ve_rail_yaw) * ve_bay_across(k) }
|
||||
|
||||
export function vehicle_place_x(kind: int, k: int) -> float {
|
||||
if kind == VEHICLE_HORSE { return vehicle_bay_x(k) }
|
||||
return vehicle_berth_x(k)
|
||||
}
|
||||
|
||||
export function vehicle_place_z(kind: int, k: int) -> float {
|
||||
if kind == VEHICLE_HORSE { return vehicle_bay_z(k) }
|
||||
return vehicle_berth_z(k)
|
||||
}
|
||||
|
||||
# who is in place k: the boat lying in the berth or the horse tied in the bay, or null
|
||||
export function vehicle_in_place(kind: int, k: int) -> Vehicle {
|
||||
let px = vehicle_place_x(kind, k)
|
||||
let pz = vehicle_place_z(kind, k)
|
||||
let l = ve_all()
|
||||
for i in 0 .. len(l) {
|
||||
let v = l[i]
|
||||
if v.kind != kind or v.rider >= 0 { continue }
|
||||
# within half a place's spacing: the bays are 0.96 m apart, and a looser test put a horse in two
|
||||
var vx = v.x
|
||||
var vz = v.z
|
||||
var near = 1.2
|
||||
if kind == VEHICLE_HORSE {
|
||||
vx = v.home_x
|
||||
vz = v.home_z
|
||||
near = 0.2
|
||||
}
|
||||
if (vx - px) * (vx - px) + (vz - pz) * (vz - pz) < near { return v }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
# the first free place, or -1
|
||||
export function vehicle_free_place(kind: int) -> int {
|
||||
for k in 0 .. VEHICLE_PLACES { if vehicle_in_place(kind, k) == null { return k } }
|
||||
return -1
|
||||
}
|
||||
|
||||
# this player's own is lying in one of the places
|
||||
export function vehicle_mine_in_place(kind: int) -> bool {
|
||||
let mine = vehicle_find(kind)
|
||||
if mine == null { return false }
|
||||
for k in 0 .. VEHICLE_PLACES {
|
||||
let h = vehicle_in_place(kind, k)
|
||||
if h != null and h.nid == mine.nid { return true }
|
||||
}
|
||||
return false
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue