Move obtainability check up higher

This commit is contained in:
Garrett Cox 2022-08-29 17:42:48 -05:00
parent 8c6774fa35
commit c7207d2e0a
3 changed files with 17 additions and 11 deletions

View File

@ -1194,8 +1194,8 @@ s16 Randomizer::GetItemFromActor(s16 actorId, s16 actorParams, s16 sceneNum, Get
return GetItemIDFromRandomizerGet(this->itemLocations[GetCheckFromActor(sceneNum, actorId, actorParams)], ogItemId);
}
CanObtainResult Randomizer::CanObtainRandomizerGet(RandomizerGet randoGet) {
switch (randoGet) {
CanObtainResult Randomizer::GetCanObtainFromRandomizerCheck(RandomizerCheck randomizerCheck) {
switch (this->itemLocations[randomizerCheck]) {
case RG_NONE:
case RG_TRIFORCE:
case RG_HINT:
@ -1532,12 +1532,6 @@ CanObtainResult Randomizer::CanObtainRandomizerGet(RandomizerGet randoGet) {
}
GetItemID Randomizer::GetItemIDFromRandomizerGet(RandomizerGet randoGet, GetItemID ogItemId) {
CanObtainResult canObtain = Randomizer::CanObtainRandomizerGet(randoGet);
if (canObtain != CAN_OBTAIN) {
return GI_RUPEE_BLUE;
}
switch (randoGet) {
case RG_NONE:
return ogItemId;

View File

@ -21,7 +21,6 @@ class Randomizer {
std::string ganonText;
std::unordered_map<RandomizerSettingKey, u8> randoSettings;
std::unordered_map<RandomizerCheck, u16> randomizerMerchantPrices;
CanObtainResult CanObtainRandomizerGet(RandomizerGet randoGet);
GetItemID GetItemIDFromRandomizerGet(RandomizerGet randoGet, GetItemID ogItemId);
s16 GetItemFromActor(s16 actorId, s16 actorParams, s16 sceneNum, GetItemID ogItemId);
void ParseRandomizerSettingsFile(const char* spoilerFileName);
@ -59,6 +58,7 @@ class Randomizer {
ScrubIdentity IdentifyScrub(s32 sceneNum, s32 actorParams, s32 respawnData);
s16 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
s16 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum);
CanObtainResult GetCanObtainFromRandomizerCheck(RandomizerCheck randomizerCheck);
static void CreateCustomMessages();
static std::string RandomizeRupeeName(std::string message, int language);
static CustomMessageEntry GetRupeeMessage(u16 rupeeTextId);

View File

@ -1631,13 +1631,19 @@ extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 tableID, s16 getItemID) {
extern "C" GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) {
s16 getItemModIndex;
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(
OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) {
RandomizerCheck randomizerCheck = OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams);
if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) {
getItemModIndex = MOD_NONE;
} else {
getItemModIndex = MOD_RANDOMIZER;
}
s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum);
// This feels awkward, maybe in the future each mod will have it's own obtainability check
if (OTRGlobals::Instance->gRandomizer->GetCanObtainFromRandomizerCheck(randomizerCheck) != CAN_OBTAIN) {
return ItemTable_RetrieveEntry(MOD_NONE, GI_RUPEE_BLUE);
}
return ItemTable_RetrieveEntry(getItemModIndex, itemID);
}
@ -1649,6 +1655,12 @@ extern "C" GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomi
getItemModIndex = MOD_RANDOMIZER;
}
s16 itemID = OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId);
// This feels awkward, maybe in the future each mod will have it's own obtainability check
if (OTRGlobals::Instance->gRandomizer->GetCanObtainFromRandomizerCheck(randomizerCheck) != CAN_OBTAIN) {
return ItemTable_RetrieveEntry(MOD_NONE, GI_RUPEE_BLUE);
}
return ItemTable_RetrieveEntry(getItemModIndex, itemID);
}