diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 45066f18..6053cb57 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -41,7 +41,8 @@ in_files = [ "src/pc/network/version.h", "include/geo_commands.h", "include/level_commands.h", - "src/audio/external.h" + "src/audio/external.h", + "src/game/envfx_snow.h" ] exclude_constants = { diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 31bd4f55..a72bd074 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -3263,6 +3263,33 @@ RESOLUTION_N64 = 1 --- @type HudUtilsResolution RESOLUTION_COUNT = 2 +--- @type integer +ENVFX_BUBBLE_START = 10 + +--- @type integer +ENVFX_FLOWERS = 11 + +--- @type integer +ENVFX_JETSTREAM_BUBBLES = 14 + +--- @type integer +ENVFX_LAVA_BUBBLES = 12 + +--- @type integer +ENVFX_MODE_NONE = 0 + +--- @type integer +ENVFX_SNOW_BLIZZARD = 3 + +--- @type integer +ENVFX_SNOW_NORMAL = 1 + +--- @type integer +ENVFX_SNOW_WATER = 2 + +--- @type integer +ENVFX_WHIRLPOOL_BUBBLES = 13 + --- @type integer SEQ_PLAYER_ENV = 1 diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index fd1bfb0e..33280fdb 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -8296,6 +8296,11 @@ function get_dialog_id() -- ... end +--- @return integer +function get_envfx() + -- ... +end + --- @param index integer --- @return number function get_environment_region(index) @@ -8453,6 +8458,12 @@ function set_lighting_dir(index, value) -- ... end +--- @param envfx integer +--- @return nil +function set_override_envfx(envfx) + -- ... +end + --- @param far number --- @return nil function set_override_far(far) diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 270c17fb..ace2677d 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -14,6 +14,7 @@ - [djui_hud_utils.h](#djui_hud_utilsh) - [enum DjuiFontType](#enum-DjuiFontType) - [enum HudUtilsResolution](#enum-HudUtilsResolution) +- [envfx_snow.h](#envfx_snowh) - [external.h](#externalh) - [geo_commands.h](#geo_commandsh) - [graph_node.h](#graph_nodeh) @@ -1101,6 +1102,21 @@
+## [envfx_snow.h](#envfx_snow.h) +- ENVFX_BUBBLE_START +- ENVFX_FLOWERS +- ENVFX_JETSTREAM_BUBBLES +- ENVFX_LAVA_BUBBLES +- ENVFX_MODE_NONE +- ENVFX_SNOW_BLIZZARD +- ENVFX_SNOW_NORMAL +- ENVFX_SNOW_WATER +- ENVFX_WHIRLPOOL_BUBBLES + +[:arrow_up_small:](#) + +
+ ## [external.h](#external.h) - SEQ_PLAYER_ENV - SEQ_PLAYER_LEVEL diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 544b597b..b4a4f5fa 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -8196,6 +8196,24 @@
+## [get_envfx](#get_envfx) + +### Lua Example +`local integerValue = get_envfx()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u16 get_envfx(void);` + +[:arrow_up_small:](#) + +
+ ## [get_environment_region](#get_environment_region) ### Lua Example @@ -8693,6 +8711,26 @@
+## [set_override_envfx](#set_override_envfx) + +### Lua Example +`set_override_envfx(envfx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| envfx | `integer` | + +### Returns +- None + +### C Prototype +`void set_override_envfx(s32 envfx);` + +[:arrow_up_small:](#) + +
+ ## [set_override_far](#set_override_far) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index d1d7d0e4..9c2891ed 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1541,6 +1541,7 @@ - [get_current_save_file_num](functions-4.md#get_current_save_file_num) - [get_dialog_box_state](functions-4.md#get_dialog_box_state) - [get_dialog_id](functions-4.md#get_dialog_id) + - [get_envfx](functions-4.md#get_envfx) - [get_environment_region](functions-4.md#get_environment_region) - [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x) - [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y) @@ -1566,6 +1567,7 @@ - [set_environment_region](functions-4.md#set_environment_region) - [set_last_star_or_key](functions-4.md#set_last_star_or_key) - [set_lighting_dir](functions-4.md#set_lighting_dir) + - [set_override_envfx](functions-4.md#set_override_envfx) - [set_override_far](functions-4.md#set_override_far) - [set_override_fov](functions-4.md#set_override_fov) - [set_override_near](functions-4.md#set_override_near) diff --git a/src/game/level_geo.c b/src/game/level_geo.c index b6674b72..47c72722 100644 --- a/src/game/level_geo.c +++ b/src/game/level_geo.c @@ -9,6 +9,9 @@ #include "envfx_snow.h" #include "level_geo.h" +u16 gReadOnlyEnvFx = 0; +s32 gOverrideEnvFx = -1; + /** * Geo function that generates a displaylist for environment effects such as * snow or jet stream bubbles. @@ -27,7 +30,8 @@ Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtxf) { if (GET_HIGH_U16_OF_32(*params) != gAreaUpdateCounter) { UNUSED struct Camera *sp2C = gCurGraphNodeCamera->config.camera; - s32 snowMode = GET_LOW_U16_OF_32(*params); + gReadOnlyEnvFx = GET_LOW_U16_OF_32(*params); + s32 snowMode = gOverrideEnvFx == -1 ? gReadOnlyEnvFx : gOverrideEnvFx; vec3f_to_vec3s(camTo, gCurGraphNodeCamera->focus); vec3f_to_vec3s(camFrom, gCurGraphNodeCamera->pos); diff --git a/src/game/level_geo.h b/src/game/level_geo.h index a99f9ddd..d0391f7d 100644 --- a/src/game/level_geo.h +++ b/src/game/level_geo.h @@ -11,6 +11,9 @@ struct Struct802761D0 u8 filler4[0x18-0x4]; }; +extern u16 gReadOnlyEnvFx; +extern s32 gOverrideEnvFx; + Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, Mat4 mtxf); Gfx *geo_skybox_main(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx); diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 13fa67e2..445b2b93 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1305,6 +1305,15 @@ char gSmluaConstants[] = "" "FONT_MENU = 1\n" "FONT_HUD = 2\n" "FONT_COUNT = 3\n" +"ENVFX_MODE_NONE = 0\n" +"ENVFX_SNOW_NORMAL = 1\n" +"ENVFX_SNOW_WATER = 2\n" +"ENVFX_SNOW_BLIZZARD = 3\n" +"ENVFX_BUBBLE_START = 10\n" +"ENVFX_FLOWERS = 11\n" +"ENVFX_LAVA_BUBBLES = 12\n" +"ENVFX_WHIRLPOOL_BUBBLES = 13\n" +"ENVFX_JETSTREAM_BUBBLES = 14\n" "SEQ_PLAYER_LEVEL = 0\n" "SEQ_PLAYER_ENV = 1\n" "SEQ_PLAYER_SFX = 2\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 9b3ab55e..4558cf29 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -27072,6 +27072,21 @@ int smlua_func_get_dialog_id(UNUSED lua_State* L) { return 1; } +int smlua_func_get_envfx(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_envfx", 0, top); + return 0; + } + + + lua_pushinteger(L, get_envfx()); + + return 1; +} + int smlua_func_get_environment_region(lua_State* L) { if (L == NULL) { return 0; } @@ -27511,6 +27526,23 @@ int smlua_func_set_lighting_dir(lua_State* L) { return 1; } +int smlua_func_set_override_envfx(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", "set_override_envfx", 1, top); + return 0; + } + + s32 envfx = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_envfx"); return 0; } + + set_override_envfx(envfx); + + return 1; +} + int smlua_func_set_override_far(lua_State* L) { if (L == NULL) { return 0; } @@ -30536,6 +30568,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num); smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state); smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id); + smlua_bind_function(L, "get_envfx", smlua_func_get_envfx); smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x); smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y); @@ -30561,6 +30594,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); smlua_bind_function(L, "set_last_star_or_key", smlua_func_set_last_star_or_key); smlua_bind_function(L, "set_lighting_dir", smlua_func_set_lighting_dir); + smlua_bind_function(L, "set_override_envfx", smlua_func_set_override_envfx); smlua_bind_function(L, "set_override_far", smlua_func_set_override_far); smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov); smlua_bind_function(L, "set_override_near", smlua_func_set_override_near); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 2956eae1..359828d0 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -20,6 +20,7 @@ #include "game/skybox.h" #include "pc/gfx/gfx_pc.h" #include "include/course_table.h" +#include "game/level_geo.h" u32 get_network_area_timer(void) { return gNetworkAreaTimer; @@ -427,3 +428,13 @@ void set_ttc_speed_setting(s16 speed) { u32 get_time(void) { return time(NULL); } + +/// + +u16 get_envfx(void) { + return gReadOnlyEnvFx; +} + +void set_override_envfx(s32 envfx) { + gOverrideEnvFx = envfx; +} diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 5394e3ae..3d16d754 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -107,4 +107,7 @@ void set_ttc_speed_setting(s16 speed); u32 get_time(void); +u16 get_envfx(void); +void set_override_envfx(s32 envfx); + #endif