Clean up Triforce Hunt U16's and GBK (#3355)

* Clean up Triforce Hunt U16's and GBK

* Apply suggestions from code review
This commit is contained in:
aMannus 2023-11-19 20:45:09 +01:00 committed by GitHub
parent 80ef399c52
commit 34556e40d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 16 deletions

View File

@ -515,7 +515,7 @@ void DrawInfoTab() {
UIWidgets::InsertHelpHoverText("Z-Targeting behavior");
if (IS_RANDO && OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT)) {
ImGui::InputScalar("Triforce Pieces", ImGuiDataType_U16, &gSaveContext.triforcePiecesCollected);
ImGui::InputScalar("Triforce Pieces", ImGuiDataType_U8, &gSaveContext.triforcePiecesCollected);
UIWidgets::InsertHelpHoverText("Currently obtained Triforce Pieces. For Triforce Hunt.");
}

View File

@ -505,6 +505,7 @@ const std::vector<FlagTable> flagTables = {
{ RAND_INF_CHILD_FISHING, "RAND_INF_CHILD_FISHING" },
{ RAND_INF_ADULT_FISHING, "RAND_INF_ADULT_FISHING" },
{ RAND_INF_10_BIG_POES, "RAND_INF_10_BIG_POES" },
{ RAND_INF_GRANT_GANONS_BOSSKEY, "RAND_INF_GRANT_GANONS_BOSSKEY" },
} },
};

View File

@ -644,16 +644,19 @@ void RegisterTriforceHunt() {
triforcePieceScale = 0.0f;
GameInteractor::State::TriforceHuntPieceGiven = 0;
}
}
});
}
uint8_t currentPieces = gSaveContext.triforcePiecesCollected;
uint8_t requiredPieces = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED);
// Give Boss Key when player loads back into the savefile.
if (currentPieces >= requiredPieces && gPlayState->transitionTrigger != TRANS_TRIGGER_START &&
(1 << 0 & gSaveContext.inventory.dungeonItems[SCENE_GANONS_TOWER]) == 0) {
GetItemEntry getItemEntry = ItemTableManager::Instance->RetrieveItemEntry(MOD_RANDOMIZER, RG_GANONS_CASTLE_BOSS_KEY);
void RegisterGrantGanonsBossKey() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
// Triforce Hunt needs the check if the player isn't being teleported to the credits scene.
if (!GameInteractor::IsGameplayPaused() &&
Flags_GetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY) && gPlayState->transitionTrigger != TRANS_TRIGGER_START &&
(1 << 0 & gSaveContext.inventory.dungeonItems[SCENE_GANONS_TOWER]) == 0) {
GetItemEntry getItemEntry =
ItemTableManager::Instance->RetrieveItemEntry(MOD_RANDOMIZER, RG_GANONS_CASTLE_BOSS_KEY);
GiveItemEntryWithoutActor(gPlayState, getItemEntry);
}
}
});
}
@ -1076,6 +1079,7 @@ void InitMods() {
RegisterMenuPathFix();
RegisterMirrorModeHandler();
RegisterTriforceHunt();
RegisterGrantGanonsBossKey();
RegisterEnemyDefeatCounts();
RegisterAltTrapTypes();
RegisterRandomizerSheikSpawn();

View File

@ -214,7 +214,7 @@ extern "C" void Randomizer_DrawTriforcePiece(PlayState* play, GetItemEntry getIt
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
uint16_t current = gSaveContext.triforcePiecesCollected;
uint8_t current = gSaveContext.triforcePiecesCollected;
Matrix_Scale(0.035f, 0.035f, 0.035f, MTXMODE_APPLY);
@ -238,8 +238,8 @@ extern "C" void Randomizer_DrawTriforcePieceGI(PlayState* play, GetItemEntry get
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
uint16_t current = gSaveContext.triforcePiecesCollected;
uint16_t required = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED);
uint8_t current = gSaveContext.triforcePiecesCollected;
uint8_t required = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED);
Matrix_Scale(triforcePieceScale, triforcePieceScale, triforcePieceScale, MTXMODE_APPLY);

View File

@ -5548,9 +5548,9 @@ void CreateTriforcePieceMessages() {
CustomMessage Randomizer::GetTriforcePieceMessage() {
// Item is only given after the textbox, so reflect that inside the textbox.
uint16_t current = gSaveContext.triforcePiecesCollected + 1;
uint16_t required = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED);
uint16_t remaining = required - current;
uint8_t current = gSaveContext.triforcePiecesCollected + 1;
uint8_t required = OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED);
uint8_t remaining = required - current;
float percentageCollected = (float)current / (float)required;
uint8_t messageIndex;

View File

@ -159,6 +159,7 @@ typedef enum {
RAND_INF_CHILD_FISHING,
RAND_INF_ADULT_FISHING,
RAND_INF_10_BIG_POES,
RAND_INF_GRANT_GANONS_BOSSKEY,
// If you add anything to this list, you need to update the size of randomizerInf in z64save.h to be ceil(RAND_INF_MAX / 16)

View File

@ -1043,7 +1043,7 @@ void GetItem_DrawTriforcePiece(PlayState* play, s16 drawId) {
Matrix_Scale(0.035f, 0.035f, 0.035f, MTXMODE_APPLY);
uint16_t index = gSaveContext.triforcePiecesCollected % 3;
uint8_t index = gSaveContext.triforcePiecesCollected % 3;
Gfx* triforcePieceDL;
switch (index) {

View File

@ -2605,6 +2605,7 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
if (gSaveContext.triforcePiecesCollected == Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED)) {
gSaveContext.sohStats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED] = GAMEPLAYSTAT_TOTAL_TIME;
gSaveContext.sohStats.gameComplete = 1;
Flags_SetRandomizerInf(RAND_INF_GRANT_GANONS_BOSSKEY);
Play_PerformSave(play);
GameInteractor_SetTriforceHuntCreditsWarpActive(true);
}