Add faster rupee accumulator (#4490)

This commit is contained in:
Garrett Cox 2024-10-28 10:25:15 -05:00 committed by GitHub
parent 1df91890fe
commit 2c08fca46c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,47 @@
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/OTRGlobals.h"
#include "spdlog/spdlog.h"
extern "C" {
#include "z64save.h"
#include "macros.h"
#include "variables.h"
#include "functions.h"
extern PlayState* gPlayState;
extern SaveContext gSaveContext;
}
void FasterRupeeAccumulator_Register() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnInterfaceUpdate>([]() {
if (!CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.FasterRupeeAccumulator"), 0)) return;
if (gSaveContext.rupeeAccumulator == 0) {
return;
}
// Gaining rupees
if (gSaveContext.rupeeAccumulator > 0) {
// Wallet is full
if (gSaveContext.rupees >= CUR_CAPACITY(UPG_WALLET)) {
return;
}
if (gSaveContext.rupeeAccumulator >= 10 && gSaveContext.rupees + 10 < CUR_CAPACITY(UPG_WALLET)) {
gSaveContext.rupeeAccumulator-= 10;
gSaveContext.rupees += 10;
}
// Losing rupees
} else if (gSaveContext.rupeeAccumulator < 0) {
// No rupees to lose
if (gSaveContext.rupees == 0) {
return;
}
if (gSaveContext.rupeeAccumulator <= -10 && gSaveContext.rupees > 10) {
gSaveContext.rupeeAccumulator += 10;
gSaveContext.rupees -= 10;
}
}
});
}

View File

@ -12,4 +12,5 @@ void TimeSavers_Register() {
// SkipMiscInteractions
MoveMidoInKokiriForest_Register();
FasterHeavyBlockLift_Register();
FasterRupeeAccumulator_Register();
}

View File

@ -14,5 +14,6 @@ void TimeSavers_Register();
// SkipMiscInteractions
void MoveMidoInKokiriForest_Register();
void FasterHeavyBlockLift_Register();
void FasterRupeeAccumulator_Register();
#endif // TIME_SAVERS_H

View File

@ -711,6 +711,7 @@ void DrawEnhancementsMenu() {
UIWidgets::PaddedEnhancementSliderInt("Crawl speed %dx", "##CRAWLSPEED", CVAR_ENHANCEMENT("CrawlSpeed"), 1, 4, "", 1, true, false, true);
UIWidgets::PaddedEnhancementCheckbox("Faster Heavy Block Lift", CVAR_ENHANCEMENT("FasterHeavyBlockLift"), false, false);
UIWidgets::Tooltip("Speeds up lifting silver rocks and obelisks");
UIWidgets::PaddedEnhancementCheckbox("Faster Rupee Accumulator", CVAR_ENHANCEMENT("TimeSavers.FasterRupeeAccumulator"), false, false);
UIWidgets::PaddedEnhancementCheckbox("Skip Pickup Messages", CVAR_ENHANCEMENT("FastDrops"), true, false);
UIWidgets::Tooltip("Skip pickup messages for new consumable items and bottle swipes");
UIWidgets::PaddedEnhancementCheckbox("Fast Ocarina Playback", CVAR_ENHANCEMENT("FastOcarinaPlayback"), true, false);