Add set_mario_y_vel_based_on_fspeed() to lua

This commit is contained in:
MysterD 2022-03-26 00:01:13 -07:00
parent b7be386200
commit 4a9e618efe
5 changed files with 49 additions and 1 deletions

View File

@ -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)

View File

@ -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
<br />
## [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:](#)
<br />
## [set_steep_jump_action](#set_steep_jump_action)
### Lua Example

View File

@ -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;

View File

@ -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);

View File

@ -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);