diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index ddd988877..deb7003d4 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -687,6 +687,8 @@ void DrawEnhancementsMenu() { "-Hug: Get the hugging cutscene\n" "-Rupee: Get the rupee reward", .defaultIndex = CREMIA_REWARD_RANDOM }); + UIWidgets::CVarSliderInt("Swordsman School Winning Score: %d", + "gEnhancements.Minigames.SwordsmanSchoolScore", 1, 30, 30); ImGui::EndMenu(); } diff --git a/mm/2s2h/BenGui/SearchableMenuItems.h b/mm/2s2h/BenGui/SearchableMenuItems.h index 4131b5941..376aa379a 100644 --- a/mm/2s2h/BenGui/SearchableMenuItems.h +++ b/mm/2s2h/BenGui/SearchableMenuItems.h @@ -1023,6 +1023,11 @@ void AddEnhancements() { "-Rupee: Get the rupee reward", WIDGET_CVAR_COMBOBOX, { .comboBoxOptions = cremiaRewardOptions } }, + { "Swordsman School Winning Score", + "gEnhancements.Minigames.SwordsmanSchoolScore", + "Sets the score required to win the Swordsman School.", + WIDGET_CVAR_SLIDER_INT, + { 1, 30, 30 } }, { "Fast Magic Arrow Equip Animation", "gEnhancements.Equipment.MagicArrowEquipSpeed", "Removes the animation for equipping Magic Arrows.", WIDGET_CVAR_CHECKBOX }, { "Instant Fin Boomerangs Recall", "gEnhancements.PlayerActions.InstantRecall", diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index 22c97aa68..411d0cd15 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -50,6 +50,7 @@ void InitEnhancements() { // Minigames RegisterAlwaysWinDoggyRace(); RegisterCremiaHugs(); + RegisterSwordsmanSchool(); // Player RegisterClimbSpeed(); diff --git a/mm/2s2h/Enhancements/Minigames/Minigames.h b/mm/2s2h/Enhancements/Minigames/Minigames.h index f616fc81a..2106dad20 100644 --- a/mm/2s2h/Enhancements/Minigames/Minigames.h +++ b/mm/2s2h/Enhancements/Minigames/Minigames.h @@ -2,7 +2,7 @@ #define MINIGAMES_H void RegisterAlwaysWinDoggyRace(); - void RegisterCremiaHugs(); +void RegisterSwordsmanSchool(); #endif // MINIGAMES_H diff --git a/mm/2s2h/Enhancements/Minigames/SwordsmanSchool.cpp b/mm/2s2h/Enhancements/Minigames/SwordsmanSchool.cpp new file mode 100644 index 000000000..6bd0448d9 --- /dev/null +++ b/mm/2s2h/Enhancements/Minigames/SwordsmanSchool.cpp @@ -0,0 +1,31 @@ +#include +#include "2s2h/GameInteractor/GameInteractor.h" + +extern "C" { +#include "overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h" + +void func_80B274BC(EnKendoJs* thisx, PlayState* play); +} + +void RegisterSwordsmanSchool() { + GameInteractor::Instance->RegisterGameHookForID( + ACTOR_EN_KENDO_JS, [](Actor* actor, bool* should) { + EnKendoJs* kendo = (EnKendoJs*)actor; + + if (kendo->actionFunc != func_80B274BC) { + return; + } + + // Finishes the game early, as soon as the player reaches the required score + if (gSaveContext.minigameScore >= CVarGetInteger("gEnhancements.Minigames.SwordsmanSchoolScore", 30)) { + kendo->unk_290 = 140; + kendo->unk_284 = 5; + } + + // Each time player chops a log, check if they've reached the required score + if (kendo->unk_290 >= 140 && kendo->unk_284 == 5 && + gSaveContext.minigameScore >= CVarGetInteger("gEnhancements.Minigames.SwordsmanSchoolScore", 30)) { + gSaveContext.minigameScore = 30; + } + }); +}