Document level_update.h and add new instant warp function (70.1%)

This commit is contained in:
Agent X 2024-12-31 19:39:36 -05:00
parent 54b2ba17e5
commit f880e6c569
7 changed files with 99 additions and 4 deletions

View file

@ -84,7 +84,7 @@ override_allowed_functions = {
"src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ], "src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
"src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*", "geo_get_.*_state" ], "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*", "geo_get_.*_state" ],
"src/pc/utils/misc.h": [ "update_all_mario_stars" ], "src/pc/utils/misc.h": [ "update_all_mario_stars" ],
"src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "fade_into_special_warp" ], "src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "fade_into_special_warp", "get_instant_warp" ],
"src/game/area.h": [ "area_get_warp_node" ], "src/game/area.h": [ "area_get_warp_node" ],
"src/engine/level_script.h": [ "area_create_warp_node" ], "src/engine/level_script.h": [ "area_create_warp_node" ],
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "close_dialog_box", ], "src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "close_dialog_box", ],

View file

@ -4764,21 +4764,32 @@ end
--- @param arg integer --- @param arg integer
--- @param color integer --- @param color integer
--- Fades into a special warp with `arg` and using `color`
function fade_into_special_warp(arg, color) function fade_into_special_warp(arg, color)
-- ... -- ...
end end
--- @param index integer
--- @return InstantWarp
--- Gets an instant warp from the current area's instant warp array (0-3)
function get_instant_warp(index)
-- ...
end
--- @return WarpNode --- @return WarpNode
--- Gets a painting warp node from the local mario's floor type
function get_painting_warp_node() function get_painting_warp_node()
-- ... -- ...
end end
--- @param paintingIndex integer --- @param paintingIndex integer
--- Initiates a painting warp of `paintingIndex`
function initiate_painting_warp(paintingIndex) function initiate_painting_warp(paintingIndex)
-- ... -- ...
end end
--- @return integer --- @return integer
--- Returns if the level timer is running
function level_control_timer_running() function level_control_timer_running()
-- ... -- ...
end end
@ -4786,6 +4797,7 @@ end
--- @param m MarioState --- @param m MarioState
--- @param warpOp integer --- @param warpOp integer
--- @return integer --- @return integer
--- Triggers a warp (WARP_OP_*) for the level. Pass in `gMarioStates[0]` for `m`
function level_trigger_warp(m, warpOp) function level_trigger_warp(m, warpOp)
-- ... -- ...
end end
@ -4793,11 +4805,13 @@ end
--- @param arg0 integer --- @param arg0 integer
--- @param levelNum integer --- @param levelNum integer
--- @return integer --- @return integer
--- Sets the level number and handles the act select screen
function lvl_set_current_level(arg0, levelNum) function lvl_set_current_level(arg0, levelNum)
-- ... -- ...
end end
--- @param arg integer --- @param arg integer
--- Special warps to arg (`SPECIAL_WARP_*`)
function warp_special(arg) function warp_special(arg)
-- ... -- ...
end end

View file

@ -6045,6 +6045,9 @@ Creates a warp node in the current level and area with id `id` that goes to the
## [fade_into_special_warp](#fade_into_special_warp) ## [fade_into_special_warp](#fade_into_special_warp)
### Description
Fades into a special warp with `arg` and using `color`
### Lua Example ### Lua Example
`fade_into_special_warp(arg, color)` `fade_into_special_warp(arg, color)`
@ -6064,8 +6067,34 @@ Creates a warp node in the current level and area with id `id` that goes to the
<br /> <br />
## [get_instant_warp](#get_instant_warp)
### Description
Gets an instant warp from the current area's instant warp array (0-3)
### Lua Example
`local InstantWarpValue = get_instant_warp(index)`
### Parameters
| Field | Type |
| ----- | ---- |
| index | `integer` |
### Returns
[InstantWarp](structs.md#InstantWarp)
### C Prototype
`struct InstantWarp *get_instant_warp(u8 index);`
[:arrow_up_small:](#)
<br />
## [get_painting_warp_node](#get_painting_warp_node) ## [get_painting_warp_node](#get_painting_warp_node)
### Description
Gets a painting warp node from the local mario's floor type
### Lua Example ### Lua Example
`local WarpNodeValue = get_painting_warp_node()` `local WarpNodeValue = get_painting_warp_node()`
@ -6084,6 +6113,9 @@ Creates a warp node in the current level and area with id `id` that goes to the
## [initiate_painting_warp](#initiate_painting_warp) ## [initiate_painting_warp](#initiate_painting_warp)
### Description
Initiates a painting warp of `paintingIndex`
### Lua Example ### Lua Example
`initiate_painting_warp(paintingIndex)` `initiate_painting_warp(paintingIndex)`
@ -6104,6 +6136,9 @@ Creates a warp node in the current level and area with id `id` that goes to the
## [level_control_timer_running](#level_control_timer_running) ## [level_control_timer_running](#level_control_timer_running)
### Description
Returns if the level timer is running
### Lua Example ### Lua Example
`local integerValue = level_control_timer_running()` `local integerValue = level_control_timer_running()`
@ -6122,6 +6157,9 @@ Creates a warp node in the current level and area with id `id` that goes to the
## [level_trigger_warp](#level_trigger_warp) ## [level_trigger_warp](#level_trigger_warp)
### Description
Triggers a warp (WARP_OP_*) for the level. Pass in `gMarioStates[0]` for `m`
### Lua Example ### Lua Example
`local integerValue = level_trigger_warp(m, warpOp)` `local integerValue = level_trigger_warp(m, warpOp)`
@ -6143,6 +6181,9 @@ Creates a warp node in the current level and area with id `id` that goes to the
## [lvl_set_current_level](#lvl_set_current_level) ## [lvl_set_current_level](#lvl_set_current_level)
### Description
Sets the level number and handles the act select screen
### Lua Example ### Lua Example
`local integerValue = lvl_set_current_level(arg0, levelNum)` `local integerValue = lvl_set_current_level(arg0, levelNum)`
@ -6164,6 +6205,9 @@ Creates a warp node in the current level and area with id `id` that goes to the
## [warp_special](#warp_special) ## [warp_special](#warp_special)
### Description
Special warps to arg (`SPECIAL_WARP_*`)
### Lua Example ### Lua Example
`warp_special(arg)` `warp_special(arg)`

View file

@ -933,6 +933,7 @@
- level_update.h - level_update.h
- [fade_into_special_warp](functions-3.md#fade_into_special_warp) - [fade_into_special_warp](functions-3.md#fade_into_special_warp)
- [get_instant_warp](functions-3.md#get_instant_warp)
- [get_painting_warp_node](functions-3.md#get_painting_warp_node) - [get_painting_warp_node](functions-3.md#get_painting_warp_node)
- [initiate_painting_warp](functions-3.md#initiate_painting_warp) - [initiate_painting_warp](functions-3.md#initiate_painting_warp)
- [level_control_timer_running](functions-3.md#level_control_timer_running) - [level_control_timer_running](functions-3.md#level_control_timer_running)

View file

@ -634,6 +634,14 @@ void warp_credits(void) {
} }
} }
struct InstantWarp *get_instant_warp(u8 index) {
if (index >= 4) { return NULL; }
if (!gCurrentArea) { return NULL; }
if (gCurrentArea->instantWarps == NULL) { return NULL; }
return &gCurrentArea->instantWarps[index];
}
void check_instant_warp(void) { void check_instant_warp(void) {
if (!gCurrentArea) { return; } if (!gCurrentArea) { return; }
s16 cameraAngle; s16 cameraAngle;
@ -747,7 +755,7 @@ s16 music_changed_through_warp(s16 arg) {
/** /**
* Set the current warp type and destination level/area/node. * Set the current warp type and destination level/area/node.
*/ */
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) { void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg) {
if (destWarpNode >= WARP_NODE_CREDITS_MIN) { if (destWarpNode >= WARP_NODE_CREDITS_MIN) {
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL; sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
} else if (destLevel != gCurrLevelNum) { } else if (destLevel != gCurrLevelNum) {
@ -761,7 +769,7 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) {
sWarpDest.levelNum = destLevel; sWarpDest.levelNum = destLevel;
sWarpDest.areaIdx = destArea; sWarpDest.areaIdx = destArea;
sWarpDest.nodeId = destWarpNode; sWarpDest.nodeId = destWarpNode;
sWarpDest.arg = arg3; sWarpDest.arg = arg;
} }
/** /**

View file

@ -166,20 +166,30 @@ enum HUDDisplayFlag {
HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020 HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020
}; };
/* |description|Returns if the level timer is running|descriptionEnd| */
u8 level_control_timer_running(void); u8 level_control_timer_running(void);
u16 level_control_timer(s32 timerOp); u16 level_control_timer(s32 timerOp);
/* |description|Fades into a special warp with `arg` and using `color`|descriptionEnd| */
void fade_into_special_warp(u32 arg, u32 color); void fade_into_special_warp(u32 arg, u32 color);
void load_level_init_text(u32 arg); void load_level_init_text(u32 arg);
void warp_credits(void); void warp_credits(void);
/* |description|Gets an instant warp from the current area's instant warp array (0-3)|descriptionEnd| */
struct InstantWarp *get_instant_warp(u8 index);
/* |description|Gets a painting warp node from the local mario's floor type|descriptionEnd| */
struct WarpNode *get_painting_warp_node(void); struct WarpNode *get_painting_warp_node(void);
/* |description|Initiates a painting warp of `paintingIndex`|descriptionEnd| */
void initiate_painting_warp(s16 paintingIndex); void initiate_painting_warp(s16 paintingIndex);
/* |description|Triggers a warp (WARP_OP_*) for the level. Pass in `gMarioStates[0]` for `m`|descriptionEnd| */
s16 level_trigger_warp(struct MarioState *m, s32 warpOp); s16 level_trigger_warp(struct MarioState *m, s32 warpOp);
void level_set_transition(s16 length, void (*updateFunction)(s16 *)); void level_set_transition(s16 length, void (*updateFunction)(s16 *));
/* |description|Special warps to arg (`SPECIAL_WARP_*`)|descriptionEnd| */
void warp_special(s32 arg); void warp_special(s32 arg);
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3); /* |description|Initiates a warp to `destLevel` in `destArea` at `destWarpNode` with `arg`. This function is unstable and it's generally recommended to use `warp_to_level` instead|descriptionEnd| */
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg);
s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused); s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused);
s32 lvl_init_from_save_file(UNUSED s16 arg0, s16 levelNum); s32 lvl_init_from_save_file(UNUSED s16 arg0, s16 levelNum);
/* |description|Sets the level number and handles the act select screen|descriptionEnd| */
s32 lvl_set_current_level(s16 arg0, s16 levelNum); s32 lvl_set_current_level(s16 arg0, s16 levelNum);
s32 lvl_play_the_end_screen_sound(UNUSED s16 arg0, UNUSED s32 arg1); s32 lvl_play_the_end_screen_sound(UNUSED s16 arg0, UNUSED s32 arg1);
void basic_update(UNUSED s16 *arg); void basic_update(UNUSED s16 *arg);

View file

@ -14749,6 +14749,23 @@ int smlua_func_fade_into_special_warp(lua_State* L) {
return 1; return 1;
} }
int smlua_func_get_instant_warp(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_instant_warp", 1, top);
return 0;
}
u8 index = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_instant_warp"); return 0; }
smlua_push_object(L, LOT_INSTANTWARP, get_instant_warp(index));
return 1;
}
int smlua_func_get_painting_warp_node(UNUSED lua_State* L) { int smlua_func_get_painting_warp_node(UNUSED lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -32838,6 +32855,7 @@ void smlua_bind_functions_autogen(void) {
// level_update.h // level_update.h
smlua_bind_function(L, "fade_into_special_warp", smlua_func_fade_into_special_warp); smlua_bind_function(L, "fade_into_special_warp", smlua_func_fade_into_special_warp);
smlua_bind_function(L, "get_instant_warp", smlua_func_get_instant_warp);
smlua_bind_function(L, "get_painting_warp_node", smlua_func_get_painting_warp_node); smlua_bind_function(L, "get_painting_warp_node", smlua_func_get_painting_warp_node);
smlua_bind_function(L, "initiate_painting_warp", smlua_func_initiate_painting_warp); smlua_bind_function(L, "initiate_painting_warp", smlua_func_initiate_painting_warp);
smlua_bind_function(L, "level_control_timer_running", smlua_func_level_control_timer_running); smlua_bind_function(L, "level_control_timer_running", smlua_func_level_control_timer_running);