From 284e02dcb10d8b259d0d6a881f63182f8ad17b97 Mon Sep 17 00:00:00 2001 From: Sunk <69110309+Sunketchupm@users.noreply.github.com> Date: Mon, 11 Sep 2023 12:42:15 -0400 Subject: [PATCH] Add gLevelValues.wdwWaterLevelSpeed (#469) Some romhacks do change the speed of the wdw water level. I am aware that the water level is an object and should be under gBehaviorValues, but that feels wrong so it's under gLevelValues. --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + src/game/behaviors/wdw_water_level.inc.c | 2 +- src/game/hardcoded.c | 3 ++- src/game/hardcoded.h | 1 + src/pc/lua/smlua_cobject_autogen.c | 3 ++- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index bd5c1b1f..27ec5c1c 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -687,6 +687,7 @@ --- @field public vanishCapDurationVcutm integer --- @field public vanishCapSequence integer --- @field public visibleSecrets integer +--- @field public wdwWaterLevelSpeed number --- @field public wingCapDuration integer --- @field public wingCapDurationTotwc integer --- @field public wingCapLookUpReq integer diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 5fe94990..41bea6d2 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1005,6 +1005,7 @@ | vanishCapDurationVcutm | `integer` | | | vanishCapSequence | `integer` | | | visibleSecrets | `integer` | | +| wdwWaterLevelSpeed | `number` | | | wingCapDuration | `integer` | | | wingCapDurationTotwc | `integer` | | | wingCapLookUpReq | `integer` | | diff --git a/src/game/behaviors/wdw_water_level.inc.c b/src/game/behaviors/wdw_water_level.inc.c index b4a2e66b..d3dd7c2f 100644 --- a/src/game/behaviors/wdw_water_level.inc.c +++ b/src/game/behaviors/wdw_water_level.inc.c @@ -72,7 +72,7 @@ void bhv_water_level_diamond_loop(void) { case WATER_LEVEL_DIAMOND_ACT_CHANGE_WATER_LEVEL: o->oAngleVelYaw = 0; *gEnvironmentLevels = (s32) approach_f32_symmetric( - (f32) *gEnvironmentLevels, (f32) o->oWaterLevelTriggerTargetWaterLevel, 10.0f); + (f32) *gEnvironmentLevels, (f32) o->oWaterLevelTriggerTargetWaterLevel, gLevelValues.wdwWaterLevelSpeed); if (*gEnvironmentLevels == o->oWaterLevelTriggerTargetWaterLevel) { if ((s16) o->oFaceAngleYaw == 0) o->oAction++; // Sets to WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index 5094d0d7..42f16a87 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -118,7 +118,8 @@ struct LevelValues gDefaultLevelValues = { .maxLives = 100, .maxCoins = 999, .numCoinsToLife = 50, - .bubbleOnDeathBarrierInCapStages = false + .bubbleOnDeathBarrierInCapStages = false, + .wdwWaterLevelSpeed = 10.0f, }; struct LevelValues gLevelValues = { 0 }; diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index 29ff6b69..8b328ad2 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -86,6 +86,7 @@ struct LevelValues { u16 maxCoins; u16 numCoinsToLife; bool bubbleOnDeathBarrierInCapStages; + f32 wdwWaterLevelSpeed; }; extern struct LevelValues gLevelValues; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 340497e3..5ced8ad7 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -743,7 +743,7 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE }, }; -#define LUA_LEVEL_VALUES_FIELD_COUNT 46 +#define LUA_LEVEL_VALUES_FIELD_COUNT 47 static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { { "bubbleOnDeathBarrierInCapStages", LVT_BOOL, offsetof(struct LevelValues, bubbleOnDeathBarrierInCapStages), false, LOT_NONE }, { "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE }, @@ -787,6 +787,7 @@ static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { "vanishCapDurationVcutm", LVT_U16, offsetof(struct LevelValues, vanishCapDurationVcutm), false, LOT_NONE }, { "vanishCapSequence", LVT_U8, offsetof(struct LevelValues, vanishCapSequence), false, LOT_NONE }, { "visibleSecrets", LVT_U8, offsetof(struct LevelValues, visibleSecrets), false, LOT_NONE }, + { "wdwWaterLevelSpeed", LVT_F32, offsetof(struct LevelValues, wdwWaterLevelSpeed), false, LOT_NONE }, { "wingCapDuration", LVT_U16, offsetof(struct LevelValues, wingCapDuration), false, LOT_NONE }, { "wingCapDurationTotwc", LVT_U16, offsetof(struct LevelValues, wingCapDurationTotwc), false, LOT_NONE }, { "wingCapLookUpReq", LVT_U8, offsetof(struct LevelValues, wingCapLookUpReq), false, LOT_NONE },