From 3ebfdb3928c7f08b203e06fc9bda5a5fdea0ca32 Mon Sep 17 00:00:00 2001 From: Eblo <7004497+Eblo@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:51:05 -0400 Subject: [PATCH] [Enhancement] Skip the scarecrow song (#723) * Add enhancement to skip the scarecrow song * Update SkipScarecrowSong to use variadic args --- mm/2s2h/BenGui/BenMenuBar.cpp | 2 ++ mm/2s2h/BenGui/SearchableMenuItems.h | 2 ++ mm/2s2h/Enhancements/Enhancements.cpp | 1 + .../Enhancements/Songs/SkipScarecrowSong.cpp | 29 +++++++++++++++++++ mm/2s2h/Enhancements/Songs/Songs.h | 1 + mm/2s2h/GameInteractor/GameInteractor.h | 1 + .../actors/ovl_En_Kakasi/z_en_kakasi.c | 8 +++-- 7 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 mm/2s2h/Enhancements/Songs/SkipScarecrowSong.cpp diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 75c615d19..93152da61 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -755,6 +755,8 @@ void DrawEnhancementsMenu() { { .tooltip = "Enables using the Dpad for Ocarina playback." }); UIWidgets::CVarCheckbox("Prevent Dropped Ocarina Inputs", "gEnhancements.Playback.NoDropOcarinaInput", { .tooltip = "Prevent dropping inputs when playing the ocarina quickly" }); + UIWidgets::CVarCheckbox("Skip Scarecrow Song", "gEnhancements.Playback.SkipScarecrowSong", + { .tooltip = "Pierre appears when the Ocarina is pulled out." }); UIWidgets::CVarCheckbox("Pause Owl Warp", "gEnhancements.Songs.PauseOwlWarp", { .tooltip = "Allows the player to use the pause menu map to owl warp instead of " "having to play the Song of Soaring." }); diff --git a/mm/2s2h/BenGui/SearchableMenuItems.h b/mm/2s2h/BenGui/SearchableMenuItems.h index 5edbf1402..1bff76ce3 100644 --- a/mm/2s2h/BenGui/SearchableMenuItems.h +++ b/mm/2s2h/BenGui/SearchableMenuItems.h @@ -1249,6 +1249,8 @@ void AddEnhancements() { { 1, 7, 7 } }, { "Prevent Dropped Ocarina Inputs", "gEnhancements.Playback.NoDropOcarinaInput", "Prevent dropping inputs when playing the ocarina quickly.", WIDGET_CVAR_CHECKBOX }, + { "Skip Scarecrow Song", "gEnhancements.Playback.SkipScarecrowSong", + "Pierre appears when the Ocarina is pulled out.", WIDGET_CVAR_CHECKBOX }, { "Faster Song Playback", "gEnhancements.Songs.FasterSongPlayback", "Speeds up the playback of songs.", diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index 6d0abc386..e0518fdc2 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -61,6 +61,7 @@ void InitEnhancements() { RegisterFasterSongPlayback(); RegisterPauseOwlWarp(); RegisterZoraEggCount(); + RegisterSkipScarecrowSong(); // Restorations RegisterPowerCrouchStab(); diff --git a/mm/2s2h/Enhancements/Songs/SkipScarecrowSong.cpp b/mm/2s2h/Enhancements/Songs/SkipScarecrowSong.cpp new file mode 100644 index 000000000..1804de148 --- /dev/null +++ b/mm/2s2h/Enhancements/Songs/SkipScarecrowSong.cpp @@ -0,0 +1,29 @@ +#include +#include "2s2h/GameInteractor/GameInteractor.h" + +extern "C" { +#include "z64.h" +#include "functions.h" +#include "src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h" +extern PlayState* gPlayState; +} + +void RegisterSkipScarecrowSong() { + REGISTER_VB_SHOULD(VB_NEED_SCARECROW_SONG, { + if (CVarGetInteger("gEnhancements.Playback.SkipScarecrowSong", 0)) { + EnKakasi* enKakasi = va_arg(args, EnKakasi*); + /* + * This is somewhat similar to the condition that the scarecrow normally checks, except it checks if the + * instrument is being played at all instead of having played the Scarecrow's Song in particular, and it + * bypasses the check that Link has taught Pierre a song this cycle. + */ + if ((enKakasi->picto.actor.xzDistToPlayer < enKakasi->songSummonDist) && + ((BREG(1) != 0) || (gPlayState->msgCtx.ocarinaMode == OCARINA_MODE_ACTIVE))) { + *should = true; + // Properly get out of the ocarina playing state + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + Message_CloseTextbox(gPlayState); + } + } + }); +} diff --git a/mm/2s2h/Enhancements/Songs/Songs.h b/mm/2s2h/Enhancements/Songs/Songs.h index ecd2a6942..d4df3cc88 100644 --- a/mm/2s2h/Enhancements/Songs/Songs.h +++ b/mm/2s2h/Enhancements/Songs/Songs.h @@ -5,6 +5,7 @@ void RegisterEnableSunsSong(); void RegisterFasterSongPlayback(); void RegisterZoraEggCount(); void RegisterPauseOwlWarp(); +void RegisterSkipScarecrowSong(); #ifdef __cplusplus extern "C" { diff --git a/mm/2s2h/GameInteractor/GameInteractor.h b/mm/2s2h/GameInteractor/GameInteractor.h index 6afed0605..28b4936d5 100644 --- a/mm/2s2h/GameInteractor/GameInteractor.h +++ b/mm/2s2h/GameInteractor/GameInteractor.h @@ -68,6 +68,7 @@ typedef enum { VB_FD_ALWAYS_WIELD_SWORD, VB_SHOULD_PUTAWAY, VB_ELEGY_CHECK_SCENE, + VB_NEED_SCARECROW_SONG, } GIVanillaBehavior; typedef enum { diff --git a/mm/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/mm/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 4e2e27cf6..c73d37e3a 100644 --- a/mm/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/mm/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -7,6 +7,7 @@ #include "prevent_bss_reordering.h" #include "z_en_kakasi.h" #include "objects/object_ka/object_ka.h" +#include "2s2h/GameInteractor/GameInteractor.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -1053,8 +1054,11 @@ void EnKakasi_SetupIdleUnderground(EnKakasi* this) { } void EnKakasi_IdleUnderground(EnKakasi* this, PlayState* play) { - if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_08) && (this->picto.actor.xzDistToPlayer < this->songSummonDist) && - ((BREG(1) != 0) || (play->msgCtx.ocarinaMode == OCARINA_MODE_PLAYED_SCARECROW_SPAWN))) { + if (GameInteractor_Should(VB_NEED_SCARECROW_SONG, + CHECK_WEEKEVENTREG(WEEKEVENTREG_79_08) && + (this->picto.actor.xzDistToPlayer < this->songSummonDist) && + ((BREG(1) != 0) || (play->msgCtx.ocarinaMode == OCARINA_MODE_PLAYED_SCARECROW_SPAWN)), + this)) { this->picto.actor.flags &= ~ACTOR_FLAG_CANT_LOCK_ON; play->msgCtx.ocarinaMode = OCARINA_MODE_END; this->actionFunc = EnKakasi_SetupRiseOutOfGround;