From cee5957e117a431b3c494c62db4c4eb18b61f4bd Mon Sep 17 00:00:00 2001 From: PeachyPeachSM64 <72323920+PeachyPeachSM64@users.noreply.github.com> Date: Fri, 29 Aug 2025 22:54:40 +0200 Subject: [PATCH] Fix cap sequences not replaced/playing on dynos warp and level entry; Add `gLevelValues.shellSequence` --- autogen/lua_definitions/structs.lua | 1 + data/dynos_warps.cpp | 9 +++++---- docs/lua/structs.md | 1 + src/game/hardcoded.c | 1 + src/game/hardcoded.h | 1 + src/game/level_update.c | 16 +++++++++++----- src/game/sound_init.c | 4 ++-- src/pc/lua/smlua_cobject_autogen.c | 3 ++- 8 files changed, 24 insertions(+), 12 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index fea9047f2..eb545250c 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -1122,6 +1122,7 @@ --- @field public wingCapSequence SeqId --- @field public metalCapSequence SeqId --- @field public vanishCapSequence SeqId +--- @field public shellSequence SeqId --- @field public starPositions StarPositions --- @field public cellHeightLimit integer --- @field public floorLowerLimit integer diff --git a/data/dynos_warps.cpp b/data/dynos_warps.cpp index e9d1c6fd9..62273ac96 100644 --- a/data/dynos_warps.cpp +++ b/data/dynos_warps.cpp @@ -6,6 +6,7 @@ extern "C" { #include "audio/external.h" #include "engine/surface_collision.h" #include "game/mario.h" +#include "game/hardcoded.h" #include "game/ingame_menu.h" #include "game/level_update.h" #include "game/sound_init.h" @@ -249,13 +250,13 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) { } // Set music - if (sWarpDest.type != WARP_TYPE_SAME_AREA && sWarpDest.type != WARP_TYPE_NOT_WARPING) { + if (sDynosWarpNodeNum == -1 || (sWarpDest.type != WARP_TYPE_SAME_AREA && sWarpDest.type != WARP_TYPE_NOT_WARPING)) { if (gCurrentArea != NULL) { set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0); } - if (gMarioState->flags & MARIO_METAL_CAP) play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_METAL_CAP)); - if (gMarioState->flags & MARIO_VANISH_CAP) play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); - if (gMarioState->flags & MARIO_WING_CAP) play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); + if (gMarioState->flags & MARIO_METAL_CAP) play_cap_music(SEQUENCE_ARGS(4, gLevelValues.metalCapSequence)); + if (gMarioState->flags & MARIO_VANISH_CAP) play_cap_music(SEQUENCE_ARGS(4, gLevelValues.vanishCapSequence)); + if (gMarioState->flags & MARIO_WING_CAP) play_cap_music(SEQUENCE_ARGS(4, gLevelValues.wingCapSequence)); if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2 || gCurrLevelNum == LEVEL_BOWSER_3) { diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 56445ba91..eb6ff0813 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1730,6 +1730,7 @@ | wingCapSequence | [enum SeqId](constants.md#enum-SeqId) | | | metalCapSequence | [enum SeqId](constants.md#enum-SeqId) | | | vanishCapSequence | [enum SeqId](constants.md#enum-SeqId) | | +| shellSequence | [enum SeqId](constants.md#enum-SeqId) | | | starPositions | [StarPositions](structs.md#StarPositions) | read-only | | cellHeightLimit | `integer` | | | floorLowerLimit | `integer` | | diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index 3e457486d..6ce8364d8 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -84,6 +84,7 @@ struct LevelValues gDefaultLevelValues = { .wingCapSequence = SEQ_EVENT_POWERUP, .metalCapSequence = SEQ_EVENT_METAL_CAP, .vanishCapSequence = SEQ_EVENT_POWERUP, + .shellSequence = SEQ_EVENT_POWERUP | SEQ_VARIATION, .starPositions = { .KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f }, .KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f }, diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index 386f35992..d0c6ebb23 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -82,6 +82,7 @@ struct LevelValues { enum SeqId wingCapSequence; enum SeqId metalCapSequence; enum SeqId vanishCapSequence; + enum SeqId shellSequence; struct StarPositions starPositions; s16 cellHeightLimit; s16 floorLowerLimit; diff --git a/src/game/level_update.c b/src/game/level_update.c index 5ae567e91..c19b9a7c9 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -505,11 +505,15 @@ void init_mario_after_warp(void) { } if (gMarioState->flags & MARIO_METAL_CAP) { - play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_METAL_CAP)); + play_cap_music(SEQUENCE_ARGS(4, gLevelValues.metalCapSequence)); } - if (gMarioState->flags & (MARIO_VANISH_CAP | MARIO_WING_CAP)) { - play_cap_music(SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)); + if (gMarioState->flags & MARIO_VANISH_CAP) { + play_cap_music(SEQUENCE_ARGS(4, gLevelValues.vanishCapSequence)); + } + + if (gMarioState->flags & MARIO_WING_CAP) { + play_cap_music(SEQUENCE_ARGS(4, gLevelValues.wingCapSequence)); } #ifndef VERSION_JP @@ -713,8 +717,10 @@ s16 music_changed_through_warp(s16 arg) { if (levelNum == LEVEL_BOB && levelNum == gCurrLevelNum && destArea == gCurrAreaIndex) { sp2C = get_current_background_music(); - if (sp2C == SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION) - || sp2C == SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP)) { + if (sp2C == SEQUENCE_ARGS(4, gLevelValues.wingCapSequence) || + sp2C == SEQUENCE_ARGS(4, gLevelValues.vanishCapSequence) || + sp2C == SEQUENCE_ARGS(4, gLevelValues.metalCapSequence) || + sp2C == SEQUENCE_ARGS(4, gLevelValues.shellSequence)) { val4 = 0; } } else { diff --git a/src/game/sound_init.c b/src/game/sound_init.c index abaef0c65..f0fee0aa4 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -298,8 +298,8 @@ void play_cutscene_music(u16 seqArgs) { * Called from threads: thread5_game_loop */ void play_shell_music(void) { - play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION), 0); - sCurrentShellMusic = SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION); + play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(4, gLevelValues.shellSequence), 0); + sCurrentShellMusic = SEQUENCE_ARGS(4, gLevelValues.shellSequence); } /** diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 9f5241721..4f852abf1 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -1392,7 +1392,7 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE, 1, sizeof(s16) }, }; -#define LUA_LEVEL_VALUES_FIELD_COUNT 55 +#define LUA_LEVEL_VALUES_FIELD_COUNT 56 static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { { "bubbleOnDeathBarrierInCapStages", LVT_U8, offsetof(struct LevelValues, bubbleOnDeathBarrierInCapStages), false, LOT_NONE, 1, sizeof(u8) }, { "ceilNormalMaxY", LVT_F32, offsetof(struct LevelValues, ceilNormalMaxY), false, LOT_NONE, 1, sizeof(f32) }, @@ -1433,6 +1433,7 @@ static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE, 1, sizeof(u8) }, { "pssSlideStarTime", LVT_U16, offsetof(struct LevelValues, pssSlideStarTime), false, LOT_NONE, 1, sizeof(u16) }, { "respawnBlueCoinsSwitch", LVT_U8, offsetof(struct LevelValues, respawnBlueCoinsSwitch), false, LOT_NONE, 1, sizeof(u8) }, + { "shellSequence", LVT_S32, offsetof(struct LevelValues, shellSequence), false, LOT_NONE, 1, sizeof(enum SeqId) }, { "showStarNumber", LVT_U8, offsetof(struct LevelValues, showStarNumber), false, LOT_NONE, 1, sizeof(u8) }, { "skipCreditsAt", LVT_S32, offsetof(struct LevelValues, skipCreditsAt), false, LOT_NONE, 1, sizeof(enum LevelNum) }, { "starHeal", LVT_U8, offsetof(struct LevelValues, starHeal), false, LOT_NONE, 1, sizeof(u8) },