# verbs.ludic - every change the rest of a game may make to the body export function char_config(character_st: mut CharacterState, walk: float, run: float) -> void { character_st.chr_walk_speed = walk character_st.chr_run_speed = run } # put the body somewhere, standing, the camera behind it export function char_teleport(character_st: mut CharacterState, x: float, z: float, yaw: float) -> void { character_st.chr_x = x character_st.chr_z = z character_st.chr_yaw = yaw character_st.chr_y = CharacterGround.height(x, z) char_halt(character_st) character_st.chr_sit = false character_st.chr_swim = false character_st.chr_dive = false character_st.chr_depth = 0.0 character_st.chr_float = 0.0 # the water where the body lands, not where it was: a trip reloaded mid-swim reads it next character_st.chr_water = CharacterGround.water(x, z) character_st.chr_cam_yaw = yaw character_st.chr_piv_x = character_st.chr_x character_st.chr_piv_y = character_st.chr_y + 1.45 character_st.chr_piv_z = character_st.chr_z char_camera(character_st, 1.0) } # a screen holds the body still by a reason, so two holders cannot release each other's hold export function char_hold(character_st: mut CharacterState, reason: int) -> void { character_st.chr_holds = character_st.chr_holds | reason } export function char_release(character_st: mut CharacterState, reason: int) -> void { if (character_st.chr_holds & reason) != 0 { character_st.chr_holds = character_st.chr_holds - reason } } # everything that carries the body stops: no fall, no stride, no run export function char_halt(character_st: mut CharacterState) -> void { character_st.chr_air = false character_st.chr_vy = 0.0 character_st.chr_speed = 0.0 character_st.chr_move = 0.0 character_st.chr_run = 0.0 } # out of strength in the water: the stroke stops and the body floats export function char_go_limp(character_st: mut CharacterState) -> void { character_st.chr_speed = 0.0 character_st.chr_float = 1.0 } # set down somewhere without the teleport's reset (a swimmer turned back) export function char_push_to(character_st: mut CharacterState, x: float, z: float) -> void { character_st.chr_x = x character_st.chr_z = z character_st.chr_speed = 0.0 } # stood on the ground at a point, facing a way export function char_stand_on(character_st: mut CharacterState, x: float, z: float, yaw: float) -> void { character_st.chr_x = x character_st.chr_z = z character_st.chr_yaw = yaw character_st.chr_y = CharacterGround.height(x, z) } # a trip saved in the middle of the lake reloads in the middle of the lake, not on the bed export function char_resume_swim(character_st: mut CharacterState, dive: bool, depth: float, breath: float) -> void { character_st.chr_water = CharacterGround.water(character_st.chr_x, character_st.chr_z) character_st.chr_swim = true character_st.chr_dive = dive character_st.chr_depth = depth character_st.chr_breath = breath character_st.chr_y = character_st.chr_water - 0.30 - character_st.chr_depth } # the map changed under the body: nothing about the old water may survive export function char_map_changed(character_st: mut CharacterState) -> void { character_st.chr_swim = false character_st.chr_dive = false character_st.chr_depth = 0.0 character_st.chr_water = CharacterGround.water(character_st.chr_x, character_st.chr_z) } export function char_face(character_st: mut CharacterState, yaw: float) -> void { character_st.chr_yaw = yaw } export function char_allow_run(character_st: mut CharacterState, on: bool) -> void { character_st.chr_can_run = on } export function char_look(character_st: mut CharacterState, yaw: float, pitch: float) -> void { character_st.chr_cam_yaw = yaw character_st.chr_cam_pitch = pitch } export function char_look_pitch(character_st: mut CharacterState, pitch: float) -> void { character_st.chr_cam_pitch = pitch } export function char_orbit(character_st: mut CharacterState, dist: float) -> void { character_st.chr_cam_dist = Math.clamp(dist, 1.8, 9.0) } export function char_lock_orbit(character_st: mut CharacterState, on: bool) -> void { character_st.chr_lock = on } export function char_set_fps(character_st: mut CharacterState, on: bool) -> void { character_st.chr_fps = on } # the eyes or the shoulder; refused while sitting or carried, and the answer says which export function char_fps_toggle(character_st: mut CharacterState) -> int { if not character_st.chr_fps and not chr_eyes_allowed(character_st) { if character_st.chr_sit { return CHAR_EYES_SITTING } return CHAR_EYES_RIDING } character_st.chr_fps = not character_st.chr_fps if character_st.chr_fps { return CHAR_EYES_ON } return CHAR_EYES_OFF } # something to ride: getting on, being carried, and stepping off onto a spot char_safe_spot found export function char_board(character_st: mut CharacterState, x: float, z: float, yaw: float) -> void { character_st.chr_sit = false character_st.chr_x = x character_st.chr_z = z character_st.chr_yaw = yaw character_st.chr_speed = 0.0 character_st.chr_move = 0.0 character_st.chr_run = 0.0 } export function char_ride_at(character_st: mut CharacterState, x: float, y: float, z: float, yaw: float, speed: float) -> void { character_st.chr_x = x character_st.chr_y = y character_st.chr_z = z character_st.chr_yaw = yaw character_st.chr_speed = speed } export function char_step_off(character_st: mut CharacterState, x: float, z: float) -> void { character_st.chr_x = x character_st.chr_z = z character_st.chr_y = CharacterGround.height(x, z) } # knocked off its feet at (vx, vz) across and `up` upward (a bear's shove): the walker carries it, # so it lands wherever the world lets it - never inside a trunk. Not while swimming or riding. export function char_knock(character_st: mut CharacterState, vx: float, vz: float, up: float) -> void { if character_st.chr_swim or CharacterBody.riding() { return } character_st.chr_sit = false character_st.chr_air = true character_st.chr_air_vx = vx character_st.chr_air_vz = vz character_st.chr_knock = up }