# mount.ludic - getting on, and getting off onto a spot the rider's own safe-spot rule found: the # same one answer a seat and a stand-up use, so a landing is never inside a boulder or on a bank # the body cannot climb off # this machine's player onto v; false when it is somebody else's, taken, or a hungry horse export function vehicle_mount(vehicles_st: mut VehiclesState, v: Vehicle) -> bool { if v == null or v.owner != 0 or v.rider >= 0 or vehicles_st.ve_cur != null { return false } if v.kind == VEHICLE_HORSE and v.food < vehicle_spec(vehicles_st, v.kind).hay_min { ve_say(vehicles_st, VEHICLE_HUNGRY, v, v.food) return false } vehicles_st.ve_cur = v v.rider = 0 VehicleRider.board(v.x, v.z, v.yaw) ve_say(vehicles_st, VEHICLE_MOUNTED, v, 0.0) return true } # Off, onto the nearest spot a body could stand and walk off: from a boat a wade of up to its spec's # off_depth, from a horse off_side out by its right flank. False (and said) when a boat is too far out. export function vehicle_dismount(vehicles_st: mut VehiclesState) -> bool { let v = vehicles_st.ve_cur if v == null { return false } let sp = vehicle_spec(vehicles_st, v.kind) if v.kind == VEHICLE_BOAT { if not VehicleRider.safe_spot(v.x, v.z, VehicleWorld.water(v.x, v.z), sp.off_depth) { ve_say(vehicles_st, VEHICLE_NO_LANDING, v, 0.0) return false } VehicleRider.step_off(VehicleRider.safe_x(), VehicleRider.safe_z()) ve_moor(v) } else { let wx = v.x + Math.cos(v.yaw) * sp.off_side let wz = v.z - Math.sin(v.yaw) * sp.off_side if VehicleRider.safe_spot(wx, wz, VehicleWorld.ground(v.x, v.z), 0.0) { VehicleRider.step_off(VehicleRider.safe_x(), VehicleRider.safe_z()) } else { VehicleRider.step_off(v.x, v.z) } v.home_x = v.x v.home_z = v.z } vehicles_st.ve_cur = null v.rider = -1 v.speed = 0.0 ve_say(vehicles_st, VEHICLE_DISMOUNTED, v, 0.0) return true } # off whatever this player is on, wherever it is (a load, a collapse, a map change) export function vehicle_drop(vehicles_st: mut VehiclesState) -> void { if vehicles_st.ve_cur != null { vehicles_st.ve_cur.rider = -1 vehicles_st.ve_cur.speed = 0.0 if vehicles_st.ve_cur.kind == VEHICLE_BOAT { ve_moor(vehicles_st.ve_cur) } } vehicles_st.ve_cur = null }