From 4d9ff3a3b1e7d57402b8d5f1b2d14faa6d67934c Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 25 Mar 2022 23:46:37 -0700 Subject: [PATCH] Added a bunch of camera functions to Lua --- autogen/convert_constants.py | 3 +- autogen/convert_functions.py | 2 +- autogen/extract_functions.py | 18 +- autogen/lua_definitions/functions.lua | 570 ++++++++ docs/lua/functions.md | 1730 ++++++++++++++++++++++++ src/pc/lua/smlua_functions_autogen.c | 1736 +++++++++++++++++++++++++ 6 files changed, 4055 insertions(+), 4 deletions(-) diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 079cb4d2..f3b77912 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -149,7 +149,8 @@ def process_define(filename, line): continue p = re.sub(r'0x[a-fA-F0-9]+', '', p) if re.search('[a-z]', p) != None: - print('UNRECOGNIZED DEFINE: ' + line) + if 'gCurrentObject' not in line: + print('UNRECOGNIZED DEFINE: ' + line) return None if not allowed_identifier(filename, ident): diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 56075a53..687e5618 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -49,7 +49,6 @@ in_files = [ override_allowed_functions = { "src/audio/external.h": [ " play_", "fade" ], - "src/game/camera.h": [ "set_.*camera_.*shake", "set_camera_mode" ], "src/game/rumble_init.c": [ "queue_rumble_", "reset_rumble_timers" ], "src/pc/djui/djui_popup.h" : [ "create" ], "src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags" ], @@ -78,6 +77,7 @@ override_disallowed_functions = { "src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ], "src/game/spawn_sound.c": [ "spawner" ], "src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ], + "src/game/camera.h": [ "update_camera", "init_camera", "stub_camera", "^reset_camera" ], } lua_function_params = { diff --git a/autogen/extract_functions.py b/autogen/extract_functions.py index a67795fd..a78c753e 100644 --- a/autogen/extract_functions.py +++ b/autogen/extract_functions.py @@ -13,16 +13,27 @@ replacements = { 'BAD_RETURN(u64)': 'void', 'BAD_RETURN(f32)': 'void', 'BAD_RETURN(f64)': 'void', + } def extract_functions(filename): with open(filename) as file: lines = file.readlines() - # deal with certain ifdefs + # combine lines txt = '' - gobbling = False for line in lines: + txt += line + + # convert multi-line stuff + txt = txt.replace('\r', ' ') + txt = txt.replace('\\\n', ' ') + + # deal with certain ifdefs + gobbling = False + tmp = txt + txt = '' + for line in tmp.splitlines(): if line.strip() == '#ifdef AVOID_UB': gobbling = True if line.strip() == '#else': @@ -32,6 +43,7 @@ def extract_functions(filename): if not gobbling: txt += line + '\n' + # do string replacements for replacement in replacements: txt = txt.replace(replacement, replacements[replacement]) @@ -43,6 +55,8 @@ def extract_functions(filename): if line.strip().startswith('#') or in_directive: in_directive = line.strip().endswith('\\') continue + if line.strip().startswith('typedef'): + continue if '//' in line: line = line.split('//', 1)[0] txt += line diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index faf67a95..84799bc6 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -12,6 +12,422 @@ function get_id_from_behavior(behavior) -- ... end +--- @param c Camera +--- @param goal number +--- @param inc number +--- @return nil +function approach_camera_height(c, goal, inc) + -- ... +end + +--- @param current number +--- @param target number +--- @param multiplier number +--- @return number +function approach_f32_asymptotic(current, target, multiplier) + -- ... +end + +--- @param current Pointer_number +--- @param target number +--- @param multiplier number +--- @return integer +function approach_f32_asymptotic_bool(current, target, multiplier) + -- ... +end + +--- @param current integer +--- @param target integer +--- @param divisor integer +--- @return integer +function approach_s16_asymptotic(current, target, divisor) + -- ... +end + +--- @param current Pointer_integer +--- @param target integer +--- @param divisor integer +--- @return integer +function approach_s16_asymptotic_bool(current, target, divisor) + -- ... +end + +--- @param current Vec3f +--- @param target Vec3f +--- @param xMul number +--- @param yMul number +--- @param zMul number +--- @return nil +function approach_vec3f_asymptotic(current, target, xMul, yMul, zMul) + -- ... +end + +--- @param a Vec3f +--- @param b Vec3f +--- @return number +function calc_abs_dist(a, b) + -- ... +end + +--- @param a Vec3f +--- @param b Vec3f +--- @return number +function calc_hor_dist(a, b) + -- ... +end + +--- @param from Vec3f +--- @param to Vec3f +--- @param pitch Pointer_integer +--- @param yaw Pointer_integer +--- @return nil +function calculate_angles(from, to, pitch, yaw) + -- ... +end + +--- @param from Vec3f +--- @param to Vec3f +--- @return integer +function calculate_pitch(from, to) + -- ... +end + +--- @param from Vec3f +--- @param to Vec3f +--- @return integer +function calculate_yaw(from, to) + -- ... +end + +--- @param angle integer +--- @return integer +function cam_select_alt_mode(angle) + -- ... +end + +--- @param value number +--- @param target number +--- @param increment number +--- @return number +function camera_approach_f32_symmetric(value, target, increment) + -- ... +end + +--- @param current Pointer_number +--- @param target number +--- @param increment number +--- @return integer +function camera_approach_f32_symmetric_bool(current, target, increment) + -- ... +end + +--- @param current Pointer_integer +--- @param target integer +--- @param increment integer +--- @return integer +function camera_approach_s16_symmetric_bool(current, target, increment) + -- ... +end + +--- @param c Camera +--- @return integer +function camera_course_processing(c) + -- ... +end + +--- @param from Vec3f +--- @param to Vec3f +--- @param maxPitch integer +--- @param minPitch integer +--- @return integer +function clamp_pitch(from, to, maxPitch, minPitch) + -- ... +end + +--- @param pos Vec3f +--- @param origin Vec3f +--- @param xMax number +--- @param xMin number +--- @param zMax number +--- @param zMin number +--- @return integer +function clamp_positions_and_find_yaw(pos, origin, xMax, xMin, zMax, zMin) + -- ... +end + +--- @param pos Vec3f +--- @param offsetY number +--- @param radius number +--- @return integer +function collide_with_walls(pos, offsetY, radius) + -- ... +end + +--- @param cutscene integer +--- @param o Object +--- @return integer +function cutscene_object(cutscene, o) + -- ... +end + +--- @param cutscene integer +--- @param o Object +--- @param dialogID integer +--- @return integer +function cutscene_object_with_dialog(cutscene, o, dialogID) + -- ... +end + +--- @param cutscene integer +--- @param o Object +--- @return integer +function cutscene_object_without_dialog(cutscene, o) + -- ... +end + +--- @param preset integer +--- @return nil +function cutscene_set_fov_shake_preset(preset) + -- ... +end + +--- @param obj integer +--- @param frame integer +--- @return integer +function cutscene_spawn_obj(obj, frame) + -- ... +end + +--- @param currentState integer +--- @param buttonsPressed integer +--- @param buttonsDown integer +--- @return integer +function find_c_buttons_pressed(currentState, buttonsPressed, buttonsDown) + -- ... +end + +--- @param pg PlayerGeometry +--- @return nil +function find_mario_floor_and_ceil(pg) + -- ... +end + +--- @param c Camera +--- @return integer +function get_cutscene_from_mario_status(c) + -- ... +end + +--- @param c Camera +--- @return nil +function handle_c_button_movement(c) + -- ... +end + +--- @param from Vec3f +--- @param to Vec3f +--- @param surf Surface +--- @param range integer +--- @param surfType integer +--- @return integer +function is_range_behind_surface(from, to, surf, range, surfType) + -- ... +end + +--- @param posX number +--- @param posY number +--- @param posZ number +--- @return integer +function is_within_100_units_of_mario(posX, posY, posZ) + -- ... +end + +--- @param c Camera +--- @return nil +function move_mario_head_c_up(c) + -- ... +end + +--- @param p Vec3f +--- @param spline[] CutsceneSplinePoint +--- @param splineSegment Pointer_integer +--- @param progress Pointer_number +--- @return integer +function move_point_along_spline(p, spline[], splineSegment, progress) + -- ... +end + +--- @param newPos Vec3f +--- @param newFoc Vec3f +--- @param curPos Vec3f +--- @param curFoc Vec3f +--- @param oldPos Vec3f +--- @param oldFoc Vec3f +--- @param yaw integer +--- @return integer +function next_lakitu_state(newPos, newFoc, curPos, curFoc, oldPos, oldFoc, yaw) + -- ... +end + +--- @param o Object +--- @param point Vec3f +--- @param pitchOff integer +--- @param yawOff integer +--- @param pitchDiv integer +--- @param yawDiv integer +--- @return nil +function obj_rotate_towards_point(o, point, pitchOff, yawOff, pitchDiv, yawDiv) + -- ... +end + +--- @param dst Vec3f +--- @param o Object +--- @return nil +function object_pos_to_vec3f(dst, o) + -- ... +end + +--- @param dst Vec3f +--- @param from Vec3f +--- @param to Vec3f +--- @param rotation Vec3s +--- @return nil +function offset_rotated(dst, from, to, rotation) + -- ... +end + +--- @param c Camera +--- @param areaYaw integer +--- @return integer +function offset_yaw_outward_radial(c, areaYaw) + -- ... +end + +--- @return nil +function play_camera_buzz_if_c_sideways() + -- ... +end + +--- @return nil +function play_camera_buzz_if_cbutton() + -- ... +end + +--- @return nil +function play_camera_buzz_if_cdown() + -- ... +end + +--- @param c Camera +--- @return nil +function play_cutscene(c) + -- ... +end + +--- @return nil +function play_sound_button_change_blocked() + -- ... +end + +--- @return nil +function play_sound_cbutton_down() + -- ... +end + +--- @return nil +function play_sound_cbutton_side() + -- ... +end + +--- @return nil +function play_sound_cbutton_up() + -- ... +end + +--- @return nil +function play_sound_if_cam_switched_to_lakitu_or_mario() + -- ... +end + +--- @return nil +function play_sound_rbutton_changed() + -- ... +end + +--- @param c Camera +--- @param unused number +--- @return integer +function radial_camera_input(c, unused) + -- ... +end + +--- @param dst Vec3s +--- @param xRange integer +--- @param yRange integer +--- @param zRange integer +--- @return nil +function random_vec3s(dst, xRange, yRange, zRange) + -- ... +end + +--- @param c Camera +--- @return nil +function reset_camera(c) + -- ... +end + +--- @param pos Vec3f +--- @param lastGood Vec3f +--- @return nil +function resolve_geometry_collisions(pos, lastGood) + -- ... +end + +--- @param c Camera +--- @param cPos Vec3f +--- @param avoidYaw Pointer_integer +--- @param yawRange integer +--- @return integer +function rotate_camera_around_walls(c, cPos, avoidYaw, yawRange) + -- ... +end + +--- @param dst Vec3f +--- @param src Vec3f +--- @param yaw integer +--- @return nil +function rotate_in_xz(dst, src, yaw) + -- ... +end + +--- @param dst Vec3f +--- @param src Vec3f +--- @param pitch integer +--- @return nil +function rotate_in_yz(dst, src, pitch) + -- ... +end + +--- @param dest Vec3f +--- @param from Vec3f +--- @param to Vec3f +--- @param scale number +--- @return nil +function scale_along_line(dest, from, to, scale) + -- ... +end + +--- @return nil +function select_mario_cam_mode() + -- ... +end + +--- @param mode integer +--- @return integer +function set_cam_angle(mode) + -- ... +end + --- @param c Camera --- @param mode integer --- @param frames integer @@ -74,6 +490,160 @@ function set_environmental_camera_shake(shake) -- ... end +--- @param preset integer +--- @return nil +function set_fixed_cam_axis_sa_lobby(preset) + -- ... +end + +--- @param func integer +--- @return nil +function set_fov_function(func) + -- ... +end + +--- @param amplitude integer +--- @param decay integer +--- @param shakeSpeed integer +--- @return nil +function set_fov_shake(amplitude, decay, shakeSpeed) + -- ... +end + +--- @param preset integer +--- @param posX number +--- @param posY number +--- @param posZ number +--- @return nil +function set_fov_shake_from_point_preset(preset, posX, posY, posZ) + -- ... +end + +--- @param mode integer +--- @return nil +function set_handheld_shake(mode) + -- ... +end + +--- @param dst Pointer_number +--- @param goal number +--- @param scale number +--- @return integer +function set_or_approach_f32_asymptotic(dst, goal, scale) + -- ... +end + +--- @param current Pointer_integer +--- @param target integer +--- @param increment integer +--- @return integer +function set_or_approach_s16_symmetric(current, target, increment) + -- ... +end + +--- @param dst Vec3f +--- @param goal Vec3f +--- @param xMul number +--- @param yMul number +--- @param zMul number +--- @return nil +function set_or_approach_vec3f_asymptotic(dst, goal, xMul, yMul, zMul) + -- ... +end + +--- @param mag integer +--- @param decay integer +--- @param inc integer +--- @param maxDist number +--- @param posX number +--- @param posY number +--- @param posZ number +--- @return nil +function set_pitch_shake_from_point(mag, decay, inc, maxDist, posX, posY, posZ) + -- ... +end + +--- @param pos Vec3f +--- @param focus Vec3f +--- @return nil +function shake_camera_handheld(pos, focus) + -- ... +end + +--- @param pos Vec3f +--- @param focus Vec3f +--- @return nil +function shake_camera_pitch(pos, focus) + -- ... +end + +--- @param roll Pointer_integer +--- @return nil +function shake_camera_roll(roll) + -- ... +end + +--- @param pos Vec3f +--- @param focus Vec3f +--- @return nil +function shake_camera_yaw(pos, focus) + -- ... +end + +--- @param c Camera +--- @return nil +function soft_reset_camera(c) + -- ... +end + +--- @param c Camera +--- @param cutscene integer +--- @return nil +function start_cutscene(c, cutscene) + -- ... +end + +--- @param cutscene integer +--- @return integer +function start_object_cutscene_without_focus(cutscene) + -- ... +end + +--- @param c Camera +--- @param frames integer +--- @return nil +function transition_next_state(c, frames) + -- ... +end + +--- @param trigger integer +--- @return integer +function trigger_cutscene_dialog(trigger) + -- ... +end + +--- @param dst Vec3f +--- @param src Vec3f +--- @return nil +function vec3f_sub(dst, src) + -- ... +end + +--- @param o Object +--- @param src Vec3f +--- @return nil +function vec3f_to_object_pos(o, src) + -- ... +end + +--- @param displacementX number +--- @param displacementY number +--- @param displacementZ number +--- @return nil +function warp_camera(displacementX, displacementY, displacementZ) + -- ... +end + --- @param m MarioState --- @return Character function get_character(m) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index e5ead5d2..7ea37196 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -16,6 +16,63 @@
- camera.h + - [approach_camera_height](#approach_camera_height) + - [approach_f32_asymptotic](#approach_f32_asymptotic) + - [approach_f32_asymptotic_bool](#approach_f32_asymptotic_bool) + - [approach_s16_asymptotic](#approach_s16_asymptotic) + - [approach_s16_asymptotic_bool](#approach_s16_asymptotic_bool) + - [approach_vec3f_asymptotic](#approach_vec3f_asymptotic) + - [calc_abs_dist](#calc_abs_dist) + - [calc_hor_dist](#calc_hor_dist) + - [calculate_angles](#calculate_angles) + - [calculate_pitch](#calculate_pitch) + - [calculate_yaw](#calculate_yaw) + - [cam_select_alt_mode](#cam_select_alt_mode) + - [camera_approach_f32_symmetric](#camera_approach_f32_symmetric) + - [camera_approach_f32_symmetric_bool](#camera_approach_f32_symmetric_bool) + - [camera_approach_s16_symmetric_bool](#camera_approach_s16_symmetric_bool) + - [camera_course_processing](#camera_course_processing) + - [clamp_pitch](#clamp_pitch) + - [clamp_positions_and_find_yaw](#clamp_positions_and_find_yaw) + - [collide_with_walls](#collide_with_walls) + - [cutscene_object](#cutscene_object) + - [cutscene_object_with_dialog](#cutscene_object_with_dialog) + - [cutscene_object_without_dialog](#cutscene_object_without_dialog) + - [cutscene_set_fov_shake_preset](#cutscene_set_fov_shake_preset) + - [cutscene_spawn_obj](#cutscene_spawn_obj) + - [find_c_buttons_pressed](#find_c_buttons_pressed) + - [find_mario_floor_and_ceil](#find_mario_floor_and_ceil) + - [get_cutscene_from_mario_status](#get_cutscene_from_mario_status) + - [handle_c_button_movement](#handle_c_button_movement) + - [is_range_behind_surface](#is_range_behind_surface) + - [is_within_100_units_of_mario](#is_within_100_units_of_mario) + - [move_mario_head_c_up](#move_mario_head_c_up) + - [move_point_along_spline](#move_point_along_spline) + - [next_lakitu_state](#next_lakitu_state) + - [obj_rotate_towards_point](#obj_rotate_towards_point) + - [object_pos_to_vec3f](#object_pos_to_vec3f) + - [offset_rotated](#offset_rotated) + - [offset_yaw_outward_radial](#offset_yaw_outward_radial) + - [play_camera_buzz_if_c_sideways](#play_camera_buzz_if_c_sideways) + - [play_camera_buzz_if_cbutton](#play_camera_buzz_if_cbutton) + - [play_camera_buzz_if_cdown](#play_camera_buzz_if_cdown) + - [play_cutscene](#play_cutscene) + - [play_sound_button_change_blocked](#play_sound_button_change_blocked) + - [play_sound_cbutton_down](#play_sound_cbutton_down) + - [play_sound_cbutton_side](#play_sound_cbutton_side) + - [play_sound_cbutton_up](#play_sound_cbutton_up) + - [play_sound_if_cam_switched_to_lakitu_or_mario](#play_sound_if_cam_switched_to_lakitu_or_mario) + - [play_sound_rbutton_changed](#play_sound_rbutton_changed) + - [radial_camera_input](#radial_camera_input) + - [random_vec3s](#random_vec3s) + - [reset_camera](#reset_camera) + - [resolve_geometry_collisions](#resolve_geometry_collisions) + - [rotate_camera_around_walls](#rotate_camera_around_walls) + - [rotate_in_xz](#rotate_in_xz) + - [rotate_in_yz](#rotate_in_yz) + - [scale_along_line](#scale_along_line) + - [select_mario_cam_mode](#select_mario_cam_mode) + - [set_cam_angle](#set_cam_angle) - [set_camera_mode](#set_camera_mode) - [set_camera_mode_fixed](#set_camera_mode_fixed) - [set_camera_pitch_shake](#set_camera_pitch_shake) @@ -24,6 +81,27 @@ - [set_camera_shake_from_point](#set_camera_shake_from_point) - [set_camera_yaw_shake](#set_camera_yaw_shake) - [set_environmental_camera_shake](#set_environmental_camera_shake) + - [set_fixed_cam_axis_sa_lobby](#set_fixed_cam_axis_sa_lobby) + - [set_fov_function](#set_fov_function) + - [set_fov_shake](#set_fov_shake) + - [set_fov_shake_from_point_preset](#set_fov_shake_from_point_preset) + - [set_handheld_shake](#set_handheld_shake) + - [set_or_approach_f32_asymptotic](#set_or_approach_f32_asymptotic) + - [set_or_approach_s16_symmetric](#set_or_approach_s16_symmetric) + - [set_or_approach_vec3f_asymptotic](#set_or_approach_vec3f_asymptotic) + - [set_pitch_shake_from_point](#set_pitch_shake_from_point) + - [shake_camera_handheld](#shake_camera_handheld) + - [shake_camera_pitch](#shake_camera_pitch) + - [shake_camera_roll](#shake_camera_roll) + - [shake_camera_yaw](#shake_camera_yaw) + - [soft_reset_camera](#soft_reset_camera) + - [start_cutscene](#start_cutscene) + - [start_object_cutscene_without_focus](#start_object_cutscene_without_focus) + - [transition_next_state](#transition_next_state) + - [trigger_cutscene_dialog](#trigger_cutscene_dialog) + - [vec3f_sub](#vec3f_sub) + - [vec3f_to_object_pos](#vec3f_to_object_pos) + - [warp_camera](#warp_camera)
@@ -851,6 +929,1210 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
+## [approach_camera_height](#approach_camera_height) + +### Lua Example +`approach_camera_height(c, goal, inc)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | +| goal | `number` | +| inc | `number` | + +### Returns +- None + +### C Prototype +`void approach_camera_height(struct Camera *c, f32 goal, f32 inc);` + +[:arrow_up_small:](#) + +
+ +## [approach_f32_asymptotic](#approach_f32_asymptotic) + +### Lua Example +`local numberValue = approach_f32_asymptotic(current, target, multiplier)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `number` | +| target | `number` | +| multiplier | `number` | + +### Returns +- `number` + +### C Prototype +`f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier);` + +[:arrow_up_small:](#) + +
+ +## [approach_f32_asymptotic_bool](#approach_f32_asymptotic_bool) + +### Lua Example +`local integerValue = approach_f32_asymptotic_bool(current, target, multiplier)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `Pointer` <`number`> | +| target | `number` | +| multiplier | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier);` + +[:arrow_up_small:](#) + +
+ +## [approach_s16_asymptotic](#approach_s16_asymptotic) + +### Lua Example +`local integerValue = approach_s16_asymptotic(current, target, divisor)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `integer` | +| target | `integer` | +| divisor | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor);` + +[:arrow_up_small:](#) + +
+ +## [approach_s16_asymptotic_bool](#approach_s16_asymptotic_bool) + +### Lua Example +`local integerValue = approach_s16_asymptotic_bool(current, target, divisor)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `Pointer` <`integer`> | +| target | `integer` | +| divisor | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor);` + +[:arrow_up_small:](#) + +
+ +## [approach_vec3f_asymptotic](#approach_vec3f_asymptotic) + +### Lua Example +`approach_vec3f_asymptotic(current, target, xMul, yMul, zMul)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | [Vec3f](structs.md#Vec3f) | +| target | [Vec3f](structs.md#Vec3f) | +| xMul | `number` | +| yMul | `number` | +| zMul | `number` | + +### Returns +- None + +### C Prototype +`void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul);` + +[:arrow_up_small:](#) + +
+ +## [calc_abs_dist](#calc_abs_dist) + +### Lua Example +`local numberValue = calc_abs_dist(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | [Vec3f](structs.md#Vec3f) | +| b | [Vec3f](structs.md#Vec3f) | + +### Returns +- `number` + +### C Prototype +`f32 calc_abs_dist(Vec3f a, Vec3f b);` + +[:arrow_up_small:](#) + +
+ +## [calc_hor_dist](#calc_hor_dist) + +### Lua Example +`local numberValue = calc_hor_dist(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | [Vec3f](structs.md#Vec3f) | +| b | [Vec3f](structs.md#Vec3f) | + +### Returns +- `number` + +### C Prototype +`f32 calc_hor_dist(Vec3f a, Vec3f b);` + +[:arrow_up_small:](#) + +
+ +## [calculate_angles](#calculate_angles) + +### Lua Example +`calculate_angles(from, to, pitch, yaw)` + +### Parameters +| Field | Type | +| ----- | ---- | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | +| pitch | `Pointer` <`integer`> | +| yaw | `Pointer` <`integer`> | + +### Returns +- None + +### C Prototype +`void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw);` + +[:arrow_up_small:](#) + +
+ +## [calculate_pitch](#calculate_pitch) + +### Lua Example +`local integerValue = calculate_pitch(from, to)` + +### Parameters +| Field | Type | +| ----- | ---- | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | + +### Returns +- `integer` + +### C Prototype +`s16 calculate_pitch(Vec3f from, Vec3f to);` + +[:arrow_up_small:](#) + +
+ +## [calculate_yaw](#calculate_yaw) + +### Lua Example +`local integerValue = calculate_yaw(from, to)` + +### Parameters +| Field | Type | +| ----- | ---- | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | + +### Returns +- `integer` + +### C Prototype +`s16 calculate_yaw(Vec3f from, Vec3f to);` + +[:arrow_up_small:](#) + +
+ +## [cam_select_alt_mode](#cam_select_alt_mode) + +### Lua Example +`local integerValue = cam_select_alt_mode(angle)` + +### Parameters +| Field | Type | +| ----- | ---- | +| angle | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 cam_select_alt_mode(s32 angle);` + +[:arrow_up_small:](#) + +
+ +## [camera_approach_f32_symmetric](#camera_approach_f32_symmetric) + +### Lua Example +`local numberValue = camera_approach_f32_symmetric(value, target, increment)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `number` | +| target | `number` | +| increment | `number` | + +### Returns +- `number` + +### C Prototype +`f32 camera_approach_f32_symmetric(f32 value, f32 target, f32 increment);` + +[:arrow_up_small:](#) + +
+ +## [camera_approach_f32_symmetric_bool](#camera_approach_f32_symmetric_bool) + +### Lua Example +`local integerValue = camera_approach_f32_symmetric_bool(current, target, increment)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `Pointer` <`number`> | +| target | `number` | +| increment | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 camera_approach_f32_symmetric_bool(f32 *current, f32 target, f32 increment);` + +[:arrow_up_small:](#) + +
+ +## [camera_approach_s16_symmetric_bool](#camera_approach_s16_symmetric_bool) + +### Lua Example +`local integerValue = camera_approach_s16_symmetric_bool(current, target, increment)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `Pointer` <`integer`> | +| target | `integer` | +| increment | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 camera_approach_s16_symmetric_bool(s16 *current, s16 target, s16 increment);` + +[:arrow_up_small:](#) + +
+ +## [camera_course_processing](#camera_course_processing) + +### Lua Example +`local integerValue = camera_course_processing(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- `integer` + +### C Prototype +`s16 camera_course_processing(struct Camera *c);` + +[:arrow_up_small:](#) + +
+ +## [clamp_pitch](#clamp_pitch) + +### Lua Example +`local integerValue = clamp_pitch(from, to, maxPitch, minPitch)` + +### Parameters +| Field | Type | +| ----- | ---- | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | +| maxPitch | `integer` | +| minPitch | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch);` + +[:arrow_up_small:](#) + +
+ +## [clamp_positions_and_find_yaw](#clamp_positions_and_find_yaw) + +### Lua Example +`local integerValue = clamp_positions_and_find_yaw(pos, origin, xMax, xMin, zMax, zMin)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pos | [Vec3f](structs.md#Vec3f) | +| origin | [Vec3f](structs.md#Vec3f) | +| xMax | `number` | +| xMin | `number` | +| zMax | `number` | +| zMin | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin);` + +[:arrow_up_small:](#) + +
+ +## [collide_with_walls](#collide_with_walls) + +### Lua Example +`local integerValue = collide_with_walls(pos, offsetY, radius)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pos | [Vec3f](structs.md#Vec3f) | +| offsetY | `number` | +| radius | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius);` + +[:arrow_up_small:](#) + +
+ +## [cutscene_object](#cutscene_object) + +### Lua Example +`local integerValue = cutscene_object(cutscene, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cutscene | `integer` | +| o | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`s16 cutscene_object(u8 cutscene, struct Object *o);` + +[:arrow_up_small:](#) + +
+ +## [cutscene_object_with_dialog](#cutscene_object_with_dialog) + +### Lua Example +`local integerValue = cutscene_object_with_dialog(cutscene, o, dialogID)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cutscene | `integer` | +| o | [Object](structs.md#Object) | +| dialogID | `integer` | + +### Returns +- `integer` + +### C Prototype +`s16 cutscene_object_with_dialog(u8 cutscene, struct Object *o, s16 dialogID);` + +[:arrow_up_small:](#) + +
+ +## [cutscene_object_without_dialog](#cutscene_object_without_dialog) + +### Lua Example +`local integerValue = cutscene_object_without_dialog(cutscene, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cutscene | `integer` | +| o | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`s16 cutscene_object_without_dialog(u8 cutscene, struct Object *o);` + +[:arrow_up_small:](#) + +
+ +## [cutscene_set_fov_shake_preset](#cutscene_set_fov_shake_preset) + +### Lua Example +`cutscene_set_fov_shake_preset(preset)` + +### Parameters +| Field | Type | +| ----- | ---- | +| preset | `integer` | + +### Returns +- None + +### C Prototype +`void cutscene_set_fov_shake_preset(u8 preset);` + +[:arrow_up_small:](#) + +
+ +## [cutscene_spawn_obj](#cutscene_spawn_obj) + +### Lua Example +`local integerValue = cutscene_spawn_obj(obj, frame)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | `integer` | +| frame | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 cutscene_spawn_obj(u32 obj, s16 frame);` + +[:arrow_up_small:](#) + +
+ +## [find_c_buttons_pressed](#find_c_buttons_pressed) + +### Lua Example +`local integerValue = find_c_buttons_pressed(currentState, buttonsPressed, buttonsDown)` + +### Parameters +| Field | Type | +| ----- | ---- | +| currentState | `integer` | +| buttonsPressed | `integer` | +| buttonsDown | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 find_c_buttons_pressed(u16 currentState, u16 buttonsPressed, u16 buttonsDown);` + +[:arrow_up_small:](#) + +
+ +## [find_mario_floor_and_ceil](#find_mario_floor_and_ceil) + +### Lua Example +`find_mario_floor_and_ceil(pg)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pg | [PlayerGeometry](structs.md#PlayerGeometry) | + +### Returns +- None + +### C Prototype +`void find_mario_floor_and_ceil(struct PlayerGeometry *pg);` + +[:arrow_up_small:](#) + +
+ +## [get_cutscene_from_mario_status](#get_cutscene_from_mario_status) + +### Lua Example +`local integerValue = get_cutscene_from_mario_status(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- `integer` + +### C Prototype +`u8 get_cutscene_from_mario_status(struct Camera *c);` + +[:arrow_up_small:](#) + +
+ +## [handle_c_button_movement](#handle_c_button_movement) + +### Lua Example +`handle_c_button_movement(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- None + +### C Prototype +`void handle_c_button_movement(struct Camera *c);` + +[:arrow_up_small:](#) + +
+ +## [is_range_behind_surface](#is_range_behind_surface) + +### Lua Example +`local integerValue = is_range_behind_surface(from, to, surf, range, surfType)` + +### Parameters +| Field | Type | +| ----- | ---- | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | +| surf | [Surface](structs.md#Surface) | +| range | `integer` | +| surfType | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 is_range_behind_surface(Vec3f from, Vec3f to, struct Surface *surf, s16 range, s16 surfType);` + +[:arrow_up_small:](#) + +
+ +## [is_within_100_units_of_mario](#is_within_100_units_of_mario) + +### Lua Example +`local integerValue = is_within_100_units_of_mario(posX, posY, posZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| posX | `number` | +| posY | `number` | +| posZ | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 is_within_100_units_of_mario(f32 posX, f32 posY, f32 posZ);` + +[:arrow_up_small:](#) + +
+ +## [move_mario_head_c_up](#move_mario_head_c_up) + +### Lua Example +`move_mario_head_c_up(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- None + +### C Prototype +`void move_mario_head_c_up(UNUSED struct Camera *c);` + +[:arrow_up_small:](#) + +
+ +## [move_point_along_spline](#move_point_along_spline) + +### Lua Example +`local integerValue = move_point_along_spline(p, spline[], splineSegment, progress)` + +### Parameters +| Field | Type | +| ----- | ---- | +| p | [Vec3f](structs.md#Vec3f) | +| spline[] | [CutsceneSplinePoint](structs.md#CutsceneSplinePoint) | +| splineSegment | `Pointer` <`integer`> | +| progress | `Pointer` <`number`> | + +### Returns +- `integer` + +### C Prototype +`s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *splineSegment, f32 *progress);` + +[:arrow_up_small:](#) + +
+ +## [next_lakitu_state](#next_lakitu_state) + +### Lua Example +`local integerValue = next_lakitu_state(newPos, newFoc, curPos, curFoc, oldPos, oldFoc, yaw)` + +### Parameters +| Field | Type | +| ----- | ---- | +| newPos | [Vec3f](structs.md#Vec3f) | +| newFoc | [Vec3f](structs.md#Vec3f) | +| curPos | [Vec3f](structs.md#Vec3f) | +| curFoc | [Vec3f](structs.md#Vec3f) | +| oldPos | [Vec3f](structs.md#Vec3f) | +| oldFoc | [Vec3f](structs.md#Vec3f) | +| yaw | `integer` | + +### Returns +- `integer` + +### C Prototype +`s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw);` + +[:arrow_up_small:](#) + +
+ +## [obj_rotate_towards_point](#obj_rotate_towards_point) + +### Lua Example +`obj_rotate_towards_point(o, point, pitchOff, yawOff, pitchDiv, yawDiv)` + +### Parameters +| Field | Type | +| ----- | ---- | +| o | [Object](structs.md#Object) | +| point | [Vec3f](structs.md#Vec3f) | +| pitchOff | `integer` | +| yawOff | `integer` | +| pitchDiv | `integer` | +| yawDiv | `integer` | + +### Returns +- None + +### C Prototype +`void obj_rotate_towards_point(struct Object *o, Vec3f point, s16 pitchOff, s16 yawOff, s16 pitchDiv, s16 yawDiv);` + +[:arrow_up_small:](#) + +
+ +## [object_pos_to_vec3f](#object_pos_to_vec3f) + +### Lua Example +`object_pos_to_vec3f(dst, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3f](structs.md#Vec3f) | +| o | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void object_pos_to_vec3f(Vec3f dst, struct Object *o);` + +[:arrow_up_small:](#) + +
+ +## [offset_rotated](#offset_rotated) + +### Lua Example +`offset_rotated(dst, from, to, rotation)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3f](structs.md#Vec3f) | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | +| rotation | [Vec3s](structs.md#Vec3s) | + +### Returns +- None + +### C Prototype +`void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation);` + +[:arrow_up_small:](#) + +
+ +## [offset_yaw_outward_radial](#offset_yaw_outward_radial) + +### Lua Example +`local integerValue = offset_yaw_outward_radial(c, areaYaw)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | +| areaYaw | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw);` + +[:arrow_up_small:](#) + +
+ +## [play_camera_buzz_if_c_sideways](#play_camera_buzz_if_c_sideways) + +### Lua Example +`play_camera_buzz_if_c_sideways()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_camera_buzz_if_c_sideways(void);` + +[:arrow_up_small:](#) + +
+ +## [play_camera_buzz_if_cbutton](#play_camera_buzz_if_cbutton) + +### Lua Example +`play_camera_buzz_if_cbutton()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_camera_buzz_if_cbutton(void);` + +[:arrow_up_small:](#) + +
+ +## [play_camera_buzz_if_cdown](#play_camera_buzz_if_cdown) + +### Lua Example +`play_camera_buzz_if_cdown()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_camera_buzz_if_cdown(void);` + +[:arrow_up_small:](#) + +
+ +## [play_cutscene](#play_cutscene) + +### Lua Example +`play_cutscene(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- None + +### C Prototype +`void play_cutscene(struct Camera *c);` + +[:arrow_up_small:](#) + +
+ +## [play_sound_button_change_blocked](#play_sound_button_change_blocked) + +### Lua Example +`play_sound_button_change_blocked()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_sound_button_change_blocked(void);` + +[:arrow_up_small:](#) + +
+ +## [play_sound_cbutton_down](#play_sound_cbutton_down) + +### Lua Example +`play_sound_cbutton_down()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_sound_cbutton_down(void);` + +[:arrow_up_small:](#) + +
+ +## [play_sound_cbutton_side](#play_sound_cbutton_side) + +### Lua Example +`play_sound_cbutton_side()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_sound_cbutton_side(void);` + +[:arrow_up_small:](#) + +
+ +## [play_sound_cbutton_up](#play_sound_cbutton_up) + +### Lua Example +`play_sound_cbutton_up()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_sound_cbutton_up(void);` + +[:arrow_up_small:](#) + +
+ +## [play_sound_if_cam_switched_to_lakitu_or_mario](#play_sound_if_cam_switched_to_lakitu_or_mario) + +### Lua Example +`play_sound_if_cam_switched_to_lakitu_or_mario()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_sound_if_cam_switched_to_lakitu_or_mario(void);` + +[:arrow_up_small:](#) + +
+ +## [play_sound_rbutton_changed](#play_sound_rbutton_changed) + +### Lua Example +`play_sound_rbutton_changed()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void play_sound_rbutton_changed(void);` + +[:arrow_up_small:](#) + +
+ +## [radial_camera_input](#radial_camera_input) + +### Lua Example +`local integerValue = radial_camera_input(c, unused)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | +| unused | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 radial_camera_input(struct Camera *c, UNUSED f32 unused);` + +[:arrow_up_small:](#) + +
+ +## [random_vec3s](#random_vec3s) + +### Lua Example +`random_vec3s(dst, xRange, yRange, zRange)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3s](structs.md#Vec3s) | +| xRange | `integer` | +| yRange | `integer` | +| zRange | `integer` | + +### Returns +- None + +### C Prototype +`void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange);` + +[:arrow_up_small:](#) + +
+ +## [reset_camera](#reset_camera) + +### Lua Example +`reset_camera(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- None + +### C Prototype +`void reset_camera(struct Camera *c);` + +[:arrow_up_small:](#) + +
+ +## [resolve_geometry_collisions](#resolve_geometry_collisions) + +### Lua Example +`resolve_geometry_collisions(pos, lastGood)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pos | [Vec3f](structs.md#Vec3f) | +| lastGood | [Vec3f](structs.md#Vec3f) | + +### Returns +- None + +### C Prototype +`void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood);` + +[:arrow_up_small:](#) + +
+ +## [rotate_camera_around_walls](#rotate_camera_around_walls) + +### Lua Example +`local integerValue = rotate_camera_around_walls(c, cPos, avoidYaw, yawRange)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | +| cPos | [Vec3f](structs.md#Vec3f) | +| avoidYaw | `Pointer` <`integer`> | +| yawRange | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 yawRange);` + +[:arrow_up_small:](#) + +
+ +## [rotate_in_xz](#rotate_in_xz) + +### Lua Example +`rotate_in_xz(dst, src, yaw)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3f](structs.md#Vec3f) | +| src | [Vec3f](structs.md#Vec3f) | +| yaw | `integer` | + +### Returns +- None + +### C Prototype +`void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw);` + +[:arrow_up_small:](#) + +
+ +## [rotate_in_yz](#rotate_in_yz) + +### Lua Example +`rotate_in_yz(dst, src, pitch)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3f](structs.md#Vec3f) | +| src | [Vec3f](structs.md#Vec3f) | +| pitch | `integer` | + +### Returns +- None + +### C Prototype +`void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch);` + +[:arrow_up_small:](#) + +
+ +## [scale_along_line](#scale_along_line) + +### Lua Example +`scale_along_line(dest, from, to, scale)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dest | [Vec3f](structs.md#Vec3f) | +| from | [Vec3f](structs.md#Vec3f) | +| to | [Vec3f](structs.md#Vec3f) | +| scale | `number` | + +### Returns +- None + +### C Prototype +`void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale);` + +[:arrow_up_small:](#) + +
+ +## [select_mario_cam_mode](#select_mario_cam_mode) + +### Lua Example +`select_mario_cam_mode()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void select_mario_cam_mode(void);` + +[:arrow_up_small:](#) + +
+ +## [set_cam_angle](#set_cam_angle) + +### Lua Example +`local integerValue = set_cam_angle(mode)` + +### Parameters +| Field | Type | +| ----- | ---- | +| mode | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 set_cam_angle(s32 mode);` + +[:arrow_up_small:](#) + +
+ ## [set_camera_mode](#set_camera_mode) ### Lua Example @@ -1025,6 +2307,454 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
+## [set_fixed_cam_axis_sa_lobby](#set_fixed_cam_axis_sa_lobby) + +### Lua Example +`set_fixed_cam_axis_sa_lobby(preset)` + +### Parameters +| Field | Type | +| ----- | ---- | +| preset | `integer` | + +### Returns +- None + +### C Prototype +`void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset);` + +[:arrow_up_small:](#) + +
+ +## [set_fov_function](#set_fov_function) + +### Lua Example +`set_fov_function(func)` + +### Parameters +| Field | Type | +| ----- | ---- | +| func | `integer` | + +### Returns +- None + +### C Prototype +`void set_fov_function(u8 func);` + +[:arrow_up_small:](#) + +
+ +## [set_fov_shake](#set_fov_shake) + +### Lua Example +`set_fov_shake(amplitude, decay, shakeSpeed)` + +### Parameters +| Field | Type | +| ----- | ---- | +| amplitude | `integer` | +| decay | `integer` | +| shakeSpeed | `integer` | + +### Returns +- None + +### C Prototype +`void set_fov_shake(s16 amplitude, s16 decay, s16 shakeSpeed);` + +[:arrow_up_small:](#) + +
+ +## [set_fov_shake_from_point_preset](#set_fov_shake_from_point_preset) + +### Lua Example +`set_fov_shake_from_point_preset(preset, posX, posY, posZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| preset | `integer` | +| posX | `number` | +| posY | `number` | +| posZ | `number` | + +### Returns +- None + +### C Prototype +`void set_fov_shake_from_point_preset(u8 preset, f32 posX, f32 posY, f32 posZ);` + +[:arrow_up_small:](#) + +
+ +## [set_handheld_shake](#set_handheld_shake) + +### Lua Example +`set_handheld_shake(mode)` + +### Parameters +| Field | Type | +| ----- | ---- | +| mode | `integer` | + +### Returns +- None + +### C Prototype +`void set_handheld_shake(u8 mode);` + +[:arrow_up_small:](#) + +
+ +## [set_or_approach_f32_asymptotic](#set_or_approach_f32_asymptotic) + +### Lua Example +`local integerValue = set_or_approach_f32_asymptotic(dst, goal, scale)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | `Pointer` <`number`> | +| goal | `number` | +| scale | `number` | + +### Returns +- `integer` + +### C Prototype +`s32 set_or_approach_f32_asymptotic(f32 *dst, f32 goal, f32 scale);` + +[:arrow_up_small:](#) + +
+ +## [set_or_approach_s16_symmetric](#set_or_approach_s16_symmetric) + +### Lua Example +`local integerValue = set_or_approach_s16_symmetric(current, target, increment)` + +### Parameters +| Field | Type | +| ----- | ---- | +| current | `Pointer` <`integer`> | +| target | `integer` | +| increment | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 set_or_approach_s16_symmetric(s16 *current, s16 target, s16 increment);` + +[:arrow_up_small:](#) + +
+ +## [set_or_approach_vec3f_asymptotic](#set_or_approach_vec3f_asymptotic) + +### Lua Example +`set_or_approach_vec3f_asymptotic(dst, goal, xMul, yMul, zMul)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3f](structs.md#Vec3f) | +| goal | [Vec3f](structs.md#Vec3f) | +| xMul | `number` | +| yMul | `number` | +| zMul | `number` | + +### Returns +- None + +### C Prototype +`void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul);` + +[:arrow_up_small:](#) + +
+ +## [set_pitch_shake_from_point](#set_pitch_shake_from_point) + +### Lua Example +`set_pitch_shake_from_point(mag, decay, inc, maxDist, posX, posY, posZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| mag | `integer` | +| decay | `integer` | +| inc | `integer` | +| maxDist | `number` | +| posX | `number` | +| posY | `number` | +| posZ | `number` | + +### Returns +- None + +### C Prototype +`void set_pitch_shake_from_point(s16 mag, s16 decay, s16 inc, f32 maxDist, f32 posX, f32 posY, f32 posZ);` + +[:arrow_up_small:](#) + +
+ +## [shake_camera_handheld](#shake_camera_handheld) + +### Lua Example +`shake_camera_handheld(pos, focus)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pos | [Vec3f](structs.md#Vec3f) | +| focus | [Vec3f](structs.md#Vec3f) | + +### Returns +- None + +### C Prototype +`void shake_camera_handheld(Vec3f pos, Vec3f focus);` + +[:arrow_up_small:](#) + +
+ +## [shake_camera_pitch](#shake_camera_pitch) + +### Lua Example +`shake_camera_pitch(pos, focus)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pos | [Vec3f](structs.md#Vec3f) | +| focus | [Vec3f](structs.md#Vec3f) | + +### Returns +- None + +### C Prototype +`void shake_camera_pitch(Vec3f pos, Vec3f focus);` + +[:arrow_up_small:](#) + +
+ +## [shake_camera_roll](#shake_camera_roll) + +### Lua Example +`shake_camera_roll(roll)` + +### Parameters +| Field | Type | +| ----- | ---- | +| roll | `Pointer` <`integer`> | + +### Returns +- None + +### C Prototype +`void shake_camera_roll(s16 *roll);` + +[:arrow_up_small:](#) + +
+ +## [shake_camera_yaw](#shake_camera_yaw) + +### Lua Example +`shake_camera_yaw(pos, focus)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pos | [Vec3f](structs.md#Vec3f) | +| focus | [Vec3f](structs.md#Vec3f) | + +### Returns +- None + +### C Prototype +`void shake_camera_yaw(Vec3f pos, Vec3f focus);` + +[:arrow_up_small:](#) + +
+ +## [soft_reset_camera](#soft_reset_camera) + +### Lua Example +`soft_reset_camera(c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | + +### Returns +- None + +### C Prototype +`void soft_reset_camera(struct Camera* c);` + +[:arrow_up_small:](#) + +
+ +## [start_cutscene](#start_cutscene) + +### Lua Example +`start_cutscene(c, cutscene)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | +| cutscene | `integer` | + +### Returns +- None + +### C Prototype +`void start_cutscene(struct Camera *c, u8 cutscene);` + +[:arrow_up_small:](#) + +
+ +## [start_object_cutscene_without_focus](#start_object_cutscene_without_focus) + +### Lua Example +`local integerValue = start_object_cutscene_without_focus(cutscene)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cutscene | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 start_object_cutscene_without_focus(u8 cutscene);` + +[:arrow_up_small:](#) + +
+ +## [transition_next_state](#transition_next_state) + +### Lua Example +`transition_next_state(c, frames)` + +### Parameters +| Field | Type | +| ----- | ---- | +| c | [Camera](structs.md#Camera) | +| frames | `integer` | + +### Returns +- None + +### C Prototype +`void transition_next_state(UNUSED struct Camera *c, s16 frames);` + +[:arrow_up_small:](#) + +
+ +## [trigger_cutscene_dialog](#trigger_cutscene_dialog) + +### Lua Example +`local integerValue = trigger_cutscene_dialog(trigger)` + +### Parameters +| Field | Type | +| ----- | ---- | +| trigger | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 trigger_cutscene_dialog(s32 trigger);` + +[:arrow_up_small:](#) + +
+ +## [vec3f_sub](#vec3f_sub) + +### Lua Example +`vec3f_sub(dst, src)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Vec3f](structs.md#Vec3f) | +| src | [Vec3f](structs.md#Vec3f) | + +### Returns +- None + +### C Prototype +`void vec3f_sub(Vec3f dst, Vec3f src);` + +[:arrow_up_small:](#) + +
+ +## [vec3f_to_object_pos](#vec3f_to_object_pos) + +### Lua Example +`vec3f_to_object_pos(o, src)` + +### Parameters +| Field | Type | +| ----- | ---- | +| o | [Object](structs.md#Object) | +| src | [Vec3f](structs.md#Vec3f) | + +### Returns +- None + +### C Prototype +`void vec3f_to_object_pos(struct Object *o, Vec3f src);` + +[:arrow_up_small:](#) + +
+ +## [warp_camera](#warp_camera) + +### Lua Example +`warp_camera(displacementX, displacementY, displacementZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| displacementX | `number` | +| displacementY | `number` | +| displacementZ | `number` | + +### Returns +- None + +### C Prototype +`void warp_camera(f32 displacementX, f32 displacementY, f32 displacementZ);` + +[:arrow_up_small:](#) + +
+ --- # functions from characters.h diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 800d2283..afeb4a40 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -56,6 +56,1264 @@ int smlua_func_get_id_from_behavior(lua_State* L) { // camera.h // ////////////// +int smlua_func_approach_camera_height(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + f32 goal = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 inc = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + approach_camera_height(c, goal, inc); + + return 1; +} + +int smlua_func_approach_f32_asymptotic(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 current = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 target = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 multiplier = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushnumber(L, approach_f32_asymptotic(current, target, multiplier)); + + return 1; +} + +int smlua_func_approach_f32_asymptotic_bool(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 * current = (f32 *)smlua_to_cpointer(L, 1, LVT_F32_P); + if (!gSmLuaConvertSuccess) { return 0; } + f32 target = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 multiplier = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, approach_f32_asymptotic_bool(current, target, multiplier)); + + return 1; +} + +int smlua_func_approach_s16_asymptotic(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s16 current = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 target = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 divisor = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, approach_s16_asymptotic(current, target, divisor)); + + return 1; +} + +int smlua_func_approach_s16_asymptotic_bool(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s16 * current = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + s16 target = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 divisor = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, approach_s16_asymptotic_bool(current, target, divisor)); + + return 1; +} + +int smlua_func_approach_vec3f_asymptotic(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 5)) { return 0; } + + + f32* current = smlua_get_vec3f_from_buffer(); + current[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + current[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + current[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* target = smlua_get_vec3f_from_buffer(); + target[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + target[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + target[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + f32 xMul = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 yMul = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + f32 zMul = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + approach_vec3f_asymptotic(current, target, xMul, yMul, zMul); + + smlua_push_number_field(1, "x", current[0]); + smlua_push_number_field(1, "y", current[1]); + smlua_push_number_field(1, "z", current[2]); + + smlua_push_number_field(2, "x", target[0]); + smlua_push_number_field(2, "y", target[1]); + smlua_push_number_field(2, "z", target[2]); + + return 1; +} + +int smlua_func_calc_abs_dist(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* a = smlua_get_vec3f_from_buffer(); + a[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + a[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + a[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* b = smlua_get_vec3f_from_buffer(); + b[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + b[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + b[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushnumber(L, calc_abs_dist(a, b)); + + smlua_push_number_field(1, "x", a[0]); + smlua_push_number_field(1, "y", a[1]); + smlua_push_number_field(1, "z", a[2]); + + smlua_push_number_field(2, "x", b[0]); + smlua_push_number_field(2, "y", b[1]); + smlua_push_number_field(2, "z", b[2]); + + return 1; +} + +int smlua_func_calc_hor_dist(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* a = smlua_get_vec3f_from_buffer(); + a[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + a[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + a[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* b = smlua_get_vec3f_from_buffer(); + b[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + b[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + b[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushnumber(L, calc_hor_dist(a, b)); + + smlua_push_number_field(1, "x", a[0]); + smlua_push_number_field(1, "y", a[1]); + smlua_push_number_field(1, "z", a[2]); + + smlua_push_number_field(2, "x", b[0]); + smlua_push_number_field(2, "y", b[1]); + smlua_push_number_field(2, "z", b[2]); + + return 1; +} + +int smlua_func_calculate_angles(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 * pitch = (s16 *)smlua_to_cpointer(L, 3, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + s16 * yaw = (s16 *)smlua_to_cpointer(L, 4, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + + calculate_angles(from, to, pitch, yaw); + + smlua_push_number_field(1, "x", from[0]); + smlua_push_number_field(1, "y", from[1]); + smlua_push_number_field(1, "z", from[2]); + + smlua_push_number_field(2, "x", to[0]); + smlua_push_number_field(2, "y", to[1]); + smlua_push_number_field(2, "z", to[2]); + + return 1; +} + +int smlua_func_calculate_pitch(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, calculate_pitch(from, to)); + + smlua_push_number_field(1, "x", from[0]); + smlua_push_number_field(1, "y", from[1]); + smlua_push_number_field(1, "z", from[2]); + + smlua_push_number_field(2, "x", to[0]); + smlua_push_number_field(2, "y", to[1]); + smlua_push_number_field(2, "z", to[2]); + + return 1; +} + +int smlua_func_calculate_yaw(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, calculate_yaw(from, to)); + + smlua_push_number_field(1, "x", from[0]); + smlua_push_number_field(1, "y", from[1]); + smlua_push_number_field(1, "z", from[2]); + + smlua_push_number_field(2, "x", to[0]); + smlua_push_number_field(2, "y", to[1]); + smlua_push_number_field(2, "z", to[2]); + + return 1; +} + +int smlua_func_cam_select_alt_mode(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 angle = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, cam_select_alt_mode(angle)); + + return 1; +} + +int smlua_func_camera_approach_f32_symmetric(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 value = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 target = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 increment = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushnumber(L, camera_approach_f32_symmetric(value, target, increment)); + + return 1; +} + +int smlua_func_camera_approach_f32_symmetric_bool(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 * current = (f32 *)smlua_to_cpointer(L, 1, LVT_F32_P); + if (!gSmLuaConvertSuccess) { return 0; } + f32 target = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 increment = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, camera_approach_f32_symmetric_bool(current, target, increment)); + + return 1; +} + +int smlua_func_camera_approach_s16_symmetric_bool(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s16 * current = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + s16 target = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 increment = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, camera_approach_s16_symmetric_bool(current, target, increment)); + + return 1; +} + +int smlua_func_camera_course_processing(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, camera_course_processing(c)); + + return 1; +} + +int smlua_func_clamp_pitch(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 maxPitch = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 minPitch = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, clamp_pitch(from, to, maxPitch, minPitch)); + + smlua_push_number_field(1, "x", from[0]); + smlua_push_number_field(1, "y", from[1]); + smlua_push_number_field(1, "z", from[2]); + + smlua_push_number_field(2, "x", to[0]); + smlua_push_number_field(2, "y", to[1]); + smlua_push_number_field(2, "z", to[2]); + + return 1; +} + +int smlua_func_clamp_positions_and_find_yaw(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 6)) { return 0; } + + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* origin = smlua_get_vec3f_from_buffer(); + origin[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + origin[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + origin[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + f32 xMax = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 xMin = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + f32 zMax = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + f32 zMin = smlua_to_number(L, 6); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, clamp_positions_and_find_yaw(pos, origin, xMax, xMin, zMax, zMin)); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + + smlua_push_number_field(2, "x", origin[0]); + smlua_push_number_field(2, "y", origin[1]); + smlua_push_number_field(2, "z", origin[2]); + + return 1; +} + +int smlua_func_collide_with_walls(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + f32 offsetY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 radius = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, collide_with_walls(pos, offsetY, radius)); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + + return 1; +} + +/* +int smlua_func_cutscene_event(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + +// CameraEvent event = (CameraEvent)smlua_to_cobject(L, 1, LOT_???); <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 2, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + s16 start = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 end = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, cutscene_event(event, c, start, end)); + + return 1; +} +*/ + +int smlua_func_cutscene_object(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + u8 cutscene = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, cutscene_object(cutscene, o)); + + return 1; +} + +int smlua_func_cutscene_object_with_dialog(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + u8 cutscene = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s16 dialogID = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, cutscene_object_with_dialog(cutscene, o, dialogID)); + + return 1; +} + +int smlua_func_cutscene_object_without_dialog(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + u8 cutscene = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, cutscene_object_without_dialog(cutscene, o)); + + return 1; +} + +int smlua_func_cutscene_set_fov_shake_preset(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + u8 preset = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + cutscene_set_fov_shake_preset(preset); + + return 1; +} + +int smlua_func_cutscene_spawn_obj(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + u32 obj = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frame = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, cutscene_spawn_obj(obj, frame)); + + return 1; +} + +int smlua_func_find_c_buttons_pressed(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + u16 currentState = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + u16 buttonsPressed = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u16 buttonsDown = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, find_c_buttons_pressed(currentState, buttonsPressed, buttonsDown)); + + return 1; +} + +int smlua_func_find_mario_floor_and_ceil(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct PlayerGeometry* pg = (struct PlayerGeometry*)smlua_to_cobject(L, 1, LOT_PLAYERGEOMETRY); + if (!gSmLuaConvertSuccess) { return 0; } + + find_mario_floor_and_ceil(pg); + + return 1; +} + +/* +int smlua_func_geo_camera_fov(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 callContext = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct GraphNode* g = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); + if (!gSmLuaConvertSuccess) { return 0; } +// void * context = (void *)smlua_to_cobject(L, 3, LOT_???); <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + UNIMPLEMENTED -->(L, geo_camera_fov(callContext, g, context)); + + return 1; +} +*/ + +/* +int smlua_func_geo_camera_main(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 callContext = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct GraphNode* g = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); + if (!gSmLuaConvertSuccess) { return 0; } +// void * context = (void *)smlua_to_cobject(L, 3, LOT_???); <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + UNIMPLEMENTED -->(L, geo_camera_main(callContext, g, context)); + + return 1; +} +*/ + +int smlua_func_get_cutscene_from_mario_status(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, get_cutscene_from_mario_status(c)); + + return 1; +} + +int smlua_func_handle_c_button_movement(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + handle_c_button_movement(c); + + return 1; +} + +int smlua_func_is_range_behind_surface(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 5)) { return 0; } + + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + struct Surface* surf = (struct Surface*)smlua_to_cobject(L, 3, LOT_SURFACE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 range = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + s16 surfType = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, is_range_behind_surface(from, to, surf, range, surfType)); + + smlua_push_number_field(1, "x", from[0]); + smlua_push_number_field(1, "y", from[1]); + smlua_push_number_field(1, "z", from[2]); + + smlua_push_number_field(2, "x", to[0]); + smlua_push_number_field(2, "y", to[1]); + smlua_push_number_field(2, "z", to[2]); + + return 1; +} + +int smlua_func_is_within_100_units_of_mario(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 posX = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posZ = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, is_within_100_units_of_mario(posX, posY, posZ)); + + return 1; +} + +int smlua_func_move_mario_head_c_up(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + move_mario_head_c_up(c); + + return 1; +} + +int smlua_func_move_point_along_spline(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + + f32* p = smlua_get_vec3f_from_buffer(); + p[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + p[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + p[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + struct CutsceneSplinePoint spline[] = (struct CutsceneSplinePoint)smlua_to_cobject(L, 2, LOT_CUTSCENESPLINEPOINT); + if (!gSmLuaConvertSuccess) { return 0; } + s16 * splineSegment = (s16 *)smlua_to_cpointer(L, 3, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + f32 * progress = (f32 *)smlua_to_cpointer(L, 4, LVT_F32_P); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, move_point_along_spline(p, spline[], splineSegment, progress)); + + smlua_push_number_field(1, "x", p[0]); + smlua_push_number_field(1, "y", p[1]); + smlua_push_number_field(1, "z", p[2]); + + return 1; +} + +int smlua_func_next_lakitu_state(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 7)) { return 0; } + + + f32* newPos = smlua_get_vec3f_from_buffer(); + newPos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + newPos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + newPos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* newFoc = smlua_get_vec3f_from_buffer(); + newFoc[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + newFoc[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + newFoc[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* curPos = smlua_get_vec3f_from_buffer(); + curPos[0] = smlua_get_number_field(3, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + curPos[1] = smlua_get_number_field(3, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + curPos[2] = smlua_get_number_field(3, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* curFoc = smlua_get_vec3f_from_buffer(); + curFoc[0] = smlua_get_number_field(4, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + curFoc[1] = smlua_get_number_field(4, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + curFoc[2] = smlua_get_number_field(4, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* oldPos = smlua_get_vec3f_from_buffer(); + oldPos[0] = smlua_get_number_field(5, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + oldPos[1] = smlua_get_number_field(5, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + oldPos[2] = smlua_get_number_field(5, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* oldFoc = smlua_get_vec3f_from_buffer(); + oldFoc[0] = smlua_get_number_field(6, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + oldFoc[1] = smlua_get_number_field(6, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + oldFoc[2] = smlua_get_number_field(6, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yaw = smlua_to_integer(L, 7); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, next_lakitu_state(newPos, newFoc, curPos, curFoc, oldPos, oldFoc, yaw)); + + smlua_push_number_field(1, "x", newPos[0]); + smlua_push_number_field(1, "y", newPos[1]); + smlua_push_number_field(1, "z", newPos[2]); + + smlua_push_number_field(2, "x", newFoc[0]); + smlua_push_number_field(2, "y", newFoc[1]); + smlua_push_number_field(2, "z", newFoc[2]); + + smlua_push_number_field(3, "x", curPos[0]); + smlua_push_number_field(3, "y", curPos[1]); + smlua_push_number_field(3, "z", curPos[2]); + + smlua_push_number_field(4, "x", curFoc[0]); + smlua_push_number_field(4, "y", curFoc[1]); + smlua_push_number_field(4, "z", curFoc[2]); + + smlua_push_number_field(5, "x", oldPos[0]); + smlua_push_number_field(5, "y", oldPos[1]); + smlua_push_number_field(5, "z", oldPos[2]); + + smlua_push_number_field(6, "x", oldFoc[0]); + smlua_push_number_field(6, "y", oldFoc[1]); + smlua_push_number_field(6, "z", oldFoc[2]); + + return 1; +} + +int smlua_func_obj_rotate_towards_point(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 6)) { return 0; } + + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* point = smlua_get_vec3f_from_buffer(); + point[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + point[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + point[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 pitchOff = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yawOff = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + s16 pitchDiv = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yawDiv = smlua_to_integer(L, 6); + if (!gSmLuaConvertSuccess) { return 0; } + + obj_rotate_towards_point(o, point, pitchOff, yawOff, pitchDiv, yawDiv); + + smlua_push_number_field(2, "x", point[0]); + smlua_push_number_field(2, "y", point[1]); + smlua_push_number_field(2, "z", point[2]); + + return 1; +} + +int smlua_func_object_pos_to_vec3f(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* dst = smlua_get_vec3f_from_buffer(); + dst[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + object_pos_to_vec3f(dst, o); + + smlua_push_number_field(1, "x", dst[0]); + smlua_push_number_field(1, "y", dst[1]); + smlua_push_number_field(1, "z", dst[2]); + + return 1; +} + +int smlua_func_offset_rotated(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + + f32* dst = smlua_get_vec3f_from_buffer(); + dst[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(3, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(3, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(3, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + s16* rotation = smlua_get_vec3s_from_buffer(); + rotation[0] = smlua_get_integer_field(4, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + rotation[1] = smlua_get_integer_field(4, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + rotation[2] = smlua_get_integer_field(4, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + offset_rotated(dst, from, to, rotation); + + smlua_push_number_field(1, "x", dst[0]); + smlua_push_number_field(1, "y", dst[1]); + smlua_push_number_field(1, "z", dst[2]); + + smlua_push_number_field(2, "x", from[0]); + smlua_push_number_field(2, "y", from[1]); + smlua_push_number_field(2, "z", from[2]); + + smlua_push_number_field(3, "x", to[0]); + smlua_push_number_field(3, "y", to[1]); + smlua_push_number_field(3, "z", to[2]); + + smlua_push_integer_field(4, "x", rotation[0]); + smlua_push_integer_field(4, "y", rotation[1]); + smlua_push_integer_field(4, "z", rotation[2]); + + return 1; +} + +int smlua_func_offset_yaw_outward_radial(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + s16 areaYaw = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, offset_yaw_outward_radial(c, areaYaw)); + + return 1; +} + +int smlua_func_play_camera_buzz_if_c_sideways(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_camera_buzz_if_c_sideways(); + + return 1; +} + +int smlua_func_play_camera_buzz_if_cbutton(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_camera_buzz_if_cbutton(); + + return 1; +} + +int smlua_func_play_camera_buzz_if_cdown(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_camera_buzz_if_cdown(); + + return 1; +} + +int smlua_func_play_cutscene(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + play_cutscene(c); + + return 1; +} + +int smlua_func_play_sound_button_change_blocked(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_sound_button_change_blocked(); + + return 1; +} + +int smlua_func_play_sound_cbutton_down(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_sound_cbutton_down(); + + return 1; +} + +int smlua_func_play_sound_cbutton_side(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_sound_cbutton_side(); + + return 1; +} + +int smlua_func_play_sound_cbutton_up(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_sound_cbutton_up(); + + return 1; +} + +int smlua_func_play_sound_if_cam_switched_to_lakitu_or_mario(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_sound_if_cam_switched_to_lakitu_or_mario(); + + return 1; +} + +int smlua_func_play_sound_rbutton_changed(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + play_sound_rbutton_changed(); + + return 1; +} + +int smlua_func_radial_camera_input(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + f32 unused = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, radial_camera_input(c, unused)); + + return 1; +} + +int smlua_func_random_vec3s(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + + s16* dst = smlua_get_vec3s_from_buffer(); + dst[0] = smlua_get_integer_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_integer_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_integer_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 xRange = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yRange = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 zRange = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + random_vec3s(dst, xRange, yRange, zRange); + + smlua_push_integer_field(1, "x", dst[0]); + smlua_push_integer_field(1, "y", dst[1]); + smlua_push_integer_field(1, "z", dst[2]); + + return 1; +} + +int smlua_func_reset_camera(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + reset_camera(c); + + return 1; +} + +int smlua_func_resolve_geometry_collisions(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* lastGood = smlua_get_vec3f_from_buffer(); + lastGood[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + lastGood[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + lastGood[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + resolve_geometry_collisions(pos, lastGood); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + + smlua_push_number_field(2, "x", lastGood[0]); + smlua_push_number_field(2, "y", lastGood[1]); + smlua_push_number_field(2, "z", lastGood[2]); + + return 1; +} + +int smlua_func_rotate_camera_around_walls(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* cPos = smlua_get_vec3f_from_buffer(); + cPos[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + cPos[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + cPos[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 * avoidYaw = (s16 *)smlua_to_cpointer(L, 3, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yawRange = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, rotate_camera_around_walls(c, cPos, avoidYaw, yawRange)); + + smlua_push_number_field(2, "x", cPos[0]); + smlua_push_number_field(2, "y", cPos[1]); + smlua_push_number_field(2, "z", cPos[2]); + + return 1; +} + +int smlua_func_rotate_in_xz(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + + f32* dst = smlua_get_vec3f_from_buffer(); + dst[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* src = smlua_get_vec3f_from_buffer(); + src[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + src[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + src[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yaw = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + rotate_in_xz(dst, src, yaw); + + smlua_push_number_field(1, "x", dst[0]); + smlua_push_number_field(1, "y", dst[1]); + smlua_push_number_field(1, "z", dst[2]); + + smlua_push_number_field(2, "x", src[0]); + smlua_push_number_field(2, "y", src[1]); + smlua_push_number_field(2, "z", src[2]); + + return 1; +} + +int smlua_func_rotate_in_yz(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + + f32* dst = smlua_get_vec3f_from_buffer(); + dst[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* src = smlua_get_vec3f_from_buffer(); + src[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + src[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + src[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + s16 pitch = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + rotate_in_yz(dst, src, pitch); + + smlua_push_number_field(1, "x", dst[0]); + smlua_push_number_field(1, "y", dst[1]); + smlua_push_number_field(1, "z", dst[2]); + + smlua_push_number_field(2, "x", src[0]); + smlua_push_number_field(2, "y", src[1]); + smlua_push_number_field(2, "z", src[2]); + + return 1; +} + +int smlua_func_scale_along_line(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + + f32* dest = smlua_get_vec3f_from_buffer(); + dest[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dest[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dest[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* from = smlua_get_vec3f_from_buffer(); + from[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + from[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + from[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* to = smlua_get_vec3f_from_buffer(); + to[0] = smlua_get_number_field(3, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + to[1] = smlua_get_number_field(3, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + to[2] = smlua_get_number_field(3, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + f32 scale = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + scale_along_line(dest, from, to, scale); + + smlua_push_number_field(1, "x", dest[0]); + smlua_push_number_field(1, "y", dest[1]); + smlua_push_number_field(1, "z", dest[2]); + + smlua_push_number_field(2, "x", from[0]); + smlua_push_number_field(2, "y", from[1]); + smlua_push_number_field(2, "z", from[2]); + + smlua_push_number_field(3, "x", to[0]); + smlua_push_number_field(3, "y", to[1]); + smlua_push_number_field(3, "z", to[2]); + + return 1; +} + +int smlua_func_select_mario_cam_mode(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + select_mario_cam_mode(); + + return 1; +} + +int smlua_func_set_cam_angle(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 mode = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_cam_angle(mode)); + + return 1; +} + int smlua_func_set_camera_mode(lua_State* L) { if(!smlua_functions_valid_param_count(L, 3)) { return 0; } @@ -172,6 +1430,403 @@ int smlua_func_set_environmental_camera_shake(lua_State* L) { return 1; } +int smlua_func_set_fixed_cam_axis_sa_lobby(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s16 preset = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + set_fixed_cam_axis_sa_lobby(preset); + + return 1; +} + +int smlua_func_set_fov_function(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + u8 func = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + set_fov_function(func); + + return 1; +} + +int smlua_func_set_fov_shake(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s16 amplitude = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 decay = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 shakeSpeed = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + set_fov_shake(amplitude, decay, shakeSpeed); + + return 1; +} + +int smlua_func_set_fov_shake_from_point_preset(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + u8 preset = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posX = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posY = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posZ = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + set_fov_shake_from_point_preset(preset, posX, posY, posZ); + + return 1; +} + +int smlua_func_set_handheld_shake(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + u8 mode = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + set_handheld_shake(mode); + + return 1; +} + +int smlua_func_set_or_approach_f32_asymptotic(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 * dst = (f32 *)smlua_to_cpointer(L, 1, LVT_F32_P); + if (!gSmLuaConvertSuccess) { return 0; } + f32 goal = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 scale = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_or_approach_f32_asymptotic(dst, goal, scale)); + + return 1; +} + +int smlua_func_set_or_approach_s16_symmetric(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s16 * current = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + s16 target = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 increment = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_or_approach_s16_symmetric(current, target, increment)); + + return 1; +} + +int smlua_func_set_or_approach_vec3f_asymptotic(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 5)) { return 0; } + + + f32* dst = smlua_get_vec3f_from_buffer(); + dst[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* goal = smlua_get_vec3f_from_buffer(); + goal[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + goal[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + goal[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + f32 xMul = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 yMul = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + f32 zMul = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + set_or_approach_vec3f_asymptotic(dst, goal, xMul, yMul, zMul); + + smlua_push_number_field(1, "x", dst[0]); + smlua_push_number_field(1, "y", dst[1]); + smlua_push_number_field(1, "z", dst[2]); + + smlua_push_number_field(2, "x", goal[0]); + smlua_push_number_field(2, "y", goal[1]); + smlua_push_number_field(2, "z", goal[2]); + + return 1; +} + +int smlua_func_set_pitch_shake_from_point(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 7)) { return 0; } + + s16 mag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 decay = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 inc = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 maxDist = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posX = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posY = smlua_to_number(L, 6); + if (!gSmLuaConvertSuccess) { return 0; } + f32 posZ = smlua_to_number(L, 7); + if (!gSmLuaConvertSuccess) { return 0; } + + set_pitch_shake_from_point(mag, decay, inc, maxDist, posX, posY, posZ); + + return 1; +} + +int smlua_func_shake_camera_handheld(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* focus = smlua_get_vec3f_from_buffer(); + focus[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + focus[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + focus[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + shake_camera_handheld(pos, focus); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + + smlua_push_number_field(2, "x", focus[0]); + smlua_push_number_field(2, "y", focus[1]); + smlua_push_number_field(2, "z", focus[2]); + + return 1; +} + +int smlua_func_shake_camera_pitch(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* focus = smlua_get_vec3f_from_buffer(); + focus[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + focus[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + focus[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + shake_camera_pitch(pos, focus); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + + smlua_push_number_field(2, "x", focus[0]); + smlua_push_number_field(2, "y", focus[1]); + smlua_push_number_field(2, "z", focus[2]); + + return 1; +} + +int smlua_func_shake_camera_roll(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s16 * roll = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + + shake_camera_roll(roll); + + return 1; +} + +int smlua_func_shake_camera_yaw(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* focus = smlua_get_vec3f_from_buffer(); + focus[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + focus[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + focus[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + shake_camera_yaw(pos, focus); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + + smlua_push_number_field(2, "x", focus[0]); + smlua_push_number_field(2, "y", focus[1]); + smlua_push_number_field(2, "z", focus[2]); + + return 1; +} + +int smlua_func_soft_reset_camera(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + + soft_reset_camera(c); + + return 1; +} + +int smlua_func_start_cutscene(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + u8 cutscene = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + start_cutscene(c, cutscene); + + return 1; +} + +int smlua_func_start_object_cutscene_without_focus(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + u8 cutscene = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, start_object_cutscene_without_focus(cutscene)); + + return 1; +} + +int smlua_func_transition_next_state(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frames = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + transition_next_state(c, frames); + + return 1; +} + +int smlua_func_trigger_cutscene_dialog(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 trigger = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, trigger_cutscene_dialog(trigger)); + + return 1; +} + +int smlua_func_vec3f_sub(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + + f32* dst = smlua_get_vec3f_from_buffer(); + dst[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + dst[2] = smlua_get_number_field(1, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* src = smlua_get_vec3f_from_buffer(); + src[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + src[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + src[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + vec3f_sub(dst, src); + + smlua_push_number_field(1, "x", dst[0]); + smlua_push_number_field(1, "y", dst[1]); + smlua_push_number_field(1, "z", dst[2]); + + smlua_push_number_field(2, "x", src[0]); + smlua_push_number_field(2, "y", src[1]); + smlua_push_number_field(2, "z", src[2]); + + return 1; +} + +int smlua_func_vec3f_to_object_pos(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* src = smlua_get_vec3f_from_buffer(); + src[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + src[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + src[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + vec3f_to_object_pos(o, src); + + smlua_push_number_field(2, "x", src[0]); + smlua_push_number_field(2, "y", src[1]); + smlua_push_number_field(2, "z", src[2]); + + return 1; +} + +int smlua_func_warp_camera(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 displacementX = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 displacementY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 displacementZ = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + warp_camera(displacementX, displacementY, displacementZ); + + return 1; +} + ////////////////// // characters.h // ////////////////// @@ -8291,6 +9946,66 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "get_id_from_behavior", smlua_func_get_id_from_behavior); // camera.h + smlua_bind_function(L, "approach_camera_height", smlua_func_approach_camera_height); + smlua_bind_function(L, "approach_f32_asymptotic", smlua_func_approach_f32_asymptotic); + smlua_bind_function(L, "approach_f32_asymptotic_bool", smlua_func_approach_f32_asymptotic_bool); + smlua_bind_function(L, "approach_s16_asymptotic", smlua_func_approach_s16_asymptotic); + smlua_bind_function(L, "approach_s16_asymptotic_bool", smlua_func_approach_s16_asymptotic_bool); + smlua_bind_function(L, "approach_vec3f_asymptotic", smlua_func_approach_vec3f_asymptotic); + smlua_bind_function(L, "calc_abs_dist", smlua_func_calc_abs_dist); + smlua_bind_function(L, "calc_hor_dist", smlua_func_calc_hor_dist); + smlua_bind_function(L, "calculate_angles", smlua_func_calculate_angles); + smlua_bind_function(L, "calculate_pitch", smlua_func_calculate_pitch); + smlua_bind_function(L, "calculate_yaw", smlua_func_calculate_yaw); + smlua_bind_function(L, "cam_select_alt_mode", smlua_func_cam_select_alt_mode); + smlua_bind_function(L, "camera_approach_f32_symmetric", smlua_func_camera_approach_f32_symmetric); + smlua_bind_function(L, "camera_approach_f32_symmetric_bool", smlua_func_camera_approach_f32_symmetric_bool); + smlua_bind_function(L, "camera_approach_s16_symmetric_bool", smlua_func_camera_approach_s16_symmetric_bool); + smlua_bind_function(L, "camera_course_processing", smlua_func_camera_course_processing); + smlua_bind_function(L, "clamp_pitch", smlua_func_clamp_pitch); + smlua_bind_function(L, "clamp_positions_and_find_yaw", smlua_func_clamp_positions_and_find_yaw); + smlua_bind_function(L, "collide_with_walls", smlua_func_collide_with_walls); + //smlua_bind_function(L, "cutscene_event", smlua_func_cutscene_event); <--- UNIMPLEMENTED + smlua_bind_function(L, "cutscene_object", smlua_func_cutscene_object); + smlua_bind_function(L, "cutscene_object_with_dialog", smlua_func_cutscene_object_with_dialog); + smlua_bind_function(L, "cutscene_object_without_dialog", smlua_func_cutscene_object_without_dialog); + smlua_bind_function(L, "cutscene_set_fov_shake_preset", smlua_func_cutscene_set_fov_shake_preset); + smlua_bind_function(L, "cutscene_spawn_obj", smlua_func_cutscene_spawn_obj); + smlua_bind_function(L, "find_c_buttons_pressed", smlua_func_find_c_buttons_pressed); + smlua_bind_function(L, "find_mario_floor_and_ceil", smlua_func_find_mario_floor_and_ceil); + //smlua_bind_function(L, "geo_camera_fov", smlua_func_geo_camera_fov); <--- UNIMPLEMENTED + //smlua_bind_function(L, "geo_camera_main", smlua_func_geo_camera_main); <--- UNIMPLEMENTED + smlua_bind_function(L, "get_cutscene_from_mario_status", smlua_func_get_cutscene_from_mario_status); + smlua_bind_function(L, "handle_c_button_movement", smlua_func_handle_c_button_movement); + smlua_bind_function(L, "is_range_behind_surface", smlua_func_is_range_behind_surface); + smlua_bind_function(L, "is_within_100_units_of_mario", smlua_func_is_within_100_units_of_mario); + smlua_bind_function(L, "move_mario_head_c_up", smlua_func_move_mario_head_c_up); + smlua_bind_function(L, "move_point_along_spline", smlua_func_move_point_along_spline); + smlua_bind_function(L, "next_lakitu_state", smlua_func_next_lakitu_state); + smlua_bind_function(L, "obj_rotate_towards_point", smlua_func_obj_rotate_towards_point); + smlua_bind_function(L, "object_pos_to_vec3f", smlua_func_object_pos_to_vec3f); + smlua_bind_function(L, "offset_rotated", smlua_func_offset_rotated); + smlua_bind_function(L, "offset_yaw_outward_radial", smlua_func_offset_yaw_outward_radial); + smlua_bind_function(L, "play_camera_buzz_if_c_sideways", smlua_func_play_camera_buzz_if_c_sideways); + smlua_bind_function(L, "play_camera_buzz_if_cbutton", smlua_func_play_camera_buzz_if_cbutton); + smlua_bind_function(L, "play_camera_buzz_if_cdown", smlua_func_play_camera_buzz_if_cdown); + smlua_bind_function(L, "play_cutscene", smlua_func_play_cutscene); + smlua_bind_function(L, "play_sound_button_change_blocked", smlua_func_play_sound_button_change_blocked); + smlua_bind_function(L, "play_sound_cbutton_down", smlua_func_play_sound_cbutton_down); + smlua_bind_function(L, "play_sound_cbutton_side", smlua_func_play_sound_cbutton_side); + smlua_bind_function(L, "play_sound_cbutton_up", smlua_func_play_sound_cbutton_up); + smlua_bind_function(L, "play_sound_if_cam_switched_to_lakitu_or_mario", smlua_func_play_sound_if_cam_switched_to_lakitu_or_mario); + smlua_bind_function(L, "play_sound_rbutton_changed", smlua_func_play_sound_rbutton_changed); + smlua_bind_function(L, "radial_camera_input", smlua_func_radial_camera_input); + smlua_bind_function(L, "random_vec3s", smlua_func_random_vec3s); + smlua_bind_function(L, "reset_camera", smlua_func_reset_camera); + smlua_bind_function(L, "resolve_geometry_collisions", smlua_func_resolve_geometry_collisions); + smlua_bind_function(L, "rotate_camera_around_walls", smlua_func_rotate_camera_around_walls); + smlua_bind_function(L, "rotate_in_xz", smlua_func_rotate_in_xz); + smlua_bind_function(L, "rotate_in_yz", smlua_func_rotate_in_yz); + smlua_bind_function(L, "scale_along_line", smlua_func_scale_along_line); + smlua_bind_function(L, "select_mario_cam_mode", smlua_func_select_mario_cam_mode); + smlua_bind_function(L, "set_cam_angle", smlua_func_set_cam_angle); smlua_bind_function(L, "set_camera_mode", smlua_func_set_camera_mode); smlua_bind_function(L, "set_camera_mode_fixed", smlua_func_set_camera_mode_fixed); smlua_bind_function(L, "set_camera_pitch_shake", smlua_func_set_camera_pitch_shake); @@ -8299,6 +10014,27 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_camera_shake_from_point", smlua_func_set_camera_shake_from_point); smlua_bind_function(L, "set_camera_yaw_shake", smlua_func_set_camera_yaw_shake); smlua_bind_function(L, "set_environmental_camera_shake", smlua_func_set_environmental_camera_shake); + smlua_bind_function(L, "set_fixed_cam_axis_sa_lobby", smlua_func_set_fixed_cam_axis_sa_lobby); + smlua_bind_function(L, "set_fov_function", smlua_func_set_fov_function); + smlua_bind_function(L, "set_fov_shake", smlua_func_set_fov_shake); + smlua_bind_function(L, "set_fov_shake_from_point_preset", smlua_func_set_fov_shake_from_point_preset); + smlua_bind_function(L, "set_handheld_shake", smlua_func_set_handheld_shake); + smlua_bind_function(L, "set_or_approach_f32_asymptotic", smlua_func_set_or_approach_f32_asymptotic); + smlua_bind_function(L, "set_or_approach_s16_symmetric", smlua_func_set_or_approach_s16_symmetric); + smlua_bind_function(L, "set_or_approach_vec3f_asymptotic", smlua_func_set_or_approach_vec3f_asymptotic); + smlua_bind_function(L, "set_pitch_shake_from_point", smlua_func_set_pitch_shake_from_point); + smlua_bind_function(L, "shake_camera_handheld", smlua_func_shake_camera_handheld); + smlua_bind_function(L, "shake_camera_pitch", smlua_func_shake_camera_pitch); + smlua_bind_function(L, "shake_camera_roll", smlua_func_shake_camera_roll); + smlua_bind_function(L, "shake_camera_yaw", smlua_func_shake_camera_yaw); + smlua_bind_function(L, "soft_reset_camera", smlua_func_soft_reset_camera); + smlua_bind_function(L, "start_cutscene", smlua_func_start_cutscene); + smlua_bind_function(L, "start_object_cutscene_without_focus", smlua_func_start_object_cutscene_without_focus); + smlua_bind_function(L, "transition_next_state", smlua_func_transition_next_state); + smlua_bind_function(L, "trigger_cutscene_dialog", smlua_func_trigger_cutscene_dialog); + smlua_bind_function(L, "vec3f_sub", smlua_func_vec3f_sub); + smlua_bind_function(L, "vec3f_to_object_pos", smlua_func_vec3f_to_object_pos); + smlua_bind_function(L, "warp_camera", smlua_func_warp_camera); // characters.h smlua_bind_function(L, "get_character", smlua_func_get_character);