diff --git a/mods/constants.lua b/mods/constants.lua index 7a6a380b1..5ddab92aa 100644 --- a/mods/constants.lua +++ b/mods/constants.lua @@ -1155,3 +1155,12 @@ MARIO_ANIM_STAR_DANCE = 205 MARIO_ANIM_RETURN_FROM_STAR_DANCE = 206 MARIO_ANIM_FORWARD_SPINNING_FLIP = 207 MARIO_ANIM_TRIPLE_JUMP_FLY = 208 + +SHAKE_ATTACK = 1 +SHAKE_GROUND_POUND = 2 +SHAKE_SMALL_DAMAGE = 3 +SHAKE_MED_DAMAGE = 4 +SHAKE_LARGE_DAMAGE = 5 +SHAKE_HIT_FROM_BELOW = 8 +SHAKE_FALL_DAMAGE = 9 +SHAKE_SHOCK = 10 diff --git a/mods/convert_header.py b/mods/convert_header.py index 206b01431..d3fd7d58a 100644 --- a/mods/convert_header.py +++ b/mods/convert_header.py @@ -6,53 +6,49 @@ number_types = ["f32", "float"] cobject_types = ["struct MarioState*", "Vec3s", "Vec3f"] cobject_lot_types = ["LOT_MARIO_STATE", "LOT_VEC3S", "LOT_VEC3F"] +do_extern = False header_h = """ -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); -void init_mario(void); -void init_mario_from_save_file(void); +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); """ functions = [] @@ -91,13 +87,19 @@ def process_line(line): if len(params_str) == 0 or params_str == 'void': pass else: + param_index = 0 for param_str in params_str.split(','): param = {} param_str = param_str.strip() - match = re.search('[a-zA-Z0-9_]+$', param_str) - param['type'] = normalize_type(param_str[0:match.span()[0]]) - param['identifier'] = match.group() + if param_str.endswith('*') or ' ' not in param_str: + param['type'] = normalize_type(param_str) + param['identifier'] = 'arg%d' % param_index + else: + match = re.search('[a-zA-Z0-9_]+$', param_str) + param['type'] = normalize_type(param_str[0:match.span()[0]]) + param['identifier'] = match.group() function['params'].append(param) + param_index += 1 functions.append(function) @@ -150,6 +152,9 @@ def build_function(function): i += 1 s += '\n' + if do_extern: + s += ' extern %s\n' % function['line'] + s += build_return(function) s += ' return 1;\n}\n' diff --git a/mods/test.lua b/mods/test.lua index d4d2a8ece..44c70b74f 100644 --- a/mods/test.lua +++ b/mods/test.lua @@ -19,11 +19,23 @@ ACT_WATER_GROUND_POUND_JUMP = (0x0CC | ACT_FLAG_MOVING | ACT_FLAG_SWIMMING | A -- initialize extra fields -- ----------------------------- +ANGLE_QUEUE_SIZE = 9 +SPIN_TIMER_SUCCESSFUL_INPUT = 4 + gMarioStateExtras = {} for i=0,(MAX_PLAYERS-1) do gMarioStateExtras[i] = {} - gMarioStateExtras[i].rotAngle = 0 - gMarioStateExtras[i].boostTimer = 0 + local e = gMarioStateExtras[i] + e.angleDeltaQueue = {} + for j=0,(ANGLE_QUEUE_SIZE-1) do e.angleDeltaQueue[j] = 0 end + e.rotAngle = 0 + e.boostTimer = 0 + e.stickLastAngle = 0 + e.spinDirection = 0 + e.spinBufferTimer = 0 + e.spinInput = 0 + e.actionLastFrame = gMarioStates[i].action + e.lastIntendedMag = 0 end --------------- @@ -239,6 +251,42 @@ function act_roll_air(m) return false 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 + 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 + return set_mario_action(m, ACT_GROUND_POUND, 0) + end + + if e.spinInput ~= 0 then + return set_mario_action(m, ACT_SPIN_JUMP, 1) + end + + if m.actionTimer == 0 then + e.rotAngle = 0 + elseif m.actionTimer == 1 then + local cx, cy, cz = get_camera_position() + play_sound(SOUND_ACTION_SPIN, cx, cy, cz) + end + + play_mario_sound(m, SOUND_ACTION_TERRAIN_JUMP, SOUND_MARIO_YAHOO) + + common_air_action_step(m, ACT_JUMP_LAND, MARIO_ANIM_SINGLE_JUMP, + 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.actionTimer = m.actionTimer + 1 + + return 0 +end + function update_roll(m) if m.action == ACT_DIVE_SLIDE then if (m.input & INPUT_ABOVE_SLIDE) == 0 then @@ -298,12 +346,291 @@ function update_roll(m) end end +---------- +-- spin -- +---------- + +function mario_update_spin_input(m) + local e = gMarioStateExtras[m.playerIndex] + local rawAngle = atan2s(-m.controller.stickY, m.controller.stickX) + e.spinInput = 0 + + -- prevent issues due to the frame going out of the dead zone registering the last angle as 0 + if e.lastIntendedMag > 0.5 and m.intendedMag > 0.5 then + local angleOverFrames = 0 + local thisFrameDelta = 0 + local i = 0 + + local newDirection = e.spinDirection + local signedOverflow = 0 + + if rawAngle < e.stickLastAngle then + if (e.stickLastAngle - rawAngle) > 0x8000 then + signedOverflow = 1 + end + if signedOverflow ~= 0 then + newDirection = 1 + else + newDirection = -1 + end + elseif rawAngle > e.stickLastAngle then + if (rawAngle - e.stickLastAngle) > 0x8000 then + signedOverflow = 1 + end + if signedOverflow ~= 0 then + newDirection = -1 + else + newDirection = 1 + end + end + + if e.spinDirection ~= newDirection then + for i=0,(ANGLE_QUEUE_SIZE-1) do + e.angleDeltaQueue[i] = 0 + end + e.spinDirection = newDirection + else + for i=(ANGLE_QUEUE_SIZE-1),1,-1 do + e.angleDeltaQueue[i] = e.angleDeltaQueue[i-1] + angleOverFrames = angleOverFrames + e.angleDeltaQueue[i] + end + end + + if e.spinDirection < 0 then + if signedOverflow ~= 0 then + thisFrameDelta = math.floor((1.0*e.stickLastAngle + 0x10000) - rawAngle) + else + thisFrameDelta = e.stickLastAngle - rawAngle + end + elseif e.spinDirection > 0 then + if signedOverflow ~= 0 then + thisFrameDelta = math.floor(1.0*rawAngle + 0x10000 - e.stickLastAngle) + else + thisFrameDelta = rawAngle - e.stickLastAngle + end + end + + e.angleDeltaQueue[0] = thisFrameDelta + angleOverFrames = angleOverFrames + thisFrameDelta + + if angleOverFrames >= 0xA000 then + e.spinBufferTimer = SPIN_TIMER_SUCCESSFUL_INPUT + end + + + -- allow a buffer after a successful input so that you can switch directions + if e.spinBufferTimer > 0 then + e.spinInput = 1 + e.spinBufferTimer = e.spinBufferTimer - 1 + end + else + e.spinDirection = 0 + e.spinBufferTimer = 0 + end + + e.stickLastAngle = rawAngle + e.lastIntendedMag = m.intendedMag +end + +function act_spin_jump(m) + local e = gMarioStateExtras[m.playerIndex] + if m.actionTimer == 0 then + -- determine clockwise/counter-clockwise spin + if e.spinDirection < 0 then + m.actionState = 1 + end + elseif m.actionTimer == 1 or m.actionTimer == 4 then + local cx, cy, cz = get_camera_position() + play_sound(SOUND_ACTION_TWIRL, cx, cy, cz) + end + + local spinDirFactor = 1 -- negative for clockwise, positive for counter-clockwise + if m.actionState == 1 then + spinDirFactor = -1 + end + + if (m.input & INPUT_B_PRESSED) ~= 0 then + return set_mario_action(m, ACT_DIVE, 0) + end + + if (m.input & INPUT_Z_PRESSED) ~= 0 then + local cx, cy, cz = get_camera_position() + play_sound(SOUND_ACTION_TWIRL, cx, cy, cz) + + m.vel.y = -50.0 + mario_set_forward_vel(m, 0.0) + + -- choose which direction to be facing on land (practically random if no input) + if (m.input & INPUT_NONZERO_ANALOG) ~= 0 then + m.faceAngle.y = m.intendedYaw + else + m.faceAngle.y = e.rotAngle + end + + return set_mario_action(m, ACT_SPIN_POUND, m.actionState) + end + + play_mario_sound(m, SOUND_ACTION_TERRAIN_JUMP, SOUND_MARIO_YAHOO) + + common_air_action_step(m, ACT_DOUBLE_JUMP_LAND, MARIO_ANIM_TWIRL, + AIR_STEP_CHECK_HANG) + + 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) + + -- 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.vel.y = m.vel.y - 0.7 + if m.vel.y < -37.5 then + m.vel.y = m.vel.y + 1.4 + if m.vel.y > -37.5 then + m.vel.y = -37.5 + end + end + else + if m.vel.y > 0 then + m.vel.y = m.vel.y - 4 + else + m.vel.y = m.vel.y + 1.4 + end + + if m.vel.y < -75.0 then + m.vel.y = -75.5 + end + end + + m.actionTimer = m.actionTimer + 1 + + return false +end + +function act_spin_pound(m) + local e = gMarioStateExtras[m.playerIndex] + if m.actionTimer == 0 then + m.actionState = m.actionArg + end + + local spinDirFactor = 1 -- negative for clockwise, positive for counter-clockwise + if m.actionState == 1 then spinDirFactor = -1 end + + set_mario_animation(m, MARIO_ANIM_TWIRL) + + if (m.input & INPUT_B_PRESSED) ~= 0 then + mario_set_forward_vel(m, 10.0) + m.vel.y = 35 + set_mario_action(m, ACT_DIVE, 0) + end + + local stepResult = perform_air_step(m, 0) + if stepResult == AIR_STEP_LANDED then + if should_get_stuck_in_ground(m) ~= 0 then + local cx, cy, cz = get_camera_position() + play_sound(SOUND_MARIO_OOOF2, cx, cy, cz) + m.particleFlags = m.particleFlags | PARTICLE_MIST_CIRCLE + set_mario_action(m, ACT_BUTT_STUCK_IN_GROUND, 0) + else + play_mario_heavy_landing_sound(m, SOUND_ACTION_TERRAIN_HEAVY_LANDING) + if check_fall_damage(m, ACT_HARD_BACKWARD_GROUND_KB) == 0 then + m.particleFlags = m.particleFlags | PARTICLE_MIST_CIRCLE | PARTICLE_HORIZONTAL_STAR + set_mario_action(m, ACT_SPIN_POUND_LAND, 0) + end + end + set_camera_shake_from_hit(SHAKE_GROUND_POUND) + elseif stepResult == AIR_STEP_HIT_WALL then + mario_set_forward_vel(m, -16.0) + if m.vel.y > 0.0 then + m.vel.y = 0.0 + end + + m.particleFlags = m.particleFlags | PARTICLE_VERTICAL_STAR + set_mario_action(m, ACT_BACKWARD_AIR_KB, 0) + end + + 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.actionTimer = m.actionTimer + 1 + + return 0 +end + +function act_spin_pound_land(m) + m.actionState = 1 + + if m.actionTimer <= 8 then + if (m.input & INPUT_UNKNOWN_10) ~= 0 then + return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0) + end + + if (m.input & INPUT_OFF_FLOOR) ~= 0 then + return set_mario_action(m, ACT_FREEFALL, 0) + end + + if (m.input & INPUT_ABOVE_SLIDE) ~= 0 then + return set_mario_action(m, ACT_BUTT_SLIDE, 0) + end + + if (m.input & INPUT_A_PRESSED) ~= 0 then + m.vel.y = 65.0 + return set_jumping_action(m, ACT_GROUND_POUND_JUMP, 0) + end + + if (m.controller.buttonPressed & R_TRIG) ~= 0 then + mario_set_forward_vel(m, 60) + + local cx, cy, cz = get_camera_position() + play_sound(SOUND_ACTION_SPIN, cx, cy, cz) + return set_mario_action(m, ACT_ROLL, 0) + end + + stationary_ground_step(m) + set_mario_animation(m, MARIO_ANIM_LAND_FROM_DOUBLE_JUMP) + else + if (m.input & INPUT_UNKNOWN_10) ~= 0 then + return set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0) + end + + if (m.input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED | INPUT_OFF_FLOOR | INPUT_ABOVE_SLIDE)) ~= 0 then + return check_common_action_exits(m) + end + + stopping_step(m, MARIO_ANIM_LAND_FROM_DOUBLE_JUMP, ACT_IDLE) + end + + m.actionTimer = m.actionTimer + 1 + + return 0 +end + --------------------------------------------------------- -function update() +function mario_action_on_change(m) + local e = gMarioStateExtras[m.playerIndex] + if e.spinInput ~= 0 then + if m.action == ACT_JUMP or m.action == ACT_DOUBLE_JUMP or m.action == ACT_TRIPLE_JUMP or m.action == ACT_SIDE_FLIP or m.action == ACT_BACKFLIP or m.action == ACT_WALL_KICK_AIR then + set_mario_action(m, ACT_SPIN_JUMP, 1) + m.vel.y = 65.0 + m.faceAngle.y = m.intendedYaw + end + end + + if m.action == ACT_GROUND_POUND_JUMP then + m.vel.y = 65.0 + elseif m.action == ACT_WALL_SLIDE then + m.vel.y = 0.0 + end end function mario_update(m) + local e = gMarioStateExtras[m.playerIndex] + + mario_update_spin_input(m) update_roll(m) -- dive hop @@ -315,9 +642,45 @@ function mario_update(m) end end + -- dive out of ACT_GROUND_POUND + if m.action == ACT_GROUND_POUND and (m.input & INPUT_B_PRESSED) ~= 0 then + mario_set_forward_vel(m, 10.0) + m.vel.y = 35.0 + set_mario_action(m, ACT_DIVE, 0) + end + + -- spin + if e.actionLastFrame == m.action and (m.action == ACT_JUMP or m.action == ACT_WALL_KICK_AIR) and e.spinInput ~= 0 then + set_mario_action(m, ACT_SPIN_JUMP, 1) + e.spinInput = 0 + end + + -- twirl pound + if m.action == ACT_TWIRLING and (m.input & INPUT_Z_PRESSED) ~= 0 then + set_mario_action(m, ACT_SPIN_POUND, 0) + end + + -- ground pound jump + if m.action == ACT_GROUND_POUND_LAND and (m.input & INPUT_A_PRESSED) ~= 0 then + set_mario_action(m, ACT_GROUND_POUND_JUMP, 0) + end + + -- action change event + if e.actionLastFrame ~= m.action then + mario_action_on_change(m) + end + e.actionLastFrame = m.action + +end + +function update() end hook_event(HOOK_UPDATE, update) hook_event(HOOK_MARIO_UPDATE, mario_update) hook_mario_action(ACT_ROLL, act_roll) hook_mario_action(ACT_ROLL_AIR, act_roll_air) +hook_mario_action(ACT_SPIN_JUMP, act_spin_jump) +hook_mario_action(ACT_SPIN_POUND, act_spin_pound) +hook_mario_action(ACT_SPIN_POUND_LAND, act_spin_pound_land) +hook_mario_action(ACT_GROUND_POUND_JUMP, act_ground_pound_jump) diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 5e5d0113a..38191af6f 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -260,8 +260,6 @@ s32 update_sliding(struct MarioState *m, f32 stopSpeed) { lossFactor = m->intendedMag / 32.0f * forward * 0.02f + 0.92f; break; } - accel = 4.0f; - lossFactor = 0.994f; oldSpeed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ); diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 3788185a8..9a9d718dc 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -3,12 +3,11 @@ #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" ///////////// // mario.h // @@ -458,8 +457,1457 @@ int smlua_func_init_mario_from_save_file(UNUSED lua_State* L) { 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 // +////////// int smlua_get_camera_position(lua_State* L) { if (gMarioStates[0].marioObj == NULL) { @@ -482,53 +1930,6 @@ int smlua_get_camera_position(lua_State* L) { return 1; } -int smlua_update_sliding(lua_State* L) { - f32 stopSpeed = lua_tonumber(L, -1); - - lua_getfield(L, -2, "playerIndex"); - int index = lua_tointeger(L, -1); - - extern s32 update_sliding(struct MarioState* m, f32 stopSpeed); - lua_pushinteger(L, update_sliding(&gMarioStates[index], stopSpeed)); - return 1; -} - -int smlua_common_slide_action(lua_State* L) { - u32 endAction = lua_tointeger(L, -3); - u32 airAction = lua_tointeger(L, -2); - u32 animation = lua_tointeger(L, -1); - - lua_getfield(L, -4, "playerIndex"); - int index = lua_tointeger(L, -1); - - extern void common_slide_action(struct MarioState* m, u32 endAction, u32 airAction, s32 animation); - common_slide_action(&gMarioStates[index], endAction, airAction, animation); - return 1; -} - -int smlua_update_sliding_angle(lua_State* L) { - f32 accel = lua_tonumber(L, -2); - f32 lossFactor = lua_tonumber(L, -1); - - lua_getfield(L, -3, "playerIndex"); - int index = lua_tointeger(L, -1); - - extern void update_sliding_angle(struct MarioState* m, f32 accel, f32 lossFactor); - update_sliding_angle(&gMarioStates[index], accel, lossFactor); - return 1; -} - -int smlua_perform_air_step(lua_State* L) { - u32 stepArg = lua_tointeger(L, -1); - - lua_getfield(L, -2, "playerIndex"); - int index = lua_tointeger(L, -1); - - extern s32 perform_air_step(struct MarioState* m, u32 stepArg); - lua_pushinteger(L, perform_air_step(&gMarioStates[index], stepArg)); - return 1; -} - int smlua_check_fall_damage_or_get_stuck(lua_State* L) { u32 hardFallAction = lua_tointeger(L, -1); @@ -540,17 +1941,6 @@ int smlua_check_fall_damage_or_get_stuck(lua_State* L) { return 1; } -int smlua_mario_bonk_reflection(lua_State* L) { - u32 negateSpeed = lua_tointeger(L, -1); - - lua_getfield(L, -2, "playerIndex"); - int index = lua_tointeger(L, -1); - - extern void mario_bonk_reflection(struct MarioState* m, u32 negateSpeed); - mario_bonk_reflection(&gMarioStates[index], negateSpeed); - return 1; -} - int smlua_play_sound(lua_State* L) { s32 soundsBits = lua_tointeger(L, -4); f32 pos[3] = { lua_tonumber(L, -3), lua_tonumber(L, -2), lua_tonumber(L, -1) }; @@ -559,6 +1949,16 @@ int smlua_play_sound(lua_State* L) { return 1; } +int smlua_func_atan2s(lua_State* L) { + f32 y = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 x = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, atan2s(y, x)); + return 1; +} + void smlua_bind_functions(void) { lua_State* L = gLuaState; @@ -613,16 +2013,188 @@ void smlua_bind_functions(void) { 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 // ////////// smlua_bind_function(L, "get_camera_position", smlua_get_camera_position); - smlua_bind_function(L, "update_sliding", smlua_update_sliding); - smlua_bind_function(L, "common_slide_action", smlua_common_slide_action); - smlua_bind_function(L, "update_sliding_angle", smlua_update_sliding_angle); - smlua_bind_function(L, "perform_air_step", smlua_perform_air_step); smlua_bind_function(L, "check_fall_damage_or_get_stuck", smlua_check_fall_damage_or_get_stuck); - smlua_bind_function(L, "mario_bonk_reflection", smlua_mario_bonk_reflection); smlua_bind_function(L, "play_sound", smlua_play_sound); + smlua_bind_function(L, "atan2s", smlua_func_atan2s); } \ No newline at end of file diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index dca33b4a1..2a28b0688 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -7,11 +7,25 @@ void smlua_bind_function(lua_State* L, const char* name, void* func) { lua_setglobal(L, name); } +static void smlua_logline(void) { + lua_State* L = gLuaState; + lua_Debug info; + int level = 0; + while (lua_getstack(L, level, &info)) { + lua_getinfo(L, "nSl", &info); + LOG_INFO(" [%d] %s:%d -- %s [%s]\n", + level, info.short_src, info.currentline, + (info.name ? info.name : ""), info.what); + ++level; + } +} + ////////////////////////////////////////////// lua_Integer smlua_to_integer(lua_State* L, int index) { if (lua_type(L, index) != LUA_TNUMBER) { LOG_LUA("LUA: smlua_to_integer received improper type '%d'", lua_type(L, index)); + smlua_logline(); gSmLuaConvertSuccess = false; return 0; } @@ -23,6 +37,7 @@ lua_Integer smlua_to_integer(lua_State* L, int index) { lua_Number smlua_to_number(lua_State* L, int index) { if (lua_type(L, index) != LUA_TNUMBER) { LOG_LUA("LUA: smlua_to_number received improper type '%d'", lua_type(L, index)); + smlua_logline(); gSmLuaConvertSuccess = false; return 0; } @@ -33,6 +48,7 @@ lua_Number smlua_to_number(lua_State* L, int index) { void* smlua_to_cobject(lua_State* L, int index, enum LuaObjectType lot) { if (lua_type(L, index) != LUA_TTABLE) { LOG_LUA("LUA: smlua_to_cobject received improper type '%d'", lua_type(L, index)); + smlua_logline(); gSmLuaConvertSuccess = false; return 0; } @@ -44,6 +60,7 @@ void* smlua_to_cobject(lua_State* L, int index, enum LuaObjectType lot) { if (lot != objLot) { LOG_LUA("LUA: smlua_to_cobject received improper LOT. Expected '%d', received '%d'", lot, objLot); + smlua_logline(); gSmLuaConvertSuccess = false; return NULL; } @@ -56,6 +73,7 @@ void* smlua_to_cobject(lua_State* L, int index, enum LuaObjectType lot) { if (pointer == NULL) { LOG_LUA("LUA: smlua_to_cobject received null pointer."); + smlua_logline(); gSmLuaConvertSuccess = false; return NULL; }