From 4a9e618efe112132b0b64f28b7ba067b780630df Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 26 Mar 2022 00:01:13 -0700 Subject: [PATCH] Add set_mario_y_vel_based_on_fspeed() to lua --- autogen/lua_definitions/functions.lua | 8 ++++++++ docs/lua/functions.md | 23 +++++++++++++++++++++++ src/game/mario.c | 2 +- src/game/mario.h | 1 + src/pc/lua/smlua_functions_autogen.c | 16 ++++++++++++++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index dd6559f4..551c6c8e 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -1224,6 +1224,14 @@ function set_mario_animation(m, targetAnimID) -- ... end +--- @param m MarioState +--- @param initialVelY number +--- @param multiplier number +--- @return nil +function set_mario_y_vel_based_on_fspeed(m, initialVelY, multiplier) + -- ... +end + --- @param m MarioState --- @return nil function set_steep_jump_action(m) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 3352cb8c..a8c66d80 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -220,6 +220,7 @@ - [set_mario_action](#set_mario_action) - [set_mario_anim_with_accel](#set_mario_anim_with_accel) - [set_mario_animation](#set_mario_animation) + - [set_mario_y_vel_based_on_fspeed](#set_mario_y_vel_based_on_fspeed) - [set_steep_jump_action](#set_steep_jump_action) - [set_water_plunge_action](#set_water_plunge_action) - [transition_submerged_to_walking](#transition_submerged_to_walking) @@ -4578,6 +4579,28 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
+## [set_mario_y_vel_based_on_fspeed](#set_mario_y_vel_based_on_fspeed) + +### Lua Example +`set_mario_y_vel_based_on_fspeed(m, initialVelY, multiplier)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| initialVelY | `number` | +| multiplier | `number` | + +### Returns +- None + +### C Prototype +`void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVelY, f32 multiplier);` + +[:arrow_up_small:](#) + +
+ ## [set_steep_jump_action](#set_steep_jump_action) ### Lua Example diff --git a/src/game/mario.c b/src/game/mario.c index e95d5815..c0db400b 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -842,7 +842,7 @@ void set_steep_jump_action(struct MarioState *m) { /** * Sets Mario's vertical speed from his forward speed. */ -static void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVelY, f32 multiplier) { +void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVelY, f32 multiplier) { // get_additive_y_vel_for_jumps is always 0 and a stubbed function. // It was likely trampoline related based on code location. m->vel[1] = initialVelY + get_additive_y_vel_for_jumps() + m->forwardVel * multiplier; diff --git a/src/game/mario.h b/src/game/mario.h index 7443bb90..0407d291 100644 --- a/src/game/mario.h +++ b/src/game/mario.h @@ -42,6 +42,7 @@ f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f 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); +void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVelY, f32 multiplier); 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); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 195163ff..d498b335 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -2963,6 +2963,21 @@ int smlua_func_set_mario_animation(lua_State* L) { return 1; } +int smlua_func_set_mario_y_vel_based_on_fspeed(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 initialVelY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 multiplier = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + set_mario_y_vel_based_on_fspeed(m, initialVelY, multiplier); + + return 1; +} + int smlua_func_set_steep_jump_action(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -10110,6 +10125,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_mario_action", smlua_func_set_mario_action); smlua_bind_function(L, "set_mario_anim_with_accel", smlua_func_set_mario_anim_with_accel); smlua_bind_function(L, "set_mario_animation", smlua_func_set_mario_animation); + smlua_bind_function(L, "set_mario_y_vel_based_on_fspeed", smlua_func_set_mario_y_vel_based_on_fspeed); smlua_bind_function(L, "set_steep_jump_action", smlua_func_set_steep_jump_action); smlua_bind_function(L, "set_water_plunge_action", smlua_func_set_water_plunge_action); smlua_bind_function(L, "transition_submerged_to_walking", smlua_func_transition_submerged_to_walking);