Skip to content

Commit

Permalink
[Enhancement] Adds options for when the deku palace guard search ball…
Browse files Browse the repository at this point in the history
…s will appear (#866)

* [Enhancement] Adds options for when the deku palace guard search balls will appear

* Addresses review comments

* Moves DekuGuardSearchBalls enhancement to difficulty options

* Remove unused variadic argument
  • Loading branch information
lscholte authored Nov 26, 2024
1 parent 7c222f9 commit af0ea33
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 2 deletions.
14 changes: 14 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ static const std::unordered_map<int32_t, const char*> timeStopOptions = {
{ TIME_STOP_TEMPLES_DUNGEONS, "Temples + Mini Dungeons" },
};

static const std::unordered_map<int32_t, const char*> dekuGuardSearchBallsOptions = {
{ DEKU_GUARD_SEARCH_BALLS_NEVER, "Never" },
{ DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY, "Night Only" },
{ DEKU_GUARD_SEARCH_BALLS_ALWAYS, "Always" },
};

namespace BenGui {
std::shared_ptr<std::vector<Ship::WindowBackend>> availableWindowBackends;
std::unordered_map<Ship::WindowBackend, const char*> availableWindowBackendsMap;
Expand Down Expand Up @@ -789,6 +795,14 @@ void DrawEnhancementsMenu() {
"swords. It may still steal other items." })) {
RegisterDisableTakkuriSteal();
}

UIWidgets::CVarCombobox(
"Deku Guard Search Balls", "gEnhancements.Cheats.DekuGuardSearchBalls", dekuGuardSearchBallsOptions,
{ .tooltip = "Choose when to show the Deku Palace Guards' search balls\n"
"- Never: Never show the search balls. This matches Majora's Mask 3D behaviour\n"
"- Night Only: Only show the search balls at night. This matches original N64 behaviour.\n"
"- Always: Always show the search balls.",
.defaultIndex = DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY });
ImGui::EndMenu();
}

Expand Down
18 changes: 17 additions & 1 deletion mm/2s2h/BenGui/SearchableMenuItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ static const std::unordered_map<int32_t, const char*> notificationPosition = {
{ 0, "Top Left" }, { 1, "Top Right" }, { 2, "Bottom Left" }, { 3, "Bottom Right" }, { 4, "Hidden" },
};

static const std::unordered_map<int32_t, const char*> dekuGuardSearchBallsOptions = {
{ DEKU_GUARD_SEARCH_BALLS_NEVER, "Never" },
{ DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY, "Night Only" },
{ DEKU_GUARD_SEARCH_BALLS_ALWAYS, "Always" },
};

void FreeLookPitchMinMax() {
f32 maxY = CVarGetFloat("gEnhancements.Camera.FreeLook.MaxPitch", 72.0f);
f32 minY = CVarGetFloat("gEnhancements.Camera.FreeLook.MinPitch", -49.0f);
Expand Down Expand Up @@ -1404,6 +1410,7 @@ void AddEnhancements() {
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterWoodfallMountainAppearance(); } } } } });

enhancementsSidebar.push_back(
{ "Difficulty Options",
3,
Expand All @@ -1412,7 +1419,16 @@ void AddEnhancements() {
"Prevents the Takkuri from stealing key items like bottles and swords. It may still steal other items.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterDisableTakkuriSteal(); } } } } });
[](widgetInfo& info) { RegisterDisableTakkuriSteal(); } },
{ "Deku Guard Search Balls",
"gEnhancements.Cheats.DekuGuardSearchBalls",
"Choose when to show the Deku Palace Guards' search balls\n"
"- Never: Never show the search balls. This matches Majora's Mask 3D behaviour\n"
"- Night Only: Only show the search balls at night. This matches original N64 behaviour.\n"
"- Always: Always show the search balls.",
WIDGET_CVAR_COMBOBOX,
{ .defaultVariant = DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY,
.comboBoxOptions = dekuGuardSearchBallsOptions } } } } });
enhancementsSidebar.push_back({ "HUD Editor",
1,
{ // HUD Editor
Expand Down
22 changes: 22 additions & 0 deletions mm/2s2h/Enhancements/DifficultyOptions/DekuGuardSearchBalls.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "Enhancements/Enhancements.h"

extern "C" {
#include "variables.h"
}

void RegisterShowDekuGuardSearchBalls() {
REGISTER_VB_SHOULD(VB_DEKU_GUARD_SHOW_SEARCH_BALLS, {
uint8_t selectedOption =
CVarGetInteger("gEnhancements.Cheats.DekuGuardSearchBalls", DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY);
switch (selectedOption) {
case DEKU_GUARD_SEARCH_BALLS_NEVER:
*should = false;
break;
case DEKU_GUARD_SEARCH_BALLS_ALWAYS:
*should = true;
break;
}
});
}
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/DifficultyOptions/DifficultyOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define DIFFICULTY_OPTIONS_H

void RegisterDisableTakkuriSteal();
void RegisterShowDekuGuardSearchBalls();

#endif // DIFFICULTY_OPTIONS_H
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ void InitEnhancements() {

// Difficulty Options
RegisterDisableTakkuriSteal();
RegisterShowDekuGuardSearchBalls();
}
6 changes: 6 additions & 0 deletions mm/2s2h/Enhancements/Enhancements.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ enum CremiaRewardsOptions {
CREMIA_REWARD_ALWAYS_RUPEE,
};

enum DekuGuardSearchBallsOptions {
DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY,
DEKU_GUARD_SEARCH_BALLS_NEVER,
DEKU_GUARD_SEARCH_BALLS_ALWAYS,
};

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
1 change: 1 addition & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ typedef enum {
VB_TRANSFORM_THUNDER_MATRIX,
VB_PLAY_HEART_CONTAINER_GET_FANFARE,
VB_BE_HOOKSHOT_SURFACE,
VB_DEKU_GUARD_SHOW_SEARCH_BALLS,
} GIVanillaBehavior;

typedef enum {
Expand Down
5 changes: 4 additions & 1 deletion mm/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "z_en_look_nuts.h"
#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h"

#include "2s2h/GameInteractor/GameInteractor.h"

#define FLAGS (ACTOR_FLAG_80000000)

#define THIS ((EnLookNuts*)thisx)
Expand Down Expand Up @@ -354,9 +356,10 @@ void EnLookNuts_Update(Actor* thisx, PlayState* play) {
if (!this->isPlayerDetected) {
s16 effectFlags = SOLDERSRCHBALL_INVISIBLE;

if (gSaveContext.save.isNight) {
if (GameInteractor_Should(VB_DEKU_GUARD_SHOW_SEARCH_BALLS, gSaveContext.save.isNight)) {
effectFlags = 0;
}

if (Player_GetMask(play) != PLAYER_MASK_STONE) {
EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->isPlayerDetected,
effectFlags);
Expand Down

0 comments on commit af0ea33

Please sign in to comment.