Skip to content

Commit

Permalink
Add enhancement to have Zora's River waterfall always open
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanLongstaff committed Oct 20, 2024
1 parent 6d1d57d commit 7485d3d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
6 changes: 6 additions & 0 deletions soh/soh/Enhancements/enhancementTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ typedef enum {
BUNNY_HOOD_FAST
} BunnyHoodMode;

typedef enum {
ZORA_WATERFALL_CLOSED,
ZORA_WATERFALL_OPEN_ADULT,
ZORA_WATERFALL_OPEN_ALWAYS
} ZoraWaterfallMode;

typedef enum {
MIRRORED_WORLD_OFF,
MIRRORED_WORLD_ALWAYS,
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/presets.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ const std::vector<const char*> enhancementsCvars = {
CVAR_ENHANCEMENT("TimeSavers.SkipChildStealth"),
CVAR_ENHANCEMENT("TimeSavers.SkipTowerEscape"),
CVAR_ENHANCEMENT("TimeSavers.SkipForcedDialog"),
CVAR_ENHANCEMENT("TimeSavers.ZoraWaterfall"),
CVAR_ENHANCEMENT("SlowTextSpeed"),
};

Expand Down
9 changes: 9 additions & 0 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static const char* imguiScaleOptions[4] = { "Small", "Normal", "Large", "X-Large
static const char* chestStyleMatchesContentsOptions[4] = { "Disabled", "Both", "Texture Only", "Size Only" };
static const char* skipGetItemAnimationOptions[3] = { "Disabled", "Junk Items", "All Items" };
static const char* skipForcedDialogOptions[4] = { "None", "Navi Only", "NPCs Only", "All" };
static const char* zoraWaterfallOptions[3] = { "Closed", "Open As Adult", "Always Open" };
static const char* bunnyHoodOptions[3] = { "Disabled", "Faster Run & Longer Jump", "Faster Run" };
static const char* mirroredWorldModes[9] = {
"Disabled", "Always", "Random", "Random (Seeded)", "Dungeons",
Expand Down Expand Up @@ -761,6 +762,14 @@ void DrawEnhancementsMenu() {
"- Not within range of Ocarina playing spots");
UIWidgets::PaddedEnhancementCheckbox("Pause Warp", CVAR_ENHANCEMENT("PauseWarp"), true, false);
UIWidgets::Tooltip("Selection of warp song in pause menu initiates warp. Disables song playback.");

UIWidgets::PaddedText("Zora's River Waterfall", true, false);
UIWidgets::EnhancementCombobox(CVAR_ENHANCEMENT("TimeSavers.ZoraWaterfall"), zoraWaterfallOptions, ZORA_WATERFALL_CLOSED);
UIWidgets::Tooltip("Skips having to play Zelda's Lullaby to enter Zora's Domain.\n\n"
"Closed: Link must always play Zelda's Lullaby.\n"
"Open As Adult: Child Link must always play Zelda's Lullaby, but Adult Link may "
"enter without playing it.\n"
"Open Always: Link may always enter Zora's Domain.");

ImGui::EndTable();
ImGui::EndMenu();
Expand Down
29 changes: 25 additions & 4 deletions soh/src/overlays/actors/ovl_Bg_Spot03_Taki/z_bg_spot03_taki.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "z_bg_spot03_taki.h"
#include "objects/object_spot03_object/object_spot03_object.h"
#include "soh/Enhancements/enhancementTypes.h"

#define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED)

Expand Down Expand Up @@ -45,18 +46,38 @@ void BgSpot03Taki_ApplyOpeningAlpha(BgSpot03Taki* this, s32 bufferIndex) {
}
}

static bool BgSpot03Taki_ShouldKeepOpen() {
switch (CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.ZoraWaterfall"), 0)) {
case ZORA_WATERFALL_OPEN_ALWAYS:
return true;
case ZORA_WATERFALL_OPEN_ADULT:
return LINK_IS_ADULT;
default:
return false;
}
}

void BgSpot03Taki_Init(Actor* thisx, PlayState* play) {
BgSpot03Taki* this = (BgSpot03Taki*)thisx;
s16 pad;
CollisionHeader* colHeader = NULL;

this->switchFlag = (this->dyna.actor.params & 0x3F);
DynaPolyActor_Init(&this->dyna, DPM_UNK);
CollisionHeader_GetVirtual(&object_spot03_object_Col_000C98, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);

if (BgSpot03Taki_ShouldKeepOpen()) {
this->state = WATERFALL_OPENED;
Flags_SetSwitch(play, this->switchFlag);
this->openingAlpha = 0.0f;
} else {
this->state = WATERFALL_CLOSED;
CollisionHeader_GetVirtual(&object_spot03_object_Col_000C98, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
this->openingAlpha = 255.0f;
}

Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
this->bufferIndex = 0;
this->openingAlpha = 255.0f;
BgSpot03Taki_ApplyOpeningAlpha(this, 0);
BgSpot03Taki_ApplyOpeningAlpha(this, 1);
this->actionFunc = func_808ADEF0;
Expand Down Expand Up @@ -90,7 +111,7 @@ void func_808ADEF0(BgSpot03Taki* this, PlayState* play) {
this->openingAlpha = 0;
}
}
} else if (this->state == WATERFALL_OPENED) {
} else if (this->state == WATERFALL_OPENED && !BgSpot03Taki_ShouldKeepOpen()) {
this->timer--;
if (this->timer < 0) {
this->state = WATERFALL_CLOSING;
Expand Down

0 comments on commit 7485d3d

Please sign in to comment.