feat(vehicles): 16 - a horse walks on legs in the game's physics (VehicleLegs): the package keeps its pace, stamina, hay and its refusal of water; the legs meet the ground, its steps and slopes and whatever is in the way, and what they cover along its heading is its speed, so a fence stops it and a trunk it glances pushes it aside. VehicleWorld.blocked is gone; the hire, hay and follow verbs move to keep.ludic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1fc01df39c
commit
bb2a4c10af
9 changed files with 156 additions and 74 deletions
39
packages/ludic.vehicles/keep.ludic
Normal file
39
packages/ludic.vehicles/keep.ludic
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# keep.ludic - what a player does with their own between rides: hires it, feeds the horse, lets it
|
||||
# wander where it is tied, and what a saved trip says of them
|
||||
# hired or rented for the trip
|
||||
export function vehicle_own(v: Vehicle) -> void { if v != null { v.owned = true } }
|
||||
|
||||
# hay for a horse, up to a full belly
|
||||
export function vehicle_feed(vehicles_st: VehiclesState, v: Vehicle, amount: float) -> void {
|
||||
if v == null { return }
|
||||
v.food = Math.min(v.food + amount, 100.0)
|
||||
ve_say(vehicles_st, VEHICLE_FED, v, amount)
|
||||
}
|
||||
|
||||
# a horse nobody rides goes where its animal goes, round the home it is tied at (home_x, home_z)
|
||||
export function vehicle_follow(v: Vehicle, x: float, y: float, z: float, yaw: float) -> void {
|
||||
if v == null or v.rider >= 0 { return }
|
||||
v.x = x
|
||||
v.y = y
|
||||
v.z = z
|
||||
v.yaw = yaw
|
||||
VehicleLegs.stand(v.nid, x, y, z)
|
||||
}
|
||||
|
||||
# a saved trip's word on this player's own: hired, and how fed
|
||||
export function vehicle_restore(vehicles_st: mut VehiclesState, kind: int, owned: bool, food: float) -> void {
|
||||
if kind == VEHICLE_HORSE {
|
||||
vehicles_st.ve_kept_horse = owned
|
||||
vehicles_st.ve_kept_food = food
|
||||
} else { vehicles_st.ve_kept_boat = owned }
|
||||
let v = vehicle_find(vehicles_st, kind)
|
||||
if v != null { ve_apply_kept(vehicles_st, v) }
|
||||
}
|
||||
|
||||
|
||||
function ve_apply_kept(vehicles_st: VehiclesState, v: Vehicle) -> void {
|
||||
if v.kind == VEHICLE_HORSE {
|
||||
v.owned = vehicles_st.ve_kept_horse
|
||||
v.food = vehicles_st.ve_kept_food
|
||||
} else { v.owned = vehicles_st.ve_kept_boat }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue