From 3ad6c721dc6cb95d00bc5ce05bce12808c5e5ca1 Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 3 Mar 2022 01:04:15 -0800 Subject: [PATCH] Initial custom behavior commit --- autogen/convert_constants.py | 4 +- autogen/convert_functions.py | 2 +- autogen/convert_structs.py | 3 +- autogen/extract_functions.py | 16 + data/behavior_data.c | 1 - data/behavior_table.c | 5 + docs/lua/constants.md | 93 + docs/lua/functions.md | 3212 ++++++++++++++++++++++++++ docs/lua/structs.md | 16 + include/sm64.h | 2 +- lib/src/hardware.h | 2 +- src/engine/behavior_script.c | 13 +- src/game/interaction.h | 2 +- src/game/object_helpers.c | 52 +- src/game/spawn_object.c | 2 + src/pc/lua/smlua_cobject_autogen.c | 12 + src/pc/lua/smlua_cobject_autogen.h | 1 + src/pc/lua/smlua_constants_autogen.c | 78 + src/pc/lua/smlua_functions_autogen.c | 2105 +++++++++++++++++ src/pc/lua/smlua_hooks.c | 157 +- src/pc/lua/smlua_hooks.h | 5 + 21 files changed, 5743 insertions(+), 40 deletions(-) diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 2b5916e7..15a8dfff 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -24,6 +24,8 @@ in_files = [ "src/pc/lua/smlua_model_utils.h", "include/object_constants.h", "include/mario_geo_switch_case_ids.h", + "src/game/object_list_processor.h", + "src/engine/graph_node.h", ] exclude_constants = { @@ -31,7 +33,7 @@ exclude_constants = { } include_constants = { - "include/object_constants.h" : [ "^ACTIVE_FLAG_", "^ACTIVE_PARTICLE_", "^HELD_", "^OBJ_FLAG_", "^RESPAWN_INFO_", ], + "include/object_constants.h" : [ "^ACTIVE_FLAG_", "^ACTIVE_PARTICLE_", "^HELD_", "^OBJ_FLAG_", "^RESPAWN_INFO_", "^OBJ_MOVE_" ], } pretend_find = [ diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 7154e916..27348d30 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -66,7 +66,7 @@ override_disallowed_functions = { "src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ], "src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ], "src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update" ], - "src/game/object_helpers.c": [ "spawn_obj" ], + "src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "abs[fi]", "^bit_shift", "_debug$", "^stub_" ], "src/game/obj_behaviors.c": [ "debug_" ], "src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ], } diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py index f8014615..4e53a76f 100644 --- a/autogen/convert_structs.py +++ b/autogen/convert_structs.py @@ -13,7 +13,8 @@ in_files = [ 'src/engine/surface_collision.h', 'src/pc/network/network_player.h', 'src/pc/djui/djui_hud_utils.h', - 'src/game/object_helpers.h' + 'src/game/object_helpers.h', + 'src/game/mario_step.h' ] smlua_cobject_autogen = 'src/pc/lua/smlua_cobject_autogen' diff --git a/autogen/extract_functions.py b/autogen/extract_functions.py index 41d00bc8..a67795fd 100644 --- a/autogen/extract_functions.py +++ b/autogen/extract_functions.py @@ -2,6 +2,19 @@ import os import re import sys +replacements = { + 'BAD_RETURN(s8)': 'void', + 'BAD_RETURN(s16)': 'void', + 'BAD_RETURN(s32)': 'void', + 'BAD_RETURN(s64)': 'void', + 'BAD_RETURN(u8)': 'void', + 'BAD_RETURN(u16)': 'void', + 'BAD_RETURN(u32)': 'void', + 'BAD_RETURN(u64)': 'void', + 'BAD_RETURN(f32)': 'void', + 'BAD_RETURN(f64)': 'void', +} + def extract_functions(filename): with open(filename) as file: lines = file.readlines() @@ -19,6 +32,9 @@ def extract_functions(filename): if not gobbling: txt += line + '\n' + for replacement in replacements: + txt = txt.replace(replacement, replacements[replacement]) + # strip directives and comments in_directive = False tmp = txt diff --git a/data/behavior_data.c b/data/behavior_data.c index 6b7b0305..8bf68eae 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -6657,4 +6657,3 @@ const BehaviorScript bhvIntroScene[] = { CALL_NATIVE(bhv_intro_scene_loop), END_LOOP(), }; - diff --git a/data/behavior_table.c b/data/behavior_table.c index 41a88c6f..896a0f64 100644 --- a/data/behavior_table.c +++ b/data/behavior_table.c @@ -1,5 +1,6 @@ #include #include "behavior_table.h" +#include "pc/lua/smlua_hooks.h" const BehaviorScript* gBehaviorTable[id_bhv_max_count] = { [id_bhvStarDoor] = bhvStarDoor, @@ -525,8 +526,12 @@ enum BehaviorId get_id_from_behavior(const BehaviorScript* behavior) { } const BehaviorScript* get_behavior_from_id(enum BehaviorId id) { + const BehaviorScript* behavior = get_lua_behavior_from_id(id); + if (behavior != NULL) { return behavior; } + if (id < 0 || id >= id_bhv_max_count) { return NULL; } + return gBehaviorTable[id]; } diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 68b5b41f..2a03d771 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -11,6 +11,7 @@ - [djui_hud_utils.h](#djui_hud_utils.h) - [DjuiFontType](#DjuiFontType) - [HudUtilsResolution](#HudUtilsResolution) +- [graph_node.h](#graph_node.h) - [interaction.c](#interaction.c) - [InteractionFlag](#InteractionFlag) - [interaction.h](#interaction.h) @@ -25,6 +26,8 @@ - [network_player.h](#network_player.h) - [NetworkPlayerType](#NetworkPlayerType) - [object_constants.h](#object_constants.h) +- [object_list_processor.h](#object_list_processor.h) + - [ObjectList](#ObjectList) - [os_cont.h](#os_cont.h) - [sm64.h](#sm64.h) - [smlua_hooks.h](#smlua_hooks.h) @@ -1299,6 +1302,49 @@
+## [graph_node.h](#graph_node.h) +- GEO_CONTEXT_AREA_INIT +- GEO_CONTEXT_AREA_LOAD +- GEO_CONTEXT_AREA_UNLOAD +- GEO_CONTEXT_CREATE +- GEO_CONTEXT_HELD_OBJ +- GEO_CONTEXT_RENDER +- GFX_NUM_MASTER_LISTS +- GRAPH_NODE_TYPE_400 +- GRAPH_NODE_TYPE_ANIMATED_PART +- GRAPH_NODE_TYPE_BACKGROUND +- GRAPH_NODE_TYPE_BILLBOARD +- GRAPH_NODE_TYPE_CAMERA +- GRAPH_NODE_TYPE_CULLING_RADIUS +- GRAPH_NODE_TYPE_DISPLAY_LIST +- GRAPH_NODE_TYPE_FUNCTIONAL +- GRAPH_NODE_TYPE_GENERATED_LIST +- GRAPH_NODE_TYPE_HELD_OBJ +- GRAPH_NODE_TYPE_LEVEL_OF_DETAIL +- GRAPH_NODE_TYPE_MASTER_LIST +- GRAPH_NODE_TYPE_OBJECT +- GRAPH_NODE_TYPE_OBJECT_PARENT +- GRAPH_NODE_TYPE_ORTHO_PROJECTION +- GRAPH_NODE_TYPE_PERSPECTIVE +- GRAPH_NODE_TYPE_ROOT +- GRAPH_NODE_TYPE_ROTATION +- GRAPH_NODE_TYPE_SCALE +- GRAPH_NODE_TYPE_SHADOW +- GRAPH_NODE_TYPE_START +- GRAPH_NODE_TYPE_SWITCH_CASE +- GRAPH_NODE_TYPE_TRANSLATION +- GRAPH_NODE_TYPE_TRANSLATION_ROTATION +- GRAPH_RENDER_ACTIVE +- GRAPH_RENDER_BILLBOARD +- GRAPH_RENDER_CHILDREN_FIRST +- GRAPH_RENDER_CYLBOARD +- GRAPH_RENDER_HAS_ANIMATION +- GRAPH_RENDER_INVISIBLE +- GRAPH_RENDER_PLAYER +- GRAPH_RENDER_Z_BUFFER + +
+ ## [interaction.c](#interaction.c) - INT_ANY_ATTACK - INT_ATTACK_NOT_FROM_BELOW @@ -1728,6 +1774,23 @@ - OBJ_FLAG_SET_THROW_MATRIX_FROM_TRANSFORM - OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT - OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE +- OBJ_MOVE_ABOVE_DEATH_BARRIER +- OBJ_MOVE_ABOVE_LAVA +- OBJ_MOVE_AT_WATER_SURFACE +- OBJ_MOVE_BOUNCE +- OBJ_MOVE_ENTERED_WATER +- OBJ_MOVE_HIT_EDGE +- OBJ_MOVE_HIT_WALL +- OBJ_MOVE_IN_AIR +- OBJ_MOVE_LANDED +- OBJ_MOVE_LEAVING_WATER +- OBJ_MOVE_LEFT_GROUND +- OBJ_MOVE_MASK_IN_WATER +- OBJ_MOVE_MASK_ON_GROUND +- OBJ_MOVE_ON_GROUND +- OBJ_MOVE_OUT_SCOPE +- OBJ_MOVE_UNDERWATER_OFF_GROUND +- OBJ_MOVE_UNDERWATER_ON_GROUND - RESPAWN_INFO_DONT_RESPAWN - RESPAWN_INFO_TYPE_16 - RESPAWN_INFO_TYPE_32 @@ -1735,6 +1798,36 @@
+## [object_list_processor.h](#object_list_processor.h) +- OBJECT_POOL_CAPACITY +- TIME_STOP_ACTIVE +- TIME_STOP_ALL_OBJECTS +- TIME_STOP_DIALOG +- TIME_STOP_ENABLED +- TIME_STOP_MARIO_AND_DOORS +- TIME_STOP_MARIO_OPENED_DOOR +- TIME_STOP_UNKNOWN_0 + +### [enum ObjectList](#ObjectList) +| Identifier | Value | +| :--------- | :---- | +| OBJ_LIST_PLAYER | 0 | +| OBJ_LIST_UNUSED_1 | 1 | +| OBJ_LIST_DESTRUCTIVE | 2 | +| OBJ_LIST_UNUSED_3 | 3 | +| OBJ_LIST_GENACTOR | 4 | +| OBJ_LIST_PUSHABLE | 5 | +| OBJ_LIST_LEVEL | 6 | +| OBJ_LIST_UNUSED_7 | 7 | +| OBJ_LIST_DEFAULT | 8 | +| OBJ_LIST_SURFACE | 9 | +| OBJ_LIST_POLELIKE | 10 | +| OBJ_LIST_SPAWNER | 11 | +| OBJ_LIST_UNIMPORTANT | 12 | +| NUM_OBJ_LISTS | 13 | + +
+ ## [os_cont.h](#os_cont.h) - A_BUTTON - B_BUTTON diff --git a/docs/lua/functions.md b/docs/lua/functions.md index c9b51b07..cfb39a42 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -270,6 +270,7 @@ - mario_step.h - [get_additive_y_vel_for_jumps](#get_additive_y_vel_for_jumps) + - [init_bully_collision_data](#init_bully_collision_data) - [mario_bonk_reflection](#mario_bonk_reflection) - [mario_push_off_steep_floor](#mario_push_off_steep_floor) - [mario_update_moving_sand](#mario_update_moving_sand) @@ -385,61 +386,214 @@
- object_helpers.c + - [abs_angle_diff](#abs_angle_diff) + - [apply_drag_to_value](#apply_drag_to_value) - [approach_f32_signed](#approach_f32_signed) - [approach_f32_symmetric](#approach_f32_symmetric) - [approach_s16_symmetric](#approach_s16_symmetric) + - [bhv_dust_smoke_loop](#bhv_dust_smoke_loop) + - [bhv_init_room](#bhv_init_room) + - [bit_shift_left](#bit_shift_left) + - [chain_segment_init](#chain_segment_init) + - [clear_move_flag](#clear_move_flag) + - [clear_time_stop_flags](#clear_time_stop_flags) - [count_objects_with_behavior](#count_objects_with_behavior) - [count_unimportant_objects](#count_unimportant_objects) + - [cur_obj_abs_y_dist_to_home](#cur_obj_abs_y_dist_to_home) + - [cur_obj_advance_looping_anim](#cur_obj_advance_looping_anim) + - [cur_obj_align_gfx_with_floor](#cur_obj_align_gfx_with_floor) + - [cur_obj_angle_to_home](#cur_obj_angle_to_home) + - [cur_obj_apply_drag_xz](#cur_obj_apply_drag_xz) + - [cur_obj_become_intangible](#cur_obj_become_intangible) + - [cur_obj_become_tangible](#cur_obj_become_tangible) + - [cur_obj_can_mario_activate_textbox](#cur_obj_can_mario_activate_textbox) + - [cur_obj_can_mario_activate_textbox_2](#cur_obj_can_mario_activate_textbox_2) - [cur_obj_change_action](#cur_obj_change_action) + - [cur_obj_check_anim_frame](#cur_obj_check_anim_frame) + - [cur_obj_check_anim_frame_in_range](#cur_obj_check_anim_frame_in_range) + - [cur_obj_check_frame_prior_current_frame](#cur_obj_check_frame_prior_current_frame) + - [cur_obj_check_grabbed_mario](#cur_obj_check_grabbed_mario) + - [cur_obj_check_if_at_animation_end](#cur_obj_check_if_at_animation_end) + - [cur_obj_check_if_near_animation_end](#cur_obj_check_if_near_animation_end) + - [cur_obj_check_interacted](#cur_obj_check_interacted) + - [cur_obj_clear_interact_status_flag](#cur_obj_clear_interact_status_flag) + - [cur_obj_compute_vel_xz](#cur_obj_compute_vel_xz) - [cur_obj_count_objects_with_behavior](#cur_obj_count_objects_with_behavior) + - [cur_obj_detect_steep_floor](#cur_obj_detect_steep_floor) + - [cur_obj_disable](#cur_obj_disable) - [cur_obj_disable_rendering](#cur_obj_disable_rendering) - [cur_obj_disable_rendering_and_become_intangible](#cur_obj_disable_rendering_and_become_intangible) - [cur_obj_dist_to_nearest_object_with_behavior](#cur_obj_dist_to_nearest_object_with_behavior) - [cur_obj_enable_rendering](#cur_obj_enable_rendering) - [cur_obj_enable_rendering_2](#cur_obj_enable_rendering_2) - [cur_obj_enable_rendering_and_become_tangible](#cur_obj_enable_rendering_and_become_tangible) + - [cur_obj_enable_rendering_if_mario_in_room](#cur_obj_enable_rendering_if_mario_in_room) + - [cur_obj_end_dialog](#cur_obj_end_dialog) + - [cur_obj_extend_animation_if_at_end](#cur_obj_extend_animation_if_at_end) - [cur_obj_find_nearby_held_actor](#cur_obj_find_nearby_held_actor) - [cur_obj_find_nearest_object_with_behavior](#cur_obj_find_nearest_object_with_behavior) - [cur_obj_find_nearest_pole](#cur_obj_find_nearest_pole) + - [cur_obj_follow_path](#cur_obj_follow_path) - [cur_obj_forward_vel_approach_upward](#cur_obj_forward_vel_approach_upward) + - [cur_obj_get_dropped](#cur_obj_get_dropped) + - [cur_obj_get_thrown_or_placed](#cur_obj_get_thrown_or_placed) + - [cur_obj_has_behavior](#cur_obj_has_behavior) + - [cur_obj_has_model](#cur_obj_has_model) - [cur_obj_hide](#cur_obj_hide) + - [cur_obj_hide_if_mario_far_away_y](#cur_obj_hide_if_mario_far_away_y) + - [cur_obj_if_hit_wall_bounce_away](#cur_obj_if_hit_wall_bounce_away) - [cur_obj_init_animation](#cur_obj_init_animation) + - [cur_obj_init_animation_and_anim_frame](#cur_obj_init_animation_and_anim_frame) + - [cur_obj_init_animation_and_check_if_near_end](#cur_obj_init_animation_and_check_if_near_end) + - [cur_obj_init_animation_and_extend_if_at_end](#cur_obj_init_animation_and_extend_if_at_end) - [cur_obj_init_animation_with_accel_and_sound](#cur_obj_init_animation_with_accel_and_sound) - [cur_obj_init_animation_with_sound](#cur_obj_init_animation_with_sound) + - [cur_obj_is_any_player_on_platform](#cur_obj_is_any_player_on_platform) + - [cur_obj_is_mario_ground_pounding_platform](#cur_obj_is_mario_ground_pounding_platform) + - [cur_obj_is_mario_on_platform](#cur_obj_is_mario_on_platform) + - [cur_obj_lateral_dist_from_mario_to_home](#cur_obj_lateral_dist_from_mario_to_home) + - [cur_obj_lateral_dist_from_obj_to_home](#cur_obj_lateral_dist_from_obj_to_home) + - [cur_obj_lateral_dist_to_home](#cur_obj_lateral_dist_to_home) + - [cur_obj_mario_far_away](#cur_obj_mario_far_away) + - [cur_obj_move_after_thrown_or_dropped](#cur_obj_move_after_thrown_or_dropped) + - [cur_obj_move_standard](#cur_obj_move_standard) + - [cur_obj_move_up_and_down](#cur_obj_move_up_and_down) + - [cur_obj_move_update_ground_air_flags](#cur_obj_move_update_ground_air_flags) + - [cur_obj_move_update_underwater_flags](#cur_obj_move_update_underwater_flags) + - [cur_obj_move_using_fvel_and_gravity](#cur_obj_move_using_fvel_and_gravity) - [cur_obj_move_using_vel](#cur_obj_move_using_vel) + - [cur_obj_move_using_vel_and_gravity](#cur_obj_move_using_vel_and_gravity) + - [cur_obj_move_xz](#cur_obj_move_xz) + - [cur_obj_move_xz_using_fvel_and_yaw](#cur_obj_move_xz_using_fvel_and_yaw) + - [cur_obj_move_y](#cur_obj_move_y) + - [cur_obj_move_y_and_get_water_level](#cur_obj_move_y_and_get_water_level) + - [cur_obj_move_y_with_terminal_vel](#cur_obj_move_y_with_terminal_vel) - [cur_obj_nearest_object_with_behavior](#cur_obj_nearest_object_with_behavior) + - [cur_obj_outside_home_rectangle](#cur_obj_outside_home_rectangle) + - [cur_obj_outside_home_square](#cur_obj_outside_home_square) + - [cur_obj_progress_direction_table](#cur_obj_progress_direction_table) + - [cur_obj_push_mario_away](#cur_obj_push_mario_away) + - [cur_obj_push_mario_away_from_cylinder](#cur_obj_push_mario_away_from_cylinder) + - [cur_obj_reflect_move_angle_off_wall](#cur_obj_reflect_move_angle_off_wall) + - [cur_obj_reset_timer_and_subaction](#cur_obj_reset_timer_and_subaction) + - [cur_obj_resolve_wall_collisions](#cur_obj_resolve_wall_collisions) + - [cur_obj_reverse_animation](#cur_obj_reverse_animation) + - [cur_obj_rotate_face_angle_using_vel](#cur_obj_rotate_face_angle_using_vel) + - [cur_obj_rotate_move_angle_using_vel](#cur_obj_rotate_move_angle_using_vel) - [cur_obj_rotate_yaw_toward](#cur_obj_rotate_yaw_toward) - [cur_obj_scale](#cur_obj_scale) + - [cur_obj_scale_over_time](#cur_obj_scale_over_time) + - [cur_obj_set_behavior](#cur_obj_set_behavior) + - [cur_obj_set_direction_table](#cur_obj_set_direction_table) + - [cur_obj_set_face_angle_to_move_angle](#cur_obj_set_face_angle_to_move_angle) + - [cur_obj_set_hitbox_and_die_if_attacked](#cur_obj_set_hitbox_and_die_if_attacked) + - [cur_obj_set_hitbox_radius_and_height](#cur_obj_set_hitbox_radius_and_height) + - [cur_obj_set_hurtbox_radius_and_height](#cur_obj_set_hurtbox_radius_and_height) + - [cur_obj_set_model](#cur_obj_set_model) - [cur_obj_set_pos_relative](#cur_obj_set_pos_relative) - [cur_obj_set_pos_relative_to_parent](#cur_obj_set_pos_relative_to_parent) + - [cur_obj_set_pos_to_home](#cur_obj_set_pos_to_home) + - [cur_obj_set_pos_to_home_and_stop](#cur_obj_set_pos_to_home_and_stop) + - [cur_obj_set_pos_to_home_with_debug](#cur_obj_set_pos_to_home_with_debug) + - [cur_obj_set_pos_via_transform](#cur_obj_set_pos_via_transform) - [cur_obj_set_vel_from_mario_vel](#cur_obj_set_vel_from_mario_vel) + - [cur_obj_set_y_vel_and_animation](#cur_obj_set_y_vel_and_animation) + - [cur_obj_shake_screen](#cur_obj_shake_screen) + - [cur_obj_shake_y](#cur_obj_shake_y) + - [cur_obj_shake_y_until](#cur_obj_shake_y_until) + - [cur_obj_spawn_loot_blue_coin](#cur_obj_spawn_loot_blue_coin) + - [cur_obj_spawn_loot_coin_at_mario_pos](#cur_obj_spawn_loot_coin_at_mario_pos) + - [cur_obj_spawn_particles](#cur_obj_spawn_particles) + - [cur_obj_spawn_star_at_y_offset](#cur_obj_spawn_star_at_y_offset) + - [cur_obj_start_cam_event](#cur_obj_start_cam_event) - [cur_obj_unhide](#cur_obj_unhide) + - [cur_obj_unrender_and_reset_state](#cur_obj_unrender_and_reset_state) - [cur_obj_unused_init_on_floor](#cur_obj_unused_init_on_floor) + - [cur_obj_unused_play_footstep_sound](#cur_obj_unused_play_footstep_sound) + - [cur_obj_unused_resolve_wall_collisions](#cur_obj_unused_resolve_wall_collisions) + - [cur_obj_update_floor](#cur_obj_update_floor) + - [cur_obj_update_floor_and_resolve_wall_collisions](#cur_obj_update_floor_and_resolve_wall_collisions) + - [cur_obj_update_floor_and_walls](#cur_obj_update_floor_and_walls) + - [cur_obj_update_floor_height](#cur_obj_update_floor_height) + - [cur_obj_update_floor_height_and_get_floor](#cur_obj_update_floor_height_and_get_floor) + - [cur_obj_wait_then_blink](#cur_obj_wait_then_blink) + - [cur_obj_was_attacked_or_ground_pounded](#cur_obj_was_attacked_or_ground_pounded) + - [cur_obj_within_12k_bounds](#cur_obj_within_12k_bounds) + - [disable_time_stop](#disable_time_stop) + - [disable_time_stop_including_mario](#disable_time_stop_including_mario) - [dist_between_object_and_point](#dist_between_object_and_point) - [dist_between_objects](#dist_between_objects) + - [enable_time_stop](#enable_time_stop) + - [enable_time_stop_including_mario](#enable_time_stop_including_mario) - [find_unimportant_object](#find_unimportant_object) + - [geo_offset_klepto_debug](#geo_offset_klepto_debug) - [get_object_list_from_behavior](#get_object_list_from_behavior) + - [increment_velocity_toward_range](#increment_velocity_toward_range) + - [is_item_in_array](#is_item_in_array) + - [is_mario_moving_fast_or_in_air](#is_mario_moving_fast_or_in_air) - [lateral_dist_between_objects](#lateral_dist_between_objects) + - [mario_is_dive_sliding](#mario_is_dive_sliding) + - [mario_is_in_air_action](#mario_is_in_air_action) + - [mario_is_within_rectangle](#mario_is_within_rectangle) + - [mario_set_flag](#mario_set_flag) - [obj_angle_to_object](#obj_angle_to_object) - [obj_angle_to_point](#obj_angle_to_point) - [obj_apply_scale_to_transform](#obj_apply_scale_to_transform) + - [obj_attack_collided_from_other_object](#obj_attack_collided_from_other_object) + - [obj_become_tangible](#obj_become_tangible) + - [obj_build_relative_transform](#obj_build_relative_transform) + - [obj_build_transform_from_pos_and_angle](#obj_build_transform_from_pos_and_angle) + - [obj_build_transform_relative_to_parent](#obj_build_transform_relative_to_parent) + - [obj_build_vel_from_transform](#obj_build_vel_from_transform) + - [obj_check_if_collided_with_object](#obj_check_if_collided_with_object) - [obj_copy_angle](#obj_copy_angle) + - [obj_copy_behavior_params](#obj_copy_behavior_params) - [obj_copy_graph_y_offset](#obj_copy_graph_y_offset) - [obj_copy_pos](#obj_copy_pos) - [obj_copy_pos_and_angle](#obj_copy_pos_and_angle) - [obj_copy_scale](#obj_copy_scale) + - [obj_create_transform_from_self](#obj_create_transform_from_self) + - [obj_explode_and_spawn_coins](#obj_explode_and_spawn_coins) + - [obj_has_behavior](#obj_has_behavior) - [obj_init_animation](#obj_init_animation) + - [obj_is_hidden](#obj_is_hidden) + - [obj_mark_for_deletion](#obj_mark_for_deletion) - [obj_pitch_to_object](#obj_pitch_to_object) - [obj_scale](#obj_scale) + - [obj_scale_random](#obj_scale_random) - [obj_scale_xyz](#obj_scale_xyz) - [obj_set_angle](#obj_set_angle) + - [obj_set_behavior](#obj_set_behavior) + - [obj_set_billboard](#obj_set_billboard) + - [obj_set_cylboard](#obj_set_cylboard) - [obj_set_face_angle_to_move_angle](#obj_set_face_angle_to_move_angle) + - [obj_set_gfx_pos_at_obj_pos](#obj_set_gfx_pos_at_obj_pos) - [obj_set_gfx_pos_from_pos](#obj_set_gfx_pos_from_pos) - [obj_set_held_state](#obj_set_held_state) + - [obj_set_hitbox](#obj_set_hitbox) - [obj_set_parent_relative_pos](#obj_set_parent_relative_pos) - [obj_set_pos](#obj_set_pos) + - [obj_set_pos_relative](#obj_set_pos_relative) + - [obj_set_throw_matrix_from_transform](#obj_set_throw_matrix_from_transform) + - [obj_spawn_loot_blue_coins](#obj_spawn_loot_blue_coins) + - [obj_spawn_loot_coins](#obj_spawn_loot_coins) + - [obj_spawn_loot_yellow_coins](#obj_spawn_loot_yellow_coins) + - [obj_translate_local](#obj_translate_local) + - [obj_translate_xyz_random](#obj_translate_xyz_random) + - [obj_translate_xz_random](#obj_translate_xz_random) - [obj_turn_toward_object](#obj_turn_toward_object) + - [player_performed_grab_escape_action](#player_performed_grab_escape_action) + - [random_f32_around_zero](#random_f32_around_zero) + - [set_mario_interact_hoot_if_in_range](#set_mario_interact_hoot_if_in_range) + - [set_time_stop_flags](#set_time_stop_flags) + - [signum_positive](#signum_positive) + - [spawn_base_star_with_no_lvl_exit](#spawn_base_star_with_no_lvl_exit) + - [spawn_mist_particles](#spawn_mist_particles) + - [spawn_mist_particles_with_sound](#spawn_mist_particles_with_sound) + - [spawn_star_with_no_lvl_exit](#spawn_star_with_no_lvl_exit) - [spawn_water_droplet](#spawn_water_droplet) + - [stub_obj_helpers_3](#stub_obj_helpers_3) + - [stub_obj_helpers_4](#stub_obj_helpers_4)
@@ -4758,6 +4912,32 @@
+## [init_bully_collision_data](#init_bully_collision_data) + +### Lua Example +`init_bully_collision_data(data, posX, posZ, forwardVel, yaw, conversionRatio, radius)` + +### Parameters +| Field | Type | +| ----- | ---- | +| data | [BullyCollisionData](structs.md#BullyCollisionData) | +| posX | number | +| posZ | number | +| forwardVel | number | +| yaw | integer | +| conversionRatio | number | +| radius | number | + +### Returns +- None + +### C Prototype +`void init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ, f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius);` + +[:arrow_up_small:](#) + +
+ ## [mario_bonk_reflection](#mario_bonk_reflection) ### Lua Example @@ -6780,6 +6960,48 @@
+## [abs_angle_diff](#abs_angle_diff) + +### Lua Example +`local integerValue = abs_angle_diff(x0, x1)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x0 | integer | +| x1 | integer | + +### Returns +- integer + +### C Prototype +`s16 abs_angle_diff(s16 x0, s16 x1);` + +[:arrow_up_small:](#) + +
+ +## [apply_drag_to_value](#apply_drag_to_value) + +### Lua Example +`apply_drag_to_value(value, dragStrength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | Pointer | +| dragStrength | number | + +### Returns +- None + +### C Prototype +`void apply_drag_to_value(f32 *value, f32 dragStrength);` + +[:arrow_up_small:](#) + +
+ ## [approach_f32_signed](#approach_f32_signed) ### Lua Example @@ -6846,6 +7068,123 @@
+## [bhv_dust_smoke_loop](#bhv_dust_smoke_loop) + +### Lua Example +`bhv_dust_smoke_loop()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void bhv_dust_smoke_loop(void);` + +[:arrow_up_small:](#) + +
+ +## [bhv_init_room](#bhv_init_room) + +### Lua Example +`bhv_init_room()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void bhv_init_room(void);` + +[:arrow_up_small:](#) + +
+ +## [bit_shift_left](#bit_shift_left) + +### Lua Example +`local integerValue = bit_shift_left(a0)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a0 | integer | + +### Returns +- integer + +### C Prototype +`s32 bit_shift_left(s32 a0);` + +[:arrow_up_small:](#) + +
+ +## [chain_segment_init](#chain_segment_init) + +### Lua Example +`chain_segment_init(segment)` + +### Parameters +| Field | Type | +| ----- | ---- | +| segment | [ChainSegment](structs.md#ChainSegment) | + +### Returns +- None + +### C Prototype +`void chain_segment_init(struct ChainSegment *segment);` + +[:arrow_up_small:](#) + +
+ +## [clear_move_flag](#clear_move_flag) + +### Lua Example +`local integerValue = clear_move_flag(bitSet, flag)` + +### Parameters +| Field | Type | +| ----- | ---- | +| bitSet | Pointer | +| flag | integer | + +### Returns +- integer + +### C Prototype +`s32 clear_move_flag(u32 *bitSet, s32 flag);` + +[:arrow_up_small:](#) + +
+ +## [clear_time_stop_flags](#clear_time_stop_flags) + +### Lua Example +`clear_time_stop_flags(flags)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flags | integer | + +### Returns +- None + +### C Prototype +`void clear_time_stop_flags(s32 flags);` + +[:arrow_up_small:](#) + +
+ ## [count_objects_with_behavior](#count_objects_with_behavior) ### Lua Example @@ -6884,6 +7223,179 @@
+## [cur_obj_abs_y_dist_to_home](#cur_obj_abs_y_dist_to_home) + +### Lua Example +`local numberValue = cur_obj_abs_y_dist_to_home()` + +### Parameters +- None + +### Returns +- number + +### C Prototype +`f32 cur_obj_abs_y_dist_to_home(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_advance_looping_anim](#cur_obj_advance_looping_anim) + +### Lua Example +`local integerValue = cur_obj_advance_looping_anim()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_advance_looping_anim(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_align_gfx_with_floor](#cur_obj_align_gfx_with_floor) + +### Lua Example +`cur_obj_align_gfx_with_floor()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_align_gfx_with_floor(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_angle_to_home](#cur_obj_angle_to_home) + +### Lua Example +`local integerValue = cur_obj_angle_to_home()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s16 cur_obj_angle_to_home(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_apply_drag_xz](#cur_obj_apply_drag_xz) + +### Lua Example +`cur_obj_apply_drag_xz(dragStrength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dragStrength | number | + +### Returns +- None + +### C Prototype +`void cur_obj_apply_drag_xz(f32 dragStrength);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_become_intangible](#cur_obj_become_intangible) + +### Lua Example +`cur_obj_become_intangible()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_become_intangible(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_become_tangible](#cur_obj_become_tangible) + +### Lua Example +`cur_obj_become_tangible()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_become_tangible(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_can_mario_activate_textbox](#cur_obj_can_mario_activate_textbox) + +### Lua Example +`local integerValue = cur_obj_can_mario_activate_textbox(m, radius, height, unused)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| radius | number | +| height | number | +| unused | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, UNUSED s32 unused);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_can_mario_activate_textbox_2](#cur_obj_can_mario_activate_textbox_2) + +### Lua Example +`local integerValue = cur_obj_can_mario_activate_textbox_2(m, radius, height)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| radius | number | +| height | number | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 height);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_change_action](#cur_obj_change_action) ### Lua Example @@ -6904,6 +7416,177 @@
+## [cur_obj_check_anim_frame](#cur_obj_check_anim_frame) + +### Lua Example +`local integerValue = cur_obj_check_anim_frame(frame)` + +### Parameters +| Field | Type | +| ----- | ---- | +| frame | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_anim_frame(s32 frame);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_check_anim_frame_in_range](#cur_obj_check_anim_frame_in_range) + +### Lua Example +`local integerValue = cur_obj_check_anim_frame_in_range(startFrame, rangeLength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| startFrame | integer | +| rangeLength | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_check_frame_prior_current_frame](#cur_obj_check_frame_prior_current_frame) + +### Lua Example +`local integerValue = cur_obj_check_frame_prior_current_frame(a0)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a0 | Pointer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_frame_prior_current_frame(s16 *a0);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_check_grabbed_mario](#cur_obj_check_grabbed_mario) + +### Lua Example +`local integerValue = cur_obj_check_grabbed_mario()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_grabbed_mario(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_check_if_at_animation_end](#cur_obj_check_if_at_animation_end) + +### Lua Example +`local integerValue = cur_obj_check_if_at_animation_end()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_if_at_animation_end(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_check_if_near_animation_end](#cur_obj_check_if_near_animation_end) + +### Lua Example +`local integerValue = cur_obj_check_if_near_animation_end()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_if_near_animation_end(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_check_interacted](#cur_obj_check_interacted) + +### Lua Example +`local integerValue = cur_obj_check_interacted()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_check_interacted(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_clear_interact_status_flag](#cur_obj_clear_interact_status_flag) + +### Lua Example +`local integerValue = cur_obj_clear_interact_status_flag(flag)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flag | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_clear_interact_status_flag(s32 flag);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_compute_vel_xz](#cur_obj_compute_vel_xz) + +### Lua Example +`cur_obj_compute_vel_xz()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_compute_vel_xz(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_count_objects_with_behavior](#cur_obj_count_objects_with_behavior) ### Lua Example @@ -6925,6 +7608,44 @@
+## [cur_obj_detect_steep_floor](#cur_obj_detect_steep_floor) + +### Lua Example +`local integerValue = cur_obj_detect_steep_floor(steepAngleDegrees)` + +### Parameters +| Field | Type | +| ----- | ---- | +| steepAngleDegrees | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_detect_steep_floor(s16 steepAngleDegrees);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_disable](#cur_obj_disable) + +### Lua Example +`cur_obj_disable()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_disable(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_disable_rendering](#cur_obj_disable_rendering) ### Lua Example @@ -7039,6 +7760,64 @@
+## [cur_obj_enable_rendering_if_mario_in_room](#cur_obj_enable_rendering_if_mario_in_room) + +### Lua Example +`cur_obj_enable_rendering_if_mario_in_room()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_enable_rendering_if_mario_in_room(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_end_dialog](#cur_obj_end_dialog) + +### Lua Example +`cur_obj_end_dialog(m, dialogFlags, dialogResult)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| dialogFlags | integer | +| dialogResult | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_end_dialog(struct MarioState* m, s32 dialogFlags, s32 dialogResult);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_extend_animation_if_at_end](#cur_obj_extend_animation_if_at_end) + +### Lua Example +`cur_obj_extend_animation_if_at_end()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_extend_animation_if_at_end(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_find_nearby_held_actor](#cur_obj_find_nearby_held_actor) ### Lua Example @@ -7099,6 +7878,26 @@
+## [cur_obj_follow_path](#cur_obj_follow_path) + +### Lua Example +`local integerValue = cur_obj_follow_path(unusedArg)` + +### Parameters +| Field | Type | +| ----- | ---- | +| unusedArg | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_follow_path(UNUSED s32 unusedArg);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_forward_vel_approach_upward](#cur_obj_forward_vel_approach_upward) ### Lua Example @@ -7120,6 +7919,86 @@
+## [cur_obj_get_dropped](#cur_obj_get_dropped) + +### Lua Example +`cur_obj_get_dropped()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_get_dropped(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_get_thrown_or_placed](#cur_obj_get_thrown_or_placed) + +### Lua Example +`cur_obj_get_thrown_or_placed(forwardVel, velY, thrownAction)` + +### Parameters +| Field | Type | +| ----- | ---- | +| forwardVel | number | +| velY | number | +| thrownAction | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_get_thrown_or_placed(f32 forwardVel, f32 velY, s32 thrownAction);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_has_behavior](#cur_obj_has_behavior) + +### Lua Example +`local integerValue = cur_obj_has_behavior(behavior)` + +### Parameters +| Field | Type | +| ----- | ---- | +| behavior | Pointer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_has_behavior(const BehaviorScript *behavior);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_has_model](#cur_obj_has_model) + +### Lua Example +`local integerValue = cur_obj_has_model(modelID)` + +### Parameters +| Field | Type | +| ----- | ---- | +| modelID | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_has_model(u16 modelID);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_hide](#cur_obj_hide) ### Lua Example @@ -7138,6 +8017,44 @@
+## [cur_obj_hide_if_mario_far_away_y](#cur_obj_hide_if_mario_far_away_y) + +### Lua Example +`local integerValue = cur_obj_hide_if_mario_far_away_y(distY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| distY | number | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_hide_if_mario_far_away_y(f32 distY);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_if_hit_wall_bounce_away](#cur_obj_if_hit_wall_bounce_away) + +### Lua Example +`cur_obj_if_hit_wall_bounce_away()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_if_hit_wall_bounce_away(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_init_animation](#cur_obj_init_animation) ### Lua Example @@ -7158,6 +8075,67 @@
+## [cur_obj_init_animation_and_anim_frame](#cur_obj_init_animation_and_anim_frame) + +### Lua Example +`cur_obj_init_animation_and_anim_frame(animIndex, animFrame)` + +### Parameters +| Field | Type | +| ----- | ---- | +| animIndex | integer | +| animFrame | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_init_animation_and_anim_frame(s32 animIndex, s32 animFrame);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_init_animation_and_check_if_near_end](#cur_obj_init_animation_and_check_if_near_end) + +### Lua Example +`local integerValue = cur_obj_init_animation_and_check_if_near_end(animIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| animIndex | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_init_animation_and_check_if_near_end(s32 animIndex);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_init_animation_and_extend_if_at_end](#cur_obj_init_animation_and_extend_if_at_end) + +### Lua Example +`cur_obj_init_animation_and_extend_if_at_end(animIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| animIndex | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_init_animation_and_extend_if_at_end(s32 animIndex);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_init_animation_with_accel_and_sound](#cur_obj_init_animation_with_accel_and_sound) ### Lua Example @@ -7199,6 +8177,252 @@
+## [cur_obj_is_any_player_on_platform](#cur_obj_is_any_player_on_platform) + +### Lua Example +`local integerValue = cur_obj_is_any_player_on_platform()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_is_any_player_on_platform(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_is_mario_ground_pounding_platform](#cur_obj_is_mario_ground_pounding_platform) + +### Lua Example +`local integerValue = cur_obj_is_mario_ground_pounding_platform()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_is_mario_ground_pounding_platform(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_is_mario_on_platform](#cur_obj_is_mario_on_platform) + +### Lua Example +`local integerValue = cur_obj_is_mario_on_platform()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_is_mario_on_platform(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_lateral_dist_from_mario_to_home](#cur_obj_lateral_dist_from_mario_to_home) + +### Lua Example +`local numberValue = cur_obj_lateral_dist_from_mario_to_home()` + +### Parameters +- None + +### Returns +- number + +### C Prototype +`f32 cur_obj_lateral_dist_from_mario_to_home(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_lateral_dist_from_obj_to_home](#cur_obj_lateral_dist_from_obj_to_home) + +### Lua Example +`local numberValue = cur_obj_lateral_dist_from_obj_to_home(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- number + +### C Prototype +`f32 cur_obj_lateral_dist_from_obj_to_home(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_lateral_dist_to_home](#cur_obj_lateral_dist_to_home) + +### Lua Example +`local numberValue = cur_obj_lateral_dist_to_home()` + +### Parameters +- None + +### Returns +- number + +### C Prototype +`f32 cur_obj_lateral_dist_to_home(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_mario_far_away](#cur_obj_mario_far_away) + +### Lua Example +`local integerValue = cur_obj_mario_far_away()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_mario_far_away(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_after_thrown_or_dropped](#cur_obj_move_after_thrown_or_dropped) + +### Lua Example +`cur_obj_move_after_thrown_or_dropped(forwardVel, velY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| forwardVel | number | +| velY | number | + +### Returns +- None + +### C Prototype +`void cur_obj_move_after_thrown_or_dropped(f32 forwardVel, f32 velY);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_standard](#cur_obj_move_standard) + +### Lua Example +`cur_obj_move_standard(steepSlopeAngleDegrees)` + +### Parameters +| Field | Type | +| ----- | ---- | +| steepSlopeAngleDegrees | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_move_standard(s16 steepSlopeAngleDegrees);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_up_and_down](#cur_obj_move_up_and_down) + +### Lua Example +`local integerValue = cur_obj_move_up_and_down(a0)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a0 | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_move_up_and_down(s32 a0);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_update_ground_air_flags](#cur_obj_move_update_ground_air_flags) + +### Lua Example +`cur_obj_move_update_ground_air_flags(gravity, bounciness)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gravity | number | +| bounciness | number | + +### Returns +- None + +### C Prototype +`void cur_obj_move_update_ground_air_flags(UNUSED f32 gravity, f32 bounciness);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_update_underwater_flags](#cur_obj_move_update_underwater_flags) + +### Lua Example +`cur_obj_move_update_underwater_flags()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_move_update_underwater_flags(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_using_fvel_and_gravity](#cur_obj_move_using_fvel_and_gravity) + +### Lua Example +`cur_obj_move_using_fvel_and_gravity()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_move_using_fvel_and_gravity(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_move_using_vel](#cur_obj_move_using_vel) ### Lua Example @@ -7217,6 +8441,124 @@
+## [cur_obj_move_using_vel_and_gravity](#cur_obj_move_using_vel_and_gravity) + +### Lua Example +`cur_obj_move_using_vel_and_gravity()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_move_using_vel_and_gravity(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_xz](#cur_obj_move_xz) + +### Lua Example +`local integerValue = cur_obj_move_xz(steepSlopeNormalY, careAboutEdgesAndSteepSlopes)` + +### Parameters +| Field | Type | +| ----- | ---- | +| steepSlopeNormalY | number | +| careAboutEdgesAndSteepSlopes | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_move_xz(f32 steepSlopeNormalY, s32 careAboutEdgesAndSteepSlopes);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_xz_using_fvel_and_yaw](#cur_obj_move_xz_using_fvel_and_yaw) + +### Lua Example +`cur_obj_move_xz_using_fvel_and_yaw()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_move_xz_using_fvel_and_yaw(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_y](#cur_obj_move_y) + +### Lua Example +`cur_obj_move_y(gravity, bounciness, buoyancy)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gravity | number | +| bounciness | number | +| buoyancy | number | + +### Returns +- None + +### C Prototype +`void cur_obj_move_y(f32 gravity, f32 bounciness, f32 buoyancy);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_y_and_get_water_level](#cur_obj_move_y_and_get_water_level) + +### Lua Example +`local numberValue = cur_obj_move_y_and_get_water_level(gravity, buoyancy)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gravity | number | +| buoyancy | number | + +### Returns +- number + +### C Prototype +`f32 cur_obj_move_y_and_get_water_level(f32 gravity, f32 buoyancy);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_move_y_with_terminal_vel](#cur_obj_move_y_with_terminal_vel) + +### Lua Example +`cur_obj_move_y_with_terminal_vel()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_move_y_with_terminal_vel(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_nearest_object_with_behavior](#cur_obj_nearest_object_with_behavior) ### Lua Example @@ -7237,6 +8579,216 @@
+## [cur_obj_outside_home_rectangle](#cur_obj_outside_home_rectangle) + +### Lua Example +`local integerValue = cur_obj_outside_home_rectangle(minX, maxX, minZ, maxZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| minX | number | +| maxX | number | +| minZ | number | +| maxZ | number | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_outside_home_rectangle(f32 minX, f32 maxX, f32 minZ, f32 maxZ);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_outside_home_square](#cur_obj_outside_home_square) + +### Lua Example +`local integerValue = cur_obj_outside_home_square(halfLength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| halfLength | number | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_outside_home_square(f32 halfLength);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_progress_direction_table](#cur_obj_progress_direction_table) + +### Lua Example +`local integerValue = cur_obj_progress_direction_table()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_progress_direction_table(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_push_mario_away](#cur_obj_push_mario_away) + +### Lua Example +`cur_obj_push_mario_away(radius)` + +### Parameters +| Field | Type | +| ----- | ---- | +| radius | number | + +### Returns +- None + +### C Prototype +`void cur_obj_push_mario_away(f32 radius);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_push_mario_away_from_cylinder](#cur_obj_push_mario_away_from_cylinder) + +### Lua Example +`cur_obj_push_mario_away_from_cylinder(radius, extentY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| radius | number | +| extentY | number | + +### Returns +- None + +### C Prototype +`void cur_obj_push_mario_away_from_cylinder(f32 radius, f32 extentY);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_reflect_move_angle_off_wall](#cur_obj_reflect_move_angle_off_wall) + +### Lua Example +`local integerValue = cur_obj_reflect_move_angle_off_wall()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s16 cur_obj_reflect_move_angle_off_wall(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_reset_timer_and_subaction](#cur_obj_reset_timer_and_subaction) + +### Lua Example +`cur_obj_reset_timer_and_subaction()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_reset_timer_and_subaction(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_resolve_wall_collisions](#cur_obj_resolve_wall_collisions) + +### Lua Example +`local integerValue = cur_obj_resolve_wall_collisions()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_resolve_wall_collisions(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_reverse_animation](#cur_obj_reverse_animation) + +### Lua Example +`cur_obj_reverse_animation()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_reverse_animation(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_rotate_face_angle_using_vel](#cur_obj_rotate_face_angle_using_vel) + +### Lua Example +`cur_obj_rotate_face_angle_using_vel()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_rotate_face_angle_using_vel(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_rotate_move_angle_using_vel](#cur_obj_rotate_move_angle_using_vel) + +### Lua Example +`cur_obj_rotate_move_angle_using_vel()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_rotate_move_angle_using_vel(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_rotate_yaw_toward](#cur_obj_rotate_yaw_toward) ### Lua Example @@ -7278,6 +8830,171 @@
+## [cur_obj_scale_over_time](#cur_obj_scale_over_time) + +### Lua Example +`cur_obj_scale_over_time(a0, a1, sp10, sp14)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a0 | integer | +| a1 | integer | +| sp10 | number | +| sp14 | number | + +### Returns +- None + +### C Prototype +`void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_behavior](#cur_obj_set_behavior) + +### Lua Example +`cur_obj_set_behavior(behavior)` + +### Parameters +| Field | Type | +| ----- | ---- | +| behavior | Pointer | + +### Returns +- None + +### C Prototype +`void cur_obj_set_behavior(const BehaviorScript *behavior);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_direction_table](#cur_obj_set_direction_table) + +### Lua Example +`local integerValue = cur_obj_set_direction_table(a0)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a0 | Pointer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_set_direction_table(s8 *a0);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_face_angle_to_move_angle](#cur_obj_set_face_angle_to_move_angle) + +### Lua Example +`cur_obj_set_face_angle_to_move_angle()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_set_face_angle_to_move_angle(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_hitbox_and_die_if_attacked](#cur_obj_set_hitbox_and_die_if_attacked) + +### Lua Example +`local integerValue = cur_obj_set_hitbox_and_die_if_attacked(hitbox, deathSound, noLootCoins)` + +### Parameters +| Field | Type | +| ----- | ---- | +| hitbox | [ObjectHitbox](structs.md#ObjectHitbox) | +| deathSound | integer | +| noLootCoins | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_set_hitbox_and_die_if_attacked(struct ObjectHitbox *hitbox, s32 deathSound, s32 noLootCoins);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_hitbox_radius_and_height](#cur_obj_set_hitbox_radius_and_height) + +### Lua Example +`cur_obj_set_hitbox_radius_and_height(radius, height)` + +### Parameters +| Field | Type | +| ----- | ---- | +| radius | number | +| height | number | + +### Returns +- None + +### C Prototype +`void cur_obj_set_hitbox_radius_and_height(f32 radius, f32 height);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_hurtbox_radius_and_height](#cur_obj_set_hurtbox_radius_and_height) + +### Lua Example +`cur_obj_set_hurtbox_radius_and_height(radius, height)` + +### Parameters +| Field | Type | +| ----- | ---- | +| radius | number | +| height | number | + +### Returns +- None + +### C Prototype +`void cur_obj_set_hurtbox_radius_and_height(f32 radius, f32 height);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_model](#cur_obj_set_model) + +### Lua Example +`cur_obj_set_model(modelID)` + +### Parameters +| Field | Type | +| ----- | ---- | +| modelID | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_set_model(s32 modelID);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_set_pos_relative](#cur_obj_set_pos_relative) ### Lua Example @@ -7323,6 +9040,78 @@
+## [cur_obj_set_pos_to_home](#cur_obj_set_pos_to_home) + +### Lua Example +`cur_obj_set_pos_to_home()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_set_pos_to_home(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_pos_to_home_and_stop](#cur_obj_set_pos_to_home_and_stop) + +### Lua Example +`cur_obj_set_pos_to_home_and_stop()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_set_pos_to_home_and_stop(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_pos_to_home_with_debug](#cur_obj_set_pos_to_home_with_debug) + +### Lua Example +`cur_obj_set_pos_to_home_with_debug()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_set_pos_to_home_with_debug(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_set_pos_via_transform](#cur_obj_set_pos_via_transform) + +### Lua Example +`cur_obj_set_pos_via_transform()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_set_pos_via_transform(void);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_set_vel_from_mario_vel](#cur_obj_set_vel_from_mario_vel) ### Lua Example @@ -7345,6 +9134,190 @@
+## [cur_obj_set_y_vel_and_animation](#cur_obj_set_y_vel_and_animation) + +### Lua Example +`cur_obj_set_y_vel_and_animation(sp18, sp1C)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp18 | number | +| sp1C | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_shake_screen](#cur_obj_shake_screen) + +### Lua Example +`cur_obj_shake_screen(shake)` + +### Parameters +| Field | Type | +| ----- | ---- | +| shake | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_shake_screen(s32 shake);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_shake_y](#cur_obj_shake_y) + +### Lua Example +`cur_obj_shake_y(amount)` + +### Parameters +| Field | Type | +| ----- | ---- | +| amount | number | + +### Returns +- None + +### C Prototype +`void cur_obj_shake_y(f32 amount);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_shake_y_until](#cur_obj_shake_y_until) + +### Lua Example +`local integerValue = cur_obj_shake_y_until(cycles, amount)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cycles | integer | +| amount | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_shake_y_until(s32 cycles, s32 amount);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_spawn_loot_blue_coin](#cur_obj_spawn_loot_blue_coin) + +### Lua Example +`cur_obj_spawn_loot_blue_coin()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_spawn_loot_blue_coin(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_spawn_loot_coin_at_mario_pos](#cur_obj_spawn_loot_coin_at_mario_pos) + +### Lua Example +`cur_obj_spawn_loot_coin_at_mario_pos(m)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | + +### Returns +- None + +### C Prototype +`void cur_obj_spawn_loot_coin_at_mario_pos(struct MarioState* m);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_spawn_particles](#cur_obj_spawn_particles) + +### Lua Example +`cur_obj_spawn_particles(info)` + +### Parameters +| Field | Type | +| ----- | ---- | +| info | [SpawnParticlesInfo](structs.md#SpawnParticlesInfo) | + +### Returns +- None + +### C Prototype +`void cur_obj_spawn_particles(struct SpawnParticlesInfo *info);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_spawn_star_at_y_offset](#cur_obj_spawn_star_at_y_offset) + +### Lua Example +`cur_obj_spawn_star_at_y_offset(targetX, targetY, targetZ, offsetY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| targetX | number | +| targetY | number | +| targetZ | number | +| offsetY | number | + +### Returns +- None + +### C Prototype +`void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_start_cam_event](#cur_obj_start_cam_event) + +### Lua Example +`cur_obj_start_cam_event(obj, cameraEvent)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| cameraEvent | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_start_cam_event(UNUSED struct Object *obj, s32 cameraEvent);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_unhide](#cur_obj_unhide) ### Lua Example @@ -7363,6 +9336,27 @@
+## [cur_obj_unrender_and_reset_state](#cur_obj_unrender_and_reset_state) + +### Lua Example +`cur_obj_unrender_and_reset_state(sp18, sp1C)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp18 | integer | +| sp1C | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C);` + +[:arrow_up_small:](#) + +
+ ## [cur_obj_unused_init_on_floor](#cur_obj_unused_init_on_floor) ### Lua Example @@ -7381,6 +9375,234 @@
+## [cur_obj_unused_play_footstep_sound](#cur_obj_unused_play_footstep_sound) + +### Lua Example +`cur_obj_unused_play_footstep_sound(animFrame1, animFrame2, sound)` + +### Parameters +| Field | Type | +| ----- | ---- | +| animFrame1 | integer | +| animFrame2 | integer | +| sound | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_unused_play_footstep_sound(s32 animFrame1, s32 animFrame2, s32 sound);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_unused_resolve_wall_collisions](#cur_obj_unused_resolve_wall_collisions) + +### Lua Example +`cur_obj_unused_resolve_wall_collisions(offsetY, radius)` + +### Parameters +| Field | Type | +| ----- | ---- | +| offsetY | number | +| radius | number | + +### Returns +- None + +### C Prototype +`void cur_obj_unused_resolve_wall_collisions(f32 offsetY, f32 radius);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_update_floor](#cur_obj_update_floor) + +### Lua Example +`cur_obj_update_floor()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_update_floor(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_update_floor_and_resolve_wall_collisions](#cur_obj_update_floor_and_resolve_wall_collisions) + +### Lua Example +`cur_obj_update_floor_and_resolve_wall_collisions(steepSlopeDegrees)` + +### Parameters +| Field | Type | +| ----- | ---- | +| steepSlopeDegrees | integer | + +### Returns +- None + +### C Prototype +`void cur_obj_update_floor_and_resolve_wall_collisions(s16 steepSlopeDegrees);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_update_floor_and_walls](#cur_obj_update_floor_and_walls) + +### Lua Example +`cur_obj_update_floor_and_walls()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_update_floor_and_walls(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_update_floor_height](#cur_obj_update_floor_height) + +### Lua Example +`cur_obj_update_floor_height()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void cur_obj_update_floor_height(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_update_floor_height_and_get_floor](#cur_obj_update_floor_height_and_get_floor) + +### Lua Example +`local SurfaceValue = cur_obj_update_floor_height_and_get_floor()` + +### Parameters +- None + +### Returns +[Surface](structs.md#Surface) + +### C Prototype +`struct Surface *cur_obj_update_floor_height_and_get_floor(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_wait_then_blink](#cur_obj_wait_then_blink) + +### Lua Example +`local integerValue = cur_obj_wait_then_blink(timeUntilBlinking, numBlinks)` + +### Parameters +| Field | Type | +| ----- | ---- | +| timeUntilBlinking | integer | +| numBlinks | integer | + +### Returns +- integer + +### C Prototype +`s32 cur_obj_wait_then_blink(s32 timeUntilBlinking, s32 numBlinks);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_was_attacked_or_ground_pounded](#cur_obj_was_attacked_or_ground_pounded) + +### Lua Example +`local integerValue = cur_obj_was_attacked_or_ground_pounded()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_was_attacked_or_ground_pounded(void);` + +[:arrow_up_small:](#) + +
+ +## [cur_obj_within_12k_bounds](#cur_obj_within_12k_bounds) + +### Lua Example +`local integerValue = cur_obj_within_12k_bounds()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 cur_obj_within_12k_bounds(void);` + +[:arrow_up_small:](#) + +
+ +## [disable_time_stop](#disable_time_stop) + +### Lua Example +`disable_time_stop()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void disable_time_stop(void);` + +[:arrow_up_small:](#) + +
+ +## [disable_time_stop_including_mario](#disable_time_stop_including_mario) + +### Lua Example +`disable_time_stop_including_mario()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void disable_time_stop_including_mario(void);` + +[:arrow_up_small:](#) + +
+ ## [dist_between_object_and_point](#dist_between_object_and_point) ### Lua Example @@ -7425,6 +9647,42 @@
+## [enable_time_stop](#enable_time_stop) + +### Lua Example +`enable_time_stop()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void enable_time_stop(void);` + +[:arrow_up_small:](#) + +
+ +## [enable_time_stop_including_mario](#enable_time_stop_including_mario) + +### Lua Example +`enable_time_stop_including_mario()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void enable_time_stop_including_mario(void);` + +[:arrow_up_small:](#) + +
+ ## [find_unimportant_object](#find_unimportant_object) ### Lua Example @@ -7443,6 +9701,28 @@
+## [geo_offset_klepto_debug](#geo_offset_klepto_debug) + +### Lua Example +`local integerValue = geo_offset_klepto_debug(callContext, a1, sp8)` + +### Parameters +| Field | Type | +| ----- | ---- | +| callContext | integer | +| a1 | [GraphNode](structs.md#GraphNode) | +| sp8 | integer | + +### Returns +- integer + +### C Prototype +`s32 geo_offset_klepto_debug(s32 callContext, struct GraphNode *a1, UNUSED s32 sp8);` + +[:arrow_up_small:](#) + +
+ ## [get_object_list_from_behavior](#get_object_list_from_behavior) ### Lua Example @@ -7463,6 +9743,70 @@
+## [increment_velocity_toward_range](#increment_velocity_toward_range) + +### Lua Example +`local numberValue = increment_velocity_toward_range(value, center, zeroThreshold, increment)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | number | +| center | number | +| zeroThreshold | number | +| increment | number | + +### Returns +- number + +### C Prototype +`f32 increment_velocity_toward_range(f32 value, f32 center, f32 zeroThreshold, f32 increment);` + +[:arrow_up_small:](#) + +
+ +## [is_item_in_array](#is_item_in_array) + +### Lua Example +`local integerValue = is_item_in_array(item, array)` + +### Parameters +| Field | Type | +| ----- | ---- | +| item | integer | +| array | Pointer | + +### Returns +- integer + +### C Prototype +`s32 is_item_in_array(s8 item, s8 *array);` + +[:arrow_up_small:](#) + +
+ +## [is_mario_moving_fast_or_in_air](#is_mario_moving_fast_or_in_air) + +### Lua Example +`local integerValue = is_mario_moving_fast_or_in_air(speedThreshold)` + +### Parameters +| Field | Type | +| ----- | ---- | +| speedThreshold | integer | + +### Returns +- integer + +### C Prototype +`s32 is_mario_moving_fast_or_in_air(s32 speedThreshold);` + +[:arrow_up_small:](#) + +
+ ## [lateral_dist_between_objects](#lateral_dist_between_objects) ### Lua Example @@ -7484,6 +9828,89 @@
+## [mario_is_dive_sliding](#mario_is_dive_sliding) + +### Lua Example +`local integerValue = mario_is_dive_sliding(m)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | + +### Returns +- integer + +### C Prototype +`s32 mario_is_dive_sliding(struct MarioState* m);` + +[:arrow_up_small:](#) + +
+ +## [mario_is_in_air_action](#mario_is_in_air_action) + +### Lua Example +`local integerValue = mario_is_in_air_action(m)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | + +### Returns +- integer + +### C Prototype +`s32 mario_is_in_air_action(struct MarioState* m);` + +[:arrow_up_small:](#) + +
+ +## [mario_is_within_rectangle](#mario_is_within_rectangle) + +### Lua Example +`local integerValue = mario_is_within_rectangle(minX, maxX, minZ, maxZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| minX | integer | +| maxX | integer | +| minZ | integer | +| maxZ | integer | + +### Returns +- integer + +### C Prototype +`s32 mario_is_within_rectangle(s16 minX, s16 maxX, s16 minZ, s16 maxZ);` + +[:arrow_up_small:](#) + +
+ +## [mario_set_flag](#mario_set_flag) + +### Lua Example +`mario_set_flag(flag)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flag | integer | + +### Returns +- None + +### C Prototype +`void mario_set_flag(s32 flag);` + +[:arrow_up_small:](#) + +
+ ## [obj_angle_to_object](#obj_angle_to_object) ### Lua Example @@ -7547,6 +9974,149 @@
+## [obj_attack_collided_from_other_object](#obj_attack_collided_from_other_object) + +### Lua Example +`local integerValue = obj_attack_collided_from_other_object(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- integer + +### C Prototype +`s32 obj_attack_collided_from_other_object(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_become_tangible](#obj_become_tangible) + +### Lua Example +`obj_become_tangible(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_become_tangible(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_build_relative_transform](#obj_build_relative_transform) + +### Lua Example +`obj_build_relative_transform(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_build_relative_transform(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_build_transform_from_pos_and_angle](#obj_build_transform_from_pos_and_angle) + +### Lua Example +`obj_build_transform_from_pos_and_angle(obj, posIndex, angleIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| posIndex | integer | +| angleIndex | integer | + +### Returns +- None + +### C Prototype +`void obj_build_transform_from_pos_and_angle(struct Object *obj, s16 posIndex, s16 angleIndex);` + +[:arrow_up_small:](#) + +
+ +## [obj_build_transform_relative_to_parent](#obj_build_transform_relative_to_parent) + +### Lua Example +`obj_build_transform_relative_to_parent(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_build_transform_relative_to_parent(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_build_vel_from_transform](#obj_build_vel_from_transform) + +### Lua Example +`obj_build_vel_from_transform(a0)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a0 | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_build_vel_from_transform(struct Object *a0);` + +[:arrow_up_small:](#) + +
+ +## [obj_check_if_collided_with_object](#obj_check_if_collided_with_object) + +### Lua Example +`local integerValue = obj_check_if_collided_with_object(obj1, obj2)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj1 | [Object](structs.md#Object) | +| obj2 | [Object](structs.md#Object) | + +### Returns +- integer + +### C Prototype +`s32 obj_check_if_collided_with_object(struct Object *obj1, struct Object *obj2);` + +[:arrow_up_small:](#) + +
+ ## [obj_copy_angle](#obj_copy_angle) ### Lua Example @@ -7568,6 +10138,27 @@
+## [obj_copy_behavior_params](#obj_copy_behavior_params) + +### Lua Example +`obj_copy_behavior_params(dst, src)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dst | [Object](structs.md#Object) | +| src | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_copy_behavior_params(struct Object *dst, struct Object *src);` + +[:arrow_up_small:](#) + +
+ ## [obj_copy_graph_y_offset](#obj_copy_graph_y_offset) ### Lua Example @@ -7652,6 +10243,68 @@
+## [obj_create_transform_from_self](#obj_create_transform_from_self) + +### Lua Example +`obj_create_transform_from_self(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_create_transform_from_self(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_explode_and_spawn_coins](#obj_explode_and_spawn_coins) + +### Lua Example +`obj_explode_and_spawn_coins(sp18, sp1C)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp18 | number | +| sp1C | integer | + +### Returns +- None + +### C Prototype +`void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C);` + +[:arrow_up_small:](#) + +
+ +## [obj_has_behavior](#obj_has_behavior) + +### Lua Example +`local integerValue = obj_has_behavior(obj, behavior)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| behavior | Pointer | + +### Returns +- integer + +### C Prototype +`s32 obj_has_behavior(struct Object *obj, const BehaviorScript *behavior);` + +[:arrow_up_small:](#) + +
+ ## [obj_init_animation](#obj_init_animation) ### Lua Example @@ -7673,6 +10326,46 @@
+## [obj_is_hidden](#obj_is_hidden) + +### Lua Example +`local integerValue = obj_is_hidden(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- integer + +### C Prototype +`s32 obj_is_hidden(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_mark_for_deletion](#obj_mark_for_deletion) + +### Lua Example +`obj_mark_for_deletion(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_mark_for_deletion(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ ## [obj_pitch_to_object](#obj_pitch_to_object) ### Lua Example @@ -7715,6 +10408,28 @@
+## [obj_scale_random](#obj_scale_random) + +### Lua Example +`obj_scale_random(obj, rangeLength, minScale)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| rangeLength | number | +| minScale | number | + +### Returns +- None + +### C Prototype +`void obj_scale_random(struct Object *obj, f32 rangeLength, f32 minScale);` + +[:arrow_up_small:](#) + +
+ ## [obj_scale_xyz](#obj_scale_xyz) ### Lua Example @@ -7761,6 +10476,67 @@
+## [obj_set_behavior](#obj_set_behavior) + +### Lua Example +`obj_set_behavior(obj, behavior)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| behavior | Pointer | + +### Returns +- None + +### C Prototype +`void obj_set_behavior(struct Object *obj, const BehaviorScript *behavior);` + +[:arrow_up_small:](#) + +
+ +## [obj_set_billboard](#obj_set_billboard) + +### Lua Example +`obj_set_billboard(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_set_billboard(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_set_cylboard](#obj_set_cylboard) + +### Lua Example +`obj_set_cylboard(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_set_cylboard(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ ## [obj_set_face_angle_to_move_angle](#obj_set_face_angle_to_move_angle) ### Lua Example @@ -7781,6 +10557,27 @@
+## [obj_set_gfx_pos_at_obj_pos](#obj_set_gfx_pos_at_obj_pos) + +### Lua Example +`obj_set_gfx_pos_at_obj_pos(obj1, obj2)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj1 | [Object](structs.md#Object) | +| obj2 | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_set_gfx_pos_at_obj_pos(struct Object *obj1, struct Object *obj2);` + +[:arrow_up_small:](#) + +
+ ## [obj_set_gfx_pos_from_pos](#obj_set_gfx_pos_from_pos) ### Lua Example @@ -7822,6 +10619,27 @@
+## [obj_set_hitbox](#obj_set_hitbox) + +### Lua Example +`obj_set_hitbox(obj, hitbox)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| hitbox | [ObjectHitbox](structs.md#ObjectHitbox) | + +### Returns +- None + +### C Prototype +`void obj_set_hitbox(struct Object *obj, struct ObjectHitbox *hitbox);` + +[:arrow_up_small:](#) + +
+ ## [obj_set_parent_relative_pos](#obj_set_parent_relative_pos) ### Lua Example @@ -7868,6 +10686,184 @@
+## [obj_set_pos_relative](#obj_set_pos_relative) + +### Lua Example +`obj_set_pos_relative(obj, other, dleft, dy, dforward)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| other | [Object](structs.md#Object) | +| dleft | number | +| dy | number | +| dforward | number | + +### Returns +- None + +### C Prototype +`void obj_set_pos_relative(struct Object *obj, struct Object *other, f32 dleft, f32 dy, f32 dforward);` + +[:arrow_up_small:](#) + +
+ +## [obj_set_throw_matrix_from_transform](#obj_set_throw_matrix_from_transform) + +### Lua Example +`obj_set_throw_matrix_from_transform(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_set_throw_matrix_from_transform(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [obj_spawn_loot_blue_coins](#obj_spawn_loot_blue_coins) + +### Lua Example +`obj_spawn_loot_blue_coins(obj, numCoins, sp28, posJitter)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| numCoins | integer | +| sp28 | number | +| posJitter | integer | + +### Returns +- None + +### C Prototype +`void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 sp28, s16 posJitter);` + +[:arrow_up_small:](#) + +
+ +## [obj_spawn_loot_coins](#obj_spawn_loot_coins) + +### Lua Example +`obj_spawn_loot_coins(obj, numCoins, sp30, coinBehavior, posJitter, model)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| numCoins | integer | +| sp30 | number | +| coinBehavior | Pointer | +| posJitter | integer | +| model | integer | + +### Returns +- None + +### C Prototype +`void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const BehaviorScript *coinBehavior, s16 posJitter, s16 model);` + +[:arrow_up_small:](#) + +
+ +## [obj_spawn_loot_yellow_coins](#obj_spawn_loot_yellow_coins) + +### Lua Example +`obj_spawn_loot_yellow_coins(obj, numCoins, sp28)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| numCoins | integer | +| sp28 | number | + +### Returns +- None + +### C Prototype +`void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 sp28);` + +[:arrow_up_small:](#) + +
+ +## [obj_translate_local](#obj_translate_local) + +### Lua Example +`obj_translate_local(obj, posIndex, localTranslateIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| posIndex | integer | +| localTranslateIndex | integer | + +### Returns +- None + +### C Prototype +`void obj_translate_local(struct Object *obj, s16 posIndex, s16 localTranslateIndex);` + +[:arrow_up_small:](#) + +
+ +## [obj_translate_xyz_random](#obj_translate_xyz_random) + +### Lua Example +`obj_translate_xyz_random(obj, rangeLength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| rangeLength | number | + +### Returns +- None + +### C Prototype +`void obj_translate_xyz_random(struct Object *obj, f32 rangeLength);` + +[:arrow_up_small:](#) + +
+ +## [obj_translate_xz_random](#obj_translate_xz_random) + +### Lua Example +`obj_translate_xz_random(obj, rangeLength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| rangeLength | number | + +### Returns +- None + +### C Prototype +`void obj_translate_xz_random(struct Object *obj, f32 rangeLength);` + +[:arrow_up_small:](#) + +
+ ## [obj_turn_toward_object](#obj_turn_toward_object) ### Lua Example @@ -7891,6 +10887,183 @@
+## [player_performed_grab_escape_action](#player_performed_grab_escape_action) + +### Lua Example +`local integerValue = player_performed_grab_escape_action()` + +### Parameters +- None + +### Returns +- integer + +### C Prototype +`s32 player_performed_grab_escape_action(void);` + +[:arrow_up_small:](#) + +
+ +## [random_f32_around_zero](#random_f32_around_zero) + +### Lua Example +`local numberValue = random_f32_around_zero(diameter)` + +### Parameters +| Field | Type | +| ----- | ---- | +| diameter | number | + +### Returns +- number + +### C Prototype +`f32 random_f32_around_zero(f32 diameter);` + +[:arrow_up_small:](#) + +
+ +## [set_mario_interact_hoot_if_in_range](#set_mario_interact_hoot_if_in_range) + +### Lua Example +`set_mario_interact_hoot_if_in_range(sp0, sp4, sp8)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp0 | integer | +| sp4 | integer | +| sp8 | number | + +### Returns +- None + +### C Prototype +`void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8);` + +[:arrow_up_small:](#) + +
+ +## [set_time_stop_flags](#set_time_stop_flags) + +### Lua Example +`set_time_stop_flags(flags)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flags | integer | + +### Returns +- None + +### C Prototype +`void set_time_stop_flags(s32 flags);` + +[:arrow_up_small:](#) + +
+ +## [signum_positive](#signum_positive) + +### Lua Example +`local integerValue = signum_positive(x)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | integer | + +### Returns +- integer + +### C Prototype +`s32 signum_positive(s32 x);` + +[:arrow_up_small:](#) + +
+ +## [spawn_base_star_with_no_lvl_exit](#spawn_base_star_with_no_lvl_exit) + +### Lua Example +`spawn_base_star_with_no_lvl_exit()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void spawn_base_star_with_no_lvl_exit(void);` + +[:arrow_up_small:](#) + +
+ +## [spawn_mist_particles](#spawn_mist_particles) + +### Lua Example +`spawn_mist_particles()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void spawn_mist_particles(void);` + +[:arrow_up_small:](#) + +
+ +## [spawn_mist_particles_with_sound](#spawn_mist_particles_with_sound) + +### Lua Example +`spawn_mist_particles_with_sound(sp18)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp18 | integer | + +### Returns +- None + +### C Prototype +`void spawn_mist_particles_with_sound(u32 sp18);` + +[:arrow_up_small:](#) + +
+ +## [spawn_star_with_no_lvl_exit](#spawn_star_with_no_lvl_exit) + +### Lua Example +`local ObjectValue = spawn_star_with_no_lvl_exit(sp20, sp24)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp20 | integer | +| sp24 | integer | + +### Returns +[Object](structs.md#Object) + +### C Prototype +`struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24);` + +[:arrow_up_small:](#) + +
+ ## [spawn_water_droplet](#spawn_water_droplet) ### Lua Example @@ -7912,6 +11085,45 @@
+## [stub_obj_helpers_3](#stub_obj_helpers_3) + +### Lua Example +`stub_obj_helpers_3(sp0, sp4)` + +### Parameters +| Field | Type | +| ----- | ---- | +| sp0 | integer | +| sp4 | integer | + +### Returns +- None + +### C Prototype +`void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4);` + +[:arrow_up_small:](#) + +
+ +## [stub_obj_helpers_4](#stub_obj_helpers_4) + +### Lua Example +`stub_obj_helpers_4()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void stub_obj_helpers_4(void);` + +[:arrow_up_small:](#) + +
+ --- # functions from save_file.h diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 5e320c10..344e63e6 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -4,6 +4,7 @@ - [AnimInfo](#AnimInfo) - [Animation](#Animation) - [Area](#Area) +- [BullyCollisionData](#BullyCollisionData) - [Camera](#Camera) - [CameraFOVStatus](#CameraFOVStatus) - [CameraStoredInfo](#CameraStoredInfo) @@ -119,6 +120,21 @@
+## [BullyCollisionData](#BullyCollisionData) + +| Field | Type | Access | +| ----- | ---- | ------ | +| conversionRatio | number | | +| posX | number | | +| posZ | number | | +| radius | number | | +| velX | number | | +| velZ | number | | + +[:arrow_up_small:](#) + +
+ ## [Camera](#Camera) | Field | Type | Access | diff --git a/include/sm64.h b/include/sm64.h index 06159cd3..7f310ed4 100644 --- a/include/sm64.h +++ b/include/sm64.h @@ -167,7 +167,7 @@ #define ACT_FLAG_PAUSE_EXIT /* 0x08000000 */ (1 << 27) #define ACT_FLAG_SWIMMING_OR_FLYING /* 0x10000000 */ (1 << 28) #define ACT_FLAG_WATER_OR_TEXT /* 0x20000000 */ (1 << 29) -#define ACT_FLAG_THROWING /* 0x80000000 */ ((u32)1 << 31) +#define ACT_FLAG_THROWING /* 0x80000000 */ (1 << 31) #define ACT_UNINITIALIZED 0x00000000 // (0x000) diff --git a/lib/src/hardware.h b/lib/src/hardware.h index ce1444f8..14848ca8 100644 --- a/lib/src/hardware.h +++ b/lib/src/hardware.h @@ -7,7 +7,7 @@ #define AI_LEN_REG 0x04500004 #define AI_CONTROL_REG 0x04500008 #define AI_STATUS_REG 0x0450000C -#define AI_STATUS_AI_FULL ((u32)1 << 31) +#define AI_STATUS_AI_FULL (1 << 31) #define AI_STATUS_AI_BUSY (1 << 30) #define AI_DACRATE_REG 0x04500010 #define AI_BITRATE_REG 0x04500014 diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index dcb39976..5301f955 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -14,6 +14,7 @@ #include "graph_node.h" #include "surface_collision.h" #include "pc/network/network.h" +#include "pc/lua/smlua_hooks.h" #include "game/rng_position.h" // Macros for retrieving arguments from behavior scripts. @@ -1022,12 +1023,14 @@ cur_obj_update_begin:; // Execute the behavior script. gCurBhvCommand = gCurrentObject->curBhvCommand; + u8 skipBehavior = smlua_call_behavior_hook(&gCurBhvCommand, gCurrentObject); - do { - bhvCmdProc = BehaviorCmdTable[*gCurBhvCommand >> 24]; - bhvProcResult = bhvCmdProc(); - } while (bhvProcResult == BHV_PROC_CONTINUE); - + if (!skipBehavior) { + do { + bhvCmdProc = BehaviorCmdTable[*gCurBhvCommand >> 24]; + bhvProcResult = bhvCmdProc(); + } while (bhvProcResult == BHV_PROC_CONTINUE); + } gCurrentObject->curBhvCommand = gCurBhvCommand; // Increment the object's timer. diff --git a/src/game/interaction.h b/src/game/interaction.h index 5a41262a..3069adea 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -37,7 +37,7 @@ enum InteractionType { INTERACT_SNUFIT_BULLET = /* 0x10000000 */ (1 << 28), INTERACT_SHOCK = /* 0x20000000 */ (1 << 29), INTERACT_IGLOO_BARRIER = /* 0x40000000 */ (1 << 30), - INTERACT_PLAYER = /* 0x80000000 */ ((u32)1 << 31), + INTERACT_PLAYER = /* 0x80000000 */ (1 << 31), }; // INTERACT_WARP diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index ec4792e9..c5874df2 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -35,10 +35,17 @@ s8 D_8032F0A0[] = { -8, 8, -4, 4 }; s16 D_8032F0A4[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; static s8 sLevelsWithRooms[] = { LEVEL_BBH, LEVEL_CASTLE, LEVEL_HMC, -1 }; -static s32 clear_move_flag(u32 *, s32); - #define o gCurrentObject +s32 clear_move_flag(u32 *bitSet, s32 flag) { + if (*bitSet & flag) { + *bitSet &= flag ^ 0xFFFFFFFF; + return TRUE; + } else { + return FALSE; + } +} + Gfx *geo_update_projectile_pos_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx) { Mat4 sp20; struct Object *sp1C; @@ -640,7 +647,7 @@ struct Object *spawn_object_with_scale(struct Object *parent, s32 model, const B return obj; } -static void obj_build_relative_transform(struct Object *obj) { +void obj_build_relative_transform(struct Object *obj) { obj_build_transform_from_pos_and_angle(obj, O_PARENT_RELATIVE_POS_INDEX, O_FACE_ANGLE_INDEX); obj_translate_local(obj, O_POS_INDEX, O_PARENT_RELATIVE_POS_INDEX); } @@ -1056,7 +1063,7 @@ struct Object *cur_obj_find_nearby_held_actor(const BehaviorScript *behavior, f3 return foundObj; } -static void cur_obj_reset_timer_and_subaction(void) { +void cur_obj_reset_timer_and_subaction(void) { o->oTimer = 0; o->oSubAction = 0; } @@ -1185,7 +1192,7 @@ void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C) { o->oAction = sp1C; } -static void cur_obj_move_after_thrown_or_dropped(f32 forwardVel, f32 velY) { +void cur_obj_move_after_thrown_or_dropped(f32 forwardVel, f32 velY) { o->oMoveFlags = 0; o->oFloorHeight = find_floor_height(o->oPosX, o->oPosY + 160.0f, o->oPosZ); @@ -1300,7 +1307,7 @@ struct Surface *cur_obj_update_floor_height_and_get_floor(void) { return floor; } -static void apply_drag_to_value(f32 *value, f32 dragStrength) { +void apply_drag_to_value(f32 *value, f32 dragStrength) { f32 decel; if (*value != 0) { @@ -1326,7 +1333,7 @@ void cur_obj_apply_drag_xz(f32 dragStrength) { apply_drag_to_value(&o->oVelZ, dragStrength); } -static s32 cur_obj_move_xz(f32 steepSlopeNormalY, s32 careAboutEdgesAndSteepSlopes) { +s32 cur_obj_move_xz(f32 steepSlopeNormalY, s32 careAboutEdgesAndSteepSlopes) { struct Surface *intendedFloor = NULL; f32 intendedX = o->oPosX + o->oVelX; @@ -1385,7 +1392,7 @@ static s32 cur_obj_move_xz(f32 steepSlopeNormalY, s32 careAboutEdgesAndSteepSlop return FALSE; } -static void cur_obj_move_update_underwater_flags(void) { +void cur_obj_move_update_underwater_flags(void) { f32 decelY = (f32)(sqrtf(o->oVelY * o->oVelY) * (o->oDragStrength * 7.0f)) / 100.0L; if (o->oVelY > 0) { @@ -1402,7 +1409,7 @@ static void cur_obj_move_update_underwater_flags(void) { } } -static void cur_obj_move_update_ground_air_flags(UNUSED f32 gravity, f32 bounciness) { +void cur_obj_move_update_ground_air_flags(UNUSED f32 gravity, f32 bounciness) { o->oMoveFlags &= ~OBJ_MOVE_BOUNCE; if (o->oPosY < o->oFloorHeight) { @@ -1437,7 +1444,7 @@ static void cur_obj_move_update_ground_air_flags(UNUSED f32 gravity, f32 bouncin o->oMoveFlags &= ~OBJ_MOVE_MASK_IN_WATER; } -static f32 cur_obj_move_y_and_get_water_level(f32 gravity, f32 buoyancy) { +f32 cur_obj_move_y_and_get_water_level(f32 gravity, f32 buoyancy) { f32 waterLevel; o->oVelY += gravity + buoyancy; @@ -1508,15 +1515,6 @@ void cur_obj_move_y(f32 gravity, f32 bounciness, f32 buoyancy) { static void stub_obj_helpers_1(void) { } -static s32 clear_move_flag(u32 *bitSet, s32 flag) { - if (*bitSet & flag) { - *bitSet &= flag ^ 0xFFFFFFFF; - return TRUE; - } else { - return FALSE; - } -} - void cur_obj_unused_resolve_wall_collisions(f32 offsetY, f32 radius) { if (radius > 0.1L) { f32_find_wall_collision(&o->oPosX, &o->oPosY, &o->oPosZ, offsetY, radius); @@ -1730,7 +1728,7 @@ void cur_obj_set_hurtbox_radius_and_height(f32 radius, f32 height) { o->hurtboxHeight = height; } -static void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, +void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const BehaviorScript *coinBehavior, s16 posJitter, s16 model) { s32 i; @@ -1809,7 +1807,7 @@ s32 cur_obj_advance_looping_anim(void) { return result; } -static s32 cur_obj_detect_steep_floor(s16 steepAngleDegrees) { +s32 cur_obj_detect_steep_floor(s16 steepAngleDegrees) { struct Surface *intendedFloor; f32 intendedX, intendedFloorHeight, intendedZ; f32 deltaFloorHeight; @@ -1870,7 +1868,7 @@ s32 cur_obj_resolve_wall_collisions(void) { return FALSE; } -static void cur_obj_update_floor(void) { +void cur_obj_update_floor(void) { struct Surface *floor = cur_obj_update_floor_height_and_get_floor(); o->oFloor = floor; @@ -1893,7 +1891,7 @@ static void cur_obj_update_floor(void) { } } -static void cur_obj_update_floor_and_resolve_wall_collisions(s16 steepSlopeDegrees) { +void cur_obj_update_floor_and_resolve_wall_collisions(s16 steepSlopeDegrees) { #ifdef VERSION_JP o->oMoveFlags &= ~OBJ_MOVE_ABOVE_LAVA; #else @@ -1969,7 +1967,7 @@ void cur_obj_move_standard(s16 steepSlopeAngleDegrees) { } } -static s32 cur_obj_within_12k_bounds(void) { +s32 cur_obj_within_12k_bounds(void) { if (o->oPosX < -12000.0f || 12000.0f < o->oPosX) { return FALSE; } @@ -2203,7 +2201,7 @@ void obj_translate_xz_random(struct Object *obj, f32 rangeLength) { obj->oPosZ += random_float() * rangeLength - rangeLength * 0.5f; } -static void obj_build_vel_from_transform(struct Object *a0) { +void obj_build_vel_from_transform(struct Object *a0) { f32 spC = a0->oUnkC0; f32 sp8 = a0->oUnkBC; f32 sp4 = a0->oForwardVel; @@ -2500,7 +2498,7 @@ void cur_obj_call_action_function(void (*actionFunctions[])(void)) { actionFunction(); } -static struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24) { +struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24) { struct Object *sp1C = spawn_object(o, MODEL_STAR, bhvSpawnedStarNoLevelExit); if (sp1C == NULL) { return NULL; } sp1C->oSparkleSpawnUnk1B0 = sp24; @@ -2742,7 +2740,7 @@ s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 h return cur_obj_can_mario_activate_textbox(m, radius, height, 0x1000); } -static void cur_obj_end_dialog(struct MarioState* m, s32 dialogFlags, s32 dialogResult) { +void cur_obj_end_dialog(struct MarioState* m, s32 dialogFlags, s32 dialogResult) { if (m->playerIndex != 0) { return; } o->oDialogResponse = dialogResult; diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index 098d97f5..41329ab6 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -14,6 +14,7 @@ #include "types.h" #include "pc/network/network.h" #include "pc/network/reservation_area.h" +#include "pc/lua/smlua_hooks.h" /** * An unused linked list struct that seems to have been replaced by ObjectNode. @@ -334,6 +335,7 @@ struct Object *create_object(const BehaviorScript *bhvScript) { s32 objListIndex; struct Object *obj; struct ObjectNode *objList; + bhvScript = smlua_override_behavior(bhvScript); const BehaviorScript *behavior = bhvScript; // If the first behavior script command is "begin ", then diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 7e7dc029..cd4dbe80 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -9,6 +9,7 @@ #include "src/pc/network/network_player.h" #include "src/pc/djui/djui_hud_utils.h" #include "src/game/object_helpers.h" +#include "src/game/mario_step.h" #include "include/object_fields.h" @@ -63,6 +64,16 @@ static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = { // { "whirlpools", LOT_???, offsetof(struct Area, whirlpools), false, LOT_??? }, <--- UNIMPLEMENTED }; +#define LUA_BULLY_COLLISION_DATA_FIELD_COUNT 6 +static struct LuaObjectField sBullyCollisionDataFields[LUA_BULLY_COLLISION_DATA_FIELD_COUNT] = { + { "conversionRatio", LVT_F32, offsetof(struct BullyCollisionData, conversionRatio), false, LOT_NONE }, + { "posX", LVT_F32, offsetof(struct BullyCollisionData, posX), false, LOT_NONE }, + { "posZ", LVT_F32, offsetof(struct BullyCollisionData, posZ), false, LOT_NONE }, + { "radius", LVT_F32, offsetof(struct BullyCollisionData, radius), false, LOT_NONE }, + { "velX", LVT_F32, offsetof(struct BullyCollisionData, velX), false, LOT_NONE }, + { "velZ", LVT_F32, offsetof(struct BullyCollisionData, velZ), false, LOT_NONE }, +}; + #define LUA_CAMERA_FIELD_COUNT 12 static struct LuaObjectField sCameraFields[LUA_CAMERA_FIELD_COUNT] = { { "areaCenX", LVT_F32, offsetof(struct Camera, areaCenX), false, LOT_NONE }, @@ -1487,6 +1498,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_ANIMINFO, sAnimInfoFields, LUA_ANIM_INFO_FIELD_COUNT }, { LOT_ANIMATION, sAnimationFields, LUA_ANIMATION_FIELD_COUNT }, { LOT_AREA, sAreaFields, LUA_AREA_FIELD_COUNT }, + { LOT_BULLYCOLLISIONDATA, sBullyCollisionDataFields, LUA_BULLY_COLLISION_DATA_FIELD_COUNT }, { LOT_CAMERA, sCameraFields, LUA_CAMERA_FIELD_COUNT }, { LOT_CAMERAFOVSTATUS, sCameraFOVStatusFields, LUA_CAMERA_FOVSTATUS_FIELD_COUNT }, { LOT_CAMERASTOREDINFO, sCameraStoredInfoFields, LUA_CAMERA_STORED_INFO_FIELD_COUNT }, diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h index 20aa65df..9bac445e 100644 --- a/src/pc/lua/smlua_cobject_autogen.h +++ b/src/pc/lua/smlua_cobject_autogen.h @@ -8,6 +8,7 @@ enum LuaObjectAutogenType { LOT_ANIMINFO, LOT_ANIMATION, LOT_AREA, + LOT_BULLYCOLLISIONDATA, LOT_CAMERA, LOT_CAMERAFOVSTATUS, LOT_CAMERASTOREDINFO, diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index ec6387af..5a02b3f1 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1367,6 +1367,45 @@ char gSmluaConstants[] = "" "FONT_MENU = 1\n" "FONT_HUD = 2\n" "FONT_COUNT = 3\n" +"GRAPH_RENDER_ACTIVE = (1 << 0)\n" +"GRAPH_RENDER_CHILDREN_FIRST = (1 << 1)\n" +"GRAPH_RENDER_BILLBOARD = (1 << 2)\n" +"GRAPH_RENDER_Z_BUFFER = (1 << 3)\n" +"GRAPH_RENDER_INVISIBLE = (1 << 4)\n" +"GRAPH_RENDER_HAS_ANIMATION = (1 << 5)\n" +"GRAPH_RENDER_CYLBOARD = (1 << 6)\n" +"GRAPH_RENDER_PLAYER = (1 << 7)\n" +"GRAPH_NODE_TYPE_FUNCTIONAL = 0x100\n" +"GRAPH_NODE_TYPE_400 = 0x400\n" +"GRAPH_NODE_TYPE_ROOT = 0x001\n" +"GRAPH_NODE_TYPE_ORTHO_PROJECTION = 0x002\n" +"GRAPH_NODE_TYPE_PERSPECTIVE = (0x003 | GRAPH_NODE_TYPE_FUNCTIONAL)\n" +"GRAPH_NODE_TYPE_MASTER_LIST = 0x004\n" +"GRAPH_NODE_TYPE_START = 0x00A\n" +"GRAPH_NODE_TYPE_LEVEL_OF_DETAIL = 0x00B\n" +"GRAPH_NODE_TYPE_SWITCH_CASE = (0x00C | GRAPH_NODE_TYPE_FUNCTIONAL)\n" +"GRAPH_NODE_TYPE_CAMERA = (0x014 | GRAPH_NODE_TYPE_FUNCTIONAL)\n" +"GRAPH_NODE_TYPE_TRANSLATION_ROTATION = 0x015\n" +"GRAPH_NODE_TYPE_TRANSLATION = 0x016\n" +"GRAPH_NODE_TYPE_ROTATION = 0x017\n" +"GRAPH_NODE_TYPE_OBJECT = 0x018\n" +"GRAPH_NODE_TYPE_ANIMATED_PART = 0x019\n" +"GRAPH_NODE_TYPE_BILLBOARD = 0x01A\n" +"GRAPH_NODE_TYPE_DISPLAY_LIST = 0x01B\n" +"GRAPH_NODE_TYPE_SCALE = 0x01C\n" +"GRAPH_NODE_TYPE_SHADOW = 0x028\n" +"GRAPH_NODE_TYPE_OBJECT_PARENT = 0x029\n" +"GRAPH_NODE_TYPE_GENERATED_LIST = (0x02A | GRAPH_NODE_TYPE_FUNCTIONAL)\n" +"GRAPH_NODE_TYPE_BACKGROUND = (0x02C | GRAPH_NODE_TYPE_FUNCTIONAL)\n" +"GRAPH_NODE_TYPE_HELD_OBJ = (0x02E | GRAPH_NODE_TYPE_FUNCTIONAL)\n" +"GRAPH_NODE_TYPE_CULLING_RADIUS = 0x02F\n" +"GFX_NUM_MASTER_LISTS = 8\n" +"GEO_CONTEXT_CREATE = 0\n" +"GEO_CONTEXT_RENDER = 1\n" +"GEO_CONTEXT_AREA_UNLOAD = 2\n" +"GEO_CONTEXT_AREA_LOAD = 3\n" +"GEO_CONTEXT_AREA_INIT = 4\n" +"GEO_CONTEXT_HELD_OBJ = 5\n" "INT_GROUND_POUND_OR_TWIRL = (1 << 0)\n" "INT_PUNCH = (1 << 1)\n" "INT_KICK = (1 << 2)\n" @@ -1727,6 +1766,23 @@ char gSmluaConstants[] = "" "HELD_HELD = 1\n" "HELD_THROWN = 2\n" "HELD_DROPPED = 3\n" +"OBJ_MOVE_LANDED = (1 << 0)\n" +"OBJ_MOVE_ON_GROUND = (1 << 1)\n" +"OBJ_MOVE_LEFT_GROUND = (1 << 2)\n" +"OBJ_MOVE_ENTERED_WATER = (1 << 3)\n" +"OBJ_MOVE_AT_WATER_SURFACE = (1 << 4)\n" +"OBJ_MOVE_UNDERWATER_OFF_GROUND = (1 << 5)\n" +"OBJ_MOVE_UNDERWATER_ON_GROUND = (1 << 6)\n" +"OBJ_MOVE_IN_AIR = (1 << 7)\n" +"OBJ_MOVE_OUT_SCOPE = (1 << 8)\n" +"OBJ_MOVE_HIT_WALL = (1 << 9)\n" +"OBJ_MOVE_HIT_EDGE = (1 << 10)\n" +"OBJ_MOVE_ABOVE_LAVA = (1 << 11)\n" +"OBJ_MOVE_LEAVING_WATER = (1 << 12)\n" +"OBJ_MOVE_BOUNCE = (1 << 13)\n" +"OBJ_MOVE_ABOVE_DEATH_BARRIER = (1 << 14)\n" +"OBJ_MOVE_MASK_ON_GROUND = (OBJ_MOVE_LANDED | OBJ_MOVE_ON_GROUND)\n" +"OBJ_MOVE_MASK_IN_WATER = ( OBJ_MOVE_ENTERED_WATER | OBJ_MOVE_AT_WATER_SURFACE | OBJ_MOVE_UNDERWATER_OFF_GROUND | OBJ_MOVE_UNDERWATER_ON_GROUND)\n" "ACTIVE_PARTICLE_DUST = (1 << 0)\n" "ACTIVE_PARTICLE_UNUSED_1 = (1 << 1)\n" "ACTIVE_PARTICLE_UNUSED_2 = (1 << 2)\n" @@ -1747,6 +1803,28 @@ char gSmluaConstants[] = "" "ACTIVE_PARTICLE_BREATH = (1 << 17)\n" "ACTIVE_PARTICLE_V_STAR = (1 << 18)\n" "ACTIVE_PARTICLE_TRIANGLE = (1 << 19)\n" +"TIME_STOP_UNKNOWN_0 = (1 << 0)\n" +"TIME_STOP_ENABLED = (1 << 1)\n" +"TIME_STOP_DIALOG = (1 << 2)\n" +"TIME_STOP_MARIO_AND_DOORS = (1 << 3)\n" +"TIME_STOP_ALL_OBJECTS = (1 << 4)\n" +"TIME_STOP_MARIO_OPENED_DOOR = (1 << 5)\n" +"TIME_STOP_ACTIVE = (1 << 6)\n" +"OBJECT_POOL_CAPACITY = 960\n" +"OBJ_LIST_PLAYER = 0\n" +"OBJ_LIST_UNUSED_1 = 1\n" +"OBJ_LIST_DESTRUCTIVE = 2\n" +"OBJ_LIST_UNUSED_3 = 3\n" +"OBJ_LIST_GENACTOR = 4\n" +"OBJ_LIST_PUSHABLE = 5\n" +"OBJ_LIST_LEVEL = 6\n" +"OBJ_LIST_UNUSED_7 = 7\n" +"OBJ_LIST_DEFAULT = 8\n" +"OBJ_LIST_SURFACE = 9\n" +"OBJ_LIST_POLELIKE = 10\n" +"OBJ_LIST_SPAWNER = 11\n" +"OBJ_LIST_UNIMPORTANT = 12\n" +"NUM_OBJ_LISTS = 13\n" "CONT_NO_RESPONSE_ERROR = 0x8\n" "CONT_OVERRUN_ERROR = 0x4\n" "CONT_FRAME_ERROR = 0x2\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index e3178613..4b135972 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -2850,6 +2850,29 @@ int smlua_func_get_additive_y_vel_for_jumps(UNUSED lua_State* L) { return 1; } +int smlua_func_init_bully_collision_data(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 7)) { return 0; } + + struct BullyCollisionData* data = (struct BullyCollisionData*)smlua_to_cobject(L, 1, LOT_BULLYCOLLISIONDATA); + 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_bonk_reflection(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4248,6 +4271,34 @@ int smlua_func_treat_far_home_as_mario(lua_State* L) { // object_helpers.c // ////////////////////// +int smlua_func_abs_angle_diff(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s16 x0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 x1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s16 abs_angle_diff(s16 x0, s16 x1); + lua_pushinteger(L, abs_angle_diff(x0, x1)); + + return 1; +} + +int smlua_func_apply_drag_to_value(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 * value = (f32 *)smlua_to_cpointer(L, 1, LVT_F32_P); + if (!gSmLuaConvertSuccess) { return 0; } + f32 dragStrength = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void apply_drag_to_value(f32 *value, f32 dragStrength); + apply_drag_to_value(value, dragStrength); + + return 1; +} + int smlua_func_approach_f32_signed(lua_State* L) { if(!smlua_functions_valid_param_count(L, 3)) { return 0; } @@ -4296,6 +4347,76 @@ int smlua_func_approach_s16_symmetric(lua_State* L) { return 1; } +int smlua_func_bhv_dust_smoke_loop(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void bhv_dust_smoke_loop(void); + bhv_dust_smoke_loop(); + + return 1; +} + +int smlua_func_bhv_init_room(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void bhv_init_room(void); + bhv_init_room(); + + return 1; +} + +int smlua_func_bit_shift_left(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 a0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 bit_shift_left(s32 a0); + lua_pushinteger(L, bit_shift_left(a0)); + + return 1; +} + +int smlua_func_chain_segment_init(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct ChainSegment* segment = (struct ChainSegment*)smlua_to_cobject(L, 1, LOT_CHAINSEGMENT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void chain_segment_init(struct ChainSegment *segment); + chain_segment_init(segment); + + return 1; +} + +int smlua_func_clear_move_flag(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + u32 * bitSet = (u32 *)smlua_to_cpointer(L, 1, LVT_U32_P); + if (!gSmLuaConvertSuccess) { return 0; } + s32 flag = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 clear_move_flag(u32 *bitSet, s32 flag); + lua_pushinteger(L, clear_move_flag(bitSet, flag)); + + return 1; +} + +int smlua_func_clear_time_stop_flags(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 flags = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void clear_time_stop_flags(s32 flags); + clear_time_stop_flags(flags); + + return 1; +} + int smlua_func_count_objects_with_behavior(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -4336,6 +4457,112 @@ int smlua_func_create_transformation_from_matrices(lua_State* L) { } */ +int smlua_func_cur_obj_abs_y_dist_to_home(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern f32 cur_obj_abs_y_dist_to_home(void); + lua_pushnumber(L, cur_obj_abs_y_dist_to_home()); + + return 1; +} + +int smlua_func_cur_obj_advance_looping_anim(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_advance_looping_anim(void); + lua_pushinteger(L, cur_obj_advance_looping_anim()); + + return 1; +} + +int smlua_func_cur_obj_align_gfx_with_floor(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_align_gfx_with_floor(void); + cur_obj_align_gfx_with_floor(); + + return 1; +} + +int smlua_func_cur_obj_angle_to_home(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s16 cur_obj_angle_to_home(void); + lua_pushinteger(L, cur_obj_angle_to_home()); + + return 1; +} + +int smlua_func_cur_obj_apply_drag_xz(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + f32 dragStrength = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_apply_drag_xz(f32 dragStrength); + cur_obj_apply_drag_xz(dragStrength); + + return 1; +} + +int smlua_func_cur_obj_become_intangible(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_become_intangible(void); + cur_obj_become_intangible(); + + return 1; +} + +int smlua_func_cur_obj_become_tangible(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_become_tangible(void); + cur_obj_become_tangible(); + + return 1; +} + +int smlua_func_cur_obj_can_mario_activate_textbox(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + f32 radius = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 height = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s32 unused = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_can_mario_activate_textbox(struct MarioState* m, f32 radius, f32 height, UNUSED s32 unused); + lua_pushinteger(L, cur_obj_can_mario_activate_textbox(m, radius, height, unused)); + + return 1; +} + +int smlua_func_cur_obj_can_mario_activate_textbox_2(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 radius = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 height = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_can_mario_activate_textbox_2(struct MarioState* m, f32 radius, f32 height); + lua_pushinteger(L, cur_obj_can_mario_activate_textbox_2(m, radius, height)); + + return 1; +} + int smlua_func_cur_obj_change_action(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -4348,6 +4575,106 @@ int smlua_func_cur_obj_change_action(lua_State* L) { return 1; } +int smlua_func_cur_obj_check_anim_frame(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 frame = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_check_anim_frame(s32 frame); + lua_pushinteger(L, cur_obj_check_anim_frame(frame)); + + return 1; +} + +int smlua_func_cur_obj_check_anim_frame_in_range(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 startFrame = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 rangeLength = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength); + lua_pushinteger(L, cur_obj_check_anim_frame_in_range(startFrame, rangeLength)); + + return 1; +} + +int smlua_func_cur_obj_check_frame_prior_current_frame(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s16 * a0 = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_check_frame_prior_current_frame(s16 *a0); + lua_pushinteger(L, cur_obj_check_frame_prior_current_frame(a0)); + + return 1; +} + +int smlua_func_cur_obj_check_grabbed_mario(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_check_grabbed_mario(void); + lua_pushinteger(L, cur_obj_check_grabbed_mario()); + + return 1; +} + +int smlua_func_cur_obj_check_if_at_animation_end(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_check_if_at_animation_end(void); + lua_pushinteger(L, cur_obj_check_if_at_animation_end()); + + return 1; +} + +int smlua_func_cur_obj_check_if_near_animation_end(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_check_if_near_animation_end(void); + lua_pushinteger(L, cur_obj_check_if_near_animation_end()); + + return 1; +} + +int smlua_func_cur_obj_check_interacted(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_check_interacted(void); + lua_pushinteger(L, cur_obj_check_interacted()); + + return 1; +} + +int smlua_func_cur_obj_clear_interact_status_flag(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 flag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_clear_interact_status_flag(s32 flag); + lua_pushinteger(L, cur_obj_clear_interact_status_flag(flag)); + + return 1; +} + +int smlua_func_cur_obj_compute_vel_xz(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_compute_vel_xz(void); + cur_obj_compute_vel_xz(); + + return 1; +} + int smlua_func_cur_obj_count_objects_with_behavior(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4362,6 +4689,28 @@ int smlua_func_cur_obj_count_objects_with_behavior(lua_State* L) { return 1; } +int smlua_func_cur_obj_detect_steep_floor(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s16 steepAngleDegrees = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_detect_steep_floor(s16 steepAngleDegrees); + lua_pushinteger(L, cur_obj_detect_steep_floor(steepAngleDegrees)); + + return 1; +} + +int smlua_func_cur_obj_disable(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_disable(void); + cur_obj_disable(); + + return 1; +} + int smlua_func_cur_obj_disable_rendering(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -4428,6 +4777,42 @@ int smlua_func_cur_obj_enable_rendering_and_become_tangible(lua_State* L) { return 1; } +int smlua_func_cur_obj_enable_rendering_if_mario_in_room(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_enable_rendering_if_mario_in_room(void); + cur_obj_enable_rendering_if_mario_in_room(); + + return 1; +} + +int smlua_func_cur_obj_end_dialog(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; } + s32 dialogFlags = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 dialogResult = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_end_dialog(struct MarioState* m, s32 dialogFlags, s32 dialogResult); + cur_obj_end_dialog(m, dialogFlags, dialogResult); + + return 1; +} + +int smlua_func_cur_obj_extend_animation_if_at_end(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_extend_animation_if_at_end(void); + cur_obj_extend_animation_if_at_end(); + + return 1; +} + int smlua_func_cur_obj_find_nearby_held_actor(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4466,6 +4851,18 @@ int smlua_func_cur_obj_find_nearest_pole(UNUSED lua_State* L) { return 1; } +int smlua_func_cur_obj_follow_path(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 unusedArg = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_follow_path(UNUSED s32 unusedArg); + lua_pushinteger(L, cur_obj_follow_path(unusedArg)); + + return 1; +} + int smlua_func_cur_obj_forward_vel_approach_upward(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4480,6 +4877,56 @@ int smlua_func_cur_obj_forward_vel_approach_upward(lua_State* L) { return 1; } +int smlua_func_cur_obj_get_dropped(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_get_dropped(void); + cur_obj_get_dropped(); + + return 1; +} + +int smlua_func_cur_obj_get_thrown_or_placed(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 forwardVel = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 velY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 thrownAction = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_get_thrown_or_placed(f32 forwardVel, f32 velY, s32 thrownAction); + cur_obj_get_thrown_or_placed(forwardVel, velY, thrownAction); + + return 1; +} + +int smlua_func_cur_obj_has_behavior(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + const BehaviorScript* behavior = (const BehaviorScript*)smlua_to_cpointer(L, 1, LVT_BEHAVIORSCRIPT_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_has_behavior(const BehaviorScript *behavior); + lua_pushinteger(L, cur_obj_has_behavior(behavior)); + + return 1; +} + +int smlua_func_cur_obj_has_model(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + u16 modelID = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_has_model(u16 modelID); + lua_pushinteger(L, cur_obj_has_model(modelID)); + + return 1; +} + int smlua_func_cur_obj_hide(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -4490,6 +4937,28 @@ int smlua_func_cur_obj_hide(UNUSED lua_State* L) { return 1; } +int smlua_func_cur_obj_hide_if_mario_far_away_y(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + f32 distY = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_hide_if_mario_far_away_y(f32 distY); + lua_pushinteger(L, cur_obj_hide_if_mario_far_away_y(distY)); + + return 1; +} + +int smlua_func_cur_obj_if_hit_wall_bounce_away(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_if_hit_wall_bounce_away(void); + cur_obj_if_hit_wall_bounce_away(); + + return 1; +} + int smlua_func_cur_obj_init_animation(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -4502,6 +4971,44 @@ int smlua_func_cur_obj_init_animation(lua_State* L) { return 1; } +int smlua_func_cur_obj_init_animation_and_anim_frame(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 animIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animFrame = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_init_animation_and_anim_frame(s32 animIndex, s32 animFrame); + cur_obj_init_animation_and_anim_frame(animIndex, animFrame); + + return 1; +} + +int smlua_func_cur_obj_init_animation_and_check_if_near_end(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 animIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_init_animation_and_check_if_near_end(s32 animIndex); + lua_pushinteger(L, cur_obj_init_animation_and_check_if_near_end(animIndex)); + + return 1; +} + +int smlua_func_cur_obj_init_animation_and_extend_if_at_end(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 animIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_init_animation_and_extend_if_at_end(s32 animIndex); + cur_obj_init_animation_and_extend_if_at_end(animIndex); + + return 1; +} + int smlua_func_cur_obj_init_animation_with_accel_and_sound(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4528,6 +5035,150 @@ int smlua_func_cur_obj_init_animation_with_sound(lua_State* L) { return 1; } +int smlua_func_cur_obj_is_any_player_on_platform(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_is_any_player_on_platform(void); + lua_pushinteger(L, cur_obj_is_any_player_on_platform()); + + return 1; +} + +int smlua_func_cur_obj_is_mario_ground_pounding_platform(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_is_mario_ground_pounding_platform(void); + lua_pushinteger(L, cur_obj_is_mario_ground_pounding_platform()); + + return 1; +} + +int smlua_func_cur_obj_is_mario_on_platform(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_is_mario_on_platform(void); + lua_pushinteger(L, cur_obj_is_mario_on_platform()); + + return 1; +} + +int smlua_func_cur_obj_lateral_dist_from_mario_to_home(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern f32 cur_obj_lateral_dist_from_mario_to_home(void); + lua_pushnumber(L, cur_obj_lateral_dist_from_mario_to_home()); + + return 1; +} + +int smlua_func_cur_obj_lateral_dist_from_obj_to_home(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern f32 cur_obj_lateral_dist_from_obj_to_home(struct Object *obj); + lua_pushnumber(L, cur_obj_lateral_dist_from_obj_to_home(obj)); + + return 1; +} + +int smlua_func_cur_obj_lateral_dist_to_home(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern f32 cur_obj_lateral_dist_to_home(void); + lua_pushnumber(L, cur_obj_lateral_dist_to_home()); + + return 1; +} + +int smlua_func_cur_obj_mario_far_away(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_mario_far_away(void); + lua_pushinteger(L, cur_obj_mario_far_away()); + + return 1; +} + +int smlua_func_cur_obj_move_after_thrown_or_dropped(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 forwardVel = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 velY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_move_after_thrown_or_dropped(f32 forwardVel, f32 velY); + cur_obj_move_after_thrown_or_dropped(forwardVel, velY); + + return 1; +} + +int smlua_func_cur_obj_move_standard(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s16 steepSlopeAngleDegrees = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_move_standard(s16 steepSlopeAngleDegrees); + cur_obj_move_standard(steepSlopeAngleDegrees); + + return 1; +} + +int smlua_func_cur_obj_move_up_and_down(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 a0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_move_up_and_down(s32 a0); + lua_pushinteger(L, cur_obj_move_up_and_down(a0)); + + return 1; +} + +int smlua_func_cur_obj_move_update_ground_air_flags(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 gravity = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 bounciness = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_move_update_ground_air_flags(UNUSED f32 gravity, f32 bounciness); + cur_obj_move_update_ground_air_flags(gravity, bounciness); + + return 1; +} + +int smlua_func_cur_obj_move_update_underwater_flags(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_move_update_underwater_flags(void); + cur_obj_move_update_underwater_flags(); + + return 1; +} + +int smlua_func_cur_obj_move_using_fvel_and_gravity(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_move_using_fvel_and_gravity(void); + cur_obj_move_using_fvel_and_gravity(); + + return 1; +} + int smlua_func_cur_obj_move_using_vel(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -4538,6 +5189,80 @@ int smlua_func_cur_obj_move_using_vel(UNUSED lua_State* L) { return 1; } +int smlua_func_cur_obj_move_using_vel_and_gravity(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_move_using_vel_and_gravity(void); + cur_obj_move_using_vel_and_gravity(); + + return 1; +} + +int smlua_func_cur_obj_move_xz(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 steepSlopeNormalY = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 careAboutEdgesAndSteepSlopes = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_move_xz(f32 steepSlopeNormalY, s32 careAboutEdgesAndSteepSlopes); + lua_pushinteger(L, cur_obj_move_xz(steepSlopeNormalY, careAboutEdgesAndSteepSlopes)); + + return 1; +} + +int smlua_func_cur_obj_move_xz_using_fvel_and_yaw(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_move_xz_using_fvel_and_yaw(void); + cur_obj_move_xz_using_fvel_and_yaw(); + + return 1; +} + +int smlua_func_cur_obj_move_y(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + f32 gravity = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 bounciness = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 buoyancy = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_move_y(f32 gravity, f32 bounciness, f32 buoyancy); + cur_obj_move_y(gravity, bounciness, buoyancy); + + return 1; +} + +int smlua_func_cur_obj_move_y_and_get_water_level(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 gravity = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 buoyancy = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern f32 cur_obj_move_y_and_get_water_level(f32 gravity, f32 buoyancy); + lua_pushnumber(L, cur_obj_move_y_and_get_water_level(gravity, buoyancy)); + + return 1; +} + +int smlua_func_cur_obj_move_y_with_terminal_vel(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_move_y_with_terminal_vel(void); + cur_obj_move_y_with_terminal_vel(); + + return 1; +} + int smlua_func_cur_obj_nearest_object_with_behavior(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -4550,6 +5275,132 @@ int smlua_func_cur_obj_nearest_object_with_behavior(lua_State* L) { return 1; } +int smlua_func_cur_obj_outside_home_rectangle(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + f32 minX = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 maxX = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 minZ = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 maxZ = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_outside_home_rectangle(f32 minX, f32 maxX, f32 minZ, f32 maxZ); + lua_pushinteger(L, cur_obj_outside_home_rectangle(minX, maxX, minZ, maxZ)); + + return 1; +} + +int smlua_func_cur_obj_outside_home_square(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + f32 halfLength = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_outside_home_square(f32 halfLength); + lua_pushinteger(L, cur_obj_outside_home_square(halfLength)); + + return 1; +} + +int smlua_func_cur_obj_progress_direction_table(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_progress_direction_table(void); + lua_pushinteger(L, cur_obj_progress_direction_table()); + + return 1; +} + +int smlua_func_cur_obj_push_mario_away(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + f32 radius = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_push_mario_away(f32 radius); + cur_obj_push_mario_away(radius); + + return 1; +} + +int smlua_func_cur_obj_push_mario_away_from_cylinder(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 radius = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 extentY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_push_mario_away_from_cylinder(f32 radius, f32 extentY); + cur_obj_push_mario_away_from_cylinder(radius, extentY); + + return 1; +} + +int smlua_func_cur_obj_reflect_move_angle_off_wall(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s16 cur_obj_reflect_move_angle_off_wall(void); + lua_pushinteger(L, cur_obj_reflect_move_angle_off_wall()); + + return 1; +} + +int smlua_func_cur_obj_reset_timer_and_subaction(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_reset_timer_and_subaction(void); + cur_obj_reset_timer_and_subaction(); + + return 1; +} + +int smlua_func_cur_obj_resolve_wall_collisions(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_resolve_wall_collisions(void); + lua_pushinteger(L, cur_obj_resolve_wall_collisions()); + + return 1; +} + +int smlua_func_cur_obj_reverse_animation(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_reverse_animation(void); + cur_obj_reverse_animation(); + + return 1; +} + +int smlua_func_cur_obj_rotate_face_angle_using_vel(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_rotate_face_angle_using_vel(void); + cur_obj_rotate_face_angle_using_vel(); + + return 1; +} + +int smlua_func_cur_obj_rotate_move_angle_using_vel(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_rotate_move_angle_using_vel(void); + cur_obj_rotate_move_angle_using_vel(); + + return 1; +} + int smlua_func_cur_obj_rotate_yaw_toward(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4576,6 +5427,114 @@ int smlua_func_cur_obj_scale(lua_State* L) { return 1; } +int smlua_func_cur_obj_scale_over_time(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + s32 a0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 a1 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 sp10 = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 sp14 = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14); + cur_obj_scale_over_time(a0, a1, sp10, sp14); + + return 1; +} + +int smlua_func_cur_obj_set_behavior(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + const BehaviorScript* behavior = (const BehaviorScript*)smlua_to_cpointer(L, 1, LVT_BEHAVIORSCRIPT_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_set_behavior(const BehaviorScript *behavior); + cur_obj_set_behavior(behavior); + + return 1; +} + +int smlua_func_cur_obj_set_direction_table(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s8 * a0 = (s8 *)smlua_to_cpointer(L, 1, LVT_S8_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_set_direction_table(s8 *a0); + lua_pushinteger(L, cur_obj_set_direction_table(a0)); + + return 1; +} + +int smlua_func_cur_obj_set_face_angle_to_move_angle(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_set_face_angle_to_move_angle(void); + cur_obj_set_face_angle_to_move_angle(); + + return 1; +} + +int smlua_func_cur_obj_set_hitbox_and_die_if_attacked(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct ObjectHitbox* hitbox = (struct ObjectHitbox*)smlua_to_cobject(L, 1, LOT_OBJECTHITBOX); + if (!gSmLuaConvertSuccess) { return 0; } + s32 deathSound = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 noLootCoins = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_set_hitbox_and_die_if_attacked(struct ObjectHitbox *hitbox, s32 deathSound, s32 noLootCoins); + lua_pushinteger(L, cur_obj_set_hitbox_and_die_if_attacked(hitbox, deathSound, noLootCoins)); + + return 1; +} + +int smlua_func_cur_obj_set_hitbox_radius_and_height(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 radius = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 height = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_set_hitbox_radius_and_height(f32 radius, f32 height); + cur_obj_set_hitbox_radius_and_height(radius, height); + + return 1; +} + +int smlua_func_cur_obj_set_hurtbox_radius_and_height(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 radius = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 height = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_set_hurtbox_radius_and_height(f32 radius, f32 height); + cur_obj_set_hurtbox_radius_and_height(radius, height); + + return 1; +} + +int smlua_func_cur_obj_set_model(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 modelID = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_set_model(s32 modelID); + cur_obj_set_model(modelID); + + return 1; +} + int smlua_func_cur_obj_set_pos_relative(lua_State* L) { if(!smlua_functions_valid_param_count(L, 4)) { return 0; } @@ -4610,6 +5569,46 @@ int smlua_func_cur_obj_set_pos_relative_to_parent(lua_State* L) { return 1; } +int smlua_func_cur_obj_set_pos_to_home(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_set_pos_to_home(void); + cur_obj_set_pos_to_home(); + + return 1; +} + +int smlua_func_cur_obj_set_pos_to_home_and_stop(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_set_pos_to_home_and_stop(void); + cur_obj_set_pos_to_home_and_stop(); + + return 1; +} + +int smlua_func_cur_obj_set_pos_to_home_with_debug(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_set_pos_to_home_with_debug(void); + cur_obj_set_pos_to_home_with_debug(); + + return 1; +} + +int smlua_func_cur_obj_set_pos_via_transform(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_set_pos_via_transform(void); + cur_obj_set_pos_via_transform(); + + return 1; +} + int smlua_func_cur_obj_set_vel_from_mario_vel(lua_State* L) { if(!smlua_functions_valid_param_count(L, 3)) { return 0; } @@ -4626,6 +5625,124 @@ int smlua_func_cur_obj_set_vel_from_mario_vel(lua_State* L) { return 1; } +int smlua_func_cur_obj_set_y_vel_and_animation(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 sp18 = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp1C = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C); + cur_obj_set_y_vel_and_animation(sp18, sp1C); + + return 1; +} + +int smlua_func_cur_obj_shake_screen(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 shake = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_shake_screen(s32 shake); + cur_obj_shake_screen(shake); + + return 1; +} + +int smlua_func_cur_obj_shake_y(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + f32 amount = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_shake_y(f32 amount); + cur_obj_shake_y(amount); + + return 1; +} + +int smlua_func_cur_obj_shake_y_until(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 cycles = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 amount = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_shake_y_until(s32 cycles, s32 amount); + lua_pushinteger(L, cur_obj_shake_y_until(cycles, amount)); + + return 1; +} + +int smlua_func_cur_obj_spawn_loot_blue_coin(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_spawn_loot_blue_coin(void); + cur_obj_spawn_loot_blue_coin(); + + return 1; +} + +int smlua_func_cur_obj_spawn_loot_coin_at_mario_pos(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_spawn_loot_coin_at_mario_pos(struct MarioState* m); + cur_obj_spawn_loot_coin_at_mario_pos(m); + + return 1; +} + +int smlua_func_cur_obj_spawn_particles(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct SpawnParticlesInfo* info = (struct SpawnParticlesInfo*)smlua_to_cobject(L, 1, LOT_SPAWNPARTICLESINFO); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_spawn_particles(struct SpawnParticlesInfo *info); + cur_obj_spawn_particles(info); + + return 1; +} + +int smlua_func_cur_obj_spawn_star_at_y_offset(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + f32 targetX = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 targetY = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 targetZ = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 offsetY = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY); + cur_obj_spawn_star_at_y_offset(targetX, targetY, targetZ, offsetY); + + return 1; +} + +int smlua_func_cur_obj_start_cam_event(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s32 cameraEvent = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_start_cam_event(UNUSED struct Object *obj, s32 cameraEvent); + cur_obj_start_cam_event(obj, cameraEvent); + + return 1; +} + int smlua_func_cur_obj_unhide(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -4636,6 +5753,20 @@ int smlua_func_cur_obj_unhide(UNUSED lua_State* L) { return 1; } +int smlua_func_cur_obj_unrender_and_reset_state(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 sp18 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp1C = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C); + cur_obj_unrender_and_reset_state(sp18, sp1C); + + return 1; +} + int smlua_func_cur_obj_unused_init_on_floor(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -4646,6 +5777,142 @@ int smlua_func_cur_obj_unused_init_on_floor(UNUSED lua_State* L) { return 1; } +int smlua_func_cur_obj_unused_play_footstep_sound(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 animFrame1 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 animFrame2 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sound = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_unused_play_footstep_sound(s32 animFrame1, s32 animFrame2, s32 sound); + cur_obj_unused_play_footstep_sound(animFrame1, animFrame2, sound); + + return 1; +} + +int smlua_func_cur_obj_unused_resolve_wall_collisions(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 offsetY = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 radius = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_unused_resolve_wall_collisions(f32 offsetY, f32 radius); + cur_obj_unused_resolve_wall_collisions(offsetY, radius); + + return 1; +} + +int smlua_func_cur_obj_update_floor(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_update_floor(void); + cur_obj_update_floor(); + + return 1; +} + +int smlua_func_cur_obj_update_floor_and_resolve_wall_collisions(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s16 steepSlopeDegrees = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void cur_obj_update_floor_and_resolve_wall_collisions(s16 steepSlopeDegrees); + cur_obj_update_floor_and_resolve_wall_collisions(steepSlopeDegrees); + + return 1; +} + +int smlua_func_cur_obj_update_floor_and_walls(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_update_floor_and_walls(void); + cur_obj_update_floor_and_walls(); + + return 1; +} + +int smlua_func_cur_obj_update_floor_height(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void cur_obj_update_floor_height(void); + cur_obj_update_floor_height(); + + return 1; +} + +int smlua_func_cur_obj_update_floor_height_and_get_floor(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern struct Surface *cur_obj_update_floor_height_and_get_floor(void); + smlua_push_object(L, LOT_SURFACE, cur_obj_update_floor_height_and_get_floor()); + + return 1; +} + +int smlua_func_cur_obj_wait_then_blink(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 timeUntilBlinking = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 numBlinks = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 cur_obj_wait_then_blink(s32 timeUntilBlinking, s32 numBlinks); + lua_pushinteger(L, cur_obj_wait_then_blink(timeUntilBlinking, numBlinks)); + + return 1; +} + +int smlua_func_cur_obj_was_attacked_or_ground_pounded(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_was_attacked_or_ground_pounded(void); + lua_pushinteger(L, cur_obj_was_attacked_or_ground_pounded()); + + return 1; +} + +int smlua_func_cur_obj_within_12k_bounds(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 cur_obj_within_12k_bounds(void); + lua_pushinteger(L, cur_obj_within_12k_bounds()); + + return 1; +} + +int smlua_func_disable_time_stop(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void disable_time_stop(void); + disable_time_stop(); + + return 1; +} + +int smlua_func_disable_time_stop_including_mario(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void disable_time_stop_including_mario(void); + disable_time_stop_including_mario(); + + return 1; +} + int smlua_func_dist_between_object_and_point(lua_State* L) { if(!smlua_functions_valid_param_count(L, 4)) { return 0; } @@ -4678,6 +5945,26 @@ int smlua_func_dist_between_objects(lua_State* L) { return 1; } +int smlua_func_enable_time_stop(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void enable_time_stop(void); + enable_time_stop(); + + return 1; +} + +int smlua_func_enable_time_stop_including_mario(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void enable_time_stop_including_mario(void); + enable_time_stop_including_mario(); + + return 1; +} + int smlua_func_find_unimportant_object(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -4688,6 +5975,40 @@ int smlua_func_find_unimportant_object(UNUSED lua_State* L) { return 1; } +int smlua_func_geo_offset_klepto_debug(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 callContext = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct GraphNode* a1 = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp8 = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 geo_offset_klepto_debug(s32 callContext, struct GraphNode *a1, UNUSED s32 sp8); + lua_pushinteger(L, geo_offset_klepto_debug(callContext, a1, sp8)); + + return 1; +} + +/* +int smlua_func_geo_offset_klepto_held_object(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 callContext = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); + if (!gSmLuaConvertSuccess) { return 0; } +// Mat4 mtx = (Mat4)smlua_to_cobject(L, 3, LOT_???); <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + extern Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); + UNIMPLEMENTED -->(L, geo_offset_klepto_held_object(callContext, node, mtx)); + + return 1; +} +*/ + /* int smlua_func_geo_switch_anim_state(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4768,6 +6089,50 @@ int smlua_func_get_object_list_from_behavior(lua_State* L) { return 1; } +int smlua_func_increment_velocity_toward_range(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + f32 value = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + f32 center = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 zeroThreshold = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 increment = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern f32 increment_velocity_toward_range(f32 value, f32 center, f32 zeroThreshold, f32 increment); + lua_pushnumber(L, increment_velocity_toward_range(value, center, zeroThreshold, increment)); + + return 1; +} + +int smlua_func_is_item_in_array(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s8 item = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s8 * array = (s8 *)smlua_to_cpointer(L, 2, LVT_S8_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 is_item_in_array(s8 item, s8 *array); + lua_pushinteger(L, is_item_in_array(item, array)); + + return 1; +} + +int smlua_func_is_mario_moving_fast_or_in_air(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 speedThreshold = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 is_mario_moving_fast_or_in_air(s32 speedThreshold); + lua_pushinteger(L, is_mario_moving_fast_or_in_air(speedThreshold)); + + return 1; +} + int smlua_func_lateral_dist_between_objects(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4858,6 +6223,60 @@ int smlua_func_linear_mtxf_transpose_mul_vec3f(lua_State* L) { } */ +int smlua_func_mario_is_dive_sliding(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_is_dive_sliding(struct MarioState* m); + lua_pushinteger(L, mario_is_dive_sliding(m)); + + return 1; +} + +int smlua_func_mario_is_in_air_action(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_is_in_air_action(struct MarioState* m); + lua_pushinteger(L, mario_is_in_air_action(m)); + + return 1; +} + +int smlua_func_mario_is_within_rectangle(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + s16 minX = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s16 maxX = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 minZ = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 maxZ = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 mario_is_within_rectangle(s16 minX, s16 maxX, s16 minZ, s16 maxZ); + lua_pushinteger(L, mario_is_within_rectangle(minX, maxX, minZ, maxZ)); + + return 1; +} + +int smlua_func_mario_set_flag(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 flag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void mario_set_flag(s32 flag); + mario_set_flag(flag); + + return 1; +} + int smlua_func_obj_angle_to_object(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4918,6 +6337,96 @@ int smlua_func_obj_apply_scale_to_transform(lua_State* L) { return 1; } +int smlua_func_obj_attack_collided_from_other_object(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 obj_attack_collided_from_other_object(struct Object *obj); + lua_pushinteger(L, obj_attack_collided_from_other_object(obj)); + + return 1; +} + +int smlua_func_obj_become_tangible(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_become_tangible(struct Object *obj); + obj_become_tangible(obj); + + return 1; +} + +int smlua_func_obj_build_relative_transform(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_build_relative_transform(struct Object *obj); + obj_build_relative_transform(obj); + + return 1; +} + +int smlua_func_obj_build_transform_from_pos_and_angle(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s16 posIndex = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 angleIndex = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_build_transform_from_pos_and_angle(struct Object *obj, s16 posIndex, s16 angleIndex); + obj_build_transform_from_pos_and_angle(obj, posIndex, angleIndex); + + return 1; +} + +int smlua_func_obj_build_transform_relative_to_parent(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_build_transform_relative_to_parent(struct Object *obj); + obj_build_transform_relative_to_parent(obj); + + return 1; +} + +int smlua_func_obj_build_vel_from_transform(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* a0 = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_build_vel_from_transform(struct Object *a0); + obj_build_vel_from_transform(a0); + + return 1; +} + +int smlua_func_obj_check_if_collided_with_object(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj1 = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* obj2 = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 obj_check_if_collided_with_object(struct Object *obj1, struct Object *obj2); + lua_pushinteger(L, obj_check_if_collided_with_object(obj1, obj2)); + + return 1; +} + int smlua_func_obj_copy_angle(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4932,6 +6441,20 @@ int smlua_func_obj_copy_angle(lua_State* L) { return 1; } +int smlua_func_obj_copy_behavior_params(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* dst = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* src = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_copy_behavior_params(struct Object *dst, struct Object *src); + obj_copy_behavior_params(dst, src); + + return 1; +} + int smlua_func_obj_copy_graph_y_offset(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -4988,6 +6511,46 @@ int smlua_func_obj_copy_scale(lua_State* L) { return 1; } +int smlua_func_obj_create_transform_from_self(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_create_transform_from_self(struct Object *obj); + obj_create_transform_from_self(obj); + + return 1; +} + +int smlua_func_obj_explode_and_spawn_coins(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + f32 sp18 = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp1C = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C); + obj_explode_and_spawn_coins(sp18, sp1C); + + return 1; +} + +int smlua_func_obj_has_behavior(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + const BehaviorScript* behavior = (const BehaviorScript*)smlua_to_cpointer(L, 2, LVT_BEHAVIORSCRIPT_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 obj_has_behavior(struct Object *obj, const BehaviorScript *behavior); + lua_pushinteger(L, obj_has_behavior(obj, behavior)); + + return 1; +} + int smlua_func_obj_init_animation(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -5020,6 +6583,30 @@ int smlua_func_obj_init_animation_with_sound(lua_State* L) { } */ +int smlua_func_obj_is_hidden(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 obj_is_hidden(struct Object *obj); + lua_pushinteger(L, obj_is_hidden(obj)); + + return 1; +} + +int smlua_func_obj_mark_for_deletion(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_mark_for_deletion(struct Object *obj); + obj_mark_for_deletion(obj); + + return 1; +} + int smlua_func_obj_pitch_to_object(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -5048,6 +6635,22 @@ int smlua_func_obj_scale(lua_State* L) { return 1; } +int smlua_func_obj_scale_random(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + f32 rangeLength = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 minScale = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_scale_random(struct Object *obj, f32 rangeLength, f32 minScale); + obj_scale_random(obj, rangeLength, minScale); + + return 1; +} + int smlua_func_obj_scale_xyz(lua_State* L) { if(!smlua_functions_valid_param_count(L, 4)) { return 0; } @@ -5084,6 +6687,60 @@ int smlua_func_obj_set_angle(lua_State* L) { return 1; } +int smlua_func_obj_set_behavior(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + const BehaviorScript* behavior = (const BehaviorScript*)smlua_to_cpointer(L, 2, LVT_BEHAVIORSCRIPT_P); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_behavior(struct Object *obj, const BehaviorScript *behavior); + obj_set_behavior(obj, behavior); + + return 1; +} + +int smlua_func_obj_set_billboard(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_billboard(struct Object *obj); + obj_set_billboard(obj); + + return 1; +} + +/* +int smlua_func_obj_set_collision_data(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } +// const void* segAddr = (const void*)smlua_to_cobject(L, 2, LOT_???); <--- UNIMPLEMENTED + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_collision_data(struct Object *obj, const void *segAddr); + obj_set_collision_data(obj, segAddr); + + return 1; +} +*/ + +int smlua_func_obj_set_cylboard(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_cylboard(struct Object *obj); + obj_set_cylboard(obj); + + return 1; +} + int smlua_func_obj_set_face_angle_to_move_angle(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -5096,6 +6753,20 @@ int smlua_func_obj_set_face_angle_to_move_angle(lua_State* L) { return 1; } +int smlua_func_obj_set_gfx_pos_at_obj_pos(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj1 = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* obj2 = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_gfx_pos_at_obj_pos(struct Object *obj1, struct Object *obj2); + obj_set_gfx_pos_at_obj_pos(obj1, obj2); + + return 1; +} + int smlua_func_obj_set_gfx_pos_from_pos(lua_State* L) { if(!smlua_functions_valid_param_count(L, 1)) { return 0; } @@ -5122,6 +6793,20 @@ int smlua_func_obj_set_held_state(lua_State* L) { return 1; } +int smlua_func_obj_set_hitbox(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + struct ObjectHitbox* hitbox = (struct ObjectHitbox*)smlua_to_cobject(L, 2, LOT_OBJECTHITBOX); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_hitbox(struct Object *obj, struct ObjectHitbox *hitbox); + obj_set_hitbox(obj, hitbox); + + return 1; +} + int smlua_func_obj_set_parent_relative_pos(lua_State* L) { if(!smlua_functions_valid_param_count(L, 4)) { return 0; } @@ -5158,6 +6843,138 @@ int smlua_func_obj_set_pos(lua_State* L) { return 1; } +int smlua_func_obj_set_pos_relative(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 5)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* other = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + f32 dleft = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + f32 dy = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + f32 dforward = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_pos_relative(struct Object *obj, struct Object *other, f32 dleft, f32 dy, f32 dforward); + obj_set_pos_relative(obj, other, dleft, dy, dforward); + + return 1; +} + +int smlua_func_obj_set_throw_matrix_from_transform(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_set_throw_matrix_from_transform(struct Object *obj); + obj_set_throw_matrix_from_transform(obj); + + return 1; +} + +int smlua_func_obj_spawn_loot_blue_coins(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 4)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s32 numCoins = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 sp28 = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + s16 posJitter = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 sp28, s16 posJitter); + obj_spawn_loot_blue_coins(obj, numCoins, sp28, posJitter); + + return 1; +} + +int smlua_func_obj_spawn_loot_coins(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 6)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s32 numCoins = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 sp30 = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + const BehaviorScript* coinBehavior = (const BehaviorScript*)smlua_to_cpointer(L, 4, LVT_BEHAVIORSCRIPT_P); + if (!gSmLuaConvertSuccess) { return 0; } + s16 posJitter = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { return 0; } + s16 model = smlua_to_integer(L, 6); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_spawn_loot_coins(struct Object *obj, s32 numCoins, f32 sp30, const BehaviorScript *coinBehavior, s16 posJitter, s16 model); + obj_spawn_loot_coins(obj, numCoins, sp30, coinBehavior, posJitter, model); + + return 1; +} + +int smlua_func_obj_spawn_loot_yellow_coins(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s32 numCoins = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 sp28 = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 sp28); + obj_spawn_loot_yellow_coins(obj, numCoins, sp28); + + return 1; +} + +int smlua_func_obj_translate_local(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + s16 posIndex = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + s16 localTranslateIndex = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_translate_local(struct Object *obj, s16 posIndex, s16 localTranslateIndex); + obj_translate_local(obj, posIndex, localTranslateIndex); + + return 1; +} + +int smlua_func_obj_translate_xyz_random(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + f32 rangeLength = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_translate_xyz_random(struct Object *obj, f32 rangeLength); + obj_translate_xyz_random(obj, rangeLength); + + return 1; +} + +int smlua_func_obj_translate_xz_random(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + f32 rangeLength = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void obj_translate_xz_random(struct Object *obj, f32 rangeLength); + obj_translate_xz_random(obj, rangeLength); + + return 1; +} + int smlua_func_obj_turn_toward_object(lua_State* L) { if(!smlua_functions_valid_param_count(L, 4)) { return 0; } @@ -5192,6 +7009,114 @@ int smlua_func_obj_update_pos_from_parent_transformation(lua_State* L) { } */ +int smlua_func_player_performed_grab_escape_action(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern s32 player_performed_grab_escape_action(void); + lua_pushinteger(L, player_performed_grab_escape_action()); + + return 1; +} + +int smlua_func_random_f32_around_zero(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + f32 diameter = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern f32 random_f32_around_zero(f32 diameter); + lua_pushnumber(L, random_f32_around_zero(diameter)); + + return 1; +} + +int smlua_func_set_mario_interact_hoot_if_in_range(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 sp0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp4 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + f32 sp8 = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8); + set_mario_interact_hoot_if_in_range(sp0, sp4, sp8); + + return 1; +} + +int smlua_func_set_time_stop_flags(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 flags = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void set_time_stop_flags(s32 flags); + set_time_stop_flags(flags); + + return 1; +} + +int smlua_func_signum_positive(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + s32 x = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern s32 signum_positive(s32 x); + lua_pushinteger(L, signum_positive(x)); + + return 1; +} + +int smlua_func_spawn_base_star_with_no_lvl_exit(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void spawn_base_star_with_no_lvl_exit(void); + spawn_base_star_with_no_lvl_exit(); + + return 1; +} + +int smlua_func_spawn_mist_particles(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void spawn_mist_particles(void); + spawn_mist_particles(); + + return 1; +} + +int smlua_func_spawn_mist_particles_with_sound(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + u32 sp18 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void spawn_mist_particles_with_sound(u32 sp18); + spawn_mist_particles_with_sound(sp18); + + return 1; +} + +int smlua_func_spawn_star_with_no_lvl_exit(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 sp20 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp24 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24); + smlua_push_object(L, LOT_OBJECT, spawn_star_with_no_lvl_exit(sp20, sp24)); + + return 1; +} + int smlua_func_spawn_water_droplet(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -5206,6 +7131,30 @@ int smlua_func_spawn_water_droplet(lua_State* L) { return 1; } +int smlua_func_stub_obj_helpers_3(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + s32 sp0 = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { return 0; } + s32 sp4 = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + + extern void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4); + stub_obj_helpers_3(sp0, sp4); + + return 1; +} + +int smlua_func_stub_obj_helpers_4(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + extern void stub_obj_helpers_4(void); + stub_obj_helpers_4(); + + return 1; +} + ///////////////// // save_file.h // ///////////////// @@ -6075,6 +8024,7 @@ void smlua_bind_functions_autogen(void) { // mario_step.h smlua_bind_function(L, "get_additive_y_vel_for_jumps", smlua_func_get_additive_y_vel_for_jumps); + smlua_bind_function(L, "init_bully_collision_data", smlua_func_init_bully_collision_data); smlua_bind_function(L, "mario_bonk_reflection", smlua_func_mario_bonk_reflection); 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); @@ -6182,71 +8132,226 @@ void smlua_bind_functions_autogen(void) { //smlua_bind_function(L, "treat_far_home_as_mario", smlua_func_treat_far_home_as_mario); <--- UNIMPLEMENTED // object_helpers.c + smlua_bind_function(L, "abs_angle_diff", smlua_func_abs_angle_diff); + smlua_bind_function(L, "apply_drag_to_value", smlua_func_apply_drag_to_value); smlua_bind_function(L, "approach_f32_signed", smlua_func_approach_f32_signed); smlua_bind_function(L, "approach_f32_symmetric", smlua_func_approach_f32_symmetric); smlua_bind_function(L, "approach_s16_symmetric", smlua_func_approach_s16_symmetric); + smlua_bind_function(L, "bhv_dust_smoke_loop", smlua_func_bhv_dust_smoke_loop); + smlua_bind_function(L, "bhv_init_room", smlua_func_bhv_init_room); + smlua_bind_function(L, "bit_shift_left", smlua_func_bit_shift_left); + smlua_bind_function(L, "chain_segment_init", smlua_func_chain_segment_init); + smlua_bind_function(L, "clear_move_flag", smlua_func_clear_move_flag); + smlua_bind_function(L, "clear_time_stop_flags", smlua_func_clear_time_stop_flags); smlua_bind_function(L, "count_objects_with_behavior", smlua_func_count_objects_with_behavior); smlua_bind_function(L, "count_unimportant_objects", smlua_func_count_unimportant_objects); //smlua_bind_function(L, "create_transformation_from_matrices", smlua_func_create_transformation_from_matrices); <--- UNIMPLEMENTED + smlua_bind_function(L, "cur_obj_abs_y_dist_to_home", smlua_func_cur_obj_abs_y_dist_to_home); + smlua_bind_function(L, "cur_obj_advance_looping_anim", smlua_func_cur_obj_advance_looping_anim); + smlua_bind_function(L, "cur_obj_align_gfx_with_floor", smlua_func_cur_obj_align_gfx_with_floor); + smlua_bind_function(L, "cur_obj_angle_to_home", smlua_func_cur_obj_angle_to_home); + smlua_bind_function(L, "cur_obj_apply_drag_xz", smlua_func_cur_obj_apply_drag_xz); + smlua_bind_function(L, "cur_obj_become_intangible", smlua_func_cur_obj_become_intangible); + smlua_bind_function(L, "cur_obj_become_tangible", smlua_func_cur_obj_become_tangible); + smlua_bind_function(L, "cur_obj_can_mario_activate_textbox", smlua_func_cur_obj_can_mario_activate_textbox); + smlua_bind_function(L, "cur_obj_can_mario_activate_textbox_2", smlua_func_cur_obj_can_mario_activate_textbox_2); smlua_bind_function(L, "cur_obj_change_action", smlua_func_cur_obj_change_action); + smlua_bind_function(L, "cur_obj_check_anim_frame", smlua_func_cur_obj_check_anim_frame); + smlua_bind_function(L, "cur_obj_check_anim_frame_in_range", smlua_func_cur_obj_check_anim_frame_in_range); + smlua_bind_function(L, "cur_obj_check_frame_prior_current_frame", smlua_func_cur_obj_check_frame_prior_current_frame); + smlua_bind_function(L, "cur_obj_check_grabbed_mario", smlua_func_cur_obj_check_grabbed_mario); + smlua_bind_function(L, "cur_obj_check_if_at_animation_end", smlua_func_cur_obj_check_if_at_animation_end); + smlua_bind_function(L, "cur_obj_check_if_near_animation_end", smlua_func_cur_obj_check_if_near_animation_end); + smlua_bind_function(L, "cur_obj_check_interacted", smlua_func_cur_obj_check_interacted); + smlua_bind_function(L, "cur_obj_clear_interact_status_flag", smlua_func_cur_obj_clear_interact_status_flag); + smlua_bind_function(L, "cur_obj_compute_vel_xz", smlua_func_cur_obj_compute_vel_xz); smlua_bind_function(L, "cur_obj_count_objects_with_behavior", smlua_func_cur_obj_count_objects_with_behavior); + smlua_bind_function(L, "cur_obj_detect_steep_floor", smlua_func_cur_obj_detect_steep_floor); + smlua_bind_function(L, "cur_obj_disable", smlua_func_cur_obj_disable); smlua_bind_function(L, "cur_obj_disable_rendering", smlua_func_cur_obj_disable_rendering); smlua_bind_function(L, "cur_obj_disable_rendering_and_become_intangible", smlua_func_cur_obj_disable_rendering_and_become_intangible); smlua_bind_function(L, "cur_obj_dist_to_nearest_object_with_behavior", smlua_func_cur_obj_dist_to_nearest_object_with_behavior); smlua_bind_function(L, "cur_obj_enable_rendering", smlua_func_cur_obj_enable_rendering); smlua_bind_function(L, "cur_obj_enable_rendering_2", smlua_func_cur_obj_enable_rendering_2); smlua_bind_function(L, "cur_obj_enable_rendering_and_become_tangible", smlua_func_cur_obj_enable_rendering_and_become_tangible); + smlua_bind_function(L, "cur_obj_enable_rendering_if_mario_in_room", smlua_func_cur_obj_enable_rendering_if_mario_in_room); + smlua_bind_function(L, "cur_obj_end_dialog", smlua_func_cur_obj_end_dialog); + smlua_bind_function(L, "cur_obj_extend_animation_if_at_end", smlua_func_cur_obj_extend_animation_if_at_end); smlua_bind_function(L, "cur_obj_find_nearby_held_actor", smlua_func_cur_obj_find_nearby_held_actor); smlua_bind_function(L, "cur_obj_find_nearest_object_with_behavior", smlua_func_cur_obj_find_nearest_object_with_behavior); smlua_bind_function(L, "cur_obj_find_nearest_pole", smlua_func_cur_obj_find_nearest_pole); + smlua_bind_function(L, "cur_obj_follow_path", smlua_func_cur_obj_follow_path); smlua_bind_function(L, "cur_obj_forward_vel_approach_upward", smlua_func_cur_obj_forward_vel_approach_upward); + smlua_bind_function(L, "cur_obj_get_dropped", smlua_func_cur_obj_get_dropped); + smlua_bind_function(L, "cur_obj_get_thrown_or_placed", smlua_func_cur_obj_get_thrown_or_placed); + smlua_bind_function(L, "cur_obj_has_behavior", smlua_func_cur_obj_has_behavior); + smlua_bind_function(L, "cur_obj_has_model", smlua_func_cur_obj_has_model); smlua_bind_function(L, "cur_obj_hide", smlua_func_cur_obj_hide); + smlua_bind_function(L, "cur_obj_hide_if_mario_far_away_y", smlua_func_cur_obj_hide_if_mario_far_away_y); + smlua_bind_function(L, "cur_obj_if_hit_wall_bounce_away", smlua_func_cur_obj_if_hit_wall_bounce_away); smlua_bind_function(L, "cur_obj_init_animation", smlua_func_cur_obj_init_animation); + smlua_bind_function(L, "cur_obj_init_animation_and_anim_frame", smlua_func_cur_obj_init_animation_and_anim_frame); + smlua_bind_function(L, "cur_obj_init_animation_and_check_if_near_end", smlua_func_cur_obj_init_animation_and_check_if_near_end); + smlua_bind_function(L, "cur_obj_init_animation_and_extend_if_at_end", smlua_func_cur_obj_init_animation_and_extend_if_at_end); smlua_bind_function(L, "cur_obj_init_animation_with_accel_and_sound", smlua_func_cur_obj_init_animation_with_accel_and_sound); smlua_bind_function(L, "cur_obj_init_animation_with_sound", smlua_func_cur_obj_init_animation_with_sound); + smlua_bind_function(L, "cur_obj_is_any_player_on_platform", smlua_func_cur_obj_is_any_player_on_platform); + smlua_bind_function(L, "cur_obj_is_mario_ground_pounding_platform", smlua_func_cur_obj_is_mario_ground_pounding_platform); + smlua_bind_function(L, "cur_obj_is_mario_on_platform", smlua_func_cur_obj_is_mario_on_platform); + smlua_bind_function(L, "cur_obj_lateral_dist_from_mario_to_home", smlua_func_cur_obj_lateral_dist_from_mario_to_home); + smlua_bind_function(L, "cur_obj_lateral_dist_from_obj_to_home", smlua_func_cur_obj_lateral_dist_from_obj_to_home); + smlua_bind_function(L, "cur_obj_lateral_dist_to_home", smlua_func_cur_obj_lateral_dist_to_home); + smlua_bind_function(L, "cur_obj_mario_far_away", smlua_func_cur_obj_mario_far_away); + smlua_bind_function(L, "cur_obj_move_after_thrown_or_dropped", smlua_func_cur_obj_move_after_thrown_or_dropped); + smlua_bind_function(L, "cur_obj_move_standard", smlua_func_cur_obj_move_standard); + smlua_bind_function(L, "cur_obj_move_up_and_down", smlua_func_cur_obj_move_up_and_down); + smlua_bind_function(L, "cur_obj_move_update_ground_air_flags", smlua_func_cur_obj_move_update_ground_air_flags); + smlua_bind_function(L, "cur_obj_move_update_underwater_flags", smlua_func_cur_obj_move_update_underwater_flags); + smlua_bind_function(L, "cur_obj_move_using_fvel_and_gravity", smlua_func_cur_obj_move_using_fvel_and_gravity); smlua_bind_function(L, "cur_obj_move_using_vel", smlua_func_cur_obj_move_using_vel); + smlua_bind_function(L, "cur_obj_move_using_vel_and_gravity", smlua_func_cur_obj_move_using_vel_and_gravity); + smlua_bind_function(L, "cur_obj_move_xz", smlua_func_cur_obj_move_xz); + smlua_bind_function(L, "cur_obj_move_xz_using_fvel_and_yaw", smlua_func_cur_obj_move_xz_using_fvel_and_yaw); + smlua_bind_function(L, "cur_obj_move_y", smlua_func_cur_obj_move_y); + smlua_bind_function(L, "cur_obj_move_y_and_get_water_level", smlua_func_cur_obj_move_y_and_get_water_level); + smlua_bind_function(L, "cur_obj_move_y_with_terminal_vel", smlua_func_cur_obj_move_y_with_terminal_vel); smlua_bind_function(L, "cur_obj_nearest_object_with_behavior", smlua_func_cur_obj_nearest_object_with_behavior); + smlua_bind_function(L, "cur_obj_outside_home_rectangle", smlua_func_cur_obj_outside_home_rectangle); + smlua_bind_function(L, "cur_obj_outside_home_square", smlua_func_cur_obj_outside_home_square); + smlua_bind_function(L, "cur_obj_progress_direction_table", smlua_func_cur_obj_progress_direction_table); + smlua_bind_function(L, "cur_obj_push_mario_away", smlua_func_cur_obj_push_mario_away); + smlua_bind_function(L, "cur_obj_push_mario_away_from_cylinder", smlua_func_cur_obj_push_mario_away_from_cylinder); + smlua_bind_function(L, "cur_obj_reflect_move_angle_off_wall", smlua_func_cur_obj_reflect_move_angle_off_wall); + smlua_bind_function(L, "cur_obj_reset_timer_and_subaction", smlua_func_cur_obj_reset_timer_and_subaction); + smlua_bind_function(L, "cur_obj_resolve_wall_collisions", smlua_func_cur_obj_resolve_wall_collisions); + smlua_bind_function(L, "cur_obj_reverse_animation", smlua_func_cur_obj_reverse_animation); + smlua_bind_function(L, "cur_obj_rotate_face_angle_using_vel", smlua_func_cur_obj_rotate_face_angle_using_vel); + smlua_bind_function(L, "cur_obj_rotate_move_angle_using_vel", smlua_func_cur_obj_rotate_move_angle_using_vel); smlua_bind_function(L, "cur_obj_rotate_yaw_toward", smlua_func_cur_obj_rotate_yaw_toward); smlua_bind_function(L, "cur_obj_scale", smlua_func_cur_obj_scale); + smlua_bind_function(L, "cur_obj_scale_over_time", smlua_func_cur_obj_scale_over_time); + smlua_bind_function(L, "cur_obj_set_behavior", smlua_func_cur_obj_set_behavior); + smlua_bind_function(L, "cur_obj_set_direction_table", smlua_func_cur_obj_set_direction_table); + smlua_bind_function(L, "cur_obj_set_face_angle_to_move_angle", smlua_func_cur_obj_set_face_angle_to_move_angle); + smlua_bind_function(L, "cur_obj_set_hitbox_and_die_if_attacked", smlua_func_cur_obj_set_hitbox_and_die_if_attacked); + smlua_bind_function(L, "cur_obj_set_hitbox_radius_and_height", smlua_func_cur_obj_set_hitbox_radius_and_height); + smlua_bind_function(L, "cur_obj_set_hurtbox_radius_and_height", smlua_func_cur_obj_set_hurtbox_radius_and_height); + smlua_bind_function(L, "cur_obj_set_model", smlua_func_cur_obj_set_model); smlua_bind_function(L, "cur_obj_set_pos_relative", smlua_func_cur_obj_set_pos_relative); smlua_bind_function(L, "cur_obj_set_pos_relative_to_parent", smlua_func_cur_obj_set_pos_relative_to_parent); + smlua_bind_function(L, "cur_obj_set_pos_to_home", smlua_func_cur_obj_set_pos_to_home); + smlua_bind_function(L, "cur_obj_set_pos_to_home_and_stop", smlua_func_cur_obj_set_pos_to_home_and_stop); + smlua_bind_function(L, "cur_obj_set_pos_to_home_with_debug", smlua_func_cur_obj_set_pos_to_home_with_debug); + smlua_bind_function(L, "cur_obj_set_pos_via_transform", smlua_func_cur_obj_set_pos_via_transform); smlua_bind_function(L, "cur_obj_set_vel_from_mario_vel", smlua_func_cur_obj_set_vel_from_mario_vel); + smlua_bind_function(L, "cur_obj_set_y_vel_and_animation", smlua_func_cur_obj_set_y_vel_and_animation); + smlua_bind_function(L, "cur_obj_shake_screen", smlua_func_cur_obj_shake_screen); + smlua_bind_function(L, "cur_obj_shake_y", smlua_func_cur_obj_shake_y); + smlua_bind_function(L, "cur_obj_shake_y_until", smlua_func_cur_obj_shake_y_until); + smlua_bind_function(L, "cur_obj_spawn_loot_blue_coin", smlua_func_cur_obj_spawn_loot_blue_coin); + smlua_bind_function(L, "cur_obj_spawn_loot_coin_at_mario_pos", smlua_func_cur_obj_spawn_loot_coin_at_mario_pos); + smlua_bind_function(L, "cur_obj_spawn_particles", smlua_func_cur_obj_spawn_particles); + smlua_bind_function(L, "cur_obj_spawn_star_at_y_offset", smlua_func_cur_obj_spawn_star_at_y_offset); + smlua_bind_function(L, "cur_obj_start_cam_event", smlua_func_cur_obj_start_cam_event); smlua_bind_function(L, "cur_obj_unhide", smlua_func_cur_obj_unhide); + smlua_bind_function(L, "cur_obj_unrender_and_reset_state", smlua_func_cur_obj_unrender_and_reset_state); smlua_bind_function(L, "cur_obj_unused_init_on_floor", smlua_func_cur_obj_unused_init_on_floor); + smlua_bind_function(L, "cur_obj_unused_play_footstep_sound", smlua_func_cur_obj_unused_play_footstep_sound); + smlua_bind_function(L, "cur_obj_unused_resolve_wall_collisions", smlua_func_cur_obj_unused_resolve_wall_collisions); + smlua_bind_function(L, "cur_obj_update_floor", smlua_func_cur_obj_update_floor); + smlua_bind_function(L, "cur_obj_update_floor_and_resolve_wall_collisions", smlua_func_cur_obj_update_floor_and_resolve_wall_collisions); + smlua_bind_function(L, "cur_obj_update_floor_and_walls", smlua_func_cur_obj_update_floor_and_walls); + smlua_bind_function(L, "cur_obj_update_floor_height", smlua_func_cur_obj_update_floor_height); + smlua_bind_function(L, "cur_obj_update_floor_height_and_get_floor", smlua_func_cur_obj_update_floor_height_and_get_floor); + smlua_bind_function(L, "cur_obj_wait_then_blink", smlua_func_cur_obj_wait_then_blink); + smlua_bind_function(L, "cur_obj_was_attacked_or_ground_pounded", smlua_func_cur_obj_was_attacked_or_ground_pounded); + smlua_bind_function(L, "cur_obj_within_12k_bounds", smlua_func_cur_obj_within_12k_bounds); + smlua_bind_function(L, "disable_time_stop", smlua_func_disable_time_stop); + smlua_bind_function(L, "disable_time_stop_including_mario", smlua_func_disable_time_stop_including_mario); smlua_bind_function(L, "dist_between_object_and_point", smlua_func_dist_between_object_and_point); smlua_bind_function(L, "dist_between_objects", smlua_func_dist_between_objects); + smlua_bind_function(L, "enable_time_stop", smlua_func_enable_time_stop); + smlua_bind_function(L, "enable_time_stop_including_mario", smlua_func_enable_time_stop_including_mario); smlua_bind_function(L, "find_unimportant_object", smlua_func_find_unimportant_object); + smlua_bind_function(L, "geo_offset_klepto_debug", smlua_func_geo_offset_klepto_debug); + //smlua_bind_function(L, "geo_offset_klepto_held_object", smlua_func_geo_offset_klepto_held_object); <--- UNIMPLEMENTED //smlua_bind_function(L, "geo_switch_anim_state", smlua_func_geo_switch_anim_state); <--- UNIMPLEMENTED //smlua_bind_function(L, "geo_switch_area", smlua_func_geo_switch_area); <--- UNIMPLEMENTED //smlua_bind_function(L, "geo_update_layer_transparency", smlua_func_geo_update_layer_transparency); <--- UNIMPLEMENTED //smlua_bind_function(L, "geo_update_projectile_pos_from_parent", smlua_func_geo_update_projectile_pos_from_parent); <--- UNIMPLEMENTED smlua_bind_function(L, "get_object_list_from_behavior", smlua_func_get_object_list_from_behavior); + smlua_bind_function(L, "increment_velocity_toward_range", smlua_func_increment_velocity_toward_range); + smlua_bind_function(L, "is_item_in_array", smlua_func_is_item_in_array); + smlua_bind_function(L, "is_mario_moving_fast_or_in_air", smlua_func_is_mario_moving_fast_or_in_air); smlua_bind_function(L, "lateral_dist_between_objects", smlua_func_lateral_dist_between_objects); //smlua_bind_function(L, "linear_mtxf_mul_vec3f", smlua_func_linear_mtxf_mul_vec3f); <--- UNIMPLEMENTED //smlua_bind_function(L, "linear_mtxf_transpose_mul_vec3f", smlua_func_linear_mtxf_transpose_mul_vec3f); <--- UNIMPLEMENTED + smlua_bind_function(L, "mario_is_dive_sliding", smlua_func_mario_is_dive_sliding); + smlua_bind_function(L, "mario_is_in_air_action", smlua_func_mario_is_in_air_action); + smlua_bind_function(L, "mario_is_within_rectangle", smlua_func_mario_is_within_rectangle); + smlua_bind_function(L, "mario_set_flag", smlua_func_mario_set_flag); smlua_bind_function(L, "obj_angle_to_object", smlua_func_obj_angle_to_object); smlua_bind_function(L, "obj_angle_to_point", smlua_func_obj_angle_to_point); //smlua_bind_function(L, "obj_apply_scale_to_matrix", smlua_func_obj_apply_scale_to_matrix); <--- UNIMPLEMENTED smlua_bind_function(L, "obj_apply_scale_to_transform", smlua_func_obj_apply_scale_to_transform); + smlua_bind_function(L, "obj_attack_collided_from_other_object", smlua_func_obj_attack_collided_from_other_object); + smlua_bind_function(L, "obj_become_tangible", smlua_func_obj_become_tangible); + smlua_bind_function(L, "obj_build_relative_transform", smlua_func_obj_build_relative_transform); + smlua_bind_function(L, "obj_build_transform_from_pos_and_angle", smlua_func_obj_build_transform_from_pos_and_angle); + smlua_bind_function(L, "obj_build_transform_relative_to_parent", smlua_func_obj_build_transform_relative_to_parent); + smlua_bind_function(L, "obj_build_vel_from_transform", smlua_func_obj_build_vel_from_transform); + smlua_bind_function(L, "obj_check_if_collided_with_object", smlua_func_obj_check_if_collided_with_object); smlua_bind_function(L, "obj_copy_angle", smlua_func_obj_copy_angle); + smlua_bind_function(L, "obj_copy_behavior_params", smlua_func_obj_copy_behavior_params); smlua_bind_function(L, "obj_copy_graph_y_offset", smlua_func_obj_copy_graph_y_offset); smlua_bind_function(L, "obj_copy_pos", smlua_func_obj_copy_pos); smlua_bind_function(L, "obj_copy_pos_and_angle", smlua_func_obj_copy_pos_and_angle); smlua_bind_function(L, "obj_copy_scale", smlua_func_obj_copy_scale); + smlua_bind_function(L, "obj_create_transform_from_self", smlua_func_obj_create_transform_from_self); + smlua_bind_function(L, "obj_explode_and_spawn_coins", smlua_func_obj_explode_and_spawn_coins); + smlua_bind_function(L, "obj_has_behavior", smlua_func_obj_has_behavior); smlua_bind_function(L, "obj_init_animation", smlua_func_obj_init_animation); //smlua_bind_function(L, "obj_init_animation_with_sound", smlua_func_obj_init_animation_with_sound); <--- UNIMPLEMENTED + smlua_bind_function(L, "obj_is_hidden", smlua_func_obj_is_hidden); + smlua_bind_function(L, "obj_mark_for_deletion", smlua_func_obj_mark_for_deletion); smlua_bind_function(L, "obj_pitch_to_object", smlua_func_obj_pitch_to_object); smlua_bind_function(L, "obj_scale", smlua_func_obj_scale); + smlua_bind_function(L, "obj_scale_random", smlua_func_obj_scale_random); smlua_bind_function(L, "obj_scale_xyz", smlua_func_obj_scale_xyz); smlua_bind_function(L, "obj_set_angle", smlua_func_obj_set_angle); + smlua_bind_function(L, "obj_set_behavior", smlua_func_obj_set_behavior); + smlua_bind_function(L, "obj_set_billboard", smlua_func_obj_set_billboard); + //smlua_bind_function(L, "obj_set_collision_data", smlua_func_obj_set_collision_data); <--- UNIMPLEMENTED + smlua_bind_function(L, "obj_set_cylboard", smlua_func_obj_set_cylboard); smlua_bind_function(L, "obj_set_face_angle_to_move_angle", smlua_func_obj_set_face_angle_to_move_angle); + smlua_bind_function(L, "obj_set_gfx_pos_at_obj_pos", smlua_func_obj_set_gfx_pos_at_obj_pos); smlua_bind_function(L, "obj_set_gfx_pos_from_pos", smlua_func_obj_set_gfx_pos_from_pos); smlua_bind_function(L, "obj_set_held_state", smlua_func_obj_set_held_state); + smlua_bind_function(L, "obj_set_hitbox", smlua_func_obj_set_hitbox); smlua_bind_function(L, "obj_set_parent_relative_pos", smlua_func_obj_set_parent_relative_pos); smlua_bind_function(L, "obj_set_pos", smlua_func_obj_set_pos); + smlua_bind_function(L, "obj_set_pos_relative", smlua_func_obj_set_pos_relative); + smlua_bind_function(L, "obj_set_throw_matrix_from_transform", smlua_func_obj_set_throw_matrix_from_transform); + smlua_bind_function(L, "obj_spawn_loot_blue_coins", smlua_func_obj_spawn_loot_blue_coins); + smlua_bind_function(L, "obj_spawn_loot_coins", smlua_func_obj_spawn_loot_coins); + smlua_bind_function(L, "obj_spawn_loot_yellow_coins", smlua_func_obj_spawn_loot_yellow_coins); + smlua_bind_function(L, "obj_translate_local", smlua_func_obj_translate_local); + smlua_bind_function(L, "obj_translate_xyz_random", smlua_func_obj_translate_xyz_random); + smlua_bind_function(L, "obj_translate_xz_random", smlua_func_obj_translate_xz_random); smlua_bind_function(L, "obj_turn_toward_object", smlua_func_obj_turn_toward_object); //smlua_bind_function(L, "obj_update_pos_from_parent_transformation", smlua_func_obj_update_pos_from_parent_transformation); <--- UNIMPLEMENTED + smlua_bind_function(L, "player_performed_grab_escape_action", smlua_func_player_performed_grab_escape_action); + smlua_bind_function(L, "random_f32_around_zero", smlua_func_random_f32_around_zero); + smlua_bind_function(L, "set_mario_interact_hoot_if_in_range", smlua_func_set_mario_interact_hoot_if_in_range); + smlua_bind_function(L, "set_time_stop_flags", smlua_func_set_time_stop_flags); + smlua_bind_function(L, "signum_positive", smlua_func_signum_positive); + smlua_bind_function(L, "spawn_base_star_with_no_lvl_exit", smlua_func_spawn_base_star_with_no_lvl_exit); + smlua_bind_function(L, "spawn_mist_particles", smlua_func_spawn_mist_particles); + smlua_bind_function(L, "spawn_mist_particles_with_sound", smlua_func_spawn_mist_particles_with_sound); + smlua_bind_function(L, "spawn_star_with_no_lvl_exit", smlua_func_spawn_star_with_no_lvl_exit); smlua_bind_function(L, "spawn_water_droplet", smlua_func_spawn_water_droplet); + smlua_bind_function(L, "stub_obj_helpers_3", smlua_func_stub_obj_helpers_3); + smlua_bind_function(L, "stub_obj_helpers_4", smlua_func_stub_obj_helpers_4); // save_file.h smlua_bind_function(L, "save_file_get_cap_pos", smlua_func_save_file_get_cap_pos); diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index d2ef4df0..534426da 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -1,7 +1,9 @@ #include "smlua.h" +#include "src/game/object_list_processor.h" #include "pc/djui/djui_chat_message.h" #define MAX_HOOKED_REFERENCES 64 +#define LUA_BEHAVIOR_FLAG (1 << 15) struct LuaHookedEvent { int reference[MAX_HOOKED_REFERENCES]; @@ -177,7 +179,7 @@ struct LuaHookedMarioAction { int reference; }; -#define MAX_HOOKED_ACTIONS 64 +#define MAX_HOOKED_ACTIONS 128 static struct LuaHookedMarioAction sHookedMarioActions[MAX_HOOKED_ACTIONS] = { 0 }; static int sHookedMarioActionsCount = 0; @@ -275,6 +277,148 @@ u32 smlua_get_action_interaction_type(struct MarioState* m) { return interactionType; } + ////////////////////// + // hooked behaviors // +////////////////////// + +struct LuaHookedBehavior { + u32 behaviorId; + BehaviorScript behavior[2]; + int initReference; + int loopReference; +}; + +#define MAX_HOOKED_BEHAVIORS 256 + +static struct LuaHookedBehavior sHookedBehaviors[MAX_HOOKED_BEHAVIORS] = { 0 }; +static int sHookedBehaviorsCount = 0; + +const BehaviorScript* smlua_override_behavior(const BehaviorScript* behavior) { + enum BehaviorId id = get_id_from_behavior(behavior); + const BehaviorScript* luaBehavior = get_lua_behavior_from_id(id); + if (luaBehavior != NULL) { return luaBehavior; } + return behavior; +} + +const BehaviorScript* get_lua_behavior_from_id(enum BehaviorId id) { + lua_State* L = gLuaState; + if (L == NULL) { return false; } + for (int i = 0; i < sHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + if (hooked->behaviorId != id) { continue; } + return hooked->behavior; + } + return NULL; +} + +int smlua_hook_behavior(lua_State* L) { + if (L == NULL) { return 0; } + if (!smlua_functions_valid_param_count(L, 4)) { return 0; } + + if (sHookedBehaviorsCount >= MAX_HOOKED_BEHAVIORS) { + LOG_LUA("Hooked behaviors exceeded maximum references!"); + smlua_logline(); + return 0; + } + + lua_Integer overrideBehaviorId = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { + LOG_LUA("Hook behavior: tried to override invalid behavior: %lld, %u", overrideBehaviorId, gSmLuaConvertSuccess); + smlua_logline(); + return 0; + } + + lua_Integer objectList = smlua_to_integer(L, 2); + if (objectList <= 0 || objectList >= NUM_OBJ_LISTS || !gSmLuaConvertSuccess) { + LOG_LUA("Hook behavior: tried use invalid object list: %lld, %u", objectList, gSmLuaConvertSuccess); + smlua_logline(); + return 0; + } + + int initReference = 0; + int initReferenceType = lua_type(L, 3); + if (initReferenceType == LUA_TNIL) { + // nothing + } else if (initReferenceType == LUA_TFUNCTION) { + // get reference + lua_pushvalue(L, 3); + initReference = luaL_ref(L, LUA_REGISTRYINDEX); + } else { + LOG_LUA("Hook behavior: tried to reference non-function for init"); + smlua_logline(); + return 0; + } + + int loopReference = 0; + int loopReferenceType = lua_type(L, 4); + if (loopReferenceType == LUA_TNIL) { + // nothing + } else if (loopReferenceType == LUA_TFUNCTION) { + // get reference + lua_pushvalue(L, 4); + loopReference = luaL_ref(L, LUA_REGISTRYINDEX); + } else { + LOG_LUA("Hook behavior: tried to reference non-function for loop"); + smlua_logline(); + return 0; + } + + struct LuaHookedBehavior* hooked = &sHookedBehaviors[sHookedBehaviorsCount]; + u16 customBehaviorId = (sHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG; + hooked->behaviorId = overrideBehaviorId != 0 ? overrideBehaviorId : customBehaviorId; + hooked->behavior[0] = (((unsigned int) (((unsigned int)(0x00) & ((0x01 << (8)) - 1)) << (24))) | ((unsigned int) (((unsigned int)(objectList) & ((0x01 << (8)) - 1)) << (16)))); // gross. this is BEGIN(objectList) + hooked->behavior[1] = (((unsigned int) (((unsigned int)(0x39) & ((0x01 << (8)) - 1)) << (24))) | ((unsigned int) (((unsigned int)(customBehaviorId) & ((0x01 << (16)) - 1)) << (0)))); // gross. this is ID(customBehaviorId) + hooked->initReference = initReference; + hooked->loopReference = loopReference; + + sHookedBehaviorsCount++; + + // return behavior ID + lua_pushinteger(L, customBehaviorId); + + return 1; +} + +bool smlua_call_behavior_hook(const BehaviorScript** behavior, struct Object* object) { + lua_State* L = gLuaState; + if (L == NULL) { return false; } + for (int i = 0; i < sHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + + // find behavior + if (object->behavior != hooked->behavior) { + continue; + } + + // retrieve and remember first run + bool firstRun = (*behavior == hooked->behavior); + if (firstRun) { *behavior = &hooked->behavior[1]; } + + // get function and null check it + int reference = firstRun ? hooked->initReference : hooked->loopReference; + if (reference == 0) { + return true; + } + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, reference); + + // push object + smlua_push_object(L, LOT_OBJECT, object); + + // call the callback + if (0 != lua_pcall(L, 1, 0, 0)) { + LOG_LUA("Failed to call the behavior callback: %u, %s", hooked->behaviorId, lua_tostring(L, -1)); + smlua_logline(); + return true; + } + + return true; + } + + return false; +} + ///////////////////////// // hooked chat command // ///////////////////////// @@ -473,6 +617,16 @@ static void smlua_clear_hooks(void) { sHookedChatCommands[i].reference = 0; } sHookedChatCommandsCount = 0; + + for (int i = 0; i < sHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + hooked->behaviorId = 0; + hooked->behavior[0] = 0; + hooked->behavior[1] = 0; + hooked->initReference = 0; + hooked->loopReference = 0; + } + sHookedBehaviorsCount = 0; } void smlua_bind_hooks(void) { @@ -483,4 +637,5 @@ void smlua_bind_hooks(void) { smlua_bind_function(L, "hook_mario_action", smlua_hook_mario_action); smlua_bind_function(L, "hook_chat_command", smlua_hook_chat_command); smlua_bind_function(L, "hook_on_sync_table_change", smlua_hook_on_sync_table_change); + smlua_bind_function(L, "hook_behavior", smlua_hook_behavior); } diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index d3f94ab0..9f0d144f 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -2,6 +2,7 @@ #define SMLUA_HOOKS_H #include +#include "include/behavior_table.h" enum LuaHookedEventType { HOOK_UPDATE, @@ -36,6 +37,10 @@ void smlua_call_event_hooks_mario_param(enum LuaHookedEventType hookType, struct void smlua_call_event_hooks_mario_params(enum LuaHookedEventType hookType, struct MarioState* m1, struct MarioState* m2); void smlua_call_event_hooks_interact_params(enum LuaHookedEventType hookType, struct MarioState* m, struct Object* obj, u32 interactType, bool interactValue); +const BehaviorScript* smlua_override_behavior(const BehaviorScript* behavior); +const BehaviorScript* get_lua_behavior_from_id(enum BehaviorId id); +bool smlua_call_behavior_hook(const BehaviorScript** behavior, struct Object* object); + bool smlua_call_action_hook(struct MarioState* m, s32* returnValue); u32 smlua_get_action_interaction_type(struct MarioState* m);