39 lines
1.5 KiB
Text
39 lines
1.5 KiB
Text
# 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 }
|
|
}
|