diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.h b/soh/soh/Enhancements/debugger/debugSaveEditor.h index ff9f9bf8f..047df95f8 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.h +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.h @@ -358,13 +358,6 @@ const std::vector flagTables = { { RAND_INF_DUNGEONS_DONE_SPIRIT_TEMPLE, "DUNGEONS_DONE_SPIRIT_TEMPLE" }, { RAND_INF_DUNGEONS_DONE_SHADOW_TEMPLE, "DUNGEONS_DONE_SHADOW_TEMPLE" }, - { RAND_INF_TRIALS_DONE_LIGHT_TRIAL, "TRIALS_DONE_LIGHT_TRIAL" }, - { RAND_INF_TRIALS_DONE_FOREST_TRIAL, "TRIALS_DONE_FOREST_TRIAL" }, - { RAND_INF_TRIALS_DONE_FIRE_TRIAL, "TRIALS_DONE_FIRE_TRIAL" }, - { RAND_INF_TRIALS_DONE_WATER_TRIAL, "TRIALS_DONE_WATER_TRIAL" }, - { RAND_INF_TRIALS_DONE_SPIRIT_TRIAL, "TRIALS_DONE_SPIRIT_TRIAL" }, - { RAND_INF_TRIALS_DONE_SHADOW_TRIAL, "TRIALS_DONE_SHADOW_TRIAL" }, - { RAND_INF_COWS_MILKED_KF_LINKS_HOUSE_COW, "COWS_MILKED_KF_LINKS_HOUSE_COW" }, { RAND_INF_COWS_MILKED_HF_COW_GROTTO_COW, "COWS_MILKED_HF_COW_GROTTO_COW" }, { RAND_INF_COWS_MILKED_LLR_STABLES_LEFT_COW, "COWS_MILKED_LLR_STABLES_LEFT_COW" }, diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index f8e1c5020..f47d1adad 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -107,6 +107,15 @@ bool MeetsLACSRequirements() { return false; } +bool CompletedAllTrials() { + return Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_WATER_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_LIGHT_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_FIRE_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_SHADOW_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_SPIRIT_TRIAL) && + Flags_GetEventChkInf(EVENTCHKINF_COMPLETED_FOREST_TRIAL); +} + // Todo Move this to randomizer context, clear it out on save load etc static std::queue randomizerQueuedChecks; static RandomizerCheck randomizerQueuedCheck = RC_UNKNOWN_CHECK; @@ -1307,6 +1316,12 @@ void RandomizerOnActorInitHandler(void* actorRef) { enGe1->actionFunc = (EnGe1ActionFunc)EnGe1_SetNormalText; } } + + if (actor->id == ACTOR_DEMO_KEKKAI && actor->params == 0) { // 0 == KEKKAI_TOWER + if (CompletedAllTrials()) { + Actor_Kill(actor); + } + } } void RandomizerRegisterHooks() { diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index eb34721b5..74409c4c7 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -164,21 +164,6 @@ Randomizer::Randomizer() { Randomizer::~Randomizer() { } -std::unordered_map spoilerFileTrialToEnum = { - { "the Forest Trial", RAND_INF_TRIALS_DONE_FOREST_TRIAL }, - { "l'épreuve de la Forêt", RAND_INF_TRIALS_DONE_FOREST_TRIAL }, - { "the Fire Trial", RAND_INF_TRIALS_DONE_FIRE_TRIAL }, - { "l'épreuve du Feu", RAND_INF_TRIALS_DONE_FIRE_TRIAL }, - { "the Water Trial", RAND_INF_TRIALS_DONE_WATER_TRIAL }, - { "l'épreuve de l'Eau", RAND_INF_TRIALS_DONE_WATER_TRIAL }, - { "the Spirit Trial", RAND_INF_TRIALS_DONE_SPIRIT_TRIAL }, - { "l'épreuve de l'Esprit", RAND_INF_TRIALS_DONE_SPIRIT_TRIAL }, - { "the Shadow Trial", RAND_INF_TRIALS_DONE_SHADOW_TRIAL }, - { "l'épreuve de l'Ombre", RAND_INF_TRIALS_DONE_SHADOW_TRIAL }, - { "the Light Trial", RAND_INF_TRIALS_DONE_LIGHT_TRIAL }, - { "l'épreuve de la Lumière", RAND_INF_TRIALS_DONE_LIGHT_TRIAL } -}; - std::unordered_map spoilerFileDungeonToScene = { { "Deku Tree", SCENE_DEKU_TREE }, { "Dodongo's Cavern", SCENE_DODONGOS_CAVERN }, @@ -576,8 +561,17 @@ void Randomizer::LoadMerchantMessages() { "\x08{{item}} {{price}} Rubis\x09&&\x1B%gAcheter&Ne pas acheter%w\x09\x02")); } -bool Randomizer::IsTrialRequired(RandomizerInf trial) { - return Rando::Context::GetInstance()->GetTrial(trial - RAND_INF_TRIALS_DONE_LIGHT_TRIAL)->IsRequired(); +std::map trialFlagToTrialKey = { + { EVENTCHKINF_COMPLETED_LIGHT_TRIAL, Rando::TrialKey::LIGHT_TRIAL, }, + { EVENTCHKINF_COMPLETED_FOREST_TRIAL, Rando::TrialKey::FOREST_TRIAL, }, + { EVENTCHKINF_COMPLETED_FIRE_TRIAL, Rando::TrialKey::FIRE_TRIAL, }, + { EVENTCHKINF_COMPLETED_WATER_TRIAL, Rando::TrialKey::WATER_TRIAL, }, + { EVENTCHKINF_COMPLETED_SPIRIT_TRIAL, Rando::TrialKey::SPIRIT_TRIAL, }, + { EVENTCHKINF_COMPLETED_SHADOW_TRIAL, Rando::TrialKey::SHADOW_TRIAL, } +}; + +bool Randomizer::IsTrialRequired(s32 trialFlag) { + return Rando::Context::GetInstance()->GetTrial(trialFlagToTrialKey[trialFlag])->IsRequired(); } GetItemEntry Randomizer::GetItemFromActor(s16 actorId, s16 sceneNum, s16 actorParams, GetItemID ogItemId, diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 4d5a2ff30..de7f216e6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -46,7 +46,7 @@ class Randomizer { bool SpoilerFileExists(const char* spoilerFileName); void LoadMerchantMessages(); void LoadHintMessages(); - bool IsTrialRequired(RandomizerInf trial); + bool IsTrialRequired(s32 trialFlag); u8 GetRandoSettingValue(RandomizerSettingKey randoSettingKey); RandomizerCheck GetCheckFromRandomizerInf(RandomizerInf randomizerInf); RandomizerInf GetRandomizerInfFromCheck(RandomizerCheck rc); diff --git a/soh/soh/Enhancements/randomizer/randomizer_inf.h b/soh/soh/Enhancements/randomizer/randomizer_inf.h index 465f5316c..8bd2cc7c1 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_inf.h +++ b/soh/soh/Enhancements/randomizer/randomizer_inf.h @@ -10,13 +10,6 @@ typedef enum { RAND_INF_DUNGEONS_DONE_SPIRIT_TEMPLE, RAND_INF_DUNGEONS_DONE_SHADOW_TEMPLE, - RAND_INF_TRIALS_DONE_LIGHT_TRIAL, - RAND_INF_TRIALS_DONE_FOREST_TRIAL, - RAND_INF_TRIALS_DONE_FIRE_TRIAL, - RAND_INF_TRIALS_DONE_WATER_TRIAL, - RAND_INF_TRIALS_DONE_SPIRIT_TRIAL, - RAND_INF_TRIALS_DONE_SHADOW_TRIAL, - RAND_INF_COWS_MILKED_KF_LINKS_HOUSE_COW, RAND_INF_COWS_MILKED_HF_COW_GROTTO_COW, RAND_INF_COWS_MILKED_LLR_STABLES_LEFT_COW, diff --git a/soh/soh/Enhancements/randomizer/savefile.cpp b/soh/soh/Enhancements/randomizer/savefile.cpp index 95840b15c..a43e9e2be 100644 --- a/soh/soh/Enhancements/randomizer/savefile.cpp +++ b/soh/soh/Enhancements/randomizer/savefile.cpp @@ -351,10 +351,15 @@ extern "C" void Randomizer_InitSaveFile() { gSaveContext.entranceIndex = -1; } - // If any trials aren't required, set them as completed - for (u16 i = RAND_INF_TRIALS_DONE_LIGHT_TRIAL; i <= RAND_INF_TRIALS_DONE_SHADOW_TRIAL; i++) { - if (!OTRGlobals::Instance->gRandomizer->IsTrialRequired((RandomizerInf)i)) { - Flags_SetRandomizerInf((RandomizerInf)i); + for (auto trialFlag : { EVENTCHKINF_COMPLETED_LIGHT_TRIAL, + EVENTCHKINF_COMPLETED_FOREST_TRIAL, + EVENTCHKINF_COMPLETED_FIRE_TRIAL, + EVENTCHKINF_COMPLETED_WATER_TRIAL, + EVENTCHKINF_COMPLETED_SPIRIT_TRIAL, + EVENTCHKINF_COMPLETED_SHADOW_TRIAL } + ) { + if (!OTRGlobals::Instance->gRandomizer->IsTrialRequired(trialFlag)) { + Flags_SetEventChkInf(trialFlag); } } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a01d96fed..c7e363ad7 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2359,8 +2359,8 @@ extern "C" void Randomizer_LoadMerchantMessages() { OTRGlobals::Instance->gRandomizer->LoadMerchantMessages(); } -extern "C" bool Randomizer_IsTrialRequired(RandomizerInf trial) { - return OTRGlobals::Instance->gRandomizer->IsTrialRequired(trial); +extern "C" bool Randomizer_IsTrialRequired(s32 trialFlag) { + return OTRGlobals::Instance->gRandomizer->IsTrialRequired(trialFlag); } extern "C" u32 SpoilerFileExists(const char* spoilerFileName) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index c90f07316..00b643bcb 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -159,7 +159,7 @@ FishIdentity Randomizer_IdentifyFish(s32 sceneNum, s32 actorParams); void Randomizer_ParseSpoiler(const char* fileLoc); void Randomizer_LoadHintMessages(); void Randomizer_LoadMerchantMessages(); -bool Randomizer_IsTrialRequired(RandomizerInf trial); +bool Randomizer_IsTrialRequired(s32 trialFlag); GetItemEntry Randomizer_GetItemFromActor(s16 actorId, s16 sceneNum, s16 actorParams, GetItemID ogId); GetItemEntry Randomizer_GetItemFromActorWithoutObtainabilityCheck(s16 actorId, s16 sceneNum, s16 actorParams, GetItemID ogId); GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); diff --git a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c index 01a2ab047..09a45856b 100644 --- a/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c +++ b/soh/src/overlays/actors/ovl_Demo_Kekkai/z_demo_kekkai.c @@ -64,66 +64,23 @@ static u8 sEnergyColors[] = { /* Forest prim */ 255, 255, 170, /* env */ 0, 200, 0, }; -// Translates from the barrier's actor params to their corresponding randInf flags. -RandomizerInf trialParamToRandInf(u16 params) { - switch (params) { - case KEKKAI_LIGHT: - return RAND_INF_TRIALS_DONE_LIGHT_TRIAL; - case KEKKAI_FOREST: - return RAND_INF_TRIALS_DONE_FOREST_TRIAL; - case KEKKAI_FIRE: - return RAND_INF_TRIALS_DONE_FIRE_TRIAL; - case KEKKAI_WATER: - return RAND_INF_TRIALS_DONE_WATER_TRIAL; - case KEKKAI_SPIRIT: - return RAND_INF_TRIALS_DONE_SPIRIT_TRIAL; - case KEKKAI_SHADOW: - return RAND_INF_TRIALS_DONE_SHADOW_TRIAL; - } -} - s32 DemoKekkai_CheckEventFlag(s32 params) { - static s32 eventFlags[] = { 0xC3, 0xBC, 0xBF, 0xBE, 0xBD, 0xAD, 0xBB }; + static s32 eventFlags[] = { + EVENTCHKINF_DISPELLED_GANONS_TOWER_BARRIER, + EVENTCHKINF_COMPLETED_WATER_TRIAL, + EVENTCHKINF_COMPLETED_LIGHT_TRIAL, + EVENTCHKINF_COMPLETED_FIRE_TRIAL, + EVENTCHKINF_COMPLETED_SHADOW_TRIAL, + EVENTCHKINF_COMPLETED_SPIRIT_TRIAL, + EVENTCHKINF_COMPLETED_FOREST_TRIAL, + }; if ((params < KEKKAI_TOWER) || (params > KEKKAI_FOREST)) { return true; } - if (IS_RANDO && params > KEKKAI_TOWER) { - return Flags_GetRandomizerInf(trialParamToRandInf(params)); - } return Flags_GetEventChkInf(eventFlags[params]); } -u32 TrialsDoneCount() { - u8 trialCount = 0; - - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_LIGHT_TRIAL)) { - trialCount++; - } - - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_FOREST_TRIAL)) { - trialCount++; - } - - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_FIRE_TRIAL)) { - trialCount++; - } - - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_WATER_TRIAL)) { - trialCount++; - } - - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_SPIRIT_TRIAL)) { - trialCount++; - } - - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_SHADOW_TRIAL)) { - trialCount++; - } - - return trialCount; -} - void DemoKekkai_Init(Actor* thisx, PlayState* play) { s32 pad; DemoKekkai* this = (DemoKekkai*)thisx; @@ -147,13 +104,6 @@ void DemoKekkai_Init(Actor* thisx, PlayState* play) { this->collider2.dim.radius = thisx->scale.x * 6100.0f; this->collider2.dim.height = thisx->scale.y * 5000.0f; this->collider2.dim.yShift = 300; - - if (IS_RANDO) { - if (TrialsDoneCount() == NUM_TRIALS) { - Actor_Kill(thisx); - return; - } - } break; case KEKKAI_WATER: case KEKKAI_LIGHT: @@ -161,10 +111,6 @@ void DemoKekkai_Init(Actor* thisx, PlayState* play) { case KEKKAI_SHADOW: case KEKKAI_SPIRIT: case KEKKAI_FOREST: - if (IS_RANDO && Flags_GetRandomizerInf(trialParamToRandInf(thisx->params))) { - Actor_Kill(thisx); - return; - } this->energyAlpha = 1.0f; this->orbScale = 1.0f; Actor_SetScale(thisx, 0.1f); @@ -265,18 +211,10 @@ void DemoKekkai_Update(Actor* thisx, PlayState* play2) { } void DemoKekkai_TrialBarrierDispel(Actor* thisx, PlayState* play) { - static s32 eventFlags[] = { 0xC3, 0xBC, 0xBF, 0xBE, 0xBD, 0xAD, 0xBB }; static u16 csFrames[] = { 0, 280, 280, 280, 280, 280, 280 }; s32 pad; DemoKekkai* this = (DemoKekkai*)thisx; - if (IS_RANDO) { - Flags_SetRandomizerInf(trialParamToRandInf(thisx->params)); - // May or may not be needed. Not sure if needed for anything - // that randoInf isn't already covering. Leaving it for safety. - Flags_SetEventChkInf(eventFlags[thisx->params]); - } - if (play->csCtx.frames == csFrames[this->actor.params]) { func_800F3F3C(0xA); } diff --git a/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index eefaf9c0c..2600acd6b 100644 --- a/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -136,27 +136,6 @@ void ObjectKankyo_Init(Actor* thisx, PlayState* play) { this->effects[5].size = 0.0f; } - if (IS_RANDO) { - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_FOREST_TRIAL)) { - this->effects[0].size = 0.0f; - } - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_WATER_TRIAL)) { - this->effects[1].size = 0.0f; - } - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_SHADOW_TRIAL)) { - this->effects[2].size = 0.0f; - } - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_FIRE_TRIAL)) { - this->effects[3].size = 0.0f; - } - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_LIGHT_TRIAL)) { - this->effects[4].size = 0.0f; - } - if (Flags_GetRandomizerInf(RAND_INF_TRIALS_DONE_SPIRIT_TRIAL)) { - this->effects[5].size = 0.0f; - } - } - if (gSaveContext.cutsceneTrigger != 0) { if (gSaveContext.entranceIndex == ENTR_INSIDE_GANONS_CASTLE_2) { this->effects[0].size = 0.1f;