diff --git a/mods/convert_header.py b/autogen/convert_header.py similarity index 56% rename from mods/convert_header.py rename to autogen/convert_header.py index d3fd7d58a..c70e3c562 100644 --- a/mods/convert_header.py +++ b/autogen/convert_header.py @@ -1,55 +1,41 @@ +import os import re rejects = "" integer_types = ["u8", "u16", "u32", "u64", "s8", "s16", "s32", "s64", "int"] number_types = ["f32", "float"] -cobject_types = ["struct MarioState*", "Vec3s", "Vec3f"] -cobject_lot_types = ["LOT_MARIO_STATE", "LOT_VEC3S", "LOT_VEC3F"] +cobject_types = ["struct MarioState*", "struct Object*"] +cobject_lot_types = ["LOT_MARIO_STATE", "LOT_OBJECT"] + +template = """/* THIS FILE IS AUTOGENERATED */ +/* SHOULD NOT BE MANUALLY CHANGED */ + +#include "smlua.h" + +#include "game/level_update.h" +#include "game/area.h" +#include "game/mario.h" +#include "game/mario_step.h" +#include "game/mario_actions_stationary.h" +#include "audio/external.h" +#include "object_fields.h" +#include "engine/math_util.h" + +$[FUNCTIONS] + +void smlua_bind_functions_autogen(void) { + lua_State* L = gLuaState; +$[BINDS] +} +""" + +built_functions = "" +built_binds = "" + +####### do_extern = False -header_h = """ -s32 check_common_idle_cancels(struct MarioState *m); -s32 check_common_hold_idle_cancels(struct MarioState *m); -s32 act_idle(struct MarioState *m); -void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound); -s32 act_start_sleeping(struct MarioState *m); -s32 act_sleeping(struct MarioState *m); -s32 act_waking_up(struct MarioState *m); -s32 act_shivering(struct MarioState *m); -s32 act_coughing(struct MarioState *m); -s32 act_standing_against_wall(struct MarioState *m); -s32 act_in_quicksand(struct MarioState *m); -s32 act_crouching(struct MarioState *m); -s32 act_panting(struct MarioState *m); -void stopping_step(struct MarioState *m, s32 animID, u32 action); -s32 act_braking_stop(struct MarioState *m); -s32 act_butt_slide_stop(struct MarioState *m); -s32 act_hold_butt_slide_stop(struct MarioState *m); -s32 act_slide_kick_slide_stop(struct MarioState *m); -s32 act_start_crouching(struct MarioState *m); -s32 act_stop_crouching(struct MarioState *m); -s32 act_start_crawling(struct MarioState *m); -s32 act_stop_crawling(struct MarioState *m); -s32 act_shockwave_bounce(struct MarioState *m); -s32 landing_step(struct MarioState *m, s32 arg1, u32 action); -s32 check_common_landing_cancels(struct MarioState *m, u32 action); -s32 act_jump_land_stop(struct MarioState *m); -s32 act_double_jump_land_stop(struct MarioState *m); -s32 act_side_flip_land_stop(struct MarioState *m); -s32 act_freefall_land_stop(struct MarioState *m); -s32 act_triple_jump_land_stop(struct MarioState *m); -s32 act_backflip_land_stop(struct MarioState *m); -s32 act_lava_boost_land(struct MarioState *m); -s32 act_long_jump_land_stop(struct MarioState *m); -s32 act_hold_jump_land_stop(struct MarioState *m); -s32 act_hold_freefall_land_stop(struct MarioState *m); -s32 act_air_throw_land(struct MarioState *m); -s32 act_twirl_land(struct MarioState *m); -s32 act_ground_pound_land(struct MarioState *m); -s32 act_first_person(struct MarioState *m); -s32 check_common_stationary_cancels(struct MarioState *m); -s32 mario_execute_stationary_action(struct MarioState *m); -""" +header_h = "" functions = [] @@ -70,6 +56,16 @@ def normalize_type(t): t = parts[0] + ' ' + parts[1].replace(' ', '') return t +def gen_comment_header(f): + comment_h = "// " + f + " //" + comment_l = "/" * len(comment_h) + s = "" + s += " " + comment_l + "\n" + s += " " + comment_h + "\n" + s += "" + comment_l + "\n" + s += "\n" + return s + def process_line(line): function = {} @@ -103,8 +99,8 @@ def process_line(line): functions.append(function) -def process_lines(): - for line in header_h.splitlines(): +def process_lines(file_str): + for line in file_str.splitlines(): if reject_line(line): global rejects rejects += line + '\n' @@ -143,7 +139,10 @@ def build_return(function): return ' %s(L, %s);\n' % (lfunc, ccall) def build_function(function): - s = 'int smlua_func_%s(lua_State* L) {\n' % function['identifier'] + if len(function['params']) <= 0: + s = 'int smlua_func_%s(UNUSED lua_State* L) {\n' % function['identifier'] + else: + s = 'int smlua_func_%s(lua_State* L) {\n' % function['identifier'] i = 1 for param in function['params']: @@ -152,32 +151,66 @@ def build_function(function): i += 1 s += '\n' + global do_extern if do_extern: s += ' extern %s\n' % function['line'] s += build_return(function) s += ' return 1;\n}\n' - function['implemented'] = not ('UNIMPLEMENTED' in s) + function['implemented'] = 'UNIMPLEMENTED' not in s if 'UNIMPLEMENTED' in s: s = "/*\n" + s + "*/\n" - print(s) + global built_functions + built_functions += s + "\n" def build_functions(): for function in functions: build_function(function) -process_lines() -build_functions() -print('') -print('-------------------') -for function in functions: +def build_bind(function): s = 'smlua_bind_function(L, "%s", smlua_func_%s);' % (function['identifier'], function['identifier']) if function['implemented']: - print(' ' + s) + s = ' ' + s else: - print(' //' + s + ' <--- UNIMPLEMENTED') -print('-------------------') -print('REJECTS:') -print(rejects) \ No newline at end of file + s = ' //' + s + ' <--- UNIMPLEMENTED' + global built_binds + built_binds += s + "\n" + +def build_binds(fname): + global built_binds + built_binds += "\n // " + fname.split('/')[-1] + "\n" + for function in functions: + build_bind(function) + +def process_file(fname): + functions.clear() + global do_extern + do_extern = fname.endswith(".c") + with open(fname) as file: + process_lines(file.read()) + build_functions() + build_binds(fname) + +def process_files(): + dir_path = os.path.dirname(os.path.realpath(__file__)) + '/lua_functions/' + files = os.listdir(dir_path) + for f in files: + comment_header = "// " + f + " //" + comment_line = "/" * len(comment_header) + + global built_functions + built_functions += gen_comment_header(f) + + process_file(dir_path + f) + +def main(): + process_files() + filename = os.path.dirname(os.path.realpath(__file__)) + '/../src/pc/lua/smlua_functions_autogen.c' + with open(filename, 'w') as out: + out.write(template.replace("$[FUNCTIONS]", built_functions).replace("$[BINDS]", built_binds)) + print('REJECTS:') + print(rejects) + +main() diff --git a/autogen/lua_functions/camera.h b/autogen/lua_functions/camera.h new file mode 100644 index 000000000..0706e030c --- /dev/null +++ b/autogen/lua_functions/camera.h @@ -0,0 +1,3 @@ +void set_camera_shake_from_hit(s16 shake); +void set_environmental_camera_shake(s16 shake); +void set_camera_shake_from_point(s16 shake, f32 posX, f32 posY, f32 posZ); \ No newline at end of file diff --git a/autogen/lua_functions/mario.h b/autogen/lua_functions/mario.h new file mode 100644 index 000000000..d46280e58 --- /dev/null +++ b/autogen/lua_functions/mario.h @@ -0,0 +1,44 @@ +s32 is_anim_at_end(struct MarioState *m); +s32 is_anim_past_end(struct MarioState *m); +s16 set_mario_animation(struct MarioState *m, s32 targetAnimID); +s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel); +void set_anim_to_frame(struct MarioState *m, s16 animFrame); +s32 is_anim_past_frame(struct MarioState *m, s16 animFrame); +s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation); +void update_mario_pos_for_anim(struct MarioState *m); +s16 return_mario_anim_y_translation(struct MarioState *m); +void play_sound_if_no_flag(struct MarioState *m, u32 soundBits, u32 flags); +void play_mario_jump_sound(struct MarioState *m); +void adjust_sound_for_speed(struct MarioState *m); +void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 waveParticleType); +void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 waveParticleType); +void play_mario_landing_sound(struct MarioState *m, u32 soundBits); +void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits); +void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits); +void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits); +void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits); +void mario_set_bubbled(struct MarioState* m); +void mario_set_forward_vel(struct MarioState *m, f32 speed); +s32 mario_get_floor_class(struct MarioState *m); +u32 mario_get_terrain_sound_addend(struct MarioState *m); +struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius); +f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil); +s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw); +u32 mario_floor_is_slippery(struct MarioState *m); +s32 mario_floor_is_slope(struct MarioState *m); +s32 mario_floor_is_steep(struct MarioState *m); +f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario); +s16 find_floor_slope(struct MarioState *m, s16 yawOffset); +void update_mario_sound_and_camera(struct MarioState *m); +void set_steep_jump_action(struct MarioState *m); +u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg); +s32 set_jump_from_landing(struct MarioState *m); +s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg); +s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg); +s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter); +s32 check_common_action_exits(struct MarioState *m); +s32 check_common_hold_action_exits(struct MarioState *m); +s32 transition_submerged_to_walking(struct MarioState *m); +s32 set_water_plunge_action(struct MarioState *m); +s32 execute_mario_action(UNUSED struct Object *o); +s32 force_idle_state(struct MarioState* m); diff --git a/autogen/lua_functions/mario_actions_airborne.c b/autogen/lua_functions/mario_actions_airborne.c new file mode 100644 index 000000000..d4ce592b1 --- /dev/null +++ b/autogen/lua_functions/mario_actions_airborne.c @@ -0,0 +1,64 @@ +void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3); +void play_far_fall_sound(struct MarioState *m); +void play_knockback_sound(struct MarioState *m); +s32 lava_boost_on_wall(struct MarioState *m); +s32 check_fall_damage(struct MarioState *m, u32 hardFallAction); +s32 check_kick_or_dive_in_air(struct MarioState *m); +s32 should_get_stuck_in_ground(struct MarioState *m); +s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction); +s32 check_horizontal_wind(struct MarioState *m); +void update_air_with_turn(struct MarioState *m); +void update_air_without_turn(struct MarioState *m); +void update_lava_boost_or_twirling(struct MarioState *m); +void update_flying_yaw(struct MarioState *m); +void update_flying_pitch(struct MarioState *m); +void update_flying(struct MarioState *m); +u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, u32 stepArg); +s32 act_jump(struct MarioState *m); +s32 act_double_jump(struct MarioState *m); +s32 act_triple_jump(struct MarioState *m); +s32 act_backflip(struct MarioState *m); +s32 act_freefall(struct MarioState *m); +s32 act_hold_jump(struct MarioState *m); +s32 act_hold_freefall(struct MarioState *m); +s32 act_side_flip(struct MarioState *m); +s32 act_wall_kick_air(struct MarioState *m); +s32 act_long_jump(struct MarioState *m); +s32 act_riding_shell_air(struct MarioState *m); +s32 act_twirling(struct MarioState *m); +s32 act_dive(struct MarioState *m); +s32 act_air_throw(struct MarioState *m); +s32 act_water_jump(struct MarioState *m); +s32 act_hold_water_jump(struct MarioState *m); +s32 act_steep_jump(struct MarioState *m); +s32 act_ground_pound(struct MarioState *m); +s32 act_burning_jump(struct MarioState *m); +s32 act_burning_fall(struct MarioState *m); +s32 act_crazy_box_bounce(struct MarioState *m); +u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFallAction, s32 animation, f32 speed); +s32 check_wall_kick(struct MarioState *m); +s32 act_backward_air_kb(struct MarioState *m); +s32 act_forward_air_kb(struct MarioState *m); +s32 act_hard_backward_air_kb(struct MarioState *m); +s32 act_hard_forward_air_kb(struct MarioState *m); +s32 act_thrown_backward(struct MarioState *m); +s32 act_thrown_forward(struct MarioState *m); +s32 act_soft_bonk(struct MarioState *m); +s32 act_getting_blown(struct MarioState *m); +s32 act_air_hit_wall(struct MarioState *m); +s32 act_forward_rollout(struct MarioState *m); +s32 act_backward_rollout(struct MarioState *m); +s32 act_butt_slide_air(struct MarioState *m); +s32 act_hold_butt_slide_air(struct MarioState *m); +s32 act_lava_boost(struct MarioState *m); +s32 act_slide_kick(struct MarioState *m); +s32 act_jump_kick(struct MarioState *m); +s32 act_shot_from_cannon(struct MarioState *m); +s32 act_flying(struct MarioState *m); +s32 act_riding_hoot(struct MarioState *m); +s32 act_flying_triple_jump(struct MarioState *m); +s32 act_top_of_pole_jump(struct MarioState *m); +s32 act_vertical_wind(struct MarioState *m); +s32 act_special_triple_jump(struct MarioState *m); +s32 check_common_airborne_cancels(struct MarioState *m); +s32 mario_execute_airborne_action(struct MarioState *m); \ No newline at end of file diff --git a/autogen/lua_functions/mario_actions_automatic.c b/autogen/lua_functions/mario_actions_automatic.c new file mode 100644 index 000000000..ded4c51b7 --- /dev/null +++ b/autogen/lua_functions/mario_actions_automatic.c @@ -0,0 +1,29 @@ +void add_tree_leaf_particles(struct MarioState *m); +void play_climbing_sounds(struct MarioState *m, s32 b); +s32 set_pole_position(struct MarioState *m, f32 offsetY); +s32 act_holding_pole(struct MarioState *m); +s32 act_climbing_pole(struct MarioState *m); +s32 act_grab_pole_slow(struct MarioState *m); +s32 act_grab_pole_fast(struct MarioState *m); +s32 act_top_of_pole_transition(struct MarioState *m); +s32 act_top_of_pole(struct MarioState *m); +s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos); +s32 update_hang_moving(struct MarioState *m); +void update_hang_stationary(struct MarioState *m); +s32 act_start_hanging(struct MarioState *m); +s32 act_hanging(struct MarioState *m); +s32 act_hang_moving(struct MarioState *m); +s32 let_go_of_ledge(struct MarioState *m); +void climb_up_ledge(struct MarioState *m); +void update_ledge_climb_camera(struct MarioState *m); +void update_ledge_climb(struct MarioState *m, s32 animation, u32 endAction); +s32 act_ledge_grab(struct MarioState *m); +s32 act_ledge_climb_slow(struct MarioState *m); +s32 act_ledge_climb_down(struct MarioState *m); +s32 act_ledge_climb_fast(struct MarioState *m); +s32 act_grabbed(struct MarioState *m); +s32 act_in_cannon(struct MarioState *m); +s32 act_tornado_twirling(struct MarioState *m); +s32 act_bubbled(struct MarioState* m); +s32 check_common_automatic_cancels(struct MarioState *m); +s32 mario_execute_automatic_action(struct MarioState *m); diff --git a/autogen/lua_functions/mario_actions_cutscene.c b/autogen/lua_functions/mario_actions_cutscene.c new file mode 100644 index 000000000..6162ad326 --- /dev/null +++ b/autogen/lua_functions/mario_actions_cutscene.c @@ -0,0 +1,11 @@ +void print_displaying_credits_entry(void); +void bhv_end_peach_loop(void); +void bhv_end_toad_loop(void); +void handle_save_menu(struct MarioState *m); +struct Object *spawn_obj_at_mario_rel_yaw(struct MarioState *m, s32 model, BehaviorScript *behavior, s16 relYaw); +void cutscene_take_cap_off(struct MarioState *m); +void cutscene_put_cap_on(struct MarioState *m); +u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object); +void general_star_dance_handler(struct MarioState *m, s32 isInWater); +void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFrame, s32 target2, s32 target3, s32 endAction); +void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius); \ No newline at end of file diff --git a/autogen/lua_functions/mario_actions_moving.c b/autogen/lua_functions/mario_actions_moving.c new file mode 100644 index 000000000..e49049bb6 --- /dev/null +++ b/autogen/lua_functions/mario_actions_moving.c @@ -0,0 +1,34 @@ +s16 tilt_body_running(struct MarioState *m); +void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2); +void align_with_floor(struct MarioState *m); +s32 begin_walking_action(struct MarioState *m, f32 forwardVel, u32 action, u32 actionArg); +void check_ledge_climb_down(struct MarioState *m); +void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction); +s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 actionArg); +void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor); +s32 update_sliding(struct MarioState *m, f32 stopSpeed); +void apply_slope_accel(struct MarioState *m); +s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor); +void update_shell_speed(struct MarioState *m); +s32 apply_slope_decel(struct MarioState *m, f32 decelCoef); +s32 update_decelerating_speed(struct MarioState *m); +void update_walking_speed(struct MarioState *m); +s32 should_begin_sliding(struct MarioState *m); +s32 analog_stick_held_back(struct MarioState *m); +s32 check_ground_dive_or_punch(struct MarioState *m); +s32 begin_braking_action(struct MarioState *m); +void anim_and_audio_for_walk(struct MarioState *m); +void anim_and_audio_for_hold_walk(struct MarioState *m); +void anim_and_audio_for_heavy_walk(struct MarioState *m); +void push_or_sidle_wall(struct MarioState *m, Vec3f startPos); +void tilt_body_walking(struct MarioState *m, s16 startYaw); +void tilt_body_ground_shell(struct MarioState *m, s16 startYaw); +void tilt_body_butt_slide(struct MarioState *m); +void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 animation); +s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jumpAction, u32 airAction, s32 animation); +s32 stomach_slide_action(struct MarioState *m, u32 stopAction, u32 airAction, s32 animation); +s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4); +u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction); +s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animation2, u32 endAction, u32 airAction); +s32 check_common_moving_cancels(struct MarioState *m); +s32 mario_execute_moving_action(struct MarioState *m); diff --git a/autogen/lua_functions/mario_actions_object.c b/autogen/lua_functions/mario_actions_object.c new file mode 100644 index 000000000..343942aa9 --- /dev/null +++ b/autogen/lua_functions/mario_actions_object.c @@ -0,0 +1,4 @@ +void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction); +s32 mario_update_punch_sequence(struct MarioState *m); +s32 check_common_object_cancels(struct MarioState *m); +s32 mario_execute_object_action(struct MarioState *m); diff --git a/autogen/lua_functions/mario_actions_stationary.c b/autogen/lua_functions/mario_actions_stationary.c new file mode 100644 index 000000000..3ccfffbe7 --- /dev/null +++ b/autogen/lua_functions/mario_actions_stationary.c @@ -0,0 +1,8 @@ +s32 check_common_idle_cancels(struct MarioState *m); +s32 check_common_hold_idle_cancels(struct MarioState *m); +void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound); +void stopping_step(struct MarioState *m, s32 animID, u32 action); +s32 landing_step(struct MarioState *m, s32 arg1, u32 action); +s32 check_common_landing_cancels(struct MarioState *m, u32 action); +s32 check_common_stationary_cancels(struct MarioState *m); +s32 mario_execute_stationary_action(struct MarioState *m); diff --git a/autogen/lua_functions/mario_actions_submerged.c b/autogen/lua_functions/mario_actions_submerged.c new file mode 100644 index 000000000..233b74307 --- /dev/null +++ b/autogen/lua_functions/mario_actions_submerged.c @@ -0,0 +1 @@ +s32 mario_execute_submerged_action(struct MarioState *m); \ No newline at end of file diff --git a/autogen/lua_functions/mario_step.h b/autogen/lua_functions/mario_step.h new file mode 100644 index 000000000..2a634f7e7 --- /dev/null +++ b/autogen/lua_functions/mario_step.h @@ -0,0 +1,11 @@ +f32 get_additive_y_vel_for_jumps(void); +void mario_bonk_reflection(struct MarioState *, u32); +u32 mario_update_quicksand(struct MarioState *, f32); +u32 mario_push_off_steep_floor(struct MarioState *, u32, u32); +u32 mario_update_moving_sand(struct MarioState *); +u32 mario_update_windy_ground(struct MarioState *); +void stop_and_set_height_to_floor(struct MarioState *); +s32 stationary_ground_step(struct MarioState *); +s32 perform_ground_step(struct MarioState *); +s32 perform_air_step(struct MarioState *, u32); +void set_vel_from_pitch_and_yaw(struct MarioState* m); diff --git a/mods/test.lua b/mods/test.lua index 44c70b74f..28f8ae5f8 100644 --- a/mods/test.lua +++ b/mods/test.lua @@ -254,12 +254,12 @@ end function act_ground_pound_jump(m) local e = gMarioStateExtras[m.playerIndex] if check_kick_or_dive_in_air(m) ~= 0 then - -- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle return 1 end if (m.input & INPUT_Z_PRESSED) ~= 0 then - -- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle return set_mario_action(m, ACT_GROUND_POUND, 0) end @@ -280,7 +280,7 @@ function act_ground_pound_jump(m) AIR_STEP_CHECK_LEDGE_GRAB | AIR_STEP_CHECK_HANG) e.rotAngle = e.rotAngle + (0x10000*1.0 - e.rotAngle) / 5.0 - -- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y - e.rotAngle + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y - e.rotAngle m.actionTimer = m.actionTimer + 1 @@ -478,12 +478,12 @@ function act_spin_jump(m) e.rotAngle = e.rotAngle + 0x2867 if (e.rotAngle > 0x10000) then e.rotAngle = e.rotAngle - 0x10000 end if (e.rotAngle < -0x10000) then e.rotAngle = e.rotAngle + 0x10000 end - -- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + (s16) (e.rotAngle * spinDirFactor) + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + (e.rotAngle * spinDirFactor) -- gravity m.vel.y = m.vel.y + 2 if (m.flags & MARIO_WING_CAP) ~= 0 and m.vel.y < 0.0 and (m.input & INPUT_A_DOWN) ~= 0 then - -- TODO: m.marioBodyState.wingFlutter = 1 + m.marioBodyState.wingFlutter = 1 m.vel.y = m.vel.y - 0.7 if m.vel.y < -37.5 then m.vel.y = m.vel.y + 1.4 @@ -553,7 +553,7 @@ function act_spin_pound(m) e.rotAngle = e.rotAngle + 0x3053 if e.rotAngle > 0x10000 then e.rotAngle = e.rotAngle - 0x10000 end if e.rotAngle < -0x10000 then e.rotAngle = e.rotAngle + 0x10000 end - -- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle * spinDirFactor + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle * spinDirFactor m.actionTimer = m.actionTimer + 1 diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index c561d3baa..5b01bb95c 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -176,6 +176,7 @@ void smlua_init(void) { smlua_bind_cobject(); smlua_bind_functions(); + smlua_bind_functions_autogen(); smlua_execfile("mods/constants.lua"); smlua_init_mario_states(); diff --git a/src/pc/lua/smlua.h b/src/pc/lua/smlua.h index 66fb492e2..52aa42aa7 100644 --- a/src/pc/lua/smlua.h +++ b/src/pc/lua/smlua.h @@ -10,6 +10,7 @@ #include "smlua_cobject.h" #include "smlua_utils.h" #include "smlua_functions.h" +#include "smlua_functions_autogen.h" #include "pc/debuglog.h" diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 1b4655eb4..37fb261f1 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -14,9 +14,8 @@ enum LuaValueType { LVT_S16, LVT_S32, LVT_F32, - LVT_VEC3S, - LVT_VEC3F, - LVT_CONTROLLER, + LVT_COBJECT, + LVT_COBJECT_P, }; struct LuaObjectField { @@ -24,93 +23,94 @@ struct LuaObjectField { enum LuaValueType valueType; size_t valueOffset; bool immutable; + enum LuaObjectType lot; }; #define LUA_VEC3S_FIELD_COUNT 3 static struct LuaObjectField sVec3sFields[LUA_VEC3S_FIELD_COUNT] = { - { "x", LVT_S16, sizeof(s16) * 0, false }, - { "y", LVT_S16, sizeof(s16) * 1, false }, - { "z", LVT_S16, sizeof(s16) * 2, false }, + { "x", LVT_S16, sizeof(s16) * 0, false, LOT_NONE }, + { "y", LVT_S16, sizeof(s16) * 1, false, LOT_NONE }, + { "z", LVT_S16, sizeof(s16) * 2, false, LOT_NONE }, }; #define LUA_VEC3F_FIELD_COUNT 3 static struct LuaObjectField sVec3fFields[LUA_VEC3F_FIELD_COUNT] = { - { "x", LVT_F32, sizeof(f32) * 0, false }, - { "y", LVT_F32, sizeof(f32) * 1, false }, - { "z", LVT_F32, sizeof(f32) * 2, false }, + { "x", LVT_F32, sizeof(f32) * 0, false, LOT_NONE }, + { "y", LVT_F32, sizeof(f32) * 1, false, LOT_NONE }, + { "z", LVT_F32, sizeof(f32) * 2, false, LOT_NONE }, }; -#define LUA_MARIO_STATE_FIELD_COUNT 56 +#define LUA_MARIO_STATE_FIELD_COUNT 62 static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { - { "playerIndex", LVT_U16, offsetof(struct MarioState, playerIndex) , true }, - { "input", LVT_U16, offsetof(struct MarioState, input) , false }, - { "flags", LVT_U32, offsetof(struct MarioState, flags) , false }, - { "particleFlags", LVT_U32, offsetof(struct MarioState, particleFlags) , false }, - { "action", LVT_U32, offsetof(struct MarioState, action) , false }, - { "prevAction", LVT_U32, offsetof(struct MarioState, prevAction) , false }, - { "terrainSoundAddend", LVT_U32, offsetof(struct MarioState, terrainSoundAddend) , false }, - { "actionState", LVT_U16, offsetof(struct MarioState, actionState) , false }, - { "actionTimer", LVT_U16, offsetof(struct MarioState, actionTimer) , false }, - { "actionArg", LVT_U32, offsetof(struct MarioState, actionArg) , false }, - { "intendedMag", LVT_F32, offsetof(struct MarioState, intendedMag) , false }, - { "intendedYaw", LVT_S16, offsetof(struct MarioState, intendedYaw) , false }, - { "invincTimer", LVT_S16, offsetof(struct MarioState, invincTimer) , false }, - { "framesSinceA", LVT_U8, offsetof(struct MarioState, framesSinceA) , false }, - { "framesSinceB", LVT_U8, offsetof(struct MarioState, framesSinceB) , false }, - { "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer) , false }, - { "doubleJumpTimer", LVT_U8, offsetof(struct MarioState, doubleJumpTimer) , false }, - { "faceAngle", LVT_VEC3S, offsetof(struct MarioState, faceAngle) , true }, - { "angleVel", LVT_VEC3S, offsetof(struct MarioState, angleVel) , true }, - { "slideYaw", LVT_S16, offsetof(struct MarioState, slideYaw) , false }, - { "twirlYaw", LVT_S16, offsetof(struct MarioState, twirlYaw) , false }, - { "pos", LVT_VEC3F, offsetof(struct MarioState, pos) , true }, - { "vel", LVT_VEC3F, offsetof(struct MarioState, vel) , true }, - { "forwardVel", LVT_F32, offsetof(struct MarioState, forwardVel) , false }, - { "slideVelX", LVT_F32, offsetof(struct MarioState, slideVelX) , false }, - { "slideVelZ", LVT_F32, offsetof(struct MarioState, slideVelZ) , false }, - { "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight) , false }, - { "floorHeight", LVT_F32, offsetof(struct MarioState, floorHeight) , false }, - { "floorAngle", LVT_S16, offsetof(struct MarioState, floorAngle) , false }, - { "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel) , false }, - { "controller", LVT_CONTROLLER, offsetof(struct MarioState, controller) , true }, - { "collidedObjInteractTypes", LVT_U32, offsetof(struct MarioState, collidedObjInteractTypes), false }, - { "numCoins", LVT_S16, offsetof(struct MarioState, numCoins) , false }, - { "numStars", LVT_S16, offsetof(struct MarioState, numStars) , false }, - { "mechani", LVT_S8, offsetof(struct MarioState, numKeys) , false }, - { "numLives", LVT_S8, offsetof(struct MarioState, numLives) , false }, - { "health", LVT_S16, offsetof(struct MarioState, health) , false }, - { "unkB0", LVT_S16, offsetof(struct MarioState, unkB0) , false }, - { "hurtCounter", LVT_U8, offsetof(struct MarioState, hurtCounter) , false }, - { "healCounter", LVT_U8, offsetof(struct MarioState, healCounter) , false }, - { "squishTimer", LVT_U8, offsetof(struct MarioState, squishTimer) , false }, - { "fadeWarpOpacity", LVT_U8, offsetof(struct MarioState, fadeWarpOpacity) , false }, - { "capTimer", LVT_U16, offsetof(struct MarioState, capTimer) , false }, - { "prevNumStarsForDialog", LVT_S16, offsetof(struct MarioState, prevNumStarsForDialog) , false }, - { "peakHeight", LVT_F32, offsetof(struct MarioState, peakHeight) , false }, - { "quicksandDepth", LVT_F32, offsetof(struct MarioState, quicksandDepth) , false }, - { "unkC4", LVT_F32, offsetof(struct MarioState, unkC4) , false }, - { "currentRoom", LVT_S16, offsetof(struct MarioState, currentRoom) , false }, - { "isSnoring", LVT_U8, offsetof(struct MarioState, isSnoring) , false }, - { "freeze", LVT_U8, offsetof(struct MarioState, freeze) , false }, - { "splineKeyframeFraction", LVT_F32, offsetof(struct MarioState, splineKeyframeFraction) , false }, - { "splineState", LVT_S32, offsetof(struct MarioState, splineState) , false }, - { "nonInstantWarpPos", LVT_VEC3F, offsetof(struct MarioState, nonInstantWarpPos) , true }, - { "wasNetworkVisible", LVT_U8, offsetof(struct MarioState, wasNetworkVisible) , false }, - { "minimumBoneY", LVT_F32, offsetof(struct MarioState, minimumBoneY) , false }, - { "curAnimOffset", LVT_F32, offsetof(struct MarioState, curAnimOffset) , false }, + { "playerIndex", LVT_U16, offsetof(struct MarioState, playerIndex), true, LOT_NONE }, + { "input", LVT_U16, offsetof(struct MarioState, input), false, LOT_NONE }, + { "flags", LVT_U32, offsetof(struct MarioState, flags), false, LOT_NONE }, + { "particleFlags", LVT_U32, offsetof(struct MarioState, particleFlags), false, LOT_NONE }, + { "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE }, + { "prevAction", LVT_U32, offsetof(struct MarioState, prevAction), false, LOT_NONE }, + { "terrainSoundAddend", LVT_U32, offsetof(struct MarioState, terrainSoundAddend), false, LOT_NONE }, + { "actionState", LVT_U16, offsetof(struct MarioState, actionState), false, LOT_NONE }, + { "actionTimer", LVT_U16, offsetof(struct MarioState, actionTimer), false, LOT_NONE }, + { "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE }, + { "intendedMag", LVT_F32, offsetof(struct MarioState, intendedMag), false, LOT_NONE }, + { "intendedYaw", LVT_S16, offsetof(struct MarioState, intendedYaw), false, LOT_NONE }, + { "invincTimer", LVT_S16, offsetof(struct MarioState, invincTimer), false, LOT_NONE }, + { "framesSinceA", LVT_U8, offsetof(struct MarioState, framesSinceA), false, LOT_NONE }, + { "framesSinceB", LVT_U8, offsetof(struct MarioState, framesSinceB), false, LOT_NONE }, + { "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer), false, LOT_NONE }, + { "doubleJumpTimer", LVT_U8, offsetof(struct MarioState, doubleJumpTimer), false, LOT_NONE }, + { "faceAngle", LVT_COBJECT, offsetof(struct MarioState, faceAngle), true, LOT_VEC3S }, + { "angleVel", LVT_COBJECT, offsetof(struct MarioState, angleVel), true, LOT_VEC3S }, + { "slideYaw", LVT_S16, offsetof(struct MarioState, slideYaw), false, LOT_NONE }, + { "twirlYaw", LVT_S16, offsetof(struct MarioState, twirlYaw), false, LOT_NONE }, + { "pos", LVT_COBJECT, offsetof(struct MarioState, pos), true, LOT_VEC3F }, + { "vel", LVT_COBJECT, offsetof(struct MarioState, vel), true, LOT_VEC3F }, + { "forwardVel", LVT_F32, offsetof(struct MarioState, forwardVel), false, LOT_NONE }, + { "slideVelX", LVT_F32, offsetof(struct MarioState, slideVelX), false, LOT_NONE }, + { "slideVelZ", LVT_F32, offsetof(struct MarioState, slideVelZ), false, LOT_NONE }, + { "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight), false, LOT_NONE }, + { "floorHeight", LVT_F32, offsetof(struct MarioState, floorHeight), false, LOT_NONE }, + { "floorAngle", LVT_S16, offsetof(struct MarioState, floorAngle), false, LOT_NONE }, + { "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel), false, LOT_NONE }, + { "interactObj", LVT_COBJECT_P, offsetof(struct MarioState, interactObj), false, LOT_OBJECT }, + { "heldObj", LVT_COBJECT_P, offsetof(struct MarioState, heldObj), false, LOT_OBJECT }, + { "usedObj", LVT_COBJECT_P, offsetof(struct MarioState, usedObj), false, LOT_OBJECT }, + { "interactObj", LVT_COBJECT_P, offsetof(struct MarioState, interactObj), false, LOT_OBJECT }, + { "marioObj", LVT_COBJECT_P, offsetof(struct MarioState, marioObj), true, LOT_OBJECT }, + { "marioBodyState", LVT_COBJECT_P, offsetof(struct MarioState, marioBodyState), true, LOT_BODY_STATE }, + { "controller", LVT_COBJECT_P, offsetof(struct MarioState, controller), true, LOT_CONTROLLER }, + { "collidedObjInteractTypes", LVT_U32, offsetof(struct MarioState, collidedObjInteractTypes), false, LOT_NONE }, + { "numCoins", LVT_S16, offsetof(struct MarioState, numCoins), false, LOT_NONE }, + { "numStars", LVT_S16, offsetof(struct MarioState, numStars), false, LOT_NONE }, + { "mechani", LVT_S8, offsetof(struct MarioState, numKeys), false, LOT_NONE }, + { "numLives", LVT_S8, offsetof(struct MarioState, numLives), false, LOT_NONE }, + { "health", LVT_S16, offsetof(struct MarioState, health), false, LOT_NONE }, + { "unkB0", LVT_S16, offsetof(struct MarioState, unkB0), false, LOT_NONE }, + { "hurtCounter", LVT_U8, offsetof(struct MarioState, hurtCounter), false, LOT_NONE }, + { "healCounter", LVT_U8, offsetof(struct MarioState, healCounter), false, LOT_NONE }, + { "squishTimer", LVT_U8, offsetof(struct MarioState, squishTimer), false, LOT_NONE }, + { "fadeWarpOpacity", LVT_U8, offsetof(struct MarioState, fadeWarpOpacity), false, LOT_NONE }, + { "capTimer", LVT_U16, offsetof(struct MarioState, capTimer), false, LOT_NONE }, + { "prevNumStarsForDialog", LVT_S16, offsetof(struct MarioState, prevNumStarsForDialog), false, LOT_NONE }, + { "peakHeight", LVT_F32, offsetof(struct MarioState, peakHeight), false, LOT_NONE }, + { "quicksandDepth", LVT_F32, offsetof(struct MarioState, quicksandDepth), false, LOT_NONE }, + { "unkC4", LVT_F32, offsetof(struct MarioState, unkC4), false, LOT_NONE }, + { "currentRoom", LVT_S16, offsetof(struct MarioState, currentRoom), false, LOT_NONE }, + { "isSnoring", LVT_U8, offsetof(struct MarioState, isSnoring), false, LOT_NONE }, + { "freeze", LVT_U8, offsetof(struct MarioState, freeze), false, LOT_NONE }, + { "splineKeyframeFraction", LVT_F32, offsetof(struct MarioState, splineKeyframeFraction), false, LOT_NONE }, + { "splineState", LVT_S32, offsetof(struct MarioState, splineState), false, LOT_NONE }, + { "nonInstantWarpPos", LVT_COBJECT, offsetof(struct MarioState, nonInstantWarpPos), true, LOT_VEC3F }, + { "wasNetworkVisible", LVT_U8, offsetof(struct MarioState, wasNetworkVisible), false, LOT_NONE }, + { "minimumBoneY", LVT_F32, offsetof(struct MarioState, minimumBoneY), false, LOT_NONE }, + { "curAnimOffset", LVT_F32, offsetof(struct MarioState, curAnimOffset), false, LOT_NONE }, /* TODO: implement struct Surface *wall; struct Surface *ceil; struct Surface *floor; - struct Object *interactObj; - struct Object *heldObj; - struct Object *usedObj; - struct Object *riddenObj; - struct Object *marioObj; struct SpawnInfo *spawnInfo; struct Area *area; struct PlayerCameraState *statusForCamera; - struct MarioBodyState *marioBodyState; struct MarioAnimation *animation; struct Object* heldByObj; struct Object* bubbleObj; @@ -121,18 +121,98 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { #define LUA_CONTROLLER_FIELD_COUNT 10 static struct LuaObjectField sControllerFields[LUA_CONTROLLER_FIELD_COUNT] = { - { "rawStickX", LVT_S16, offsetof(struct Controller, rawStickX), false }, - { "rawStickY", LVT_S16, offsetof(struct Controller, rawStickY), false }, - { "stickX", LVT_F32, offsetof(struct Controller, stickX), false }, - { "stickY", LVT_F32, offsetof(struct Controller, stickY), false }, - { "stickMag", LVT_F32, offsetof(struct Controller, stickMag), false }, - { "buttonDown", LVT_U16, offsetof(struct Controller, buttonDown), false }, - { "buttonPressed", LVT_U16, offsetof(struct Controller, buttonPressed), false }, - //{ "statusData", LVT_OSCONTSTATUS, offsetof(struct Controller, statusData), false }, - //{ "controllerData", LVT_OSCONTPAD, offsetof(struct Controller, controllerData), false }, - { "port", LVT_S32, offsetof(struct Controller, port), false }, - { "extStickX", LVT_S16, offsetof(struct Controller, extStickX), false }, - { "extStickY", LVT_S16, offsetof(struct Controller, extStickY), false }, + { "rawStickX", LVT_S16, offsetof(struct Controller, rawStickX), false, LOT_NONE }, + { "rawStickY", LVT_S16, offsetof(struct Controller, rawStickY), false, LOT_NONE }, + { "stickX", LVT_F32, offsetof(struct Controller, stickX), false, LOT_NONE }, + { "stickY", LVT_F32, offsetof(struct Controller, stickY), false, LOT_NONE }, + { "stickMag", LVT_F32, offsetof(struct Controller, stickMag), false, LOT_NONE }, + { "buttonDown", LVT_U16, offsetof(struct Controller, buttonDown), false, LOT_NONE }, + { "buttonPressed", LVT_U16, offsetof(struct Controller, buttonPressed), false, LOT_NONE }, + //{ "statusData", LVT_OSCONTSTATUS, offsetof(struct Controller, statusData), false, LOT_NONE }, + //{ "controllerData", LVT_OSCONTPAD, offsetof(struct Controller, controllerData), false, LOT_NONE }, + { "port", LVT_S32, offsetof(struct Controller, port), false, LOT_NONE }, + { "extStickX", LVT_S16, offsetof(struct Controller, extStickX), false, LOT_NONE }, + { "extStickY", LVT_S16, offsetof(struct Controller, extStickY), false, LOT_NONE }, +}; + +#define LUA_BODY_STATE_FIELD_COUNT 11 +static struct LuaObjectField sMarioBodyStateFields[LUA_BODY_STATE_FIELD_COUNT] = { + { "action", LVT_U32, offsetof(struct MarioBodyState, action), false, LOT_NONE }, + { "capState", LVT_S8, offsetof(struct MarioBodyState, capState), false, LOT_NONE }, + { "eyeState", LVT_S8, offsetof(struct MarioBodyState, eyeState), false, LOT_NONE }, + { "handState", LVT_S8, offsetof(struct MarioBodyState, handState), false, LOT_NONE }, + { "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE }, + { "modelState", LVT_S16, offsetof(struct MarioBodyState, modelState), false, LOT_NONE }, + { "grabPos", LVT_S8, offsetof(struct MarioBodyState, grabPos), false, LOT_NONE }, + { "punchState", LVT_U8, offsetof(struct MarioBodyState, punchState), false, LOT_NONE }, + { "torsoAngle", LVT_COBJECT, offsetof(struct MarioBodyState, torsoAngle), true, LOT_VEC3S }, + { "headAngle", LVT_COBJECT, offsetof(struct MarioBodyState, headAngle), true, LOT_VEC3S }, + { "heldObjLastPosition", LVT_COBJECT, offsetof(struct MarioBodyState, heldObjLastPosition), true, LOT_VEC3S }, +}; + +#define LUA_OBJECT_FIELD_COUNT 16 +static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = { + { "header", LVT_COBJECT, offsetof(struct Object, header), true, LOT_OBJECTNODE }, + { "parentObj", LVT_COBJECT_P, offsetof(struct Object, parentObj), false, LOT_OBJECT }, + { "prevObj", LVT_COBJECT_P, offsetof(struct Object, prevObj), false, LOT_OBJECT }, + { "collidedObjInteractTypes", LVT_U32, offsetof(struct Object, collidedObjInteractTypes), false, LOT_NONE }, + { "activeFlags", LVT_S16, offsetof(struct Object, activeFlags), false, LOT_NONE }, + { "numCollidedObjs", LVT_S16, offsetof(struct Object, numCollidedObjs), false, LOT_NONE }, + { "bhvStackIndex", LVT_U32, offsetof(struct Object, bhvStackIndex), false, LOT_NONE }, + { "bhvDelayTimer", LVT_S16, offsetof(struct Object, bhvDelayTimer), false, LOT_NONE }, + { "respawnInfoType", LVT_S16, offsetof(struct Object, respawnInfoType), false, LOT_NONE }, + { "hitboxRadius", LVT_F32, offsetof(struct Object, hitboxRadius), false, LOT_NONE }, + { "hitboxHeight", LVT_F32, offsetof(struct Object, hitboxHeight), false, LOT_NONE }, + { "hurtboxRadius", LVT_F32, offsetof(struct Object, hurtboxRadius), false, LOT_NONE }, + { "hurtboxHeight", LVT_F32, offsetof(struct Object, hurtboxHeight), false, LOT_NONE }, + { "hitboxDownOffset", LVT_F32, offsetof(struct Object, hitboxDownOffset), false, LOT_NONE }, + { "heldByPlayerIndex", LVT_U32, offsetof(struct Object, heldByPlayerIndex), false, LOT_NONE }, + { "platform", LVT_COBJECT_P, offsetof(struct Object, platform), false, LOT_OBJECT }, + /* TODO: implement + struct Object *collidedObjs[4] + union rawData + const BehaviorScript *curBhvCommand + uintptr_t bhvStack[8] + const BehaviorScript *behavior + void *collisionData + Mat4 transform + void *respawnInfo + */ +}; + +#define LUA_OBJECTNODE_FIELD_COUNT 3 +static struct LuaObjectField sObjectNodeFields[LUA_OBJECTNODE_FIELD_COUNT] = { + { "gfx", LVT_COBJECT, offsetof(struct ObjectNode, gfx), true, LOT_GRAPHNODEOBJECT }, + { "next", LVT_COBJECT_P, offsetof(struct ObjectNode, next), true, LOT_OBJECTNODE }, + { "prev", LVT_COBJECT_P, offsetof(struct ObjectNode, prev), true, LOT_OBJECTNODE }, +}; + +#define LUA_GRAPHNODEOBJECT_FIELD_COUNT 13 +static struct LuaObjectField sGraphNodeObjectFields[LUA_GRAPHNODEOBJECT_FIELD_COUNT] = { + { "unk18", LVT_S8, offsetof(struct GraphNodeObject, unk18), false, LOT_NONE }, + { "unk19", LVT_S8, offsetof(struct GraphNodeObject, unk19), false, LOT_NONE }, + { "angle", LVT_COBJECT, offsetof(struct GraphNodeObject, angle), false, LOT_VEC3S }, + { "pos", LVT_COBJECT, offsetof(struct GraphNodeObject, pos), false, LOT_VEC3F }, + { "prevAngle", LVT_COBJECT, offsetof(struct GraphNodeObject, prevAngle), false, LOT_VEC3S }, + { "prevPos", LVT_COBJECT, offsetof(struct GraphNodeObject, prevPos), false, LOT_VEC3F }, + { "prevTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevTimestamp), false, LOT_NONE }, + { "prevShadowPos", LVT_COBJECT, offsetof(struct GraphNodeObject, prevShadowPos), false, LOT_VEC3F }, + { "prevShadowPosTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevShadowPosTimestamp), false, LOT_NONE }, + { "scale", LVT_COBJECT, offsetof(struct GraphNodeObject, scale), false, LOT_VEC3F }, + { "prevScale", LVT_COBJECT, offsetof(struct GraphNodeObject, prevScale), false, LOT_VEC3F }, + { "prevScaleTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevScaleTimestamp), false, LOT_NONE }, + { "cameraToObject", LVT_COBJECT, offsetof(struct GraphNodeObject, cameraToObject), false, LOT_VEC3F }, + /* unimplemented + struct GraphNode node; + struct GraphNode *sharedChild; + struct GraphNodeObject_sub unk38; + struct SpawnInfo *unk4C; + Mat4 *throwMatrix; + Mat4 prevThrowMatrix; + u32 prevThrowMatrixTimestamp; + Mat4 *throwMatrixInterpolated; + u32 skipInterpolationTimestamp; + */ }; struct LuaObjectTable { @@ -142,10 +222,15 @@ struct LuaObjectTable { }; struct LuaObjectTable sLuaObjectTable[LOT_MAX] = { - { LOT_VEC3S, sVec3sFields, LUA_VEC3S_FIELD_COUNT }, - { LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT }, - { LOT_MARIO_STATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT }, - { LOT_CONTROLLER, sControllerFields, LUA_CONTROLLER_FIELD_COUNT }, + { LOT_NONE, NULL, 0 }, + { LOT_VEC3S, sVec3sFields, LUA_VEC3S_FIELD_COUNT }, + { LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT }, + { LOT_MARIO_STATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT }, + { LOT_CONTROLLER, sControllerFields, LUA_CONTROLLER_FIELD_COUNT }, + { LOT_BODY_STATE, sMarioBodyStateFields, LUA_BODY_STATE_FIELD_COUNT }, + { LOT_OBJECT, sObjectFields, LUA_OBJECT_FIELD_COUNT }, + { LOT_OBJECTNODE, sObjectNodeFields, LUA_OBJECTNODE_FIELD_COUNT }, + { LOT_GRAPHNODEOBJECT, sGraphNodeObjectFields, LUA_GRAPHNODEOBJECT_FIELD_COUNT }, }; static struct LuaObjectField* smlua_get_object_field(struct LuaObjectTable* ot, const char* key) { @@ -175,22 +260,21 @@ static int smlua__get_field(lua_State* L) { struct LuaObjectField* data = smlua_get_object_field(&sLuaObjectTable[lot], key); if (data == NULL) { - LOG_LUA("_get_field on invalid key '%s'", key); + LOG_LUA("_get_field on invalid key '%s', lot '%d'", key, lot); return 0; } u8* p = ((u8*)pointer) + data->valueOffset; switch (data->valueType) { - case LVT_U8: lua_pushinteger(L, *(u8* )p); break; - case LVT_U16: lua_pushinteger(L, *(u16*)p); break; - case LVT_U32: lua_pushinteger(L, *(u32*)p); break; - case LVT_S8: lua_pushinteger(L, *(s8* )p); break; - case LVT_S16: lua_pushinteger(L, *(s16*)p); break; - case LVT_S32: lua_pushinteger(L, *(s32*)p); break; - case LVT_F32: lua_pushnumber( L, *(f32*)p); break; - case LVT_VEC3S: smlua_push_object(L, LOT_VEC3S, p); break; - case LVT_VEC3F: smlua_push_object(L, LOT_VEC3F, p); break; - case LVT_CONTROLLER: smlua_push_object(L, LOT_CONTROLLER, *(struct Controller**)p); break; + case LVT_U8: lua_pushinteger(L, *(u8* )p); break; + case LVT_U16: lua_pushinteger(L, *(u16*)p); break; + case LVT_U32: lua_pushinteger(L, *(u32*)p); break; + case LVT_S8: lua_pushinteger(L, *(s8* )p); break; + case LVT_S16: lua_pushinteger(L, *(s16*)p); break; + case LVT_S32: lua_pushinteger(L, *(s32*)p); break; + case LVT_F32: lua_pushnumber( L, *(f32*)p); break; + case LVT_COBJECT: smlua_push_object(L, data->lot, p); break; + case LVT_COBJECT_P: smlua_push_object(L, data->lot, *(u8**)p); break; default: LOG_LUA("_get_field on unimplemented type '%d', key '%s'", data->valueType, key); return 0; @@ -205,39 +289,43 @@ static int smlua__set_field(lua_State* L) { const char* key = lua_tostring(L, -2); if (pointer == 0) { - LOG_LUA("_get_field on null pointer"); + LOG_LUA("_set_field on null pointer"); return 0; } if (lot >= LOT_MAX) { - LOG_LUA("_get_field on invalid LOT '%u'", lot); + LOG_LUA("_set_field on invalid LOT '%u'", lot); return 0; } struct LuaObjectField* data = smlua_get_object_field(&sLuaObjectTable[lot], key); if (data == NULL) { - LOG_LUA("_get_field on invalid key '%s'", key); + LOG_LUA("_set_field on invalid key '%s'", key); return 0; } if (data->immutable) { - LOG_LUA("_get_field on immutable key '%s'", key); + LOG_LUA("_set_field on immutable key '%s'", key); return 0; } u8* p = ((u8*)pointer) + data->valueOffset; switch (data->valueType) { - case LVT_U8: *(u8*) p = lua_tointeger(L, -1); break; - case LVT_U16: *(u16*)p = lua_tointeger(L, -1); break; - case LVT_U32: *(u32*)p = lua_tointeger(L, -1); break; - case LVT_S8: *(s8*) p = lua_tointeger(L, -1); break; - case LVT_S16: *(s16*)p = lua_tointeger(L, -1); break; - case LVT_S32: *(s32*)p = lua_tointeger(L, -1); break; - case LVT_F32: *(f32*)p = lua_tonumber(L, -1); break; + case LVT_U8: *(u8*) p = smlua_to_integer(L, -1); break; + case LVT_U16: *(u16*)p = smlua_to_integer(L, -1); break; + case LVT_U32: *(u32*)p = smlua_to_integer(L, -1); break; + case LVT_S8: *(s8*) p = smlua_to_integer(L, -1); break; + case LVT_S16: *(s16*)p = smlua_to_integer(L, -1); break; + case LVT_S32: *(s32*)p = smlua_to_integer(L, -1); break; + case LVT_F32: *(f32*)p = smlua_to_number(L, -1); break; default: - LOG_LUA("_get_field on unimplemented type '%d', key '%s'", data->valueType, key); + LOG_LUA("_set_field on unimplemented type '%d', key '%s'", data->valueType, key); return 0; } + if (!gSmLuaConvertSuccess) { + LOG_LUA("_set_field failed to retrieve value type '%d', key '%s'", data->valueType, key); + return 0; + } return 1; } diff --git a/src/pc/lua/smlua_cobject.h b/src/pc/lua/smlua_cobject.h index 8b44a02c9..2dee918aa 100644 --- a/src/pc/lua/smlua_cobject.h +++ b/src/pc/lua/smlua_cobject.h @@ -2,10 +2,15 @@ #define SMLUA_COBJECT_H enum LuaObjectType { + LOT_NONE, LOT_VEC3S, LOT_VEC3F, LOT_MARIO_STATE, LOT_CONTROLLER, + LOT_BODY_STATE, + LOT_OBJECT, + LOT_OBJECTNODE, + LOT_GRAPHNODEOBJECT, LOT_MAX, }; diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 9a9d718dc..36a3ab377 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -9,1902 +9,6 @@ #include "object_fields.h" #include "engine/math_util.h" - ///////////// - // mario.h // -///////////// - -int smlua_func_is_anim_at_end(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, is_anim_at_end(m)); - return 1; -} - -int smlua_func_is_anim_past_end(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, is_anim_past_end(m)); - return 1; -} - -int smlua_func_set_mario_animation(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 targetAnimID = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, set_mario_animation(m, targetAnimID)); - return 1; -} - -int smlua_func_set_mario_anim_with_accel(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 targetAnimID = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s32 accel = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, set_mario_anim_with_accel(m, targetAnimID, accel)); - return 1; -} - -int smlua_func_set_anim_to_frame(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 animFrame = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - set_anim_to_frame(m, animFrame); - return 1; -} - -int smlua_func_is_anim_past_frame(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 animFrame = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, is_anim_past_frame(m, animFrame)); - return 1; -} - -/* -int smlua_func_find_mario_anim_flags_and_translation(lua_State* L) { - struct Object* o <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { return 0; } - s32 yaw = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - Vec3s translation = (Vec3s)smlua_to_cobject(L, 3, LOT_VEC3S); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, find_mario_anim_flags_and_translation(o, yaw, translation)); - return 1; -} -*/ - -int smlua_func_update_mario_pos_for_anim(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - update_mario_pos_for_anim(m); - return 1; -} - -int smlua_func_return_mario_anim_y_translation(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, return_mario_anim_y_translation(m)); - return 1; -} - -int smlua_func_play_sound_if_no_flag(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 flags = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - play_sound_if_no_flag(m, soundBits, flags); - return 1; -} - -int smlua_func_play_mario_jump_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_jump_sound(m); - return 1; -} - -int smlua_func_adjust_sound_for_speed(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - adjust_sound_for_speed(m); - return 1; -} - -int smlua_func_play_sound_and_spawn_particles(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 waveParticleType = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - play_sound_and_spawn_particles(m, soundBits, waveParticleType); - return 1; -} - -int smlua_func_play_mario_action_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 waveParticleType = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_action_sound(m, soundBits, waveParticleType); - return 1; -} - -int smlua_func_play_mario_landing_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_landing_sound(m, soundBits); - return 1; -} - -int smlua_func_play_mario_landing_sound_once(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_landing_sound_once(m, soundBits); - return 1; -} - -int smlua_func_play_mario_heavy_landing_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_heavy_landing_sound(m, soundBits); - return 1; -} - -int smlua_func_play_mario_heavy_landing_sound_once(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 soundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_heavy_landing_sound_once(m, soundBits); - return 1; -} - -int smlua_func_play_mario_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 primarySoundBits = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s32 scondarySoundBits = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - play_mario_sound(m, primarySoundBits, scondarySoundBits); - return 1; -} - -int smlua_func_mario_set_bubbled(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - mario_set_bubbled(m); - return 1; -} - -int smlua_func_mario_set_forward_vel(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 speed = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - mario_set_forward_vel(m, speed); - return 1; -} - -int smlua_func_mario_get_floor_class(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_get_floor_class(m)); - return 1; -} - -int smlua_func_mario_get_terrain_sound_addend(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_get_terrain_sound_addend(m)); - return 1; -} - -/* -int smlua_func_resolve_and_return_wall_collisions(lua_State* L) { - Vec3f pos = (Vec3f)smlua_to_cobject(L, 1, LOT_VEC3F); - if (!gSmLuaConvertSuccess) { return 0; } - f32 offset = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - f32 radius = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - UNIMPLEMENTED -->(L, resolve_and_return_wall_collisions(pos, offset, radius)); - return 1; -} -*/ - -/* -int smlua_func_vec3f_find_ceil(lua_State* L) { - Vec3f pos = (Vec3f)smlua_to_cobject(L, 1, LOT_VEC3F); - if (!gSmLuaConvertSuccess) { return 0; } - f32 height = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - struct Surface** ceil <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushnumber(L, vec3f_find_ceil(pos, height, ceil)); - return 1; -} -*/ - -int smlua_func_mario_facing_downhill(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 turnYaw = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_facing_downhill(m, turnYaw)); - return 1; -} - -int smlua_func_mario_floor_is_slippery(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_floor_is_slippery(m)); - return 1; -} - -int smlua_func_mario_floor_is_slope(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_floor_is_slope(m)); - return 1; -} - -int smlua_func_mario_floor_is_steep(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_floor_is_steep(m)); - return 1; -} - -int smlua_func_find_floor_height_relative_polar(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 angleFromMario = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - f32 distFromMario = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushnumber(L, find_floor_height_relative_polar(m, angleFromMario, distFromMario)); - return 1; -} - -int smlua_func_find_floor_slope(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 yawOffset = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, find_floor_slope(m, yawOffset)); - return 1; -} - -int smlua_func_update_mario_sound_and_camera(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - update_mario_sound_and_camera(m); - return 1; -} - -int smlua_func_set_steep_jump_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - set_steep_jump_action(m); - return 1; -} - -int smlua_func_set_mario_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionArg = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, set_mario_action(m, action, actionArg)); - return 1; -} - -int smlua_func_set_jump_from_landing(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, set_jump_from_landing(m)); - return 1; -} - -int smlua_func_set_jumping_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionArg = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, set_jumping_action(m, action, actionArg)); - return 1; -} - -int smlua_func_drop_and_set_mario_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionArg = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, drop_and_set_mario_action(m, action, actionArg)); - return 1; -} - -int smlua_func_hurt_and_set_mario_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionArg = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - s16 hurtCounter = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, hurt_and_set_mario_action(m, action, actionArg, hurtCounter)); - return 1; -} - -int smlua_func_check_common_action_exits(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, check_common_action_exits(m)); - return 1; -} - -int smlua_func_check_common_hold_action_exits(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, check_common_hold_action_exits(m)); - return 1; -} - -int smlua_func_transition_submerged_to_walking(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, transition_submerged_to_walking(m)); - return 1; -} - -int smlua_func_set_water_plunge_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, set_water_plunge_action(m)); - return 1; -} - -/* -int smlua_func_execute_mario_action(lua_State* L) { - struct Object* o <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, execute_mario_action(o)); - return 1; -} -*/ - -int smlua_func_force_idle_state(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, force_idle_state(m)); - return 1; -} - -int smlua_func_init_mario(UNUSED lua_State* L) { - init_mario(); - return 1; -} - -int smlua_func_init_mario_from_save_file(UNUSED lua_State* L) { - init_mario_from_save_file(); - return 1; -} - - //////////////////////////// - // mario_actions_moving.c // -//////////////////////////// - -int smlua_func_tilt_body_running(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s16 tilt_body_running(struct MarioState* m); - lua_pushinteger(L, tilt_body_running(m)); - return 1; -} - -int smlua_func_play_step_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 frame1 = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s16 frame2 = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void play_step_sound(struct MarioState* m, s16 frame1, s16 frame2); - play_step_sound(m, frame1, frame2); - return 1; -} - -int smlua_func_align_with_floor(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void align_with_floor(struct MarioState* m); - align_with_floor(m); - return 1; -} - -int smlua_func_begin_walking_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 forwardVel = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionArg = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 begin_walking_action(struct MarioState* m, f32 forwardVel, u32 action, u32 actionArg); - lua_pushinteger(L, begin_walking_action(m, forwardVel, action, actionArg)); - return 1; -} - -int smlua_func_check_ledge_climb_down(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void check_ledge_climb_down(struct MarioState* m); - check_ledge_climb_down(m); - return 1; -} - -int smlua_func_slide_bonk(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 fastAction = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 slowAction = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void slide_bonk(struct MarioState* m, u32 fastAction, u32 slowAction); - slide_bonk(m, fastAction, slowAction); - return 1; -} - -int smlua_func_set_triple_jump_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionArg = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 set_triple_jump_action(struct MarioState* m, UNUSED u32 action, UNUSED u32 actionArg); - lua_pushinteger(L, set_triple_jump_action(m, action, actionArg)); - return 1; -} - -int smlua_func_update_sliding_angle(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 accel = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - f32 lossFactor = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_sliding_angle(struct MarioState* m, f32 accel, f32 lossFactor); - update_sliding_angle(m, accel, lossFactor); - return 1; -} - -int smlua_func_update_sliding(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 stopSpeed = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 update_sliding(struct MarioState* m, f32 stopSpeed); - lua_pushinteger(L, update_sliding(m, stopSpeed)); - return 1; -} - -int smlua_func_apply_slope_accel(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void apply_slope_accel(struct MarioState* m); - apply_slope_accel(m); - return 1; -} - -int smlua_func_apply_landing_accel(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 frictionFactor = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 apply_landing_accel(struct MarioState* m, f32 frictionFactor); - lua_pushinteger(L, apply_landing_accel(m, frictionFactor)); - return 1; -} - -int smlua_func_update_shell_speed(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_shell_speed(struct MarioState* m); - update_shell_speed(m); - return 1; -} - -int smlua_func_apply_slope_decel(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 decelCoef = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 apply_slope_decel(struct MarioState* m, f32 decelCoef); - lua_pushinteger(L, apply_slope_decel(m, decelCoef)); - return 1; -} - -int smlua_func_update_decelerating_speed(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 update_decelerating_speed(struct MarioState* m); - lua_pushinteger(L, update_decelerating_speed(m)); - return 1; -} - -int smlua_func_update_walking_speed(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_walking_speed(struct MarioState* m); - update_walking_speed(m); - return 1; -} - -int smlua_func_should_begin_sliding(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 should_begin_sliding(struct MarioState* m); - lua_pushinteger(L, should_begin_sliding(m)); - return 1; -} - -int smlua_func_analog_stick_held_back(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 analog_stick_held_back(struct MarioState* m); - lua_pushinteger(L, analog_stick_held_back(m)); - return 1; -} - -int smlua_func_check_ground_dive_or_punch(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_ground_dive_or_punch(struct MarioState* m); - lua_pushinteger(L, check_ground_dive_or_punch(m)); - return 1; -} - -int smlua_func_begin_braking_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 begin_braking_action(struct MarioState* m); - lua_pushinteger(L, begin_braking_action(m)); - return 1; -} - -int smlua_func_anim_and_audio_for_walk(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void anim_and_audio_for_walk(struct MarioState* m); - anim_and_audio_for_walk(m); - return 1; -} - -int smlua_func_anim_and_audio_for_hold_walk(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void anim_and_audio_for_hold_walk(struct MarioState* m); - anim_and_audio_for_hold_walk(m); - return 1; -} - -int smlua_func_anim_and_audio_for_heavy_walk(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void anim_and_audio_for_heavy_walk(struct MarioState* m); - anim_and_audio_for_heavy_walk(m); - return 1; -} - -int smlua_func_push_or_sidle_wall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32* startPos = (f32*)smlua_to_cobject(L, 2, LOT_VEC3F); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void push_or_sidle_wall(struct MarioState* m, f32* startPos); - push_or_sidle_wall(m, startPos); - return 1; -} - -int smlua_func_tilt_body_walking(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 startYaw = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void tilt_body_walking(struct MarioState* m, s16 startYaw); - tilt_body_walking(m, startYaw); - return 1; -} - -int smlua_func_tilt_body_ground_shell(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 startYaw = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void tilt_body_ground_shell(struct MarioState* m, s16 startYaw); - tilt_body_ground_shell(m, startYaw); - return 1; -} - -int smlua_func_tilt_body_butt_slide(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void tilt_body_butt_slide(struct MarioState* m); - tilt_body_butt_slide(m); - return 1; -} - -int smlua_func_common_slide_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 endAction = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 airAction = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - s32 animation = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void common_slide_action(struct MarioState* m, u32 endAction, u32 airAction, s32 animation); - common_slide_action(m, endAction, airAction, animation); - return 1; -} - -int smlua_func_stomach_slide_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 stopAction = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 airAction = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - s32 animation = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 stomach_slide_action(struct MarioState* m, u32 stopAction, u32 airAction, s32 animation); - lua_pushinteger(L, stomach_slide_action(m, stopAction, airAction, animation)); - return 1; -} - -int smlua_func_common_ground_knockback_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 animation = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s32 arg2 = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - s32 arg3 = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - s32 arg4 = smlua_to_integer(L, 5); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 common_ground_knockback_action(struct MarioState* m, s32 animation, s32 arg2, s32 arg3, s32 arg4); - lua_pushinteger(L, common_ground_knockback_action(m, animation, arg2, arg3, arg4)); - return 1; -} - -int smlua_func_common_landing_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 animation = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 airAction = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - extern u32 common_landing_action(struct MarioState* m, s16 animation, u32 airAction); - lua_pushinteger(L, common_landing_action(m, animation, airAction)); - return 1; -} - -int smlua_func_check_common_moving_cancels(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_common_moving_cancels(struct MarioState* m); - lua_pushinteger(L, check_common_moving_cancels(m)); - return 1; -} - -int smlua_func_mario_execute_moving_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 mario_execute_moving_action(struct MarioState* m); - lua_pushinteger(L, mario_execute_moving_action(m)); - return 1; -} - - ////////////////// - // mario_step.h // -////////////////// - -int smlua_func_mario_bonk_reflection(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 arg1 = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - mario_bonk_reflection(arg0, arg1); - return 1; -} - -/* -int smlua_func_transfer_bully_speed(lua_State* L) { - struct BullyCollisionData* obj1 <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { return 0; } - struct BullyCollisionData* obj2 <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { return 0; } - - transfer_bully_speed(obj1, obj2); - return 1; -} -*/ - -/* -int smlua_func_init_bully_collision_data(lua_State* L) { - struct BullyCollisionData* data <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { return 0; } - f32 posX = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - f32 posZ = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - f32 forwardVel = smlua_to_number(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - s16 yaw = smlua_to_integer(L, 5); - if (!gSmLuaConvertSuccess) { return 0; } - f32 conversionRatio = smlua_to_number(L, 6); - if (!gSmLuaConvertSuccess) { return 0; } - f32 radius = smlua_to_number(L, 7); - if (!gSmLuaConvertSuccess) { return 0; } - - init_bully_collision_data(data, posX, posZ, forwardVel, yaw, conversionRatio, radius); - return 1; -} -*/ - -int smlua_func_mario_update_quicksand(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - f32 arg1 = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_update_quicksand(arg0, arg1)); - return 1; -} - -int smlua_func_mario_push_off_steep_floor(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 arg1 = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 arg2 = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_push_off_steep_floor(arg0, arg1, arg2)); - return 1; -} - -int smlua_func_mario_update_moving_sand(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_update_moving_sand(arg0)); - return 1; -} - -int smlua_func_mario_update_windy_ground(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_update_windy_ground(arg0)); - return 1; -} - -int smlua_func_stop_and_set_height_to_floor(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - stop_and_set_height_to_floor(arg0); - return 1; -} - -int smlua_func_stationary_ground_step(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, stationary_ground_step(arg0)); - return 1; -} - -int smlua_func_perform_ground_step(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, perform_ground_step(arg0)); - return 1; -} - -int smlua_func_perform_air_step(lua_State* L) { - struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 arg1 = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, perform_air_step(arg0, arg1)); - return 1; -} - -int smlua_func_set_vel_from_pitch_and_yaw(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - set_vel_from_pitch_and_yaw(m); - return 1; -} - - ////////////////////////////// - // mario_actions_airborne.c // -////////////////////////////// - -int smlua_func_play_flip_sounds(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s16 frame1 = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s16 frame2 = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - s16 frame3 = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void play_flip_sounds(struct MarioState* m, s16 frame1, s16 frame2, s16 frame3); - play_flip_sounds(m, frame1, frame2, frame3); - return 1; -} - -int smlua_func_play_far_fall_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void play_far_fall_sound(struct MarioState* m); - play_far_fall_sound(m); - return 1; -} - -int smlua_func_play_knockback_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void play_knockback_sound(struct MarioState* m); - play_knockback_sound(m); - return 1; -} - -int smlua_func_lava_boost_on_wall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 lava_boost_on_wall(struct MarioState* m); - lua_pushinteger(L, lava_boost_on_wall(m)); - return 1; -} - -int smlua_func_check_fall_damage(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 hardFallAction = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_fall_damage(struct MarioState* m, u32 hardFallAction); - lua_pushinteger(L, check_fall_damage(m, hardFallAction)); - return 1; -} - -int smlua_func_check_kick_or_dive_in_air(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_kick_or_dive_in_air(struct MarioState* m); - lua_pushinteger(L, check_kick_or_dive_in_air(m)); - return 1; -} - -int smlua_func_should_get_stuck_in_ground(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 should_get_stuck_in_ground(struct MarioState* m); - lua_pushinteger(L, should_get_stuck_in_ground(m)); - return 1; -} - -int smlua_func_check_fall_damage_or_get_stuck(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 hardFallAction = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_fall_damage_or_get_stuck(struct MarioState* m, u32 hardFallAction); - lua_pushinteger(L, check_fall_damage_or_get_stuck(m, hardFallAction)); - return 1; -} - -int smlua_func_check_horizontal_wind(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_horizontal_wind(struct MarioState* m); - lua_pushinteger(L, check_horizontal_wind(m)); - return 1; -} - -int smlua_func_update_air_with_turn(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_air_with_turn(struct MarioState* m); - update_air_with_turn(m); - return 1; -} - -int smlua_func_update_air_without_turn(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_air_without_turn(struct MarioState* m); - update_air_without_turn(m); - return 1; -} - -int smlua_func_update_lava_boost_or_twirling(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_lava_boost_or_twirling(struct MarioState* m); - update_lava_boost_or_twirling(m); - return 1; -} - -int smlua_func_update_flying_yaw(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_flying_yaw(struct MarioState* m); - update_flying_yaw(m); - return 1; -} - -int smlua_func_update_flying_pitch(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_flying_pitch(struct MarioState* m); - update_flying_pitch(m); - return 1; -} - -int smlua_func_update_flying(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void update_flying(struct MarioState* m); - update_flying(m); - return 1; -} - -int smlua_func_common_air_action_step(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 landAction = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s32 animation = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - u32 stepArg = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - extern u32 common_air_action_step(struct MarioState* m, u32 landAction, s32 animation, u32 stepArg); - lua_pushinteger(L, common_air_action_step(m, landAction, animation, stepArg)); - return 1; -} - -int smlua_func_act_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_jump(struct MarioState* m); - lua_pushinteger(L, act_jump(m)); - return 1; -} - -int smlua_func_act_double_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_double_jump(struct MarioState* m); - lua_pushinteger(L, act_double_jump(m)); - return 1; -} - -int smlua_func_act_triple_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_triple_jump(struct MarioState* m); - lua_pushinteger(L, act_triple_jump(m)); - return 1; -} - -int smlua_func_act_backflip(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_backflip(struct MarioState* m); - lua_pushinteger(L, act_backflip(m)); - return 1; -} - -int smlua_func_act_freefall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_freefall(struct MarioState* m); - lua_pushinteger(L, act_freefall(m)); - return 1; -} - -int smlua_func_act_hold_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_hold_jump(struct MarioState* m); - lua_pushinteger(L, act_hold_jump(m)); - return 1; -} - -int smlua_func_act_hold_freefall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_hold_freefall(struct MarioState* m); - lua_pushinteger(L, act_hold_freefall(m)); - return 1; -} - -int smlua_func_act_side_flip(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_side_flip(struct MarioState* m); - lua_pushinteger(L, act_side_flip(m)); - return 1; -} - -int smlua_func_act_wall_kick_air(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_wall_kick_air(struct MarioState* m); - lua_pushinteger(L, act_wall_kick_air(m)); - return 1; -} - -int smlua_func_act_long_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_long_jump(struct MarioState* m); - lua_pushinteger(L, act_long_jump(m)); - return 1; -} - -int smlua_func_act_riding_shell_air(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_riding_shell_air(struct MarioState* m); - lua_pushinteger(L, act_riding_shell_air(m)); - return 1; -} - -int smlua_func_act_twirling(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_twirling(struct MarioState* m); - lua_pushinteger(L, act_twirling(m)); - return 1; -} - -int smlua_func_act_dive(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_dive(struct MarioState* m); - lua_pushinteger(L, act_dive(m)); - return 1; -} - -int smlua_func_act_air_throw(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_air_throw(struct MarioState* m); - lua_pushinteger(L, act_air_throw(m)); - return 1; -} - -int smlua_func_act_water_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_water_jump(struct MarioState* m); - lua_pushinteger(L, act_water_jump(m)); - return 1; -} - -int smlua_func_act_hold_water_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_hold_water_jump(struct MarioState* m); - lua_pushinteger(L, act_hold_water_jump(m)); - return 1; -} - -int smlua_func_act_steep_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_steep_jump(struct MarioState* m); - lua_pushinteger(L, act_steep_jump(m)); - return 1; -} - -int smlua_func_act_ground_pound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_ground_pound(struct MarioState* m); - lua_pushinteger(L, act_ground_pound(m)); - return 1; -} - -int smlua_func_act_burning_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_burning_jump(struct MarioState* m); - lua_pushinteger(L, act_burning_jump(m)); - return 1; -} - -int smlua_func_act_burning_fall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_burning_fall(struct MarioState* m); - lua_pushinteger(L, act_burning_fall(m)); - return 1; -} - -int smlua_func_act_crazy_box_bounce(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_crazy_box_bounce(struct MarioState* m); - lua_pushinteger(L, act_crazy_box_bounce(m)); - return 1; -} - -int smlua_func_check_wall_kick(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_wall_kick(struct MarioState* m); - lua_pushinteger(L, check_wall_kick(m)); - return 1; -} - -int smlua_func_act_backward_air_kb(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_backward_air_kb(struct MarioState* m); - lua_pushinteger(L, act_backward_air_kb(m)); - return 1; -} - -int smlua_func_act_forward_air_kb(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_forward_air_kb(struct MarioState* m); - lua_pushinteger(L, act_forward_air_kb(m)); - return 1; -} - -int smlua_func_act_hard_backward_air_kb(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_hard_backward_air_kb(struct MarioState* m); - lua_pushinteger(L, act_hard_backward_air_kb(m)); - return 1; -} - -int smlua_func_act_hard_forward_air_kb(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_hard_forward_air_kb(struct MarioState* m); - lua_pushinteger(L, act_hard_forward_air_kb(m)); - return 1; -} - -int smlua_func_act_thrown_backward(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_thrown_backward(struct MarioState* m); - lua_pushinteger(L, act_thrown_backward(m)); - return 1; -} - -int smlua_func_act_thrown_forward(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_thrown_forward(struct MarioState* m); - lua_pushinteger(L, act_thrown_forward(m)); - return 1; -} - -int smlua_func_act_soft_bonk(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_soft_bonk(struct MarioState* m); - lua_pushinteger(L, act_soft_bonk(m)); - return 1; -} - -int smlua_func_act_getting_blown(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_getting_blown(struct MarioState* m); - lua_pushinteger(L, act_getting_blown(m)); - return 1; -} - -int smlua_func_act_air_hit_wall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_air_hit_wall(struct MarioState* m); - lua_pushinteger(L, act_air_hit_wall(m)); - return 1; -} - -int smlua_func_act_forward_rollout(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_forward_rollout(struct MarioState* m); - lua_pushinteger(L, act_forward_rollout(m)); - return 1; -} - -int smlua_func_act_backward_rollout(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_backward_rollout(struct MarioState* m); - lua_pushinteger(L, act_backward_rollout(m)); - return 1; -} - -int smlua_func_act_butt_slide_air(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_butt_slide_air(struct MarioState* m); - lua_pushinteger(L, act_butt_slide_air(m)); - return 1; -} - -int smlua_func_act_hold_butt_slide_air(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_hold_butt_slide_air(struct MarioState* m); - lua_pushinteger(L, act_hold_butt_slide_air(m)); - return 1; -} - -int smlua_func_act_lava_boost(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_lava_boost(struct MarioState* m); - lua_pushinteger(L, act_lava_boost(m)); - return 1; -} - -int smlua_func_act_slide_kick(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_slide_kick(struct MarioState* m); - lua_pushinteger(L, act_slide_kick(m)); - return 1; -} - -int smlua_func_act_jump_kick(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_jump_kick(struct MarioState* m); - lua_pushinteger(L, act_jump_kick(m)); - return 1; -} - -int smlua_func_act_shot_from_cannon(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_shot_from_cannon(struct MarioState* m); - lua_pushinteger(L, act_shot_from_cannon(m)); - return 1; -} - -int smlua_func_act_flying(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_flying(struct MarioState* m); - lua_pushinteger(L, act_flying(m)); - return 1; -} - -int smlua_func_act_riding_hoot(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_riding_hoot(struct MarioState* m); - lua_pushinteger(L, act_riding_hoot(m)); - return 1; -} - -int smlua_func_act_flying_triple_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_flying_triple_jump(struct MarioState* m); - lua_pushinteger(L, act_flying_triple_jump(m)); - return 1; -} - -int smlua_func_act_top_of_pole_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_top_of_pole_jump(struct MarioState* m); - lua_pushinteger(L, act_top_of_pole_jump(m)); - return 1; -} - -int smlua_func_act_vertical_wind(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_vertical_wind(struct MarioState* m); - lua_pushinteger(L, act_vertical_wind(m)); - return 1; -} - -int smlua_func_act_special_triple_jump(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 act_special_triple_jump(struct MarioState* m); - lua_pushinteger(L, act_special_triple_jump(m)); - return 1; -} - -int smlua_func_check_common_airborne_cancels(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 check_common_airborne_cancels(struct MarioState* m); - lua_pushinteger(L, check_common_airborne_cancels(m)); - return 1; -} - -int smlua_func_mario_execute_airborne_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - extern s32 mario_execute_airborne_action(struct MarioState* m); - lua_pushinteger(L, mario_execute_airborne_action(m)); - return 1; -} - - ////////////// - // camera.h // -////////////// - -int smlua_func_set_camera_shake_from_hit(lua_State* L) { - s16 shake = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { return 0; } - - set_camera_shake_from_hit(shake); - return 1; -} - -int smlua_func_set_environmental_camera_shake(lua_State* L) { - s16 shake = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { return 0; } - - set_environmental_camera_shake(shake); - return 1; -} - -int smlua_func_set_camera_shake_from_point(lua_State* L) { - s16 shake = 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_camera_shake_from_point(shake, posX, posY, posZ); - return 1; -} - - //////////////////////////////// - // mario_actions_stationary.h // -//////////////////////////////// - - -int smlua_func_check_common_idle_cancels(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, check_common_idle_cancels(m)); - return 1; -} - -int smlua_func_check_common_hold_idle_cancels(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, check_common_hold_idle_cancels(m)); - return 1; -} - -int smlua_func_act_idle(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_idle(m)); - return 1; -} - -int smlua_func_play_anim_sound(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 actionState = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - s32 animFrame = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - u32 sound = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { return 0; } - - play_anim_sound(m, actionState, animFrame, sound); - return 1; -} - -int smlua_func_act_start_sleeping(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_start_sleeping(m)); - return 1; -} - -int smlua_func_act_sleeping(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_sleeping(m)); - return 1; -} - -int smlua_func_act_waking_up(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_waking_up(m)); - return 1; -} - -int smlua_func_act_shivering(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_shivering(m)); - return 1; -} - -int smlua_func_act_coughing(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_coughing(m)); - return 1; -} - -int smlua_func_act_standing_against_wall(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_standing_against_wall(m)); - return 1; -} - -int smlua_func_act_in_quicksand(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_in_quicksand(m)); - return 1; -} - -int smlua_func_act_crouching(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_crouching(m)); - return 1; -} - -int smlua_func_act_panting(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_panting(m)); - return 1; -} - -int smlua_func_stopping_step(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 animID = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - stopping_step(m, animID, action); - return 1; -} - -int smlua_func_act_braking_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_braking_stop(m)); - return 1; -} - -int smlua_func_act_butt_slide_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_butt_slide_stop(m)); - return 1; -} - -int smlua_func_act_hold_butt_slide_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_hold_butt_slide_stop(m)); - return 1; -} - -int smlua_func_act_slide_kick_slide_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_slide_kick_slide_stop(m)); - return 1; -} - -int smlua_func_act_start_crouching(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_start_crouching(m)); - return 1; -} - -int smlua_func_act_stop_crouching(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_stop_crouching(m)); - return 1; -} - -int smlua_func_act_start_crawling(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_start_crawling(m)); - return 1; -} - -int smlua_func_act_stop_crawling(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_stop_crawling(m)); - return 1; -} - -int smlua_func_act_shockwave_bounce(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_shockwave_bounce(m)); - return 1; -} - -int smlua_func_landing_step(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - s32 arg1 = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, landing_step(m, arg1, action)); - return 1; -} - -int smlua_func_check_common_landing_cancels(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - u32 action = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, check_common_landing_cancels(m, action)); - return 1; -} - -int smlua_func_act_jump_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_jump_land_stop(m)); - return 1; -} - -int smlua_func_act_double_jump_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_double_jump_land_stop(m)); - return 1; -} - -int smlua_func_act_side_flip_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_side_flip_land_stop(m)); - return 1; -} - -int smlua_func_act_freefall_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_freefall_land_stop(m)); - return 1; -} - -int smlua_func_act_triple_jump_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_triple_jump_land_stop(m)); - return 1; -} - -int smlua_func_act_backflip_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_backflip_land_stop(m)); - return 1; -} - -int smlua_func_act_lava_boost_land(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_lava_boost_land(m)); - return 1; -} - -int smlua_func_act_long_jump_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_long_jump_land_stop(m)); - return 1; -} - -int smlua_func_act_hold_jump_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_hold_jump_land_stop(m)); - return 1; -} - -int smlua_func_act_hold_freefall_land_stop(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_hold_freefall_land_stop(m)); - return 1; -} - -int smlua_func_act_air_throw_land(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_air_throw_land(m)); - return 1; -} - -int smlua_func_act_twirl_land(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_twirl_land(m)); - return 1; -} - -int smlua_func_act_ground_pound_land(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_ground_pound_land(m)); - return 1; -} - -int smlua_func_act_first_person(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, act_first_person(m)); - return 1; -} - -int smlua_func_check_common_stationary_cancels(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, check_common_stationary_cancels(m)); - return 1; -} - -int smlua_func_mario_execute_stationary_action(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - lua_pushinteger(L, mario_execute_stationary_action(m)); - return 1; -} - ////////// // misc // ////////// @@ -1962,237 +66,7 @@ int smlua_func_atan2s(lua_State* L) { void smlua_bind_functions(void) { lua_State* L = gLuaState; - ///////////// - // mario.h // - ///////////// - - smlua_bind_function(L, "is_anim_at_end", smlua_func_is_anim_at_end); - smlua_bind_function(L, "is_anim_past_end", smlua_func_is_anim_past_end); - smlua_bind_function(L, "set_mario_animation", smlua_func_set_mario_animation); - smlua_bind_function(L, "set_mario_anim_with_accel", smlua_func_set_mario_anim_with_accel); - smlua_bind_function(L, "set_anim_to_frame", smlua_func_set_anim_to_frame); - smlua_bind_function(L, "is_anim_past_frame", smlua_func_is_anim_past_frame); - //smlua_bind_function(L, "find_mario_anim_flags_and_translation", smlua_func_find_mario_anim_flags_and_translation); <--- UNIMPLEMENTED - smlua_bind_function(L, "update_mario_pos_for_anim", smlua_func_update_mario_pos_for_anim); - smlua_bind_function(L, "return_mario_anim_y_translation", smlua_func_return_mario_anim_y_translation); - smlua_bind_function(L, "play_sound_if_no_flag", smlua_func_play_sound_if_no_flag); - smlua_bind_function(L, "play_mario_jump_sound", smlua_func_play_mario_jump_sound); - smlua_bind_function(L, "adjust_sound_for_speed", smlua_func_adjust_sound_for_speed); - smlua_bind_function(L, "play_sound_and_spawn_particles", smlua_func_play_sound_and_spawn_particles); - smlua_bind_function(L, "play_mario_action_sound", smlua_func_play_mario_action_sound); - smlua_bind_function(L, "play_mario_landing_sound", smlua_func_play_mario_landing_sound); - smlua_bind_function(L, "play_mario_landing_sound_once", smlua_func_play_mario_landing_sound_once); - smlua_bind_function(L, "play_mario_heavy_landing_sound", smlua_func_play_mario_heavy_landing_sound); - smlua_bind_function(L, "play_mario_heavy_landing_sound_once", smlua_func_play_mario_heavy_landing_sound_once); - smlua_bind_function(L, "play_mario_sound", smlua_func_play_mario_sound); - smlua_bind_function(L, "mario_set_bubbled", smlua_func_mario_set_bubbled); - smlua_bind_function(L, "mario_set_forward_vel", smlua_func_mario_set_forward_vel); - smlua_bind_function(L, "mario_get_floor_class", smlua_func_mario_get_floor_class); - smlua_bind_function(L, "mario_get_terrain_sound_addend", smlua_func_mario_get_terrain_sound_addend); - //smlua_bind_function(L, "resolve_and_return_wall_collisions", smlua_func_resolve_and_return_wall_collisions); <--- UNIMPLEMENTED - //smlua_bind_function(L, "vec3f_find_ceil", smlua_func_vec3f_find_ceil); <--- UNIMPLEMENTED - smlua_bind_function(L, "mario_facing_downhill", smlua_func_mario_facing_downhill); - smlua_bind_function(L, "mario_floor_is_slippery", smlua_func_mario_floor_is_slippery); - smlua_bind_function(L, "mario_floor_is_slope", smlua_func_mario_floor_is_slope); - smlua_bind_function(L, "mario_floor_is_steep", smlua_func_mario_floor_is_steep); - smlua_bind_function(L, "find_floor_height_relative_polar", smlua_func_find_floor_height_relative_polar); - smlua_bind_function(L, "find_floor_slope", smlua_func_find_floor_slope); - smlua_bind_function(L, "update_mario_sound_and_camera", smlua_func_update_mario_sound_and_camera); - smlua_bind_function(L, "set_steep_jump_action", smlua_func_set_steep_jump_action); - smlua_bind_function(L, "set_mario_action", smlua_func_set_mario_action); - smlua_bind_function(L, "set_jump_from_landing", smlua_func_set_jump_from_landing); - smlua_bind_function(L, "set_jumping_action", smlua_func_set_jumping_action); - smlua_bind_function(L, "drop_and_set_mario_action", smlua_func_drop_and_set_mario_action); - smlua_bind_function(L, "hurt_and_set_mario_action", smlua_func_hurt_and_set_mario_action); - smlua_bind_function(L, "check_common_action_exits", smlua_func_check_common_action_exits); - smlua_bind_function(L, "check_common_hold_action_exits", smlua_func_check_common_hold_action_exits); - smlua_bind_function(L, "transition_submerged_to_walking", smlua_func_transition_submerged_to_walking); - smlua_bind_function(L, "set_water_plunge_action", smlua_func_set_water_plunge_action); - //smlua_bind_function(L, "execute_mario_action", smlua_func_execute_mario_action); <--- UNIMPLEMENTED - smlua_bind_function(L, "force_idle_state", smlua_func_force_idle_state); - smlua_bind_function(L, "init_mario", smlua_func_init_mario); - smlua_bind_function(L, "init_mario_from_save_file", smlua_func_init_mario_from_save_file); - - //////////////////////////// - // mario_actions_moving.c // - //////////////////////////// - - smlua_bind_function(L, "tilt_body_running", smlua_func_tilt_body_running); - smlua_bind_function(L, "play_step_sound", smlua_func_play_step_sound); - smlua_bind_function(L, "align_with_floor", smlua_func_align_with_floor); - smlua_bind_function(L, "begin_walking_action", smlua_func_begin_walking_action); - smlua_bind_function(L, "check_ledge_climb_down", smlua_func_check_ledge_climb_down); - smlua_bind_function(L, "slide_bonk", smlua_func_slide_bonk); - smlua_bind_function(L, "set_triple_jump_action", smlua_func_set_triple_jump_action); - smlua_bind_function(L, "update_sliding_angle", smlua_func_update_sliding_angle); - smlua_bind_function(L, "update_sliding", smlua_func_update_sliding); - smlua_bind_function(L, "apply_slope_accel", smlua_func_apply_slope_accel); - smlua_bind_function(L, "apply_landing_accel", smlua_func_apply_landing_accel); - smlua_bind_function(L, "update_shell_speed", smlua_func_update_shell_speed); - smlua_bind_function(L, "apply_slope_decel", smlua_func_apply_slope_decel); - smlua_bind_function(L, "update_decelerating_speed", smlua_func_update_decelerating_speed); - smlua_bind_function(L, "update_walking_speed", smlua_func_update_walking_speed); - smlua_bind_function(L, "should_begin_sliding", smlua_func_should_begin_sliding); - smlua_bind_function(L, "analog_stick_held_back", smlua_func_analog_stick_held_back); - smlua_bind_function(L, "check_ground_dive_or_punch", smlua_func_check_ground_dive_or_punch); - smlua_bind_function(L, "begin_braking_action", smlua_func_begin_braking_action); - smlua_bind_function(L, "anim_and_audio_for_walk", smlua_func_anim_and_audio_for_walk); - smlua_bind_function(L, "anim_and_audio_for_hold_walk", smlua_func_anim_and_audio_for_hold_walk); - smlua_bind_function(L, "anim_and_audio_for_heavy_walk", smlua_func_anim_and_audio_for_heavy_walk); - smlua_bind_function(L, "push_or_sidle_wall", smlua_func_push_or_sidle_wall); - smlua_bind_function(L, "tilt_body_walking", smlua_func_tilt_body_walking); - smlua_bind_function(L, "tilt_body_ground_shell", smlua_func_tilt_body_ground_shell); - smlua_bind_function(L, "tilt_body_butt_slide", smlua_func_tilt_body_butt_slide); - smlua_bind_function(L, "common_slide_action", smlua_func_common_slide_action); - smlua_bind_function(L, "stomach_slide_action", smlua_func_stomach_slide_action); - smlua_bind_function(L, "common_ground_knockback_action", smlua_func_common_ground_knockback_action); - smlua_bind_function(L, "common_landing_action", smlua_func_common_landing_action); - smlua_bind_function(L, "check_common_moving_cancels", smlua_func_check_common_moving_cancels); - smlua_bind_function(L, "mario_execute_moving_action", smlua_func_mario_execute_moving_action); - - ////////////////// - // mario_step.h // - ////////////////// - - smlua_bind_function(L, "mario_bonk_reflection", smlua_func_mario_bonk_reflection); - //smlua_bind_function(L, "transfer_bully_speed", smlua_func_transfer_bully_speed); <--- UNIMPLEMENTED - //smlua_bind_function(L, "init_bully_collision_data", smlua_func_init_bully_collision_data); <--- UNIMPLEMENTED - smlua_bind_function(L, "mario_update_quicksand", smlua_func_mario_update_quicksand); - smlua_bind_function(L, "mario_push_off_steep_floor", smlua_func_mario_push_off_steep_floor); - smlua_bind_function(L, "mario_update_moving_sand", smlua_func_mario_update_moving_sand); - smlua_bind_function(L, "mario_update_windy_ground", smlua_func_mario_update_windy_ground); - smlua_bind_function(L, "stop_and_set_height_to_floor", smlua_func_stop_and_set_height_to_floor); - smlua_bind_function(L, "stationary_ground_step", smlua_func_stationary_ground_step); - smlua_bind_function(L, "perform_ground_step", smlua_func_perform_ground_step); - smlua_bind_function(L, "perform_air_step", smlua_func_perform_air_step); - smlua_bind_function(L, "set_vel_from_pitch_and_yaw", smlua_func_set_vel_from_pitch_and_yaw); - - ////////////////////////////// - // mario_actions_airborne.c // - ////////////////////////////// - - smlua_bind_function(L, "play_flip_sounds", smlua_func_play_flip_sounds); - smlua_bind_function(L, "play_far_fall_sound", smlua_func_play_far_fall_sound); - smlua_bind_function(L, "play_knockback_sound", smlua_func_play_knockback_sound); - smlua_bind_function(L, "lava_boost_on_wall", smlua_func_lava_boost_on_wall); - smlua_bind_function(L, "check_fall_damage", smlua_func_check_fall_damage); - smlua_bind_function(L, "check_kick_or_dive_in_air", smlua_func_check_kick_or_dive_in_air); - smlua_bind_function(L, "should_get_stuck_in_ground", smlua_func_should_get_stuck_in_ground); - smlua_bind_function(L, "check_fall_damage_or_get_stuck", smlua_func_check_fall_damage_or_get_stuck); - smlua_bind_function(L, "check_horizontal_wind", smlua_func_check_horizontal_wind); - smlua_bind_function(L, "update_air_with_turn", smlua_func_update_air_with_turn); - smlua_bind_function(L, "update_air_without_turn", smlua_func_update_air_without_turn); - smlua_bind_function(L, "update_lava_boost_or_twirling", smlua_func_update_lava_boost_or_twirling); - smlua_bind_function(L, "update_flying_yaw", smlua_func_update_flying_yaw); - smlua_bind_function(L, "update_flying_pitch", smlua_func_update_flying_pitch); - smlua_bind_function(L, "update_flying", smlua_func_update_flying); - smlua_bind_function(L, "common_air_action_step", smlua_func_common_air_action_step); - smlua_bind_function(L, "act_jump", smlua_func_act_jump); - smlua_bind_function(L, "act_double_jump", smlua_func_act_double_jump); - smlua_bind_function(L, "act_triple_jump", smlua_func_act_triple_jump); - smlua_bind_function(L, "act_backflip", smlua_func_act_backflip); - smlua_bind_function(L, "act_freefall", smlua_func_act_freefall); - smlua_bind_function(L, "act_hold_jump", smlua_func_act_hold_jump); - smlua_bind_function(L, "act_hold_freefall", smlua_func_act_hold_freefall); - smlua_bind_function(L, "act_side_flip", smlua_func_act_side_flip); - smlua_bind_function(L, "act_wall_kick_air", smlua_func_act_wall_kick_air); - smlua_bind_function(L, "act_long_jump", smlua_func_act_long_jump); - smlua_bind_function(L, "act_riding_shell_air", smlua_func_act_riding_shell_air); - smlua_bind_function(L, "act_twirling", smlua_func_act_twirling); - smlua_bind_function(L, "act_dive", smlua_func_act_dive); - smlua_bind_function(L, "act_air_throw", smlua_func_act_air_throw); - smlua_bind_function(L, "act_water_jump", smlua_func_act_water_jump); - smlua_bind_function(L, "act_hold_water_jump", smlua_func_act_hold_water_jump); - smlua_bind_function(L, "act_steep_jump", smlua_func_act_steep_jump); - smlua_bind_function(L, "act_ground_pound", smlua_func_act_ground_pound); - smlua_bind_function(L, "act_burning_jump", smlua_func_act_burning_jump); - smlua_bind_function(L, "act_burning_fall", smlua_func_act_burning_fall); - smlua_bind_function(L, "act_crazy_box_bounce", smlua_func_act_crazy_box_bounce); - smlua_bind_function(L, "check_wall_kick", smlua_func_check_wall_kick); - smlua_bind_function(L, "act_backward_air_kb", smlua_func_act_backward_air_kb); - smlua_bind_function(L, "act_forward_air_kb", smlua_func_act_forward_air_kb); - smlua_bind_function(L, "act_hard_backward_air_kb", smlua_func_act_hard_backward_air_kb); - smlua_bind_function(L, "act_hard_forward_air_kb", smlua_func_act_hard_forward_air_kb); - smlua_bind_function(L, "act_thrown_backward", smlua_func_act_thrown_backward); - smlua_bind_function(L, "act_thrown_forward", smlua_func_act_thrown_forward); - smlua_bind_function(L, "act_soft_bonk", smlua_func_act_soft_bonk); - smlua_bind_function(L, "act_getting_blown", smlua_func_act_getting_blown); - smlua_bind_function(L, "act_air_hit_wall", smlua_func_act_air_hit_wall); - smlua_bind_function(L, "act_forward_rollout", smlua_func_act_forward_rollout); - smlua_bind_function(L, "act_backward_rollout", smlua_func_act_backward_rollout); - smlua_bind_function(L, "act_butt_slide_air", smlua_func_act_butt_slide_air); - smlua_bind_function(L, "act_hold_butt_slide_air", smlua_func_act_hold_butt_slide_air); - smlua_bind_function(L, "act_lava_boost", smlua_func_act_lava_boost); - smlua_bind_function(L, "act_slide_kick", smlua_func_act_slide_kick); - smlua_bind_function(L, "act_jump_kick", smlua_func_act_jump_kick); - smlua_bind_function(L, "act_shot_from_cannon", smlua_func_act_shot_from_cannon); - smlua_bind_function(L, "act_flying", smlua_func_act_flying); - smlua_bind_function(L, "act_riding_hoot", smlua_func_act_riding_hoot); - smlua_bind_function(L, "act_flying_triple_jump", smlua_func_act_flying_triple_jump); - smlua_bind_function(L, "act_top_of_pole_jump", smlua_func_act_top_of_pole_jump); - smlua_bind_function(L, "act_vertical_wind", smlua_func_act_vertical_wind); - smlua_bind_function(L, "act_special_triple_jump", smlua_func_act_special_triple_jump); - smlua_bind_function(L, "check_common_airborne_cancels", smlua_func_check_common_airborne_cancels); - smlua_bind_function(L, "mario_execute_airborne_action", smlua_func_mario_execute_airborne_action); - - ////////////// - // camera.h // - ////////////// - - smlua_bind_function(L, "set_camera_shake_from_hit", smlua_func_set_camera_shake_from_hit); - smlua_bind_function(L, "set_environmental_camera_shake", smlua_func_set_environmental_camera_shake); - smlua_bind_function(L, "set_camera_shake_from_point", smlua_func_set_camera_shake_from_point); - - //////////////////////////////// - // mario_actions_stationary.h // - //////////////////////////////// - - smlua_bind_function(L, "check_common_idle_cancels", smlua_func_check_common_idle_cancels); - smlua_bind_function(L, "check_common_hold_idle_cancels", smlua_func_check_common_hold_idle_cancels); - smlua_bind_function(L, "act_idle", smlua_func_act_idle); - smlua_bind_function(L, "play_anim_sound", smlua_func_play_anim_sound); - smlua_bind_function(L, "act_start_sleeping", smlua_func_act_start_sleeping); - smlua_bind_function(L, "act_sleeping", smlua_func_act_sleeping); - smlua_bind_function(L, "act_waking_up", smlua_func_act_waking_up); - smlua_bind_function(L, "act_shivering", smlua_func_act_shivering); - smlua_bind_function(L, "act_coughing", smlua_func_act_coughing); - smlua_bind_function(L, "act_standing_against_wall", smlua_func_act_standing_against_wall); - smlua_bind_function(L, "act_in_quicksand", smlua_func_act_in_quicksand); - smlua_bind_function(L, "act_crouching", smlua_func_act_crouching); - smlua_bind_function(L, "act_panting", smlua_func_act_panting); - smlua_bind_function(L, "stopping_step", smlua_func_stopping_step); - smlua_bind_function(L, "act_braking_stop", smlua_func_act_braking_stop); - smlua_bind_function(L, "act_butt_slide_stop", smlua_func_act_butt_slide_stop); - smlua_bind_function(L, "act_hold_butt_slide_stop", smlua_func_act_hold_butt_slide_stop); - smlua_bind_function(L, "act_slide_kick_slide_stop", smlua_func_act_slide_kick_slide_stop); - smlua_bind_function(L, "act_start_crouching", smlua_func_act_start_crouching); - smlua_bind_function(L, "act_stop_crouching", smlua_func_act_stop_crouching); - smlua_bind_function(L, "act_start_crawling", smlua_func_act_start_crawling); - smlua_bind_function(L, "act_stop_crawling", smlua_func_act_stop_crawling); - smlua_bind_function(L, "act_shockwave_bounce", smlua_func_act_shockwave_bounce); - smlua_bind_function(L, "landing_step", smlua_func_landing_step); - smlua_bind_function(L, "check_common_landing_cancels", smlua_func_check_common_landing_cancels); - smlua_bind_function(L, "act_jump_land_stop", smlua_func_act_jump_land_stop); - smlua_bind_function(L, "act_double_jump_land_stop", smlua_func_act_double_jump_land_stop); - smlua_bind_function(L, "act_side_flip_land_stop", smlua_func_act_side_flip_land_stop); - smlua_bind_function(L, "act_freefall_land_stop", smlua_func_act_freefall_land_stop); - smlua_bind_function(L, "act_triple_jump_land_stop", smlua_func_act_triple_jump_land_stop); - smlua_bind_function(L, "act_backflip_land_stop", smlua_func_act_backflip_land_stop); - smlua_bind_function(L, "act_lava_boost_land", smlua_func_act_lava_boost_land); - smlua_bind_function(L, "act_long_jump_land_stop", smlua_func_act_long_jump_land_stop); - smlua_bind_function(L, "act_hold_jump_land_stop", smlua_func_act_hold_jump_land_stop); - smlua_bind_function(L, "act_hold_freefall_land_stop", smlua_func_act_hold_freefall_land_stop); - smlua_bind_function(L, "act_air_throw_land", smlua_func_act_air_throw_land); - smlua_bind_function(L, "act_twirl_land", smlua_func_act_twirl_land); - smlua_bind_function(L, "act_ground_pound_land", smlua_func_act_ground_pound_land); - smlua_bind_function(L, "act_first_person", smlua_func_act_first_person); - smlua_bind_function(L, "check_common_stationary_cancels", smlua_func_check_common_stationary_cancels); - smlua_bind_function(L, "mario_execute_stationary_action", smlua_func_mario_execute_stationary_action); - - ////////// - // misc // - ////////// - + // misc smlua_bind_function(L, "get_camera_position", smlua_get_camera_position); smlua_bind_function(L, "check_fall_damage_or_get_stuck", smlua_check_fall_damage_or_get_stuck); smlua_bind_function(L, "play_sound", smlua_play_sound); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c new file mode 100644 index 000000000..cc3f5d40d --- /dev/null +++ b/src/pc/lua/smlua_functions_autogen.c @@ -0,0 +1,2360 @@ +/* THIS FILE IS AUTOGENERATED */ +/* SHOULD NOT BE MANUALLY CHANGED */ + +#include "smlua.h" + +#include "game/level_update.h" +#include "game/area.h" +#include "game/mario.h" +#include "game/mario_step.h" +#include "game/mario_actions_stationary.h" +#include "audio/external.h" +#include "object_fields.h" +#include "engine/math_util.h" + + ////////////// + // camera.h // +////////////// + +int smlua_func_set_camera_shake_from_hit(lua_State* L) { + s16 shake = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + set_camera_shake_from_hit(shake); + return 1; +} + +int smlua_func_set_environmental_camera_shake(lua_State* L) { + s16 shake = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + set_environmental_camera_shake(shake); + return 1; +} + +int smlua_func_set_camera_shake_from_point(lua_State* L) { + s16 shake = 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_camera_shake_from_point(shake, posX, posY, posZ); + return 1; +} + + ///////////// + // mario.h // +///////////// + +int smlua_func_is_anim_at_end(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, is_anim_at_end(m)); + return 1; +} + +int smlua_func_is_anim_past_end(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, is_anim_past_end(m)); + return 1; +} + +int smlua_func_set_mario_animation(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 targetAnimID = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_mario_animation(m, targetAnimID)); + return 1; +} + +int smlua_func_set_mario_anim_with_accel(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 targetAnimID = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 accel = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_mario_anim_with_accel(m, targetAnimID, accel)); + return 1; +} + +int smlua_func_set_anim_to_frame(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 animFrame = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + set_anim_to_frame(m, animFrame); + return 1; +} + +int smlua_func_is_anim_past_frame(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 animFrame = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, is_anim_past_frame(m, animFrame)); + return 1; +} + +/* +int smlua_func_find_mario_anim_flags_and_translation(lua_State* L) { + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s32 yaw = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + Vec3s translation <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, find_mario_anim_flags_and_translation(o, yaw, translation)); + return 1; +} +*/ + +int smlua_func_update_mario_pos_for_anim(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + update_mario_pos_for_anim(m); + return 1; +} + +int smlua_func_return_mario_anim_y_translation(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, return_mario_anim_y_translation(m)); + return 1; +} + +int smlua_func_play_sound_if_no_flag(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 flags = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + play_sound_if_no_flag(m, soundBits, flags); + return 1; +} + +int smlua_func_play_mario_jump_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_jump_sound(m); + return 1; +} + +int smlua_func_adjust_sound_for_speed(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + adjust_sound_for_speed(m); + return 1; +} + +int smlua_func_play_sound_and_spawn_particles(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 waveParticleType = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + play_sound_and_spawn_particles(m, soundBits, waveParticleType); + return 1; +} + +int smlua_func_play_mario_action_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 waveParticleType = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_action_sound(m, soundBits, waveParticleType); + return 1; +} + +int smlua_func_play_mario_landing_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_landing_sound(m, soundBits); + return 1; +} + +int smlua_func_play_mario_landing_sound_once(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_landing_sound_once(m, soundBits); + return 1; +} + +int smlua_func_play_mario_heavy_landing_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_heavy_landing_sound(m, soundBits); + return 1; +} + +int smlua_func_play_mario_heavy_landing_sound_once(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 soundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_heavy_landing_sound_once(m, soundBits); + return 1; +} + +int smlua_func_play_mario_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 primarySoundBits = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 scondarySoundBits = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + play_mario_sound(m, primarySoundBits, scondarySoundBits); + return 1; +} + +int smlua_func_mario_set_bubbled(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + mario_set_bubbled(m); + return 1; +} + +int smlua_func_mario_set_forward_vel(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 speed = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + mario_set_forward_vel(m, speed); + return 1; +} + +int smlua_func_mario_get_floor_class(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_get_floor_class(m)); + return 1; +} + +int smlua_func_mario_get_terrain_sound_addend(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_get_terrain_sound_addend(m)); + return 1; +} + +/* +int smlua_func_resolve_and_return_wall_collisions(lua_State* L) { + Vec3f pos <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + f32 offset = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 radius = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + UNIMPLEMENTED -->(L, resolve_and_return_wall_collisions(pos, offset, radius)); + return 1; +} +*/ + +/* +int smlua_func_vec3f_find_ceil(lua_State* L) { + Vec3f pos <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + f32 height = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + struct Surface** ceil <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushnumber(L, vec3f_find_ceil(pos, height, ceil)); + return 1; +} +*/ + +int smlua_func_mario_facing_downhill(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 turnYaw = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_facing_downhill(m, turnYaw)); + return 1; +} + +int smlua_func_mario_floor_is_slippery(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_floor_is_slippery(m)); + return 1; +} + +int smlua_func_mario_floor_is_slope(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_floor_is_slope(m)); + return 1; +} + +int smlua_func_mario_floor_is_steep(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_floor_is_steep(m)); + return 1; +} + +int smlua_func_find_floor_height_relative_polar(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 angleFromMario = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 distFromMario = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushnumber(L, find_floor_height_relative_polar(m, angleFromMario, distFromMario)); + return 1; +} + +int smlua_func_find_floor_slope(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 yawOffset = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, find_floor_slope(m, yawOffset)); + return 1; +} + +int smlua_func_update_mario_sound_and_camera(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + update_mario_sound_and_camera(m); + return 1; +} + +int smlua_func_set_steep_jump_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + set_steep_jump_action(m); + return 1; +} + +int smlua_func_set_mario_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionArg = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_mario_action(m, action, actionArg)); + return 1; +} + +int smlua_func_set_jump_from_landing(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_jump_from_landing(m)); + return 1; +} + +int smlua_func_set_jumping_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionArg = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_jumping_action(m, action, actionArg)); + return 1; +} + +int smlua_func_drop_and_set_mario_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionArg = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, drop_and_set_mario_action(m, action, actionArg)); + return 1; +} + +int smlua_func_hurt_and_set_mario_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionArg = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 hurtCounter = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, hurt_and_set_mario_action(m, action, actionArg, hurtCounter)); + return 1; +} + +int smlua_func_check_common_action_exits(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, check_common_action_exits(m)); + return 1; +} + +int smlua_func_check_common_hold_action_exits(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, check_common_hold_action_exits(m)); + return 1; +} + +int smlua_func_transition_submerged_to_walking(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, transition_submerged_to_walking(m)); + return 1; +} + +int smlua_func_set_water_plunge_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, set_water_plunge_action(m)); + return 1; +} + +int smlua_func_execute_mario_action(lua_State* L) { + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, execute_mario_action(o)); + return 1; +} + +int smlua_func_force_idle_state(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, force_idle_state(m)); + return 1; +} + + ////////////////////////////// + // mario_actions_airborne.c // +////////////////////////////// + +int smlua_func_play_flip_sounds(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frame1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frame2 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frame3 = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3); + play_flip_sounds(m, frame1, frame2, frame3); + return 1; +} + +int smlua_func_play_far_fall_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void play_far_fall_sound(struct MarioState *m); + play_far_fall_sound(m); + return 1; +} + +int smlua_func_play_knockback_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void play_knockback_sound(struct MarioState *m); + play_knockback_sound(m); + return 1; +} + +int smlua_func_lava_boost_on_wall(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 lava_boost_on_wall(struct MarioState *m); + lua_pushinteger(L, lava_boost_on_wall(m)); + return 1; +} + +int smlua_func_check_fall_damage(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 hardFallAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_fall_damage(struct MarioState *m, u32 hardFallAction); + lua_pushinteger(L, check_fall_damage(m, hardFallAction)); + return 1; +} + +int smlua_func_check_kick_or_dive_in_air(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_kick_or_dive_in_air(struct MarioState *m); + lua_pushinteger(L, check_kick_or_dive_in_air(m)); + return 1; +} + +int smlua_func_should_get_stuck_in_ground(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 should_get_stuck_in_ground(struct MarioState *m); + lua_pushinteger(L, should_get_stuck_in_ground(m)); + return 1; +} + +int smlua_func_check_fall_damage_or_get_stuck(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 hardFallAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction); + lua_pushinteger(L, check_fall_damage_or_get_stuck(m, hardFallAction)); + return 1; +} + +int smlua_func_check_horizontal_wind(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_horizontal_wind(struct MarioState *m); + lua_pushinteger(L, check_horizontal_wind(m)); + return 1; +} + +int smlua_func_update_air_with_turn(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_air_with_turn(struct MarioState *m); + update_air_with_turn(m); + return 1; +} + +int smlua_func_update_air_without_turn(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_air_without_turn(struct MarioState *m); + update_air_without_turn(m); + return 1; +} + +int smlua_func_update_lava_boost_or_twirling(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_lava_boost_or_twirling(struct MarioState *m); + update_lava_boost_or_twirling(m); + return 1; +} + +int smlua_func_update_flying_yaw(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_flying_yaw(struct MarioState *m); + update_flying_yaw(m); + return 1; +} + +int smlua_func_update_flying_pitch(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_flying_pitch(struct MarioState *m); + update_flying_pitch(m); + return 1; +} + +int smlua_func_update_flying(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_flying(struct MarioState *m); + update_flying(m); + return 1; +} + +int smlua_func_common_air_action_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 landAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + u32 stepArg = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, u32 stepArg); + lua_pushinteger(L, common_air_action_step(m, landAction, animation, stepArg)); + return 1; +} + +int smlua_func_act_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_jump(struct MarioState *m); + lua_pushinteger(L, act_jump(m)); + return 1; +} + +int smlua_func_act_double_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_double_jump(struct MarioState *m); + lua_pushinteger(L, act_double_jump(m)); + return 1; +} + +int smlua_func_act_triple_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_triple_jump(struct MarioState *m); + lua_pushinteger(L, act_triple_jump(m)); + return 1; +} + +int smlua_func_act_backflip(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_backflip(struct MarioState *m); + lua_pushinteger(L, act_backflip(m)); + return 1; +} + +int smlua_func_act_freefall(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_freefall(struct MarioState *m); + lua_pushinteger(L, act_freefall(m)); + return 1; +} + +int smlua_func_act_hold_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hold_jump(struct MarioState *m); + lua_pushinteger(L, act_hold_jump(m)); + return 1; +} + +int smlua_func_act_hold_freefall(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hold_freefall(struct MarioState *m); + lua_pushinteger(L, act_hold_freefall(m)); + return 1; +} + +int smlua_func_act_side_flip(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_side_flip(struct MarioState *m); + lua_pushinteger(L, act_side_flip(m)); + return 1; +} + +int smlua_func_act_wall_kick_air(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_wall_kick_air(struct MarioState *m); + lua_pushinteger(L, act_wall_kick_air(m)); + return 1; +} + +int smlua_func_act_long_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_long_jump(struct MarioState *m); + lua_pushinteger(L, act_long_jump(m)); + return 1; +} + +int smlua_func_act_riding_shell_air(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_riding_shell_air(struct MarioState *m); + lua_pushinteger(L, act_riding_shell_air(m)); + return 1; +} + +int smlua_func_act_twirling(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_twirling(struct MarioState *m); + lua_pushinteger(L, act_twirling(m)); + return 1; +} + +int smlua_func_act_dive(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_dive(struct MarioState *m); + lua_pushinteger(L, act_dive(m)); + return 1; +} + +int smlua_func_act_air_throw(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_air_throw(struct MarioState *m); + lua_pushinteger(L, act_air_throw(m)); + return 1; +} + +int smlua_func_act_water_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_water_jump(struct MarioState *m); + lua_pushinteger(L, act_water_jump(m)); + return 1; +} + +int smlua_func_act_hold_water_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hold_water_jump(struct MarioState *m); + lua_pushinteger(L, act_hold_water_jump(m)); + return 1; +} + +int smlua_func_act_steep_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_steep_jump(struct MarioState *m); + lua_pushinteger(L, act_steep_jump(m)); + return 1; +} + +int smlua_func_act_ground_pound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_ground_pound(struct MarioState *m); + lua_pushinteger(L, act_ground_pound(m)); + return 1; +} + +int smlua_func_act_burning_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_burning_jump(struct MarioState *m); + lua_pushinteger(L, act_burning_jump(m)); + return 1; +} + +int smlua_func_act_burning_fall(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_burning_fall(struct MarioState *m); + lua_pushinteger(L, act_burning_fall(m)); + return 1; +} + +int smlua_func_act_crazy_box_bounce(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_crazy_box_bounce(struct MarioState *m); + lua_pushinteger(L, act_crazy_box_bounce(m)); + return 1; +} + +int smlua_func_common_air_knockback_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 landAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 hardFallAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + f32 speed = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + extern u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFallAction, s32 animation, f32 speed); + lua_pushinteger(L, common_air_knockback_step(m, landAction, hardFallAction, animation, speed)); + return 1; +} + +int smlua_func_check_wall_kick(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_wall_kick(struct MarioState *m); + lua_pushinteger(L, check_wall_kick(m)); + return 1; +} + +int smlua_func_act_backward_air_kb(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_backward_air_kb(struct MarioState *m); + lua_pushinteger(L, act_backward_air_kb(m)); + return 1; +} + +int smlua_func_act_forward_air_kb(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_forward_air_kb(struct MarioState *m); + lua_pushinteger(L, act_forward_air_kb(m)); + return 1; +} + +int smlua_func_act_hard_backward_air_kb(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hard_backward_air_kb(struct MarioState *m); + lua_pushinteger(L, act_hard_backward_air_kb(m)); + return 1; +} + +int smlua_func_act_hard_forward_air_kb(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hard_forward_air_kb(struct MarioState *m); + lua_pushinteger(L, act_hard_forward_air_kb(m)); + return 1; +} + +int smlua_func_act_thrown_backward(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_thrown_backward(struct MarioState *m); + lua_pushinteger(L, act_thrown_backward(m)); + return 1; +} + +int smlua_func_act_thrown_forward(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_thrown_forward(struct MarioState *m); + lua_pushinteger(L, act_thrown_forward(m)); + return 1; +} + +int smlua_func_act_soft_bonk(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_soft_bonk(struct MarioState *m); + lua_pushinteger(L, act_soft_bonk(m)); + return 1; +} + +int smlua_func_act_getting_blown(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_getting_blown(struct MarioState *m); + lua_pushinteger(L, act_getting_blown(m)); + return 1; +} + +int smlua_func_act_air_hit_wall(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_air_hit_wall(struct MarioState *m); + lua_pushinteger(L, act_air_hit_wall(m)); + return 1; +} + +int smlua_func_act_forward_rollout(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_forward_rollout(struct MarioState *m); + lua_pushinteger(L, act_forward_rollout(m)); + return 1; +} + +int smlua_func_act_backward_rollout(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_backward_rollout(struct MarioState *m); + lua_pushinteger(L, act_backward_rollout(m)); + return 1; +} + +int smlua_func_act_butt_slide_air(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_butt_slide_air(struct MarioState *m); + lua_pushinteger(L, act_butt_slide_air(m)); + return 1; +} + +int smlua_func_act_hold_butt_slide_air(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hold_butt_slide_air(struct MarioState *m); + lua_pushinteger(L, act_hold_butt_slide_air(m)); + return 1; +} + +int smlua_func_act_lava_boost(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_lava_boost(struct MarioState *m); + lua_pushinteger(L, act_lava_boost(m)); + return 1; +} + +int smlua_func_act_slide_kick(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_slide_kick(struct MarioState *m); + lua_pushinteger(L, act_slide_kick(m)); + return 1; +} + +int smlua_func_act_jump_kick(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_jump_kick(struct MarioState *m); + lua_pushinteger(L, act_jump_kick(m)); + return 1; +} + +int smlua_func_act_shot_from_cannon(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_shot_from_cannon(struct MarioState *m); + lua_pushinteger(L, act_shot_from_cannon(m)); + return 1; +} + +int smlua_func_act_flying(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_flying(struct MarioState *m); + lua_pushinteger(L, act_flying(m)); + return 1; +} + +int smlua_func_act_riding_hoot(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_riding_hoot(struct MarioState *m); + lua_pushinteger(L, act_riding_hoot(m)); + return 1; +} + +int smlua_func_act_flying_triple_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_flying_triple_jump(struct MarioState *m); + lua_pushinteger(L, act_flying_triple_jump(m)); + return 1; +} + +int smlua_func_act_top_of_pole_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_top_of_pole_jump(struct MarioState *m); + lua_pushinteger(L, act_top_of_pole_jump(m)); + return 1; +} + +int smlua_func_act_vertical_wind(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_vertical_wind(struct MarioState *m); + lua_pushinteger(L, act_vertical_wind(m)); + return 1; +} + +int smlua_func_act_special_triple_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_special_triple_jump(struct MarioState *m); + lua_pushinteger(L, act_special_triple_jump(m)); + return 1; +} + +int smlua_func_check_common_airborne_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_airborne_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_airborne_cancels(m)); + return 1; +} + +int smlua_func_mario_execute_airborne_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_execute_airborne_action(struct MarioState *m); + lua_pushinteger(L, mario_execute_airborne_action(m)); + return 1; +} + + /////////////////////////////// + // mario_actions_automatic.c // +/////////////////////////////// + +int smlua_func_add_tree_leaf_particles(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void add_tree_leaf_particles(struct MarioState *m); + add_tree_leaf_particles(m); + return 1; +} + +int smlua_func_play_climbing_sounds(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 b = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void play_climbing_sounds(struct MarioState *m, s32 b); + play_climbing_sounds(m, b); + return 1; +} + +int smlua_func_set_pole_position(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 offsetY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 set_pole_position(struct MarioState *m, f32 offsetY); + lua_pushinteger(L, set_pole_position(m, offsetY)); + return 1; +} + +int smlua_func_act_holding_pole(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_holding_pole(struct MarioState *m); + lua_pushinteger(L, act_holding_pole(m)); + return 1; +} + +int smlua_func_act_climbing_pole(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_climbing_pole(struct MarioState *m); + lua_pushinteger(L, act_climbing_pole(m)); + return 1; +} + +int smlua_func_act_grab_pole_slow(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_grab_pole_slow(struct MarioState *m); + lua_pushinteger(L, act_grab_pole_slow(m)); + return 1; +} + +int smlua_func_act_grab_pole_fast(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_grab_pole_fast(struct MarioState *m); + lua_pushinteger(L, act_grab_pole_fast(m)); + return 1; +} + +int smlua_func_act_top_of_pole_transition(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_top_of_pole_transition(struct MarioState *m); + lua_pushinteger(L, act_top_of_pole_transition(m)); + return 1; +} + +int smlua_func_act_top_of_pole(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_top_of_pole(struct MarioState *m); + lua_pushinteger(L, act_top_of_pole(m)); + return 1; +} + +/* +int smlua_func_perform_hanging_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + Vec3f nextPos <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos); + lua_pushinteger(L, perform_hanging_step(m, nextPos)); + return 1; +} +*/ + +int smlua_func_update_hang_moving(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 update_hang_moving(struct MarioState *m); + lua_pushinteger(L, update_hang_moving(m)); + return 1; +} + +int smlua_func_update_hang_stationary(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_hang_stationary(struct MarioState *m); + update_hang_stationary(m); + return 1; +} + +int smlua_func_act_start_hanging(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_start_hanging(struct MarioState *m); + lua_pushinteger(L, act_start_hanging(m)); + return 1; +} + +int smlua_func_act_hanging(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hanging(struct MarioState *m); + lua_pushinteger(L, act_hanging(m)); + return 1; +} + +int smlua_func_act_hang_moving(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_hang_moving(struct MarioState *m); + lua_pushinteger(L, act_hang_moving(m)); + return 1; +} + +int smlua_func_let_go_of_ledge(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 let_go_of_ledge(struct MarioState *m); + lua_pushinteger(L, let_go_of_ledge(m)); + return 1; +} + +int smlua_func_climb_up_ledge(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void climb_up_ledge(struct MarioState *m); + climb_up_ledge(m); + return 1; +} + +int smlua_func_update_ledge_climb_camera(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_ledge_climb_camera(struct MarioState *m); + update_ledge_climb_camera(m); + return 1; +} + +int smlua_func_update_ledge_climb(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 endAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_ledge_climb(struct MarioState *m, s32 animation, u32 endAction); + update_ledge_climb(m, animation, endAction); + return 1; +} + +int smlua_func_act_ledge_grab(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_ledge_grab(struct MarioState *m); + lua_pushinteger(L, act_ledge_grab(m)); + return 1; +} + +int smlua_func_act_ledge_climb_slow(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_ledge_climb_slow(struct MarioState *m); + lua_pushinteger(L, act_ledge_climb_slow(m)); + return 1; +} + +int smlua_func_act_ledge_climb_down(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_ledge_climb_down(struct MarioState *m); + lua_pushinteger(L, act_ledge_climb_down(m)); + return 1; +} + +int smlua_func_act_ledge_climb_fast(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_ledge_climb_fast(struct MarioState *m); + lua_pushinteger(L, act_ledge_climb_fast(m)); + return 1; +} + +int smlua_func_act_grabbed(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_grabbed(struct MarioState *m); + lua_pushinteger(L, act_grabbed(m)); + return 1; +} + +int smlua_func_act_in_cannon(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_in_cannon(struct MarioState *m); + lua_pushinteger(L, act_in_cannon(m)); + return 1; +} + +int smlua_func_act_tornado_twirling(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_tornado_twirling(struct MarioState *m); + lua_pushinteger(L, act_tornado_twirling(m)); + return 1; +} + +int smlua_func_act_bubbled(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 act_bubbled(struct MarioState* m); + lua_pushinteger(L, act_bubbled(m)); + return 1; +} + +int smlua_func_check_common_automatic_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_automatic_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_automatic_cancels(m)); + return 1; +} + +int smlua_func_mario_execute_automatic_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_execute_automatic_action(struct MarioState *m); + lua_pushinteger(L, mario_execute_automatic_action(m)); + return 1; +} + + ////////////////////////////// + // mario_actions_cutscene.c // +////////////////////////////// + +int smlua_func_print_displaying_credits_entry(UNUSED lua_State* L) { + + extern void print_displaying_credits_entry(void); + print_displaying_credits_entry(); + return 1; +} + +int smlua_func_bhv_end_peach_loop(UNUSED lua_State* L) { + + extern void bhv_end_peach_loop(void); + bhv_end_peach_loop(); + return 1; +} + +int smlua_func_bhv_end_toad_loop(UNUSED lua_State* L) { + + extern void bhv_end_toad_loop(void); + bhv_end_toad_loop(); + return 1; +} + +int smlua_func_handle_save_menu(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void handle_save_menu(struct MarioState *m); + handle_save_menu(m); + return 1; +} + +/* +int smlua_func_spawn_obj_at_mario_rel_yaw(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 model = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + BehaviorScript * behavior <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + s16 relYaw = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern struct Object *spawn_obj_at_mario_rel_yaw(struct MarioState *m, s32 model, BehaviorScript *behavior, s16 relYaw); + UNIMPLEMENTED -->(L, spawn_obj_at_mario_rel_yaw(m, model, behavior, relYaw)); + return 1; +} +*/ + +int smlua_func_cutscene_take_cap_off(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cutscene_take_cap_off(struct MarioState *m); + cutscene_take_cap_off(m); + return 1; +} + +int smlua_func_cutscene_put_cap_on(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cutscene_put_cap_on(struct MarioState *m); + cutscene_put_cap_on(m); + return 1; +} + +int smlua_func_should_start_or_continue_dialog(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* object = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object); + lua_pushinteger(L, should_start_or_continue_dialog(m, object)); + return 1; +} + +int smlua_func_general_star_dance_handler(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 isInWater = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void general_star_dance_handler(struct MarioState *m, s32 isInWater); + general_star_dance_handler(m, isInWater); + return 1; +} + +int smlua_func_stuck_in_ground_handler(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 unstuckFrame = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s32 target2 = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + s32 target3 = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + s32 endAction = smlua_to_integer(L, 6); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFrame, s32 target2, s32 target3, s32 endAction); + stuck_in_ground_handler(m, animation, unstuckFrame, target2, target3, endAction); + return 1; +} + +int smlua_func_generate_yellow_sparkles(lua_State* L) { + s16 x = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 y = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 z = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 radius = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius); + generate_yellow_sparkles(x, y, z, radius); + return 1; +} + + //////////////////////////// + // mario_actions_moving.c // +//////////////////////////// + +int smlua_func_tilt_body_running(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s16 tilt_body_running(struct MarioState *m); + lua_pushinteger(L, tilt_body_running(m)); + return 1; +} + +int smlua_func_play_step_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frame1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 frame2 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2); + play_step_sound(m, frame1, frame2); + return 1; +} + +int smlua_func_align_with_floor(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void align_with_floor(struct MarioState *m); + align_with_floor(m); + return 1; +} + +int smlua_func_begin_walking_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 forwardVel = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionArg = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 begin_walking_action(struct MarioState *m, f32 forwardVel, u32 action, u32 actionArg); + lua_pushinteger(L, begin_walking_action(m, forwardVel, action, actionArg)); + return 1; +} + +int smlua_func_check_ledge_climb_down(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void check_ledge_climb_down(struct MarioState *m); + check_ledge_climb_down(m); + return 1; +} + +int smlua_func_slide_bonk(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 fastAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 slowAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction); + slide_bonk(m, fastAction, slowAction); + return 1; +} + +int smlua_func_set_triple_jump_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionArg = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 actionArg); + lua_pushinteger(L, set_triple_jump_action(m, action, actionArg)); + return 1; +} + +int smlua_func_update_sliding_angle(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 accel = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 lossFactor = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor); + update_sliding_angle(m, accel, lossFactor); + return 1; +} + +int smlua_func_update_sliding(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 stopSpeed = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 update_sliding(struct MarioState *m, f32 stopSpeed); + lua_pushinteger(L, update_sliding(m, stopSpeed)); + return 1; +} + +int smlua_func_apply_slope_accel(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void apply_slope_accel(struct MarioState *m); + apply_slope_accel(m); + return 1; +} + +int smlua_func_apply_landing_accel(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 frictionFactor = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor); + lua_pushinteger(L, apply_landing_accel(m, frictionFactor)); + return 1; +} + +int smlua_func_update_shell_speed(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_shell_speed(struct MarioState *m); + update_shell_speed(m); + return 1; +} + +int smlua_func_apply_slope_decel(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 decelCoef = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 apply_slope_decel(struct MarioState *m, f32 decelCoef); + lua_pushinteger(L, apply_slope_decel(m, decelCoef)); + return 1; +} + +int smlua_func_update_decelerating_speed(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 update_decelerating_speed(struct MarioState *m); + lua_pushinteger(L, update_decelerating_speed(m)); + return 1; +} + +int smlua_func_update_walking_speed(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void update_walking_speed(struct MarioState *m); + update_walking_speed(m); + return 1; +} + +int smlua_func_should_begin_sliding(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 should_begin_sliding(struct MarioState *m); + lua_pushinteger(L, should_begin_sliding(m)); + return 1; +} + +int smlua_func_analog_stick_held_back(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 analog_stick_held_back(struct MarioState *m); + lua_pushinteger(L, analog_stick_held_back(m)); + return 1; +} + +int smlua_func_check_ground_dive_or_punch(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_ground_dive_or_punch(struct MarioState *m); + lua_pushinteger(L, check_ground_dive_or_punch(m)); + return 1; +} + +int smlua_func_begin_braking_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 begin_braking_action(struct MarioState *m); + lua_pushinteger(L, begin_braking_action(m)); + return 1; +} + +int smlua_func_anim_and_audio_for_walk(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void anim_and_audio_for_walk(struct MarioState *m); + anim_and_audio_for_walk(m); + return 1; +} + +int smlua_func_anim_and_audio_for_hold_walk(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void anim_and_audio_for_hold_walk(struct MarioState *m); + anim_and_audio_for_hold_walk(m); + return 1; +} + +int smlua_func_anim_and_audio_for_heavy_walk(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void anim_and_audio_for_heavy_walk(struct MarioState *m); + anim_and_audio_for_heavy_walk(m); + return 1; +} + +/* +int smlua_func_push_or_sidle_wall(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + Vec3f startPos <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + extern void push_or_sidle_wall(struct MarioState *m, Vec3f startPos); + push_or_sidle_wall(m, startPos); + return 1; +} +*/ + +int smlua_func_tilt_body_walking(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 startYaw = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void tilt_body_walking(struct MarioState *m, s16 startYaw); + tilt_body_walking(m, startYaw); + return 1; +} + +int smlua_func_tilt_body_ground_shell(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 startYaw = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void tilt_body_ground_shell(struct MarioState *m, s16 startYaw); + tilt_body_ground_shell(m, startYaw); + return 1; +} + +int smlua_func_tilt_body_butt_slide(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void tilt_body_butt_slide(struct MarioState *m); + tilt_body_butt_slide(m); + return 1; +} + +int smlua_func_common_slide_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 endAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 airAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 animation); + common_slide_action(m, endAction, airAction, animation); + return 1; +} + +int smlua_func_common_slide_action_with_jump(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 stopAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 jumpAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + u32 airAction = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jumpAction, u32 airAction, s32 animation); + lua_pushinteger(L, common_slide_action_with_jump(m, stopAction, jumpAction, airAction, animation)); + return 1; +} + +int smlua_func_stomach_slide_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 stopAction = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 airAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 stomach_slide_action(struct MarioState *m, u32 stopAction, u32 airAction, s32 animation); + lua_pushinteger(L, stomach_slide_action(m, stopAction, airAction, animation)); + return 1; +} + +int smlua_func_common_ground_knockback_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 arg2 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s32 arg3 = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + s32 arg4 = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4); + lua_pushinteger(L, common_ground_knockback_action(m, animation, arg2, arg3, arg4)); + return 1; +} + +int smlua_func_common_landing_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 animation = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 airAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction); + lua_pushinteger(L, common_landing_action(m, animation, airAction)); + return 1; +} + +int smlua_func_quicksand_jump_land_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation2 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + u32 endAction = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + u32 airAction = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animation2, u32 endAction, u32 airAction); + lua_pushinteger(L, quicksand_jump_land_action(m, animation1, animation2, endAction, airAction)); + return 1; +} + +int smlua_func_check_common_moving_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_moving_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_moving_cancels(m)); + return 1; +} + +int smlua_func_mario_execute_moving_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_execute_moving_action(struct MarioState *m); + lua_pushinteger(L, mario_execute_moving_action(m)); + return 1; +} + + //////////////////////////// + // mario_actions_object.c // +//////////////////////////// + +int smlua_func_animated_stationary_ground_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animation = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 endAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction); + animated_stationary_ground_step(m, animation, endAction); + return 1; +} + +int smlua_func_mario_update_punch_sequence(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_update_punch_sequence(struct MarioState *m); + lua_pushinteger(L, mario_update_punch_sequence(m)); + return 1; +} + +int smlua_func_check_common_object_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_object_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_object_cancels(m)); + return 1; +} + +int smlua_func_mario_execute_object_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_execute_object_action(struct MarioState *m); + lua_pushinteger(L, mario_execute_object_action(m)); + return 1; +} + + //////////////////////////////// + // mario_actions_stationary.c // +//////////////////////////////// + +int smlua_func_check_common_idle_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_idle_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_idle_cancels(m)); + return 1; +} + +int smlua_func_check_common_hold_idle_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_hold_idle_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_hold_idle_cancels(m)); + return 1; +} + +int smlua_func_play_anim_sound(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 actionState = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animFrame = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + u32 sound = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound); + play_anim_sound(m, actionState, animFrame, sound); + return 1; +} + +int smlua_func_stopping_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animID = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void stopping_step(struct MarioState *m, s32 animID, u32 action); + stopping_step(m, animID, action); + return 1; +} + +int smlua_func_landing_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 arg1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 landing_step(struct MarioState *m, s32 arg1, u32 action); + lua_pushinteger(L, landing_step(m, arg1, action)); + return 1; +} + +int smlua_func_check_common_landing_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 action = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_landing_cancels(struct MarioState *m, u32 action); + lua_pushinteger(L, check_common_landing_cancels(m, action)); + return 1; +} + +int smlua_func_check_common_stationary_cancels(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 check_common_stationary_cancels(struct MarioState *m); + lua_pushinteger(L, check_common_stationary_cancels(m)); + return 1; +} + +int smlua_func_mario_execute_stationary_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_execute_stationary_action(struct MarioState *m); + lua_pushinteger(L, mario_execute_stationary_action(m)); + return 1; +} + + /////////////////////////////// + // mario_actions_submerged.c // +/////////////////////////////// + +int smlua_func_mario_execute_submerged_action(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_execute_submerged_action(struct MarioState *m); + lua_pushinteger(L, mario_execute_submerged_action(m)); + return 1; +} + + ////////////////// + // mario_step.h // +////////////////// + +int smlua_func_get_additive_y_vel_for_jumps(UNUSED lua_State* L) { + + lua_pushnumber(L, get_additive_y_vel_for_jumps()); + return 1; +} + +int smlua_func_mario_bonk_reflection(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 arg1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + mario_bonk_reflection(arg0, arg1); + return 1; +} + +int smlua_func_mario_update_quicksand(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 arg1 = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_update_quicksand(arg0, arg1)); + return 1; +} + +int smlua_func_mario_push_off_steep_floor(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 arg1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + u32 arg2 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_push_off_steep_floor(arg0, arg1, arg2)); + return 1; +} + +int smlua_func_mario_update_moving_sand(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_update_moving_sand(arg0)); + return 1; +} + +int smlua_func_mario_update_windy_ground(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, mario_update_windy_ground(arg0)); + return 1; +} + +int smlua_func_stop_and_set_height_to_floor(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + stop_and_set_height_to_floor(arg0); + return 1; +} + +int smlua_func_stationary_ground_step(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, stationary_ground_step(arg0)); + return 1; +} + +int smlua_func_perform_ground_step(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, perform_ground_step(arg0)); + return 1; +} + +int smlua_func_perform_air_step(lua_State* L) { + struct MarioState* arg0 = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 arg1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, perform_air_step(arg0, arg1)); + return 1; +} + +int smlua_func_set_vel_from_pitch_and_yaw(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + set_vel_from_pitch_and_yaw(m); + return 1; +} + + + +void smlua_bind_functions_autogen(void) { + lua_State* L = gLuaState; + + // camera.h + smlua_bind_function(L, "set_camera_shake_from_hit", smlua_func_set_camera_shake_from_hit); + smlua_bind_function(L, "set_environmental_camera_shake", smlua_func_set_environmental_camera_shake); + smlua_bind_function(L, "set_camera_shake_from_point", smlua_func_set_camera_shake_from_point); + + // mario.h + smlua_bind_function(L, "is_anim_at_end", smlua_func_is_anim_at_end); + smlua_bind_function(L, "is_anim_past_end", smlua_func_is_anim_past_end); + smlua_bind_function(L, "set_mario_animation", smlua_func_set_mario_animation); + smlua_bind_function(L, "set_mario_anim_with_accel", smlua_func_set_mario_anim_with_accel); + smlua_bind_function(L, "set_anim_to_frame", smlua_func_set_anim_to_frame); + smlua_bind_function(L, "is_anim_past_frame", smlua_func_is_anim_past_frame); + //smlua_bind_function(L, "find_mario_anim_flags_and_translation", smlua_func_find_mario_anim_flags_and_translation); <--- UNIMPLEMENTED + smlua_bind_function(L, "update_mario_pos_for_anim", smlua_func_update_mario_pos_for_anim); + smlua_bind_function(L, "return_mario_anim_y_translation", smlua_func_return_mario_anim_y_translation); + smlua_bind_function(L, "play_sound_if_no_flag", smlua_func_play_sound_if_no_flag); + smlua_bind_function(L, "play_mario_jump_sound", smlua_func_play_mario_jump_sound); + smlua_bind_function(L, "adjust_sound_for_speed", smlua_func_adjust_sound_for_speed); + smlua_bind_function(L, "play_sound_and_spawn_particles", smlua_func_play_sound_and_spawn_particles); + smlua_bind_function(L, "play_mario_action_sound", smlua_func_play_mario_action_sound); + smlua_bind_function(L, "play_mario_landing_sound", smlua_func_play_mario_landing_sound); + smlua_bind_function(L, "play_mario_landing_sound_once", smlua_func_play_mario_landing_sound_once); + smlua_bind_function(L, "play_mario_heavy_landing_sound", smlua_func_play_mario_heavy_landing_sound); + smlua_bind_function(L, "play_mario_heavy_landing_sound_once", smlua_func_play_mario_heavy_landing_sound_once); + smlua_bind_function(L, "play_mario_sound", smlua_func_play_mario_sound); + smlua_bind_function(L, "mario_set_bubbled", smlua_func_mario_set_bubbled); + smlua_bind_function(L, "mario_set_forward_vel", smlua_func_mario_set_forward_vel); + smlua_bind_function(L, "mario_get_floor_class", smlua_func_mario_get_floor_class); + smlua_bind_function(L, "mario_get_terrain_sound_addend", smlua_func_mario_get_terrain_sound_addend); + //smlua_bind_function(L, "resolve_and_return_wall_collisions", smlua_func_resolve_and_return_wall_collisions); <--- UNIMPLEMENTED + //smlua_bind_function(L, "vec3f_find_ceil", smlua_func_vec3f_find_ceil); <--- UNIMPLEMENTED + smlua_bind_function(L, "mario_facing_downhill", smlua_func_mario_facing_downhill); + smlua_bind_function(L, "mario_floor_is_slippery", smlua_func_mario_floor_is_slippery); + smlua_bind_function(L, "mario_floor_is_slope", smlua_func_mario_floor_is_slope); + smlua_bind_function(L, "mario_floor_is_steep", smlua_func_mario_floor_is_steep); + smlua_bind_function(L, "find_floor_height_relative_polar", smlua_func_find_floor_height_relative_polar); + smlua_bind_function(L, "find_floor_slope", smlua_func_find_floor_slope); + smlua_bind_function(L, "update_mario_sound_and_camera", smlua_func_update_mario_sound_and_camera); + smlua_bind_function(L, "set_steep_jump_action", smlua_func_set_steep_jump_action); + smlua_bind_function(L, "set_mario_action", smlua_func_set_mario_action); + smlua_bind_function(L, "set_jump_from_landing", smlua_func_set_jump_from_landing); + smlua_bind_function(L, "set_jumping_action", smlua_func_set_jumping_action); + smlua_bind_function(L, "drop_and_set_mario_action", smlua_func_drop_and_set_mario_action); + smlua_bind_function(L, "hurt_and_set_mario_action", smlua_func_hurt_and_set_mario_action); + smlua_bind_function(L, "check_common_action_exits", smlua_func_check_common_action_exits); + smlua_bind_function(L, "check_common_hold_action_exits", smlua_func_check_common_hold_action_exits); + smlua_bind_function(L, "transition_submerged_to_walking", smlua_func_transition_submerged_to_walking); + smlua_bind_function(L, "set_water_plunge_action", smlua_func_set_water_plunge_action); + smlua_bind_function(L, "execute_mario_action", smlua_func_execute_mario_action); + smlua_bind_function(L, "force_idle_state", smlua_func_force_idle_state); + + // mario_actions_airborne.c + smlua_bind_function(L, "play_flip_sounds", smlua_func_play_flip_sounds); + smlua_bind_function(L, "play_far_fall_sound", smlua_func_play_far_fall_sound); + smlua_bind_function(L, "play_knockback_sound", smlua_func_play_knockback_sound); + smlua_bind_function(L, "lava_boost_on_wall", smlua_func_lava_boost_on_wall); + smlua_bind_function(L, "check_fall_damage", smlua_func_check_fall_damage); + smlua_bind_function(L, "check_kick_or_dive_in_air", smlua_func_check_kick_or_dive_in_air); + smlua_bind_function(L, "should_get_stuck_in_ground", smlua_func_should_get_stuck_in_ground); + smlua_bind_function(L, "check_fall_damage_or_get_stuck", smlua_func_check_fall_damage_or_get_stuck); + smlua_bind_function(L, "check_horizontal_wind", smlua_func_check_horizontal_wind); + smlua_bind_function(L, "update_air_with_turn", smlua_func_update_air_with_turn); + smlua_bind_function(L, "update_air_without_turn", smlua_func_update_air_without_turn); + smlua_bind_function(L, "update_lava_boost_or_twirling", smlua_func_update_lava_boost_or_twirling); + smlua_bind_function(L, "update_flying_yaw", smlua_func_update_flying_yaw); + smlua_bind_function(L, "update_flying_pitch", smlua_func_update_flying_pitch); + smlua_bind_function(L, "update_flying", smlua_func_update_flying); + smlua_bind_function(L, "common_air_action_step", smlua_func_common_air_action_step); + smlua_bind_function(L, "act_jump", smlua_func_act_jump); + smlua_bind_function(L, "act_double_jump", smlua_func_act_double_jump); + smlua_bind_function(L, "act_triple_jump", smlua_func_act_triple_jump); + smlua_bind_function(L, "act_backflip", smlua_func_act_backflip); + smlua_bind_function(L, "act_freefall", smlua_func_act_freefall); + smlua_bind_function(L, "act_hold_jump", smlua_func_act_hold_jump); + smlua_bind_function(L, "act_hold_freefall", smlua_func_act_hold_freefall); + smlua_bind_function(L, "act_side_flip", smlua_func_act_side_flip); + smlua_bind_function(L, "act_wall_kick_air", smlua_func_act_wall_kick_air); + smlua_bind_function(L, "act_long_jump", smlua_func_act_long_jump); + smlua_bind_function(L, "act_riding_shell_air", smlua_func_act_riding_shell_air); + smlua_bind_function(L, "act_twirling", smlua_func_act_twirling); + smlua_bind_function(L, "act_dive", smlua_func_act_dive); + smlua_bind_function(L, "act_air_throw", smlua_func_act_air_throw); + smlua_bind_function(L, "act_water_jump", smlua_func_act_water_jump); + smlua_bind_function(L, "act_hold_water_jump", smlua_func_act_hold_water_jump); + smlua_bind_function(L, "act_steep_jump", smlua_func_act_steep_jump); + smlua_bind_function(L, "act_ground_pound", smlua_func_act_ground_pound); + smlua_bind_function(L, "act_burning_jump", smlua_func_act_burning_jump); + smlua_bind_function(L, "act_burning_fall", smlua_func_act_burning_fall); + smlua_bind_function(L, "act_crazy_box_bounce", smlua_func_act_crazy_box_bounce); + smlua_bind_function(L, "common_air_knockback_step", smlua_func_common_air_knockback_step); + smlua_bind_function(L, "check_wall_kick", smlua_func_check_wall_kick); + smlua_bind_function(L, "act_backward_air_kb", smlua_func_act_backward_air_kb); + smlua_bind_function(L, "act_forward_air_kb", smlua_func_act_forward_air_kb); + smlua_bind_function(L, "act_hard_backward_air_kb", smlua_func_act_hard_backward_air_kb); + smlua_bind_function(L, "act_hard_forward_air_kb", smlua_func_act_hard_forward_air_kb); + smlua_bind_function(L, "act_thrown_backward", smlua_func_act_thrown_backward); + smlua_bind_function(L, "act_thrown_forward", smlua_func_act_thrown_forward); + smlua_bind_function(L, "act_soft_bonk", smlua_func_act_soft_bonk); + smlua_bind_function(L, "act_getting_blown", smlua_func_act_getting_blown); + smlua_bind_function(L, "act_air_hit_wall", smlua_func_act_air_hit_wall); + smlua_bind_function(L, "act_forward_rollout", smlua_func_act_forward_rollout); + smlua_bind_function(L, "act_backward_rollout", smlua_func_act_backward_rollout); + smlua_bind_function(L, "act_butt_slide_air", smlua_func_act_butt_slide_air); + smlua_bind_function(L, "act_hold_butt_slide_air", smlua_func_act_hold_butt_slide_air); + smlua_bind_function(L, "act_lava_boost", smlua_func_act_lava_boost); + smlua_bind_function(L, "act_slide_kick", smlua_func_act_slide_kick); + smlua_bind_function(L, "act_jump_kick", smlua_func_act_jump_kick); + smlua_bind_function(L, "act_shot_from_cannon", smlua_func_act_shot_from_cannon); + smlua_bind_function(L, "act_flying", smlua_func_act_flying); + smlua_bind_function(L, "act_riding_hoot", smlua_func_act_riding_hoot); + smlua_bind_function(L, "act_flying_triple_jump", smlua_func_act_flying_triple_jump); + smlua_bind_function(L, "act_top_of_pole_jump", smlua_func_act_top_of_pole_jump); + smlua_bind_function(L, "act_vertical_wind", smlua_func_act_vertical_wind); + smlua_bind_function(L, "act_special_triple_jump", smlua_func_act_special_triple_jump); + smlua_bind_function(L, "check_common_airborne_cancels", smlua_func_check_common_airborne_cancels); + smlua_bind_function(L, "mario_execute_airborne_action", smlua_func_mario_execute_airborne_action); + + // mario_actions_automatic.c + smlua_bind_function(L, "add_tree_leaf_particles", smlua_func_add_tree_leaf_particles); + smlua_bind_function(L, "play_climbing_sounds", smlua_func_play_climbing_sounds); + smlua_bind_function(L, "set_pole_position", smlua_func_set_pole_position); + smlua_bind_function(L, "act_holding_pole", smlua_func_act_holding_pole); + smlua_bind_function(L, "act_climbing_pole", smlua_func_act_climbing_pole); + smlua_bind_function(L, "act_grab_pole_slow", smlua_func_act_grab_pole_slow); + smlua_bind_function(L, "act_grab_pole_fast", smlua_func_act_grab_pole_fast); + smlua_bind_function(L, "act_top_of_pole_transition", smlua_func_act_top_of_pole_transition); + smlua_bind_function(L, "act_top_of_pole", smlua_func_act_top_of_pole); + //smlua_bind_function(L, "perform_hanging_step", smlua_func_perform_hanging_step); <--- UNIMPLEMENTED + smlua_bind_function(L, "update_hang_moving", smlua_func_update_hang_moving); + smlua_bind_function(L, "update_hang_stationary", smlua_func_update_hang_stationary); + smlua_bind_function(L, "act_start_hanging", smlua_func_act_start_hanging); + smlua_bind_function(L, "act_hanging", smlua_func_act_hanging); + smlua_bind_function(L, "act_hang_moving", smlua_func_act_hang_moving); + smlua_bind_function(L, "let_go_of_ledge", smlua_func_let_go_of_ledge); + smlua_bind_function(L, "climb_up_ledge", smlua_func_climb_up_ledge); + smlua_bind_function(L, "update_ledge_climb_camera", smlua_func_update_ledge_climb_camera); + smlua_bind_function(L, "update_ledge_climb", smlua_func_update_ledge_climb); + smlua_bind_function(L, "act_ledge_grab", smlua_func_act_ledge_grab); + smlua_bind_function(L, "act_ledge_climb_slow", smlua_func_act_ledge_climb_slow); + smlua_bind_function(L, "act_ledge_climb_down", smlua_func_act_ledge_climb_down); + smlua_bind_function(L, "act_ledge_climb_fast", smlua_func_act_ledge_climb_fast); + smlua_bind_function(L, "act_grabbed", smlua_func_act_grabbed); + smlua_bind_function(L, "act_in_cannon", smlua_func_act_in_cannon); + smlua_bind_function(L, "act_tornado_twirling", smlua_func_act_tornado_twirling); + smlua_bind_function(L, "act_bubbled", smlua_func_act_bubbled); + smlua_bind_function(L, "check_common_automatic_cancels", smlua_func_check_common_automatic_cancels); + smlua_bind_function(L, "mario_execute_automatic_action", smlua_func_mario_execute_automatic_action); + + // mario_actions_cutscene.c + smlua_bind_function(L, "print_displaying_credits_entry", smlua_func_print_displaying_credits_entry); + smlua_bind_function(L, "bhv_end_peach_loop", smlua_func_bhv_end_peach_loop); + smlua_bind_function(L, "bhv_end_toad_loop", smlua_func_bhv_end_toad_loop); + smlua_bind_function(L, "handle_save_menu", smlua_func_handle_save_menu); + //smlua_bind_function(L, "spawn_obj_at_mario_rel_yaw", smlua_func_spawn_obj_at_mario_rel_yaw); <--- UNIMPLEMENTED + smlua_bind_function(L, "cutscene_take_cap_off", smlua_func_cutscene_take_cap_off); + smlua_bind_function(L, "cutscene_put_cap_on", smlua_func_cutscene_put_cap_on); + smlua_bind_function(L, "should_start_or_continue_dialog", smlua_func_should_start_or_continue_dialog); + smlua_bind_function(L, "general_star_dance_handler", smlua_func_general_star_dance_handler); + smlua_bind_function(L, "stuck_in_ground_handler", smlua_func_stuck_in_ground_handler); + smlua_bind_function(L, "generate_yellow_sparkles", smlua_func_generate_yellow_sparkles); + + // mario_actions_moving.c + smlua_bind_function(L, "tilt_body_running", smlua_func_tilt_body_running); + smlua_bind_function(L, "play_step_sound", smlua_func_play_step_sound); + smlua_bind_function(L, "align_with_floor", smlua_func_align_with_floor); + smlua_bind_function(L, "begin_walking_action", smlua_func_begin_walking_action); + smlua_bind_function(L, "check_ledge_climb_down", smlua_func_check_ledge_climb_down); + smlua_bind_function(L, "slide_bonk", smlua_func_slide_bonk); + smlua_bind_function(L, "set_triple_jump_action", smlua_func_set_triple_jump_action); + smlua_bind_function(L, "update_sliding_angle", smlua_func_update_sliding_angle); + smlua_bind_function(L, "update_sliding", smlua_func_update_sliding); + smlua_bind_function(L, "apply_slope_accel", smlua_func_apply_slope_accel); + smlua_bind_function(L, "apply_landing_accel", smlua_func_apply_landing_accel); + smlua_bind_function(L, "update_shell_speed", smlua_func_update_shell_speed); + smlua_bind_function(L, "apply_slope_decel", smlua_func_apply_slope_decel); + smlua_bind_function(L, "update_decelerating_speed", smlua_func_update_decelerating_speed); + smlua_bind_function(L, "update_walking_speed", smlua_func_update_walking_speed); + smlua_bind_function(L, "should_begin_sliding", smlua_func_should_begin_sliding); + smlua_bind_function(L, "analog_stick_held_back", smlua_func_analog_stick_held_back); + smlua_bind_function(L, "check_ground_dive_or_punch", smlua_func_check_ground_dive_or_punch); + smlua_bind_function(L, "begin_braking_action", smlua_func_begin_braking_action); + smlua_bind_function(L, "anim_and_audio_for_walk", smlua_func_anim_and_audio_for_walk); + smlua_bind_function(L, "anim_and_audio_for_hold_walk", smlua_func_anim_and_audio_for_hold_walk); + smlua_bind_function(L, "anim_and_audio_for_heavy_walk", smlua_func_anim_and_audio_for_heavy_walk); + //smlua_bind_function(L, "push_or_sidle_wall", smlua_func_push_or_sidle_wall); <--- UNIMPLEMENTED + smlua_bind_function(L, "tilt_body_walking", smlua_func_tilt_body_walking); + smlua_bind_function(L, "tilt_body_ground_shell", smlua_func_tilt_body_ground_shell); + smlua_bind_function(L, "tilt_body_butt_slide", smlua_func_tilt_body_butt_slide); + smlua_bind_function(L, "common_slide_action", smlua_func_common_slide_action); + smlua_bind_function(L, "common_slide_action_with_jump", smlua_func_common_slide_action_with_jump); + smlua_bind_function(L, "stomach_slide_action", smlua_func_stomach_slide_action); + smlua_bind_function(L, "common_ground_knockback_action", smlua_func_common_ground_knockback_action); + smlua_bind_function(L, "common_landing_action", smlua_func_common_landing_action); + smlua_bind_function(L, "quicksand_jump_land_action", smlua_func_quicksand_jump_land_action); + smlua_bind_function(L, "check_common_moving_cancels", smlua_func_check_common_moving_cancels); + smlua_bind_function(L, "mario_execute_moving_action", smlua_func_mario_execute_moving_action); + + // mario_actions_object.c + smlua_bind_function(L, "animated_stationary_ground_step", smlua_func_animated_stationary_ground_step); + smlua_bind_function(L, "mario_update_punch_sequence", smlua_func_mario_update_punch_sequence); + smlua_bind_function(L, "check_common_object_cancels", smlua_func_check_common_object_cancels); + smlua_bind_function(L, "mario_execute_object_action", smlua_func_mario_execute_object_action); + + // mario_actions_stationary.c + smlua_bind_function(L, "check_common_idle_cancels", smlua_func_check_common_idle_cancels); + smlua_bind_function(L, "check_common_hold_idle_cancels", smlua_func_check_common_hold_idle_cancels); + smlua_bind_function(L, "play_anim_sound", smlua_func_play_anim_sound); + smlua_bind_function(L, "stopping_step", smlua_func_stopping_step); + smlua_bind_function(L, "landing_step", smlua_func_landing_step); + smlua_bind_function(L, "check_common_landing_cancels", smlua_func_check_common_landing_cancels); + smlua_bind_function(L, "check_common_stationary_cancels", smlua_func_check_common_stationary_cancels); + smlua_bind_function(L, "mario_execute_stationary_action", smlua_func_mario_execute_stationary_action); + + // mario_actions_submerged.c + smlua_bind_function(L, "mario_execute_submerged_action", smlua_func_mario_execute_submerged_action); + + // mario_step.h + smlua_bind_function(L, "get_additive_y_vel_for_jumps", smlua_func_get_additive_y_vel_for_jumps); + smlua_bind_function(L, "mario_bonk_reflection", smlua_func_mario_bonk_reflection); + smlua_bind_function(L, "mario_update_quicksand", smlua_func_mario_update_quicksand); + smlua_bind_function(L, "mario_push_off_steep_floor", smlua_func_mario_push_off_steep_floor); + smlua_bind_function(L, "mario_update_moving_sand", smlua_func_mario_update_moving_sand); + smlua_bind_function(L, "mario_update_windy_ground", smlua_func_mario_update_windy_ground); + smlua_bind_function(L, "stop_and_set_height_to_floor", smlua_func_stop_and_set_height_to_floor); + smlua_bind_function(L, "stationary_ground_step", smlua_func_stationary_ground_step); + smlua_bind_function(L, "perform_ground_step", smlua_func_perform_ground_step); + smlua_bind_function(L, "perform_air_step", smlua_func_perform_air_step); + smlua_bind_function(L, "set_vel_from_pitch_and_yaw", smlua_func_set_vel_from_pitch_and_yaw); + +} diff --git a/src/pc/lua/smlua_functions_autogen.h b/src/pc/lua/smlua_functions_autogen.h new file mode 100644 index 000000000..2ff774b68 --- /dev/null +++ b/src/pc/lua/smlua_functions_autogen.h @@ -0,0 +1,6 @@ +#ifndef SMLUA_FUNCTIONS_AUTOGEN_H +#define SMLUA_FUNCTIONS_AUTOGEN_H + +void smlua_bind_functions_autogen(void); + +#endif \ No newline at end of file