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:
Orkun ÇAKILKAYA 2026-09-25 08:39:50 +03:00
parent fdf9866e88
commit 6e2212de7b
13 changed files with 877 additions and 0 deletions

View file

@ -0,0 +1,74 @@
# state.ludic - every vehicle, the one this machine's player is on, where the places are measured
# from, and the facts
var ve_list: []Vehicle = null
var ve_cur: Vehicle = null
var ve_dock_x: float = 0.0
var ve_dock_z: float = 0.0
var ve_dock_yaw: float = 0.0
var ve_rail_x: float = 0.0
var ve_rail_z: float = 0.0
var ve_rail_yaw: float = 0.0
var ve_have_dock: bool = false
var ve_swell_said: float = 0.0
var ve_fact_q: Queue<VehicleFact> = null
const ve_pi: float = 3.14159265
export function vehicle_facts() -> Queue<VehicleFact> {
if ve_fact_q == null { ve_fact_q = queue_new("vehicles.facts") }
return ve_fact_q
}
function ve_say(what: int, v: Vehicle, n: float) -> void {
let f = new VehicleFact
f.what = what
f.nid = v.nid
f.kind = v.kind
f.owner = v.owner
f.x = v.x
f.z = v.z
f.v = n
q_push(vehicle_facts(), f)
}
function ve_all() -> []Vehicle {
if ve_list == null { ve_list = new []Vehicle }
return ve_list
}
# every vehicle in the valley, to draw and to aim at (change one only through the verbs)
export function vehicles_all() -> []Vehicle { return ve_all() }
# the kind this machine's player is riding, 0 none
export function vehicle_ride_kind() -> int {
if ve_cur == null { return 0 }
return ve_cur.kind
}
export function vehicle_current() -> Vehicle { return ve_cur }
export function vehicle_of(pid: int, kind: int) -> Vehicle {
let l = ve_all()
for i in 0 .. len(l) { if l[i].kind == kind and l[i].owner == pid { return l[i] } }
return null
}
# this player's own boat or horse
export function vehicle_find(kind: int) -> Vehicle { return vehicle_of(0, kind) }
# the nearest vehicle nobody is on within `reach` of (x, z); nothing while riding
export function vehicle_nearest(x: float, z: float, reach: float) -> Vehicle {
if ve_cur != null { return null }
var best: Vehicle = null
var bd = reach
let l = ve_all()
for i in 0 .. len(l) {
let v = l[i]
if v.rider >= 0 { continue }
let d = Math.sqrt((v.x - x) * (v.x - x) + (v.z - z) * (v.z - z))
if d < bd {
bd = d
best = v
}
}
return best
}