diff --git a/autogen/convert_header.py b/autogen/convert_header.py index 8e55d08d6..fbe84bd65 100644 --- a/autogen/convert_header.py +++ b/autogen/convert_header.py @@ -6,6 +6,9 @@ integer_types = ["u8", "u16", "u32", "u64", "s8", "s16", "s32", "s64", "int"] number_types = ["f32", "float"] cobject_types = ["struct MarioState*", "struct Object*", "struct Surface*"] cobject_lot_types = ["LOT_MARIO_STATE", "LOT_OBJECT", "LOT_SURFACE"] +param_override_build = {} + +########################################################### template = """/* THIS FILE IS AUTOGENERATED */ /* SHOULD NOT BE MANUALLY CHANGED */ @@ -29,6 +32,50 @@ $[BINDS] } """ +########################################################### + +param_vec3f_before_call = """ + f32* $[IDENTIFIER] = smlua_get_vec3f_from_buffer(); + $[IDENTIFIER][0] = smlua_get_number_field($[INDEX], "x"); + if (!gSmLuaConvertSuccess) { return 0; } + $[IDENTIFIER][1] = smlua_get_number_field($[INDEX], "y"); + if (!gSmLuaConvertSuccess) { return 0; } + $[IDENTIFIER][2] = smlua_get_number_field($[INDEX], "z"); +""" + +param_vec3f_after_call = """ + smlua_push_number_field($[INDEX], "x", $[IDENTIFIER][0]); + smlua_push_number_field($[INDEX], "y", $[IDENTIFIER][1]); + smlua_push_number_field($[INDEX], "z", $[IDENTIFIER][2]); +""" + +param_override_build['Vec3f'] = { + 'before': param_vec3f_before_call, + 'after': param_vec3f_after_call +} + +param_vec3s_before_call = """ + s16* $[IDENTIFIER] = smlua_get_vec3s_from_buffer(); + $[IDENTIFIER][0] = smlua_get_integer_field($[INDEX], "x"); + if (!gSmLuaConvertSuccess) { return 0; } + $[IDENTIFIER][1] = smlua_get_integer_field($[INDEX], "y"); + if (!gSmLuaConvertSuccess) { return 0; } + $[IDENTIFIER][2] = smlua_get_integer_field($[INDEX], "z"); +""" + +param_vec3s_after_call = """ + smlua_push_integer_field($[INDEX], "x", $[IDENTIFIER][0]); + smlua_push_integer_field($[INDEX], "y", $[IDENTIFIER][1]); + smlua_push_integer_field($[INDEX], "z", $[IDENTIFIER][2]); +""" + +param_override_build['Vec3s'] = { + 'before': param_vec3s_before_call, + 'after': param_vec3s_after_call +} + +########################################################### + built_functions = "" built_binds = "" @@ -111,7 +158,9 @@ def build_param(param, i): ptype = param['type'] pid = param['identifier'] - if ptype in integer_types: + if ptype in param_override_build: + return param_override_build[ptype]['before'].replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i)) + elif ptype in integer_types: return ' %s %s = smlua_to_integer(L, %d);\n' % (ptype, pid, i) elif ptype in number_types: return ' %s %s = smlua_to_number(L, %d);\n' % (ptype, pid, i) @@ -121,7 +170,16 @@ def build_param(param, i): else: return ' ' + ptype + ' ' + pid + ' <--- UNIMPLEMENTED' + '\n' -def build_return(function): +def build_param_after(param, i): + ptype = param['type'] + pid = param['identifier'] + + if ptype in param_override_build: + return param_override_build[ptype]['after'].replace('$[IDENTIFIER]', str(pid)).replace('$[INDEX]', str(i)) + else: + return '' + +def build_call(function): ftype = function['type'] fid = function['identifier'] @@ -155,7 +213,14 @@ def build_function(function): if do_extern: s += ' extern %s\n' % function['line'] - s += build_return(function) + s += build_call(function) + + i = 1 + for param in function['params']: + s += build_param_after(param, i) + i += 1 + s += '\n' + s += ' return 1;\n}\n' function['implemented'] = 'UNIMPLEMENTED' not in s diff --git a/autogen/lua_functions/external.h b/autogen/lua_functions/external.h new file mode 100644 index 000000000..635efa996 --- /dev/null +++ b/autogen/lua_functions/external.h @@ -0,0 +1 @@ +void play_sound(s32 soundBits, Vec3f pos); diff --git a/autogen/lua_functions/mario_actions_submerged.c b/autogen/lua_functions/mario_actions_submerged.c index afd254078..587461a07 100644 --- a/autogen/lua_functions/mario_actions_submerged.c +++ b/autogen/lua_functions/mario_actions_submerged.c @@ -1,4 +1,6 @@ void set_swimming_at_surface_particles(struct MarioState *m, u32 particleFlag); u32 perform_water_step(struct MarioState *m); +u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos); s32 mario_execute_submerged_action(struct MarioState *m); -void float_surface_gfx(struct MarioState *m); \ No newline at end of file +void float_surface_gfx(struct MarioState *m); +void apply_water_current(struct MarioState *m, Vec3f step); diff --git a/autogen/lua_functions/thread6.c b/autogen/lua_functions/thread6.c new file mode 100644 index 000000000..9c8d6f3ba --- /dev/null +++ b/autogen/lua_functions/thread6.c @@ -0,0 +1,3 @@ +void queue_rumble_data(s16 a0, s16 a1); +void queue_rumble_data_object(struct Object* object, s16 a0, s16 a1); +void queue_rumble_data_mario(struct MarioState* m, s16 a0, s16 a1); diff --git a/mods/constants.lua b/mods/constants.lua index fb5d54157..7774617fa 100644 --- a/mods/constants.lua +++ b/mods/constants.lua @@ -4,7 +4,8 @@ HOOK_UPDATE = 0 HOOK_MARIO_UPDATE = 1 -HOOK_MAX = 2 +HOOK_BEFORE_MARIO_UPDATE = 2 +HOOK_MAX = 3 _CObject = { __index = function (t,k) diff --git a/mods/test.lua b/mods/test.lua index 72c0f248e..168daae0c 100644 --- a/mods/test.lua +++ b/mods/test.lua @@ -41,52 +41,75 @@ for i=0,(MAX_PLAYERS-1) do e.lastPos.x = m.pos.x e.lastPos.y = m.pos.y e.lastPos.z = m.pos.z -end ---------------- --- utilities -- ---------------- - -function sins(theta) - return math.sin(theta * math.pi / (2 * 16384)) -end - -function coss(theta) - return math.cos(theta * math.pi / (2 * 16384)) + e.fakeSavedAction = 0 + e.fakeSavedPrevAction = 0 + e.fakeSavedActionTimer = 0 + e.fakeWroteAction = 0 + e.fakeSaved = false end ---------- -- roll -- ---------- -function increase_roll_yaw(m) - local newFacingDYaw = m.faceAngle.y - m.slideYaw +function update_roll_sliding_angle(m, accel, lossFactor) + local floor = m.floor + local slopeAngle = atan2s(floor.normal.z, floor.normal.x) + local steepness = math.sqrt(floor.normal.x * floor.normal.x + floor.normal.z * floor.normal.z) + + m.slideVelX = m.slideVelX + accel * steepness * sins(slopeAngle) + m.slideVelZ = m.slideVelZ + accel * steepness * coss(slopeAngle) + + m.slideVelX = m.slideVelX * lossFactor + m.slideVelZ = m.slideVelZ * lossFactor + + m.slideYaw = atan2s(m.slideVelZ, m.slideVelX) + + local facingDYaw = m.faceAngle.y - m.slideYaw + local newFacingDYaw = facingDYaw if newFacingDYaw > 0 and newFacingDYaw <= 0x4000 then newFacingDYaw = newFacingDYaw - 0x200 - if newFacingDYaw < 0 then - newFacingDYaw = 0 - end - elseif newFacingDYaw > -0x4000 and newFacingDYaw < 0 then + if newFacingDYaw < 0 then newFacingDYaw = 0 end + + elseif newFacingDYaw >= -0x4000 and newFacingDYaw < 0 then newFacingDYaw = newFacingDYaw + 0x200 - if newFacingDYaw > 0 then - newFacingDYaw = 0 - end + if newFacingDYaw > 0 then newFacingDYaw = 0 end + elseif newFacingDYaw > 0x4000 and newFacingDYaw < 0x8000 then newFacingDYaw = newFacingDYaw + 0x200 - if newFacingDYaw > 0x8000 then - newFacingDYaw = 0x8000 - end + if newFacingDYaw > 0x8000 then newFacingDYaw = 0x8000 end + elseif newFacingDYaw > -0x8000 and newFacingDYaw < -0x4000 then newFacingDYaw = newFacingDYaw - 0x200 - if newFacingDYaw < -0x8000 then - newFacingDYaw = -0x8000 - end + if newFacingDYaw < -0x8000 then newFacingDYaw = -0x8000 end + end + + m.faceAngle.y = m.slideYaw + newFacingDYaw + + m.vel.x = m.slideVelX + m.vel.y = 0.0 + m.vel.z = m.slideVelZ + + mario_update_moving_sand(m) + mario_update_windy_ground(m) + + --! Speed is capped a frame late (butt slide HSG) + m.forwardVel = math.sqrt(m.slideVelX * m.slideVelX + m.slideVelZ * m.slideVelZ) + if m.forwardVel > 100.0 then + m.slideVelX = m.slideVelX * 100.0 / m.forwardVel + m.slideVelZ = m.slideVelZ * 100.0 / m.forwardVel end if newFacingDYaw < -0x4000 or newFacingDYaw > 0x4000 then + m.forwardVel = m.forwardVel * -1.0 m.faceAngle.y = m.faceAngle.y + 0x4000 end + + -- HACK: instead of approaching slideYaw, just set faceAngle to it + -- this is different than the original Extended Movement... just couldn't figure out the bug + m.faceAngle.y = m.slideYaw end function update_roll_sliding(m, stopSpeed) @@ -109,7 +132,7 @@ function update_roll_sliding(m, stopSpeed) --! This is uses trig derivatives to rotate Mario's speed. -- In vanilla, it was slightly off/asymmetric since it uses the new X speed, but the old -- Z speed. I've gone and fixed it here. - local angleChange = (m.intendedMag / 32.0) --* 0.6 + local angleChange = (m.intendedMag / 32.0) * 0.6 local modSlideVelX = m.slideVelZ * angleChange * sideward * 0.05 local modSlideVelZ = m.slideVelX * angleChange * sideward * 0.05 @@ -123,8 +146,7 @@ function update_roll_sliding(m, stopSpeed) m.slideVelZ = m.slideVelZ * oldSpeed / newSpeed end - update_sliding_angle(m, accel, lossFactor) - increase_roll_yaw(m) + update_roll_sliding_angle(m, accel, lossFactor) if m.playerIndex == 0 and mario_floor_is_slope(m) == 0 and m.forwardVel * m.forwardVel < stopSpeed * stopSpeed then mario_set_forward_vel(m, 0.0) @@ -153,57 +175,58 @@ function act_roll(m) end elseif m.actionTimer >= ROLL_CANCEL_LOCKOUT_TIME or m.actionArg == 1 then if (m.input & INPUT_Z_DOWN) == 0 then - return set_mario_action(m, ACT_WALKING, 0); + return set_mario_action(m, ACT_WALKING, 0) end end if (m.input & INPUT_B_PRESSED) ~= 0 then - return set_jumping_action(m, ACT_FORWARD_ROLLOUT, 0); + queue_rumble_data_mario(m, 5, 80) + return set_jumping_action(m, ACT_FORWARD_ROLLOUT, 0) end if (m.input & INPUT_A_PRESSED) ~= 0 then - return set_jumping_action(m, ACT_LONG_JUMP, 0); + return set_jumping_action(m, ACT_LONG_JUMP, 0) end if (m.controller.buttonPressed & R_TRIG) ~= 0 and m.actionTimer > 0 then - m.vel.y = 19.0; - play_mario_sound(m, SOUND_ACTION_TERRAIN_JUMP, 0); + m.vel.y = 19.0 + play_mario_sound(m, SOUND_ACTION_TERRAIN_JUMP, 0) if e.boostTimer >= BOOST_LOCKOUT_TIME then - e.boostTimer = 0; + e.boostTimer = 0 if m.forwardVel < MAX_NORMAL_ROLL_SPEED then - mario_set_forward_vel(m, math.min(m.forwardVel + ROLL_BOOST_GAIN, MAX_NORMAL_ROLL_SPEED)); + mario_set_forward_vel(m, math.min(m.forwardVel + ROLL_BOOST_GAIN, MAX_NORMAL_ROLL_SPEED)) end - m.particleFlags = m.particleFlags | PARTICLE_HORIZONTAL_STAR; + m.particleFlags = m.particleFlags | PARTICLE_HORIZONTAL_STAR -- ! playing this after the call to play_mario_sound seems to matter in making this sound play play_sound(SOUND_ACTION_SPIN, m.marioObj.header.gfx.cameraToObject) end - return set_mario_action(m, ACT_ROLL_AIR, m.actionArg); + return set_mario_action(m, ACT_ROLL_AIR, m.actionArg) end - set_mario_animation(m, MARIO_ANIM_FORWARD_SPINNING); + set_mario_animation(m, MARIO_ANIM_FORWARD_SPINNING) if update_roll_sliding(m, 10.0) ~= 0 then - return set_mario_action(m, ACT_CROUCH_SLIDE, 0); + return set_mario_action(m, ACT_CROUCH_SLIDE, 0) end - common_slide_action(m, ACT_CROUCH_SLIDE, ACT_ROLL_AIR, MARIO_ANIM_FORWARD_SPINNING); + common_slide_action(m, ACT_CROUCH_SLIDE, ACT_ROLL_AIR, MARIO_ANIM_FORWARD_SPINNING) - e.rotAngle = e.rotAngle + (0x80 * m.forwardVel); + e.rotAngle = e.rotAngle + (0x80 * m.forwardVel) if e.rotAngle > 0x10000 then - e.rotAngle = e.rotAngle - 0x10000; + e.rotAngle = e.rotAngle - 0x10000 end - set_anim_to_frame(m, 10 * e.rotAngle / 0x10000); + set_anim_to_frame(m, 10 * e.rotAngle / 0x10000) - e.boostTimer = e.boostTimer + 1; + e.boostTimer = e.boostTimer + 1 - m.actionTimer = m.actionTimer + 1; + m.actionTimer = m.actionTimer + 1 - return 0; + return 0 end function act_roll_air(m) @@ -231,6 +254,7 @@ function act_roll_air(m) return set_mario_action(m, ACT_ROLL, m.actionArg) end elseif air_step == AIR_STEP_HIT_WALL then + queue_rumble_data_mario(m, 5, 40) mario_bonk_reflection(m, false) m.faceAngle.y = m.faceAngle.y + 0x8000 @@ -295,10 +319,6 @@ function update_roll(m) if (m.input & INPUT_ABOVE_SLIDE) == 0 then if (m.input & INPUT_Z_DOWN) ~= 0 and m.actionTimer < 2 then return set_mario_action(m, ACT_ROLL, 1) - elseif (m.input & INPUT_B_PRESSED) ~= 0 then - -- dive hop - -- m.vel.y = 21.0 - -- return set_mario_action(m, ACT_DIVE, 1) end end m.actionTimer = m.actionTimer + 1 @@ -306,8 +326,8 @@ function update_roll(m) if m.action == ACT_LONG_JUMP_LAND then if (m.input & INPUT_Z_DOWN) ~= 0 and m.forwardVel > 15.0 and m.actionTimer < 1 then - play_mario_landing_sound_once(m, SOUND_ACTION_TERRAIN_LANDING); - return set_mario_action(m, ACT_ROLL, 1); + play_mario_landing_sound_once(m, SOUND_ACTION_TERRAIN_LANDING) + return set_mario_action(m, ACT_ROLL, 1) end end @@ -473,6 +493,12 @@ function act_spin_jump(m) common_air_action_step(m, ACT_DOUBLE_JUMP_LAND, MARIO_ANIM_TWIRL, AIR_STEP_CHECK_HANG) + -- set facing direction + -- not part of original Extended Moveset + local yawDiff = m.faceAngle.y - m.intendedYaw + e.rotAngle = e.rotAngle + yawDiff + m.faceAngle.y = m.intendedYaw + 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 @@ -526,6 +552,7 @@ function act_spin_pound(m) local stepResult = perform_air_step(m, 0) if stepResult == AIR_STEP_LANDED then if should_get_stuck_in_ground(m) ~= 0 then + queue_rumble_data_mario(m, 5, 80) play_sound(SOUND_MARIO_OOOF2, m.marioObj.header.gfx.cameraToObject) m.particleFlags = m.particleFlags | PARTICLE_MIST_CIRCLE set_mario_action(m, ACT_BUTT_STUCK_IN_GROUND, 0) @@ -547,6 +574,12 @@ function act_spin_pound(m) set_mario_action(m, ACT_BACKWARD_AIR_KB, 0) end + -- set facing direction + -- not part of original Extended Moveset + local yawDiff = m.faceAngle.y - m.intendedYaw + e.rotAngle = e.rotAngle + yawDiff + m.faceAngle.y = m.intendedYaw + 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 @@ -662,6 +695,10 @@ function act_water_ground_pound(m) end m.particleFlags = m.particleFlags | PARTICLE_WATER_SPLASH + + if (m.prevAction & ACT_FLAG_AIR) ~= 0 then + queue_rumble_data_mario(m, 5, 80) + end end m.actionState = m.actionArg @@ -684,7 +721,7 @@ function act_water_ground_pound(m) end m.actionTimer = m.actionTimer + 1 - if (m.actionTimer >= m.marioObj.header.gfx.unk38.curAnim.unk08 + 4) then + if (m.actionTimer >= m.marioObj.header.gfx.animInfo.curAnim.loopEnd + 4) then -- play_sound(SOUND_MARIO_GROUND_POUND_WAH, m.marioObj.header.gfx.cameraToObject) play_sound(SOUND_ACTION_SWIM_FAST, m.marioObj.header.gfx.cameraToObject) m.vel.y = -45.0 @@ -864,6 +901,56 @@ function act_water_ground_pound_jump(m) return 0 end +------------------- +-- ledge parkour -- +------------------- + +function act_ledge_parkour(m) + set_mario_animation(m, MARIO_ANIM_SLIDEFLIP) + + local animFrame = m.marioObj.header.gfx.animInfo.animFrame + + if m.actionTimer == 0 then + play_sound(SOUND_MARIO_HAHA_2, m.marioObj.header.gfx.cameraToObject) + elseif m.actionTimer == 1 then + play_sound(SOUND_ACTION_SIDE_FLIP_UNK, m.marioObj.header.gfx.cameraToObject) + end + + update_air_without_turn(m) + + local step = perform_air_step(m, AIR_STEP_CHECK_LEDGE_GRAB) + if step == AIR_STEP_NONE then + -- play the side flip animation at double speed for a portion of it + if animFrame < 15 then + animFrame = animFrame + 2 + elseif animFrame > 23 then + animFrame = 23 + else + animFrame = animFrame + 1 + end + + set_anim_to_frame(m, animFrame) + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + 0x8000 + + elseif step == AIR_STEP_LANDED then + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + 0x8000 + set_mario_action(m, ACT_FREEFALL_LAND_STOP, 0) + play_mario_landing_sound(m, SOUND_ACTION_TERRAIN_LANDING) + + elseif step == AIR_STEP_HIT_WALL then + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + 0x8000 + mario_set_forward_vel(m, 0.0) + + elseif step == AIR_STEP_HIT_LAVA_WALL then + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + 0x8000 + lava_boost_on_wall(m) + end + + m.actionTimer = m.actionTimer + 1 + + return 0 +end + --------------------------------------------------------- function mario_action_on_change(m) @@ -889,6 +976,36 @@ function mario_action_on_change(m) m.vel.z = 0 elseif m.action == ACT_WATER_PLUNGE and e.actionLastFrame == ACT_GROUND_POUND then return set_mario_action(m, ACT_WATER_GROUND_POUND, 1) + elseif m.action == ACT_GROUND_POUND and e.actionLastFrame == ACT_SIDE_FLIP then + -- correct animation + m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y - 0x8000 + elseif m.action == ACT_LEDGE_GRAB then + e.rotAngle = m.forwardVel + end +end + +function before_mario_update(m) + local e = gMarioStateExtras[m.playerIndex] + -- revert fake saved action + if e.fakeSaved == true then + if m.action == e.fakeWroteAction and m.prevAction == e.fakeSavedPrevAction and m.actionTimer == e.fakeSavedActionTimer then + m.action = e.fakeSavedAction + end + e.fakeSaved = false + end +end + +function after_mario_update(m) + local e = gMarioStateExtras[m.playerIndex] + -- pretend *_POUND_LAND is ACT_GROUND_POUND_LAND so switches work correctly + if m.action == ACT_SPIN_POUND_LAND or m.action == ACT_WATER_GROUND_POUND_LAND then + e.fakeSavedAction = m.action + e.fakeSavedPrevAction = m.prevAction + e.fakeSavedActionTimer = m.actionTimer + + m.action = ACT_GROUND_POUND_LAND + e.fakeWroteAction = m.action + e.fakeSaved = true end end @@ -943,6 +1060,17 @@ function mario_update(m) m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y - e.rotAngle end + -- edge parkour + if m.action == ACT_LEDGE_GRAB and m.actionTimer < 4 and (m.input & INPUT_B_PRESSED) ~= 0 then + local hasSpaceForMario = (m.ceilHeight - m.floorHeight >= 160.0) + if hasSpaceForMario and (e.rotAngle >= 31.0 or m.forwardVel >= 31.0) then + mario_set_forward_vel(m, e.rotAngle + 5.0) + m.vel.y = 25.0 + queue_rumble_data_mario(m, 5, 80) + set_mario_action(m, ACT_LEDGE_PARKOUR, 0) + end + end + -- action change event if e.actionLastFrame ~= m.action then mario_action_on_change(m) @@ -954,13 +1082,16 @@ function mario_update(m) e.lastPos.y = m.pos.y e.lastPos.z = m.pos.z + after_mario_update(m) end function update() end hook_event(HOOK_UPDATE, update) +hook_event(HOOK_BEFORE_MARIO_UPDATE, before_mario_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) @@ -972,3 +1103,4 @@ hook_mario_action(ACT_WATER_GROUND_POUND, act_water_ground_pound) hook_mario_action(ACT_WATER_GROUND_POUND_LAND, act_water_ground_pound_land) hook_mario_action(ACT_WATER_GROUND_POUND_STROKE, act_water_ground_pound_stroke) hook_mario_action(ACT_WATER_GROUND_POUND_JUMP, act_water_ground_pound_jump) +hook_mario_action(ACT_LEDGE_PARKOUR, act_ledge_parkour) diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 38191af6f..89f0f8f00 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -187,7 +187,7 @@ void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor) { if ((newFacingDYaw -= 0x200) < 0) { newFacingDYaw = 0; } - } else if (newFacingDYaw >= -0x4000 && newFacingDYaw < 0) { + } else if (newFacingDYaw > -0x4000 && newFacingDYaw < 0) { if ((newFacingDYaw += 0x200) > 0) { newFacingDYaw = 0; } diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 292c14efe..2bd3da8f9 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -281,6 +281,8 @@ void bhv_mario_update(void) { vec3f_copy(gMarioState->marioBodyState->torsoPos, gMarioState->pos); } + smlua_call_event_hooks_mario_param(HOOK_BEFORE_MARIO_UPDATE, gMarioState); + u32 particleFlags = 0; s32 i; diff --git a/src/pc/controller/controller_keyboard_debug.c b/src/pc/controller/controller_keyboard_debug.c index 0ba62e730..743e6f586 100644 --- a/src/pc/controller/controller_keyboard_debug.c +++ b/src/pc/controller/controller_keyboard_debug.c @@ -13,7 +13,7 @@ #ifdef DEBUG -static u8 warpToLevel = LEVEL_SSL; +static u8 warpToLevel = LEVEL_BOB; static u8 warpToArea = 27; // warpToArea: 26 = basement // warpToArea: 27 = upstairs @@ -44,7 +44,6 @@ static void debug_warp_level(u8 level) { gCurrLevelNum = 0; gCurrAreaIndex = 0; gCurrActStarNum = 0; - gCurrAreaIndex = 0; gChangeLevel = level; return; diff --git a/src/pc/lua/smlua.h b/src/pc/lua/smlua.h index 52aa42aa7..cce4e4fd8 100644 --- a/src/pc/lua/smlua.h +++ b/src/pc/lua/smlua.h @@ -19,6 +19,7 @@ enum LuaHookedEventType { HOOK_UPDATE, HOOK_MARIO_UPDATE, + HOOK_BEFORE_MARIO_UPDATE, HOOK_MAX, }; diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index fe9c62d46..7fd1be3c8 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -189,8 +189,8 @@ static struct LuaObjectField sObjectNodeFields[LUA_OBJECTNODE_FIELD_COUNT] = { #define LUA_GRAPHNODEOBJECT_FIELD_COUNT 14 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 }, + { "areaIndex", LVT_S8, offsetof(struct GraphNodeObject, unk18), false, LOT_NONE }, + { "activeAreaIndex", 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 }, @@ -201,7 +201,7 @@ static struct LuaObjectField sGraphNodeObjectFields[LUA_GRAPHNODEOBJECT_FIELD_CO { "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 }, - { "unk38", LVT_COBJECT, offsetof(struct GraphNodeObject, unk38), false, LOT_GRAPHNODEOBJECTSUB }, + { "animInfo", LVT_COBJECT, offsetof(struct GraphNodeObject, unk38), false, LOT_GRAPHNODEOBJECTSUB }, { "cameraToObject", LVT_COBJECT, offsetof(struct GraphNodeObject, cameraToObject), false, LOT_VEC3F }, /* unimplemented struct GraphNode node; @@ -253,13 +253,13 @@ static struct LuaObjectField sGraphNodeObjectSubFields[LUA_GRAPHNODEOBJECTSUB_FI #define LUA_ANIMATION_FIELD_COUNT 7 static struct LuaObjectField sAnimationFields[LUA_ANIMATION_FIELD_COUNT] = { - { "flags", LVT_S16, offsetof(struct Animation, flags), false, LOT_NONE }, - { "unk02", LVT_S16, offsetof(struct Animation, unk02), false, LOT_NONE }, - { "unk04", LVT_S16, offsetof(struct Animation, unk04), false, LOT_NONE }, - { "unk06", LVT_S16, offsetof(struct Animation, unk06), false, LOT_NONE }, - { "unk08", LVT_S16, offsetof(struct Animation, unk08), false, LOT_NONE }, - { "unk0A", LVT_S16, offsetof(struct Animation, unk0A), false, LOT_NONE }, - { "length", LVT_U32, offsetof(struct Animation, length), false, LOT_NONE }, + { "flags", LVT_S16, offsetof(struct Animation, flags), false, LOT_NONE }, + { "animYTransDivisor", LVT_S16, offsetof(struct Animation, unk02), false, LOT_NONE }, + { "startFrame", LVT_S16, offsetof(struct Animation, unk04), false, LOT_NONE }, + { "loopStart", LVT_S16, offsetof(struct Animation, unk06), false, LOT_NONE }, + { "loopEnd", LVT_S16, offsetof(struct Animation, unk08), false, LOT_NONE }, + { "unusedBoneCount", LVT_S16, offsetof(struct Animation, unk0A), false, LOT_NONE }, + { "length", LVT_U32, offsetof(struct Animation, length), false, LOT_NONE }, /* const s16 *values; const u16 *index; diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 2cf180fa1..75b5d1c69 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -13,63 +13,22 @@ // misc // ////////// -int smlua_play_sound(lua_State* L) { - s32 soundsBits = lua_tointeger(L, 1); - - f32* pos = smlua_get_vec3f_from_buffer(); - pos[0] = smlua_get_number_field(2, "x"); - if (!gSmLuaConvertSuccess) { return 0; } - pos[1] = smlua_get_number_field(2, "y"); - if (!gSmLuaConvertSuccess) { return 0; } - pos[2] = smlua_get_number_field(2, "z"); +int smlua_func_sins(lua_State* L) { + f32 x = smlua_to_number(L, 1); if (!gSmLuaConvertSuccess) { return 0; } - extern void play_sound(s32 soundBits, f32 * pos); - play_sound(soundsBits, pos); - + lua_pushnumber(L, sins(x)); return 1; } -int smlua_func_perform_water_full_step(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); +int smlua_func_coss(lua_State* L) { + f32 x = smlua_to_number(L, 1); if (!gSmLuaConvertSuccess) { return 0; } - f32* nextPos = smlua_get_vec3f_from_buffer(); - nextPos[0] = smlua_get_number_field(2, "x"); - if (!gSmLuaConvertSuccess) { return 0; } - nextPos[1] = smlua_get_number_field(2, "y"); - if (!gSmLuaConvertSuccess) { return 0; } - nextPos[2] = smlua_get_number_field(2, "z"); - if (!gSmLuaConvertSuccess) { return 0; } - - extern u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos); - lua_pushinteger(L, perform_water_full_step(m, nextPos)); + lua_pushnumber(L, coss(x)); return 1; } -int smlua_func_apply_water_current(lua_State* L) { - struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); - if (!gSmLuaConvertSuccess) { return 0; } - - Vec3f step; - step[0] = smlua_get_number_field(2, "x"); - if (!gSmLuaConvertSuccess) { return 0; } - step[1] = smlua_get_number_field(2, "y"); - if (!gSmLuaConvertSuccess) { return 0; } - step[2] = smlua_get_number_field(2, "z"); - if (!gSmLuaConvertSuccess) { return 0; } - - extern void apply_water_current(struct MarioState *m, Vec3f step); - apply_water_current(m, step); - - smlua_push_number_field(step[0], "x"); - smlua_push_number_field(step[1], "y"); - smlua_push_number_field(step[2], "z"); - - return 1; -} - - int smlua_func_atan2s(lua_State* L) { f32 y = smlua_to_number(L, 1); if (!gSmLuaConvertSuccess) { return 0; } @@ -84,8 +43,7 @@ void smlua_bind_functions(void) { lua_State* L = gLuaState; // misc - smlua_bind_function(L, "play_sound", smlua_play_sound); - smlua_bind_function(L, "perform_water_full_step", smlua_func_perform_water_full_step); - smlua_bind_function(L, "apply_water_current", smlua_func_apply_water_current); + smlua_bind_function(L, "sins", smlua_func_sins); + smlua_bind_function(L, "coss", smlua_func_coss); smlua_bind_function(L, "atan2s", smlua_func_atan2s); } \ No newline at end of file diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 2f13b3676..c2d668b20 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -21,6 +21,7 @@ int smlua_func_set_camera_shake_from_hit(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } set_camera_shake_from_hit(shake); + return 1; } @@ -29,6 +30,7 @@ int smlua_func_set_environmental_camera_shake(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } set_environmental_camera_shake(shake); + return 1; } @@ -43,6 +45,32 @@ int smlua_func_set_camera_shake_from_point(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } set_camera_shake_from_point(shake, posX, posY, posZ); + + return 1; +} + + //////////////// + // external.h // +//////////////// + +int smlua_func_play_sound(lua_State* L) { + s32 soundBits = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + play_sound(soundBits, pos); + + smlua_push_number_field(2, "x", pos[0]); + smlua_push_number_field(2, "y", pos[1]); + smlua_push_number_field(2, "z", pos[2]); + return 1; } @@ -55,6 +83,7 @@ int smlua_func_is_anim_at_end(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, is_anim_at_end(m)); + return 1; } @@ -63,6 +92,7 @@ int smlua_func_is_anim_past_end(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, is_anim_past_end(m)); + return 1; } @@ -73,6 +103,7 @@ int smlua_func_set_mario_animation(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, set_mario_animation(m, targetAnimID)); + return 1; } @@ -85,6 +116,7 @@ int smlua_func_set_mario_anim_with_accel(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, set_mario_anim_with_accel(m, targetAnimID, accel)); + return 1; } @@ -95,6 +127,7 @@ int smlua_func_set_anim_to_frame(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } set_anim_to_frame(m, animFrame); + return 1; } @@ -105,28 +138,39 @@ int smlua_func_is_anim_past_frame(lua_State* L) { 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 + + s16* translation = smlua_get_vec3s_from_buffer(); + translation[0] = smlua_get_integer_field(3, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + translation[1] = smlua_get_integer_field(3, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + translation[2] = smlua_get_integer_field(3, "z"); if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, find_mario_anim_flags_and_translation(o, yaw, translation)); + + smlua_push_integer_field(3, "x", translation[0]); + smlua_push_integer_field(3, "y", translation[1]); + smlua_push_integer_field(3, "z", translation[2]); + 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; } @@ -135,6 +179,7 @@ int smlua_func_return_mario_anim_y_translation(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, return_mario_anim_y_translation(m)); + return 1; } @@ -147,6 +192,7 @@ int smlua_func_play_sound_if_no_flag(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_sound_if_no_flag(m, soundBits, flags); + return 1; } @@ -155,6 +201,7 @@ int smlua_func_play_mario_jump_sound(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_jump_sound(m); + return 1; } @@ -163,6 +210,7 @@ int smlua_func_adjust_sound_for_speed(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } adjust_sound_for_speed(m); + return 1; } @@ -175,6 +223,7 @@ int smlua_func_play_sound_and_spawn_particles(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_sound_and_spawn_particles(m, soundBits, waveParticleType); + return 1; } @@ -187,6 +236,7 @@ int smlua_func_play_mario_action_sound(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_action_sound(m, soundBits, waveParticleType); + return 1; } @@ -197,6 +247,7 @@ int smlua_func_play_mario_landing_sound(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_landing_sound(m, soundBits); + return 1; } @@ -207,6 +258,7 @@ int smlua_func_play_mario_landing_sound_once(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_landing_sound_once(m, soundBits); + return 1; } @@ -217,6 +269,7 @@ int smlua_func_play_mario_heavy_landing_sound(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_heavy_landing_sound(m, soundBits); + return 1; } @@ -227,6 +280,7 @@ int smlua_func_play_mario_heavy_landing_sound_once(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_heavy_landing_sound_once(m, soundBits); + return 1; } @@ -239,6 +293,7 @@ int smlua_func_play_mario_sound(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } play_mario_sound(m, primarySoundBits, scondarySoundBits); + return 1; } @@ -247,6 +302,7 @@ int smlua_func_mario_set_bubbled(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } mario_set_bubbled(m); + return 1; } @@ -257,6 +313,7 @@ int smlua_func_mario_set_forward_vel(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } mario_set_forward_vel(m, speed); + return 1; } @@ -265,6 +322,7 @@ int smlua_func_mario_get_floor_class(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_get_floor_class(m)); + return 1; } @@ -273,12 +331,19 @@ int smlua_func_mario_get_terrain_sound_addend(lua_State* L) { 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 + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); if (!gSmLuaConvertSuccess) { return 0; } f32 offset = smlua_to_number(L, 2); if (!gSmLuaConvertSuccess) { return 0; } @@ -286,13 +351,24 @@ int smlua_func_resolve_and_return_wall_collisions(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } UNIMPLEMENTED -->(L, resolve_and_return_wall_collisions(pos, offset, radius)); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + return 1; } */ /* int smlua_func_vec3f_find_ceil(lua_State* L) { - Vec3f pos <--- UNIMPLEMENTED + + f32* pos = smlua_get_vec3f_from_buffer(); + pos[0] = smlua_get_number_field(1, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[1] = smlua_get_number_field(1, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + pos[2] = smlua_get_number_field(1, "z"); if (!gSmLuaConvertSuccess) { return 0; } f32 height = smlua_to_number(L, 2); if (!gSmLuaConvertSuccess) { return 0; } @@ -300,6 +376,11 @@ int smlua_func_vec3f_find_ceil(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushnumber(L, vec3f_find_ceil(pos, height, ceil)); + + smlua_push_number_field(1, "x", pos[0]); + smlua_push_number_field(1, "y", pos[1]); + smlua_push_number_field(1, "z", pos[2]); + return 1; } */ @@ -311,6 +392,7 @@ int smlua_func_mario_facing_downhill(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_facing_downhill(m, turnYaw)); + return 1; } @@ -319,6 +401,7 @@ int smlua_func_mario_floor_is_slippery(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_floor_is_slippery(m)); + return 1; } @@ -327,6 +410,7 @@ int smlua_func_mario_floor_is_slope(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_floor_is_slope(m)); + return 1; } @@ -335,6 +419,7 @@ int smlua_func_mario_floor_is_steep(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_floor_is_steep(m)); + return 1; } @@ -347,6 +432,7 @@ int smlua_func_find_floor_height_relative_polar(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushnumber(L, find_floor_height_relative_polar(m, angleFromMario, distFromMario)); + return 1; } @@ -357,6 +443,7 @@ int smlua_func_find_floor_slope(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, find_floor_slope(m, yawOffset)); + return 1; } @@ -365,6 +452,7 @@ int smlua_func_update_mario_sound_and_camera(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } update_mario_sound_and_camera(m); + return 1; } @@ -373,6 +461,7 @@ int smlua_func_set_steep_jump_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } set_steep_jump_action(m); + return 1; } @@ -385,6 +474,7 @@ int smlua_func_set_mario_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, set_mario_action(m, action, actionArg)); + return 1; } @@ -393,6 +483,7 @@ int smlua_func_set_jump_from_landing(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, set_jump_from_landing(m)); + return 1; } @@ -405,6 +496,7 @@ int smlua_func_set_jumping_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, set_jumping_action(m, action, actionArg)); + return 1; } @@ -417,6 +509,7 @@ int smlua_func_drop_and_set_mario_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, drop_and_set_mario_action(m, action, actionArg)); + return 1; } @@ -431,6 +524,7 @@ int smlua_func_hurt_and_set_mario_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, hurt_and_set_mario_action(m, action, actionArg, hurtCounter)); + return 1; } @@ -439,6 +533,7 @@ int smlua_func_check_common_action_exits(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, check_common_action_exits(m)); + return 1; } @@ -447,6 +542,7 @@ int smlua_func_check_common_hold_action_exits(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, check_common_hold_action_exits(m)); + return 1; } @@ -455,6 +551,7 @@ int smlua_func_transition_submerged_to_walking(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, transition_submerged_to_walking(m)); + return 1; } @@ -463,6 +560,7 @@ int smlua_func_set_water_plunge_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, set_water_plunge_action(m)); + return 1; } @@ -471,6 +569,7 @@ int smlua_func_execute_mario_action(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, execute_mario_action(o)); + return 1; } @@ -479,6 +578,7 @@ int smlua_func_force_idle_state(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, force_idle_state(m)); + return 1; } @@ -498,6 +598,7 @@ int smlua_func_play_flip_sounds(lua_State* L) { extern void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3); play_flip_sounds(m, frame1, frame2, frame3); + return 1; } @@ -507,6 +608,7 @@ int smlua_func_play_far_fall_sound(lua_State* L) { extern void play_far_fall_sound(struct MarioState *m); play_far_fall_sound(m); + return 1; } @@ -516,6 +618,7 @@ int smlua_func_play_knockback_sound(lua_State* L) { extern void play_knockback_sound(struct MarioState *m); play_knockback_sound(m); + return 1; } @@ -525,6 +628,7 @@ int smlua_func_lava_boost_on_wall(lua_State* L) { extern s32 lava_boost_on_wall(struct MarioState *m); lua_pushinteger(L, lava_boost_on_wall(m)); + return 1; } @@ -536,6 +640,7 @@ int smlua_func_check_fall_damage(lua_State* L) { extern s32 check_fall_damage(struct MarioState *m, u32 hardFallAction); lua_pushinteger(L, check_fall_damage(m, hardFallAction)); + return 1; } @@ -545,6 +650,7 @@ int smlua_func_check_kick_or_dive_in_air(lua_State* L) { extern s32 check_kick_or_dive_in_air(struct MarioState *m); lua_pushinteger(L, check_kick_or_dive_in_air(m)); + return 1; } @@ -554,6 +660,7 @@ int smlua_func_should_get_stuck_in_ground(lua_State* L) { extern s32 should_get_stuck_in_ground(struct MarioState *m); lua_pushinteger(L, should_get_stuck_in_ground(m)); + return 1; } @@ -565,6 +672,7 @@ int smlua_func_check_fall_damage_or_get_stuck(lua_State* L) { 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; } @@ -574,6 +682,7 @@ int smlua_func_check_horizontal_wind(lua_State* L) { extern s32 check_horizontal_wind(struct MarioState *m); lua_pushinteger(L, check_horizontal_wind(m)); + return 1; } @@ -583,6 +692,7 @@ int smlua_func_update_air_with_turn(lua_State* L) { extern void update_air_with_turn(struct MarioState *m); update_air_with_turn(m); + return 1; } @@ -592,6 +702,7 @@ int smlua_func_update_air_without_turn(lua_State* L) { extern void update_air_without_turn(struct MarioState *m); update_air_without_turn(m); + return 1; } @@ -601,6 +712,7 @@ int smlua_func_update_lava_boost_or_twirling(lua_State* L) { extern void update_lava_boost_or_twirling(struct MarioState *m); update_lava_boost_or_twirling(m); + return 1; } @@ -610,6 +722,7 @@ int smlua_func_update_flying_yaw(lua_State* L) { extern void update_flying_yaw(struct MarioState *m); update_flying_yaw(m); + return 1; } @@ -619,6 +732,7 @@ int smlua_func_update_flying_pitch(lua_State* L) { extern void update_flying_pitch(struct MarioState *m); update_flying_pitch(m); + return 1; } @@ -628,6 +742,7 @@ int smlua_func_update_flying(lua_State* L) { extern void update_flying(struct MarioState *m); update_flying(m); + return 1; } @@ -643,6 +758,7 @@ int smlua_func_common_air_action_step(lua_State* L) { 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; } @@ -652,6 +768,7 @@ int smlua_func_act_jump(lua_State* L) { extern s32 act_jump(struct MarioState *m); lua_pushinteger(L, act_jump(m)); + return 1; } @@ -661,6 +778,7 @@ int smlua_func_act_double_jump(lua_State* L) { extern s32 act_double_jump(struct MarioState *m); lua_pushinteger(L, act_double_jump(m)); + return 1; } @@ -670,6 +788,7 @@ int smlua_func_act_triple_jump(lua_State* L) { extern s32 act_triple_jump(struct MarioState *m); lua_pushinteger(L, act_triple_jump(m)); + return 1; } @@ -679,6 +798,7 @@ int smlua_func_act_backflip(lua_State* L) { extern s32 act_backflip(struct MarioState *m); lua_pushinteger(L, act_backflip(m)); + return 1; } @@ -688,6 +808,7 @@ int smlua_func_act_freefall(lua_State* L) { extern s32 act_freefall(struct MarioState *m); lua_pushinteger(L, act_freefall(m)); + return 1; } @@ -697,6 +818,7 @@ int smlua_func_act_hold_jump(lua_State* L) { extern s32 act_hold_jump(struct MarioState *m); lua_pushinteger(L, act_hold_jump(m)); + return 1; } @@ -706,6 +828,7 @@ int smlua_func_act_hold_freefall(lua_State* L) { extern s32 act_hold_freefall(struct MarioState *m); lua_pushinteger(L, act_hold_freefall(m)); + return 1; } @@ -715,6 +838,7 @@ int smlua_func_act_side_flip(lua_State* L) { extern s32 act_side_flip(struct MarioState *m); lua_pushinteger(L, act_side_flip(m)); + return 1; } @@ -724,6 +848,7 @@ int smlua_func_act_wall_kick_air(lua_State* L) { extern s32 act_wall_kick_air(struct MarioState *m); lua_pushinteger(L, act_wall_kick_air(m)); + return 1; } @@ -733,6 +858,7 @@ int smlua_func_act_long_jump(lua_State* L) { extern s32 act_long_jump(struct MarioState *m); lua_pushinteger(L, act_long_jump(m)); + return 1; } @@ -742,6 +868,7 @@ int smlua_func_act_riding_shell_air(lua_State* L) { extern s32 act_riding_shell_air(struct MarioState *m); lua_pushinteger(L, act_riding_shell_air(m)); + return 1; } @@ -751,6 +878,7 @@ int smlua_func_act_twirling(lua_State* L) { extern s32 act_twirling(struct MarioState *m); lua_pushinteger(L, act_twirling(m)); + return 1; } @@ -760,6 +888,7 @@ int smlua_func_act_dive(lua_State* L) { extern s32 act_dive(struct MarioState *m); lua_pushinteger(L, act_dive(m)); + return 1; } @@ -769,6 +898,7 @@ int smlua_func_act_air_throw(lua_State* L) { extern s32 act_air_throw(struct MarioState *m); lua_pushinteger(L, act_air_throw(m)); + return 1; } @@ -778,6 +908,7 @@ int smlua_func_act_water_jump(lua_State* L) { extern s32 act_water_jump(struct MarioState *m); lua_pushinteger(L, act_water_jump(m)); + return 1; } @@ -787,6 +918,7 @@ int smlua_func_act_hold_water_jump(lua_State* L) { extern s32 act_hold_water_jump(struct MarioState *m); lua_pushinteger(L, act_hold_water_jump(m)); + return 1; } @@ -796,6 +928,7 @@ int smlua_func_act_steep_jump(lua_State* L) { extern s32 act_steep_jump(struct MarioState *m); lua_pushinteger(L, act_steep_jump(m)); + return 1; } @@ -805,6 +938,7 @@ int smlua_func_act_ground_pound(lua_State* L) { extern s32 act_ground_pound(struct MarioState *m); lua_pushinteger(L, act_ground_pound(m)); + return 1; } @@ -814,6 +948,7 @@ int smlua_func_act_burning_jump(lua_State* L) { extern s32 act_burning_jump(struct MarioState *m); lua_pushinteger(L, act_burning_jump(m)); + return 1; } @@ -823,6 +958,7 @@ int smlua_func_act_burning_fall(lua_State* L) { extern s32 act_burning_fall(struct MarioState *m); lua_pushinteger(L, act_burning_fall(m)); + return 1; } @@ -832,6 +968,7 @@ int smlua_func_act_crazy_box_bounce(lua_State* L) { extern s32 act_crazy_box_bounce(struct MarioState *m); lua_pushinteger(L, act_crazy_box_bounce(m)); + return 1; } @@ -849,6 +986,7 @@ int smlua_func_common_air_knockback_step(lua_State* L) { 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; } @@ -858,6 +996,7 @@ int smlua_func_check_wall_kick(lua_State* L) { extern s32 check_wall_kick(struct MarioState *m); lua_pushinteger(L, check_wall_kick(m)); + return 1; } @@ -867,6 +1006,7 @@ int smlua_func_act_backward_air_kb(lua_State* L) { extern s32 act_backward_air_kb(struct MarioState *m); lua_pushinteger(L, act_backward_air_kb(m)); + return 1; } @@ -876,6 +1016,7 @@ int smlua_func_act_forward_air_kb(lua_State* L) { extern s32 act_forward_air_kb(struct MarioState *m); lua_pushinteger(L, act_forward_air_kb(m)); + return 1; } @@ -885,6 +1026,7 @@ int smlua_func_act_hard_backward_air_kb(lua_State* L) { extern s32 act_hard_backward_air_kb(struct MarioState *m); lua_pushinteger(L, act_hard_backward_air_kb(m)); + return 1; } @@ -894,6 +1036,7 @@ int smlua_func_act_hard_forward_air_kb(lua_State* L) { extern s32 act_hard_forward_air_kb(struct MarioState *m); lua_pushinteger(L, act_hard_forward_air_kb(m)); + return 1; } @@ -903,6 +1046,7 @@ int smlua_func_act_thrown_backward(lua_State* L) { extern s32 act_thrown_backward(struct MarioState *m); lua_pushinteger(L, act_thrown_backward(m)); + return 1; } @@ -912,6 +1056,7 @@ int smlua_func_act_thrown_forward(lua_State* L) { extern s32 act_thrown_forward(struct MarioState *m); lua_pushinteger(L, act_thrown_forward(m)); + return 1; } @@ -921,6 +1066,7 @@ int smlua_func_act_soft_bonk(lua_State* L) { extern s32 act_soft_bonk(struct MarioState *m); lua_pushinteger(L, act_soft_bonk(m)); + return 1; } @@ -930,6 +1076,7 @@ int smlua_func_act_getting_blown(lua_State* L) { extern s32 act_getting_blown(struct MarioState *m); lua_pushinteger(L, act_getting_blown(m)); + return 1; } @@ -939,6 +1086,7 @@ int smlua_func_act_air_hit_wall(lua_State* L) { extern s32 act_air_hit_wall(struct MarioState *m); lua_pushinteger(L, act_air_hit_wall(m)); + return 1; } @@ -948,6 +1096,7 @@ int smlua_func_act_forward_rollout(lua_State* L) { extern s32 act_forward_rollout(struct MarioState *m); lua_pushinteger(L, act_forward_rollout(m)); + return 1; } @@ -957,6 +1106,7 @@ int smlua_func_act_backward_rollout(lua_State* L) { extern s32 act_backward_rollout(struct MarioState *m); lua_pushinteger(L, act_backward_rollout(m)); + return 1; } @@ -966,6 +1116,7 @@ int smlua_func_act_butt_slide_air(lua_State* L) { extern s32 act_butt_slide_air(struct MarioState *m); lua_pushinteger(L, act_butt_slide_air(m)); + return 1; } @@ -975,6 +1126,7 @@ int smlua_func_act_hold_butt_slide_air(lua_State* L) { extern s32 act_hold_butt_slide_air(struct MarioState *m); lua_pushinteger(L, act_hold_butt_slide_air(m)); + return 1; } @@ -984,6 +1136,7 @@ int smlua_func_act_lava_boost(lua_State* L) { extern s32 act_lava_boost(struct MarioState *m); lua_pushinteger(L, act_lava_boost(m)); + return 1; } @@ -993,6 +1146,7 @@ int smlua_func_act_slide_kick(lua_State* L) { extern s32 act_slide_kick(struct MarioState *m); lua_pushinteger(L, act_slide_kick(m)); + return 1; } @@ -1002,6 +1156,7 @@ int smlua_func_act_jump_kick(lua_State* L) { extern s32 act_jump_kick(struct MarioState *m); lua_pushinteger(L, act_jump_kick(m)); + return 1; } @@ -1011,6 +1166,7 @@ int smlua_func_act_shot_from_cannon(lua_State* L) { extern s32 act_shot_from_cannon(struct MarioState *m); lua_pushinteger(L, act_shot_from_cannon(m)); + return 1; } @@ -1020,6 +1176,7 @@ int smlua_func_act_flying(lua_State* L) { extern s32 act_flying(struct MarioState *m); lua_pushinteger(L, act_flying(m)); + return 1; } @@ -1029,6 +1186,7 @@ int smlua_func_act_riding_hoot(lua_State* L) { extern s32 act_riding_hoot(struct MarioState *m); lua_pushinteger(L, act_riding_hoot(m)); + return 1; } @@ -1038,6 +1196,7 @@ int smlua_func_act_flying_triple_jump(lua_State* L) { extern s32 act_flying_triple_jump(struct MarioState *m); lua_pushinteger(L, act_flying_triple_jump(m)); + return 1; } @@ -1047,6 +1206,7 @@ int smlua_func_act_top_of_pole_jump(lua_State* L) { extern s32 act_top_of_pole_jump(struct MarioState *m); lua_pushinteger(L, act_top_of_pole_jump(m)); + return 1; } @@ -1056,6 +1216,7 @@ int smlua_func_act_vertical_wind(lua_State* L) { extern s32 act_vertical_wind(struct MarioState *m); lua_pushinteger(L, act_vertical_wind(m)); + return 1; } @@ -1065,6 +1226,7 @@ int smlua_func_act_special_triple_jump(lua_State* L) { extern s32 act_special_triple_jump(struct MarioState *m); lua_pushinteger(L, act_special_triple_jump(m)); + return 1; } @@ -1074,6 +1236,7 @@ int smlua_func_check_common_airborne_cancels(lua_State* L) { extern s32 check_common_airborne_cancels(struct MarioState *m); lua_pushinteger(L, check_common_airborne_cancels(m)); + return 1; } @@ -1083,6 +1246,7 @@ int smlua_func_mario_execute_airborne_action(lua_State* L) { extern s32 mario_execute_airborne_action(struct MarioState *m); lua_pushinteger(L, mario_execute_airborne_action(m)); + return 1; } @@ -1096,6 +1260,7 @@ int smlua_func_add_tree_leaf_particles(lua_State* L) { extern void add_tree_leaf_particles(struct MarioState *m); add_tree_leaf_particles(m); + return 1; } @@ -1107,6 +1272,7 @@ int smlua_func_play_climbing_sounds(lua_State* L) { extern void play_climbing_sounds(struct MarioState *m, s32 b); play_climbing_sounds(m, b); + return 1; } @@ -1118,6 +1284,7 @@ int smlua_func_set_pole_position(lua_State* L) { extern s32 set_pole_position(struct MarioState *m, f32 offsetY); lua_pushinteger(L, set_pole_position(m, offsetY)); + return 1; } @@ -1127,6 +1294,7 @@ int smlua_func_act_holding_pole(lua_State* L) { extern s32 act_holding_pole(struct MarioState *m); lua_pushinteger(L, act_holding_pole(m)); + return 1; } @@ -1136,6 +1304,7 @@ int smlua_func_act_climbing_pole(lua_State* L) { extern s32 act_climbing_pole(struct MarioState *m); lua_pushinteger(L, act_climbing_pole(m)); + return 1; } @@ -1145,6 +1314,7 @@ int smlua_func_act_grab_pole_slow(lua_State* L) { extern s32 act_grab_pole_slow(struct MarioState *m); lua_pushinteger(L, act_grab_pole_slow(m)); + return 1; } @@ -1154,6 +1324,7 @@ int smlua_func_act_grab_pole_fast(lua_State* L) { extern s32 act_grab_pole_fast(struct MarioState *m); lua_pushinteger(L, act_grab_pole_fast(m)); + return 1; } @@ -1163,6 +1334,7 @@ int smlua_func_act_top_of_pole_transition(lua_State* L) { extern s32 act_top_of_pole_transition(struct MarioState *m); lua_pushinteger(L, act_top_of_pole_transition(m)); + return 1; } @@ -1172,21 +1344,31 @@ int smlua_func_act_top_of_pole(lua_State* L) { 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 + + f32* nextPos = smlua_get_vec3f_from_buffer(); + nextPos[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + nextPos[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + nextPos[2] = smlua_get_number_field(2, "z"); if (!gSmLuaConvertSuccess) { return 0; } extern s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos); lua_pushinteger(L, perform_hanging_step(m, nextPos)); + + smlua_push_number_field(2, "x", nextPos[0]); + smlua_push_number_field(2, "y", nextPos[1]); + smlua_push_number_field(2, "z", nextPos[2]); + return 1; } -*/ int smlua_func_update_hang_moving(lua_State* L) { struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); @@ -1194,6 +1376,7 @@ int smlua_func_update_hang_moving(lua_State* L) { extern s32 update_hang_moving(struct MarioState *m); lua_pushinteger(L, update_hang_moving(m)); + return 1; } @@ -1203,6 +1386,7 @@ int smlua_func_update_hang_stationary(lua_State* L) { extern void update_hang_stationary(struct MarioState *m); update_hang_stationary(m); + return 1; } @@ -1212,6 +1396,7 @@ int smlua_func_act_start_hanging(lua_State* L) { extern s32 act_start_hanging(struct MarioState *m); lua_pushinteger(L, act_start_hanging(m)); + return 1; } @@ -1221,6 +1406,7 @@ int smlua_func_act_hanging(lua_State* L) { extern s32 act_hanging(struct MarioState *m); lua_pushinteger(L, act_hanging(m)); + return 1; } @@ -1230,6 +1416,7 @@ int smlua_func_act_hang_moving(lua_State* L) { extern s32 act_hang_moving(struct MarioState *m); lua_pushinteger(L, act_hang_moving(m)); + return 1; } @@ -1239,6 +1426,7 @@ int smlua_func_let_go_of_ledge(lua_State* L) { extern s32 let_go_of_ledge(struct MarioState *m); lua_pushinteger(L, let_go_of_ledge(m)); + return 1; } @@ -1248,6 +1436,7 @@ int smlua_func_climb_up_ledge(lua_State* L) { extern void climb_up_ledge(struct MarioState *m); climb_up_ledge(m); + return 1; } @@ -1257,6 +1446,7 @@ int smlua_func_update_ledge_climb_camera(lua_State* L) { extern void update_ledge_climb_camera(struct MarioState *m); update_ledge_climb_camera(m); + return 1; } @@ -1270,6 +1460,7 @@ int smlua_func_update_ledge_climb(lua_State* L) { extern void update_ledge_climb(struct MarioState *m, s32 animation, u32 endAction); update_ledge_climb(m, animation, endAction); + return 1; } @@ -1279,6 +1470,7 @@ int smlua_func_act_ledge_grab(lua_State* L) { extern s32 act_ledge_grab(struct MarioState *m); lua_pushinteger(L, act_ledge_grab(m)); + return 1; } @@ -1288,6 +1480,7 @@ int smlua_func_act_ledge_climb_slow(lua_State* L) { extern s32 act_ledge_climb_slow(struct MarioState *m); lua_pushinteger(L, act_ledge_climb_slow(m)); + return 1; } @@ -1297,6 +1490,7 @@ int smlua_func_act_ledge_climb_down(lua_State* L) { extern s32 act_ledge_climb_down(struct MarioState *m); lua_pushinteger(L, act_ledge_climb_down(m)); + return 1; } @@ -1306,6 +1500,7 @@ int smlua_func_act_ledge_climb_fast(lua_State* L) { extern s32 act_ledge_climb_fast(struct MarioState *m); lua_pushinteger(L, act_ledge_climb_fast(m)); + return 1; } @@ -1315,6 +1510,7 @@ int smlua_func_act_grabbed(lua_State* L) { extern s32 act_grabbed(struct MarioState *m); lua_pushinteger(L, act_grabbed(m)); + return 1; } @@ -1324,6 +1520,7 @@ int smlua_func_act_in_cannon(lua_State* L) { extern s32 act_in_cannon(struct MarioState *m); lua_pushinteger(L, act_in_cannon(m)); + return 1; } @@ -1333,6 +1530,7 @@ int smlua_func_act_tornado_twirling(lua_State* L) { extern s32 act_tornado_twirling(struct MarioState *m); lua_pushinteger(L, act_tornado_twirling(m)); + return 1; } @@ -1342,6 +1540,7 @@ int smlua_func_act_bubbled(lua_State* L) { extern s32 act_bubbled(struct MarioState* m); lua_pushinteger(L, act_bubbled(m)); + return 1; } @@ -1351,6 +1550,7 @@ int smlua_func_check_common_automatic_cancels(lua_State* L) { extern s32 check_common_automatic_cancels(struct MarioState *m); lua_pushinteger(L, check_common_automatic_cancels(m)); + return 1; } @@ -1360,6 +1560,7 @@ int smlua_func_mario_execute_automatic_action(lua_State* L) { extern s32 mario_execute_automatic_action(struct MarioState *m); lua_pushinteger(L, mario_execute_automatic_action(m)); + return 1; } @@ -1371,6 +1572,7 @@ int smlua_func_print_displaying_credits_entry(UNUSED lua_State* L) { extern void print_displaying_credits_entry(void); print_displaying_credits_entry(); + return 1; } @@ -1378,6 +1580,7 @@ int smlua_func_bhv_end_peach_loop(UNUSED lua_State* L) { extern void bhv_end_peach_loop(void); bhv_end_peach_loop(); + return 1; } @@ -1385,6 +1588,7 @@ int smlua_func_bhv_end_toad_loop(UNUSED lua_State* L) { extern void bhv_end_toad_loop(void); bhv_end_toad_loop(); + return 1; } @@ -1394,6 +1598,7 @@ int smlua_func_handle_save_menu(lua_State* L) { extern void handle_save_menu(struct MarioState *m); handle_save_menu(m); + return 1; } @@ -1410,6 +1615,7 @@ int smlua_func_spawn_obj_at_mario_rel_yaw(lua_State* L) { 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; } */ @@ -1420,6 +1626,7 @@ int smlua_func_cutscene_take_cap_off(lua_State* L) { extern void cutscene_take_cap_off(struct MarioState *m); cutscene_take_cap_off(m); + return 1; } @@ -1429,6 +1636,7 @@ int smlua_func_cutscene_put_cap_on(lua_State* L) { extern void cutscene_put_cap_on(struct MarioState *m); cutscene_put_cap_on(m); + return 1; } @@ -1440,6 +1648,7 @@ int smlua_func_should_start_or_continue_dialog(lua_State* L) { 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; } @@ -1451,6 +1660,7 @@ int smlua_func_general_star_dance_handler(lua_State* L) { extern void general_star_dance_handler(struct MarioState *m, s32 isInWater); general_star_dance_handler(m, isInWater); + return 1; } @@ -1470,6 +1680,7 @@ int smlua_func_stuck_in_ground_handler(lua_State* L) { 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; } @@ -1485,6 +1696,7 @@ int smlua_func_generate_yellow_sparkles(lua_State* L) { extern void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius); generate_yellow_sparkles(x, y, z, radius); + return 1; } @@ -1498,6 +1710,7 @@ int smlua_func_tilt_body_running(lua_State* L) { extern s16 tilt_body_running(struct MarioState *m); lua_pushinteger(L, tilt_body_running(m)); + return 1; } @@ -1511,6 +1724,7 @@ int smlua_func_play_step_sound(lua_State* L) { extern void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2); play_step_sound(m, frame1, frame2); + return 1; } @@ -1520,6 +1734,7 @@ int smlua_func_align_with_floor(lua_State* L) { extern void align_with_floor(struct MarioState *m); align_with_floor(m); + return 1; } @@ -1535,6 +1750,7 @@ int smlua_func_begin_walking_action(lua_State* L) { 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; } @@ -1544,6 +1760,7 @@ int smlua_func_check_ledge_climb_down(lua_State* L) { extern void check_ledge_climb_down(struct MarioState *m); check_ledge_climb_down(m); + return 1; } @@ -1557,6 +1774,7 @@ int smlua_func_slide_bonk(lua_State* L) { extern void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction); slide_bonk(m, fastAction, slowAction); + return 1; } @@ -1570,6 +1788,7 @@ int smlua_func_set_triple_jump_action(lua_State* L) { 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; } @@ -1583,6 +1802,7 @@ int smlua_func_update_sliding_angle(lua_State* L) { extern void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor); update_sliding_angle(m, accel, lossFactor); + return 1; } @@ -1594,6 +1814,7 @@ int smlua_func_update_sliding(lua_State* L) { extern s32 update_sliding(struct MarioState *m, f32 stopSpeed); lua_pushinteger(L, update_sliding(m, stopSpeed)); + return 1; } @@ -1603,6 +1824,7 @@ int smlua_func_apply_slope_accel(lua_State* L) { extern void apply_slope_accel(struct MarioState *m); apply_slope_accel(m); + return 1; } @@ -1614,6 +1836,7 @@ int smlua_func_apply_landing_accel(lua_State* L) { extern s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor); lua_pushinteger(L, apply_landing_accel(m, frictionFactor)); + return 1; } @@ -1623,6 +1846,7 @@ int smlua_func_update_shell_speed(lua_State* L) { extern void update_shell_speed(struct MarioState *m); update_shell_speed(m); + return 1; } @@ -1634,6 +1858,7 @@ int smlua_func_apply_slope_decel(lua_State* L) { extern s32 apply_slope_decel(struct MarioState *m, f32 decelCoef); lua_pushinteger(L, apply_slope_decel(m, decelCoef)); + return 1; } @@ -1643,6 +1868,7 @@ int smlua_func_update_decelerating_speed(lua_State* L) { extern s32 update_decelerating_speed(struct MarioState *m); lua_pushinteger(L, update_decelerating_speed(m)); + return 1; } @@ -1652,6 +1878,7 @@ int smlua_func_update_walking_speed(lua_State* L) { extern void update_walking_speed(struct MarioState *m); update_walking_speed(m); + return 1; } @@ -1661,6 +1888,7 @@ int smlua_func_should_begin_sliding(lua_State* L) { extern s32 should_begin_sliding(struct MarioState *m); lua_pushinteger(L, should_begin_sliding(m)); + return 1; } @@ -1670,6 +1898,7 @@ int smlua_func_analog_stick_held_back(lua_State* L) { extern s32 analog_stick_held_back(struct MarioState *m); lua_pushinteger(L, analog_stick_held_back(m)); + return 1; } @@ -1679,6 +1908,7 @@ int smlua_func_check_ground_dive_or_punch(lua_State* L) { extern s32 check_ground_dive_or_punch(struct MarioState *m); lua_pushinteger(L, check_ground_dive_or_punch(m)); + return 1; } @@ -1688,6 +1918,7 @@ int smlua_func_begin_braking_action(lua_State* L) { extern s32 begin_braking_action(struct MarioState *m); lua_pushinteger(L, begin_braking_action(m)); + return 1; } @@ -1697,6 +1928,7 @@ int smlua_func_anim_and_audio_for_walk(lua_State* L) { extern void anim_and_audio_for_walk(struct MarioState *m); anim_and_audio_for_walk(m); + return 1; } @@ -1706,6 +1938,7 @@ int smlua_func_anim_and_audio_for_hold_walk(lua_State* L) { extern void anim_and_audio_for_hold_walk(struct MarioState *m); anim_and_audio_for_hold_walk(m); + return 1; } @@ -1715,21 +1948,31 @@ int smlua_func_anim_and_audio_for_heavy_walk(lua_State* L) { 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 + + f32* startPos = smlua_get_vec3f_from_buffer(); + startPos[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + startPos[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + startPos[2] = smlua_get_number_field(2, "z"); if (!gSmLuaConvertSuccess) { return 0; } extern void push_or_sidle_wall(struct MarioState *m, Vec3f startPos); push_or_sidle_wall(m, startPos); + + smlua_push_number_field(2, "x", startPos[0]); + smlua_push_number_field(2, "y", startPos[1]); + smlua_push_number_field(2, "z", startPos[2]); + return 1; } -*/ int smlua_func_tilt_body_walking(lua_State* L) { struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); @@ -1739,6 +1982,7 @@ int smlua_func_tilt_body_walking(lua_State* L) { extern void tilt_body_walking(struct MarioState *m, s16 startYaw); tilt_body_walking(m, startYaw); + return 1; } @@ -1750,6 +1994,7 @@ int smlua_func_tilt_body_ground_shell(lua_State* L) { extern void tilt_body_ground_shell(struct MarioState *m, s16 startYaw); tilt_body_ground_shell(m, startYaw); + return 1; } @@ -1759,6 +2004,7 @@ int smlua_func_tilt_body_butt_slide(lua_State* L) { extern void tilt_body_butt_slide(struct MarioState *m); tilt_body_butt_slide(m); + return 1; } @@ -1774,6 +2020,7 @@ int smlua_func_common_slide_action(lua_State* L) { extern void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 animation); common_slide_action(m, endAction, airAction, animation); + return 1; } @@ -1791,6 +2038,7 @@ int smlua_func_common_slide_action_with_jump(lua_State* L) { 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; } @@ -1806,6 +2054,7 @@ int smlua_func_stomach_slide_action(lua_State* L) { 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; } @@ -1823,6 +2072,7 @@ int smlua_func_common_ground_knockback_action(lua_State* L) { 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; } @@ -1836,6 +2086,7 @@ int smlua_func_common_landing_action(lua_State* L) { extern u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction); lua_pushinteger(L, common_landing_action(m, animation, airAction)); + return 1; } @@ -1853,6 +2104,7 @@ int smlua_func_quicksand_jump_land_action(lua_State* L) { 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; } @@ -1862,6 +2114,7 @@ int smlua_func_check_common_moving_cancels(lua_State* L) { extern s32 check_common_moving_cancels(struct MarioState *m); lua_pushinteger(L, check_common_moving_cancels(m)); + return 1; } @@ -1871,6 +2124,7 @@ int smlua_func_mario_execute_moving_action(lua_State* L) { extern s32 mario_execute_moving_action(struct MarioState *m); lua_pushinteger(L, mario_execute_moving_action(m)); + return 1; } @@ -1888,6 +2142,7 @@ int smlua_func_animated_stationary_ground_step(lua_State* L) { extern void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction); animated_stationary_ground_step(m, animation, endAction); + return 1; } @@ -1897,6 +2152,7 @@ int smlua_func_mario_update_punch_sequence(lua_State* L) { extern s32 mario_update_punch_sequence(struct MarioState *m); lua_pushinteger(L, mario_update_punch_sequence(m)); + return 1; } @@ -1906,6 +2162,7 @@ int smlua_func_check_common_object_cancels(lua_State* L) { extern s32 check_common_object_cancels(struct MarioState *m); lua_pushinteger(L, check_common_object_cancels(m)); + return 1; } @@ -1915,6 +2172,7 @@ int smlua_func_mario_execute_object_action(lua_State* L) { extern s32 mario_execute_object_action(struct MarioState *m); lua_pushinteger(L, mario_execute_object_action(m)); + return 1; } @@ -1928,6 +2186,7 @@ int smlua_func_check_common_idle_cancels(lua_State* L) { extern s32 check_common_idle_cancels(struct MarioState *m); lua_pushinteger(L, check_common_idle_cancels(m)); + return 1; } @@ -1937,6 +2196,7 @@ int smlua_func_check_common_hold_idle_cancels(lua_State* L) { extern s32 check_common_hold_idle_cancels(struct MarioState *m); lua_pushinteger(L, check_common_hold_idle_cancels(m)); + return 1; } @@ -1952,6 +2212,7 @@ int smlua_func_play_anim_sound(lua_State* L) { extern void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound); play_anim_sound(m, actionState, animFrame, sound); + return 1; } @@ -1965,6 +2226,7 @@ int smlua_func_stopping_step(lua_State* L) { extern void stopping_step(struct MarioState *m, s32 animID, u32 action); stopping_step(m, animID, action); + return 1; } @@ -1978,6 +2240,7 @@ int smlua_func_landing_step(lua_State* L) { extern s32 landing_step(struct MarioState *m, s32 arg1, u32 action); lua_pushinteger(L, landing_step(m, arg1, action)); + return 1; } @@ -1989,6 +2252,7 @@ int smlua_func_check_common_landing_cancels(lua_State* L) { extern s32 check_common_landing_cancels(struct MarioState *m, u32 action); lua_pushinteger(L, check_common_landing_cancels(m, action)); + return 1; } @@ -1998,6 +2262,7 @@ int smlua_func_check_common_stationary_cancels(lua_State* L) { extern s32 check_common_stationary_cancels(struct MarioState *m); lua_pushinteger(L, check_common_stationary_cancels(m)); + return 1; } @@ -2007,6 +2272,7 @@ int smlua_func_mario_execute_stationary_action(lua_State* L) { extern s32 mario_execute_stationary_action(struct MarioState *m); lua_pushinteger(L, mario_execute_stationary_action(m)); + return 1; } @@ -2022,6 +2288,7 @@ int smlua_func_set_swimming_at_surface_particles(lua_State* L) { extern void set_swimming_at_surface_particles(struct MarioState *m, u32 particleFlag); set_swimming_at_surface_particles(m, particleFlag); + return 1; } @@ -2031,6 +2298,29 @@ int smlua_func_perform_water_step(lua_State* L) { extern u32 perform_water_step(struct MarioState *m); lua_pushinteger(L, perform_water_step(m)); + + return 1; +} + +int smlua_func_perform_water_full_step(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* nextPos = smlua_get_vec3f_from_buffer(); + nextPos[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + nextPos[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + nextPos[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + extern u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos); + lua_pushinteger(L, perform_water_full_step(m, nextPos)); + + smlua_push_number_field(2, "x", nextPos[0]); + smlua_push_number_field(2, "y", nextPos[1]); + smlua_push_number_field(2, "z", nextPos[2]); + return 1; } @@ -2040,6 +2330,7 @@ int smlua_func_mario_execute_submerged_action(lua_State* L) { extern s32 mario_execute_submerged_action(struct MarioState *m); lua_pushinteger(L, mario_execute_submerged_action(m)); + return 1; } @@ -2049,6 +2340,29 @@ int smlua_func_float_surface_gfx(lua_State* L) { extern void float_surface_gfx(struct MarioState *m); float_surface_gfx(m); + + return 1; +} + +int smlua_func_apply_water_current(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + + f32* step = smlua_get_vec3f_from_buffer(); + step[0] = smlua_get_number_field(2, "x"); + if (!gSmLuaConvertSuccess) { return 0; } + step[1] = smlua_get_number_field(2, "y"); + if (!gSmLuaConvertSuccess) { return 0; } + step[2] = smlua_get_number_field(2, "z"); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void apply_water_current(struct MarioState *m, Vec3f step); + apply_water_current(m, step); + + smlua_push_number_field(2, "x", step[0]); + smlua_push_number_field(2, "y", step[1]); + smlua_push_number_field(2, "z", step[2]); + return 1; } @@ -2059,6 +2373,7 @@ int smlua_func_float_surface_gfx(lua_State* L) { int smlua_func_get_additive_y_vel_for_jumps(UNUSED lua_State* L) { lua_pushnumber(L, get_additive_y_vel_for_jumps()); + return 1; } @@ -2069,6 +2384,7 @@ int smlua_func_mario_bonk_reflection(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } mario_bonk_reflection(arg0, arg1); + return 1; } @@ -2079,6 +2395,7 @@ int smlua_func_mario_update_quicksand(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_update_quicksand(arg0, arg1)); + return 1; } @@ -2091,6 +2408,7 @@ int smlua_func_mario_push_off_steep_floor(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_push_off_steep_floor(arg0, arg1, arg2)); + return 1; } @@ -2099,6 +2417,7 @@ int smlua_func_mario_update_moving_sand(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_update_moving_sand(arg0)); + return 1; } @@ -2107,6 +2426,7 @@ int smlua_func_mario_update_windy_ground(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, mario_update_windy_ground(arg0)); + return 1; } @@ -2115,6 +2435,7 @@ int smlua_func_stop_and_set_height_to_floor(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } stop_and_set_height_to_floor(arg0); + return 1; } @@ -2123,6 +2444,7 @@ int smlua_func_stationary_ground_step(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, stationary_ground_step(arg0)); + return 1; } @@ -2131,6 +2453,7 @@ int smlua_func_perform_ground_step(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, perform_ground_step(arg0)); + return 1; } @@ -2141,6 +2464,7 @@ int smlua_func_perform_air_step(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } lua_pushinteger(L, perform_air_step(arg0, arg1)); + return 1; } @@ -2149,6 +2473,51 @@ int smlua_func_set_vel_from_pitch_and_yaw(lua_State* L) { if (!gSmLuaConvertSuccess) { return 0; } set_vel_from_pitch_and_yaw(m); + + return 1; +} + + /////////////// + // thread6.c // +/////////////// + +int smlua_func_queue_rumble_data(lua_State* L) { + s16 a0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 a1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void queue_rumble_data(s16 a0, s16 a1); + queue_rumble_data(a0, a1); + + return 1; +} + +int smlua_func_queue_rumble_data_object(lua_State* L) { + struct Object* object = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s16 a0 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 a1 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void queue_rumble_data_object(struct Object* object, s16 a0, s16 a1); + queue_rumble_data_object(object, a0, a1); + + return 1; +} + +int smlua_func_queue_rumble_data_mario(lua_State* L) { + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIO_STATE); + if (!gSmLuaConvertSuccess) { return 0; } + s16 a0 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 a1 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void queue_rumble_data_mario(struct MarioState* m, s16 a0, s16 a1); + queue_rumble_data_mario(m, a0, a1); + return 1; } @@ -2162,6 +2531,9 @@ void smlua_bind_functions_autogen(void) { 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); + // external.h + smlua_bind_function(L, "play_sound", smlua_func_play_sound); + // 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); @@ -2169,7 +2541,7 @@ void smlua_bind_functions_autogen(void) { 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, "find_mario_anim_flags_and_translation", smlua_func_find_mario_anim_flags_and_translation); 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); @@ -2284,7 +2656,7 @@ void smlua_bind_functions_autogen(void) { 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, "perform_hanging_step", smlua_func_perform_hanging_step); 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); @@ -2341,7 +2713,7 @@ void smlua_bind_functions_autogen(void) { 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, "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); @@ -2373,8 +2745,10 @@ void smlua_bind_functions_autogen(void) { // mario_actions_submerged.c smlua_bind_function(L, "set_swimming_at_surface_particles", smlua_func_set_swimming_at_surface_particles); smlua_bind_function(L, "perform_water_step", smlua_func_perform_water_step); + smlua_bind_function(L, "perform_water_full_step", smlua_func_perform_water_full_step); smlua_bind_function(L, "mario_execute_submerged_action", smlua_func_mario_execute_submerged_action); smlua_bind_function(L, "float_surface_gfx", smlua_func_float_surface_gfx); + smlua_bind_function(L, "apply_water_current", smlua_func_apply_water_current); // mario_step.h smlua_bind_function(L, "get_additive_y_vel_for_jumps", smlua_func_get_additive_y_vel_for_jumps); @@ -2389,4 +2763,9 @@ void smlua_bind_functions_autogen(void) { 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); + // thread6.c + smlua_bind_function(L, "queue_rumble_data", smlua_func_queue_rumble_data); + smlua_bind_function(L, "queue_rumble_data_object", smlua_func_queue_rumble_data_object); + smlua_bind_function(L, "queue_rumble_data_mario", smlua_func_queue_rumble_data_mario); + } diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index 20aa521de..f3cced4cb 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -6,11 +6,20 @@ u8 gSmLuaConvertSuccess = false; static Vec3f sVec3fBuffer[VEC3F_BUFFER_COUNT] = { 0 }; static u8 sVec3fBufferIndex = 0; +#define VEC3S_BUFFER_COUNT 64 +static Vec3s sVec3sBuffer[VEC3S_BUFFER_COUNT] = { 0 }; +static u8 sVec3sBufferIndex = 0; + f32* smlua_get_vec3f_from_buffer(void) { if (sVec3fBufferIndex > VEC3F_BUFFER_COUNT) { sVec3fBufferIndex = 0; } return sVec3fBuffer[sVec3fBufferIndex++]; } +s16* smlua_get_vec3s_from_buffer(void) { + if (sVec3sBufferIndex > VEC3S_BUFFER_COUNT) { sVec3sBufferIndex = 0; } + return sVec3sBuffer[sVec3sBufferIndex++]; +} + void smlua_bind_function(lua_State* L, const char* name, void* func) { lua_pushcfunction(L, func); lua_setglobal(L, name); @@ -99,24 +108,23 @@ void smlua_push_object(lua_State* L, enum LuaObjectType lot, void* p) { return; } lua_newtable(L); - smlua_push_integer_field(lot, "_lot"); - smlua_push_integer_field((u64)p, "_pointer"); + int t = lua_gettop(L); + smlua_push_integer_field(t, "_lot", lot); + smlua_push_integer_field(t, "_pointer", (u64)p); lua_pushglobaltable(L); lua_getfield(gLuaState, -1, "_CObject"); lua_setmetatable(L, -3); lua_pop(L, 1); // pop global table } -void smlua_push_integer_field(lua_Integer val, char* name) { - int t = lua_gettop(gLuaState); +void smlua_push_integer_field(int index, char* name, lua_Integer val) { lua_pushinteger(gLuaState, val); - lua_setfield(gLuaState, t, name); + lua_setfield(gLuaState, index, name); } -void smlua_push_number_field(lua_Number val, char* name) { - int t = lua_gettop(gLuaState); +void smlua_push_number_field(int index, char* name, lua_Number val) { lua_pushnumber(gLuaState, val); - lua_setfield(gLuaState, t, name); + lua_setfield(gLuaState, index, name); } lua_Integer smlua_get_integer_field(int index, char* name) { diff --git a/src/pc/lua/smlua_utils.h b/src/pc/lua/smlua_utils.h index a8231f8c4..5e35b114d 100644 --- a/src/pc/lua/smlua_utils.h +++ b/src/pc/lua/smlua_utils.h @@ -4,6 +4,7 @@ extern u8 gSmLuaConvertSuccess; f32* smlua_get_vec3f_from_buffer(void); +s16* smlua_get_vec3s_from_buffer(void); void smlua_bind_function(lua_State* L, const char* name, void* func); @@ -12,8 +13,8 @@ lua_Number smlua_to_number(lua_State* L, int index); void* smlua_to_cobject(lua_State* L, int index, enum LuaObjectType lot); void smlua_push_object(lua_State* L, enum LuaObjectType lot, void* p); -void smlua_push_integer_field(lua_Integer val, char* name); -void smlua_push_number_field(lua_Number val, char* name); +void smlua_push_integer_field(int index, char* name, lua_Integer val); +void smlua_push_number_field(int index, char* name, lua_Number val); lua_Integer smlua_get_integer_field(int index, char* name); lua_Number smlua_get_number_field(int index, char* name);