diff --git a/soh/include/functions.h b/soh/include/functions.h index 086b98939..be9e2bb1b 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -452,7 +452,9 @@ u32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx); s8 func_8002F368(GlobalContext* globalCtx); void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y); u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); -s32 GiveItemWithoutActor(GlobalContext* globalCtx, s32 getItemId); +s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry); +s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange); +void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry); s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange); void func_8002F554(Actor* actor, GlobalContext* globalCtx, s32 getItemId); void func_8002F580(Actor* actor, GlobalContext* globalCtx); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 9a189bfa3..747a63421 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1618,15 +1618,6 @@ extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 tableID, s16 getItemID) { return ItemTableManager::Instance->RetrieveItemEntry(tableID, getItemID); } -extern "C" s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) { - if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(OTRGlobals::Instance->gRandomizer->GetCheckFromActor(sceneNum, actorId, actorParams))) { - OTRGlobals::Instance->getItemModIndex = MOD_NONE; - } else { - OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER; - } - return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId, actorParams, sceneNum); -} - extern "C" GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum) { s16 getItemModIndex; if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem( @@ -1639,15 +1630,6 @@ extern "C" GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId return ItemTable_RetrieveEntry(getItemModIndex, itemID); } -extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) { - if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) { - OTRGlobals::Instance->getItemModIndex = MOD_NONE; - } else { - OTRGlobals::Instance->getItemModIndex = MOD_RANDOMIZER; - } - return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); -} - extern "C" GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId) { s16 getItemModIndex; if (OTRGlobals::Instance->gRandomizer->CheckContainsVanillaItem(randomizerCheck)) { @@ -1661,11 +1643,11 @@ extern "C" GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomi extern "C" bool Randomizer_ObtainedFreestandingIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId, Actor* actor) { return gSaveContext.n64ddFlag && (actor->parent != NULL) && - Randomizer_GetItemIdFromKnownCheck(randomizerCheck, ogId) == GI_ICE_TRAP; + Randomizer_GetItemFromKnownCheck(randomizerCheck, ogId).getItemId == RG_ICE_TRAP; } extern "C" bool Randomizer_ItemIsIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId) { - return gSaveContext.n64ddFlag && Randomizer_GetItemIdFromKnownCheck(randomizerCheck, ogId) == GI_ICE_TRAP; + return gSaveContext.n64ddFlag && Randomizer_GetItemFromKnownCheck(randomizerCheck, ogId).getItemId == RG_ICE_TRAP; } extern "C" CustomMessageEntry Randomizer_GetCustomGetItemMessage(GetItemID giid, char* buffer, const int maxBufferSize) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index f29d7dc97..750dd911e 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -98,10 +98,7 @@ u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); RandomizerCheck Randomizer_GetCheckFromActor(s16 actorId, s16 actorParams, s16 sceneNum); void Randomizer_LoadHintLocations(const char* spoilerFileName); void Randomizer_LoadItemLocations(const char* spoilerFileName, bool silent); -s16 Randomizer_GetItemModelFromId(s16 itemId); -s32 Randomizer_GetItemIDFromGetItemID(s32 getItemId); -s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); -s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); +s32 Randomizer_GetItemIDFromGetItemID(s32 getItemId); // TODO: Remove me GetItemEntry Randomizer_GetRandomizedItem(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); bool Randomizer_ObtainedFreestandingIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId, Actor* actor); diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 5bfa6572e..559f7ec69 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -1955,15 +1955,16 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { } } -s32 GiveItemWithoutActor(GlobalContext* globalCtx, s32 getItemId) { +s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry) { Player* player = GET_PLAYER(globalCtx); if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { - if (((player->heldActor != NULL) && ((getItemId > GI_NONE) && (getItemId < GI_MAX)) || - (gSaveContext.n64ddFlag && (getItemId > RG_NONE) && (getItemId < RG_MAX))) || + if (((player->heldActor != NULL) && ((getItemEntry.getItemId > GI_NONE) && (getItemEntry.getItemId < GI_MAX)) || + (gSaveContext.n64ddFlag && (getItemEntry.getItemId > RG_NONE) && (getItemEntry.getItemId < RG_MAX))) || (!(player->stateFlags1 & 0x20000800))) { - if ((getItemId != GI_NONE)) { - player->getItemId = getItemId; + if ((getItemEntry.getItemId != GI_NONE)) { + player->getItemEntry = getItemEntry; + player->getItemId = getItemEntry.getItemId; player->interactRangeActor = &player->actor; player->getItemDirection = player->actor.shape.rot.y; return true; @@ -1974,6 +1975,38 @@ s32 GiveItemWithoutActor(GlobalContext* globalCtx, s32 getItemId) { return false; } +s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if ((((player->heldActor != NULL) || (actor == player->targetActor)) && + ((!gSaveContext.n64ddFlag && ((getItemEntry.getItemId > GI_NONE) && (getItemEntry.getItemId < GI_MAX))) || + (gSaveContext.n64ddFlag && ((getItemEntry.getItemId > RG_NONE) && (getItemEntry.getItemId < RG_MAX))))) || + (!(player->stateFlags1 & 0x20000800))) { + if ((actor->xzDistToPlayer < xzRange) && (fabsf(actor->yDistToPlayer) < yRange)) { + s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; + s32 absYawDiff = ABS(yawDiff); + + if ((getItemEntry.getItemId != GI_NONE) || (player->getItemDirection < absYawDiff)) { + player->getItemEntry = getItemEntry; + player->getItemId = getItemEntry.getItemId; + player->interactRangeActor = actor; + player->getItemDirection = absYawDiff; + return true; + } + } + } + } + + return false; +} + +void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry) { + GiveItemEntryFromActor(actor, globalCtx, getItemEntry, 50.0f, 10.0f); +} + +// TODO: Rename to GiveItemIdFromActor or similar +// If you're doing something for randomizer, you're probably looking for GiveItemEntryFromActor s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(globalCtx); @@ -1998,6 +2031,8 @@ s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzR return false; } +// TODO: Rename to GiveItemIdFromActorWithFixedRange or similar +// If you're doing something for randomizer, you're probably looking for GiveItemEntryFromActorWithFixedRange void func_8002F554(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { func_8002F434(actor, globalCtx, getItemId, 50.0f, 10.0f); } diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index 5245e45c0..478ce891e 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -512,8 +512,11 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { if ((gSaveContext.n64ddFlag || getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum); getItemId = getItem.getItemId; - func_8002F554(&this->actor, globalCtx, getItemId); - GET_PLAYER(globalCtx)->getItemEntry = getItem; + if (!gSaveContext.n64ddFlag) { + func_8002F554(&this->actor, globalCtx, getItemId); + } else { + GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem); + } } EnItem00_SetupAction(this, func_8001E5C8); @@ -668,10 +671,15 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) { void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(this->getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum); if (this->getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, globalCtx)) { - func_8002F434(&this->actor, globalCtx, this->getItemId, 50.0f, 80.0f); + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 50.0f, 80.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 50.0f, 80.0f); + } this->unk_15A++; } else { this->getItemId = GI_NONE; @@ -884,12 +892,13 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { params = &this->actor.params; if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { - if (gSaveContext.n64ddFlag) { + if (!gSaveContext.n64ddFlag) { + func_8002F554(&this->actor, globalCtx, getItemId); + } else { getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum); - GET_PLAYER(globalCtx)->getItemEntry = getItem; getItemId = getItem.getItemId; + GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem); } - func_8002F554(&this->actor, globalCtx, getItemId); } switch (*params) { diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index fb35c5209..8156f06e6 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -201,8 +201,8 @@ void GivePlayerRandoRewardSongOfTime(GlobalContext* globalCtx, RandomizerCheck c if (gSaveContext.entranceIndex == 0x050F && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && !Flags_GetTreasure(globalCtx, 0x1F) && gSaveContext.nextTransition == 0xFF) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_SONG_OF_TIME); - GiveItemWithoutActor(globalCtx, getItemId); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); player->pendingFlag.flagID = 0x1F; player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } @@ -216,8 +216,8 @@ void GivePlayerRandoRewardNocturne(GlobalContext* globalCtx, RandomizerCheck che gSaveContext.entranceIndex == 0x0195) && LINK_IS_ADULT && CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST) && CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_QUEST_ITEM(QUEST_MEDALLION_WATER) && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && !Flags_GetEventChkInf(0xAA)) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_NOCTURNE_OF_SHADOW); - GiveItemWithoutActor(globalCtx, getItemId); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_NOCTURNE_OF_SHADOW); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetEventChkInf(0xAA); } } @@ -228,8 +228,8 @@ void GivePlayerRandoRewardRequiem(GlobalContext* globalCtx, RandomizerCheck chec if ((gSaveContext.gameMode == 0) && (gSaveContext.respawnFlag <= 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) { if ((gSaveContext.entranceIndex == 0x01E1) && !Flags_GetEventChkInf(0xAC) && player != NULL && !Player_InBlockingCsMode(globalCtx, player)) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_SONG_OF_TIME); - GiveItemWithoutActor(globalCtx, getItemId); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetEventChkInf(0xAC); } } @@ -243,8 +243,7 @@ void GivePlayerRandoRewardZeldaLightArrowsGift(GlobalContext* globalCtx, Randomi !Flags_GetTreasure(globalCtx, 0x1E) && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && globalCtx->sceneLoadFlag == 0) { GetItemEntry getItem = Randomizer_GetItemFromKnownCheck(check, GI_ARROW_LIGHT); - if (player->pendingFlag.flagType == FLAG_NONE && GiveItemWithoutActor(globalCtx, getItem.getItemId)) { - player->getItemEntry = getItem; + if (player->pendingFlag.flagType == FLAG_NONE && GiveItemEntryWithoutActor(globalCtx, getItem)) { player->pendingFlag.flagID = 0x1E; player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } @@ -254,11 +253,11 @@ void GivePlayerRandoRewardZeldaLightArrowsGift(GlobalContext* globalCtx, Randomi void GivePlayerRandoRewardSariaGift(GlobalContext* globalCtx, RandomizerCheck check) { Player* player = GET_PLAYER(globalCtx); if (gSaveContext.entranceIndex == 0x05E0) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_ZELDAS_LULLABY); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_ZELDAS_LULLABY); - if ((!Flags_GetEventChkInf(0xC1) || (player->getItemId == getItemId && getItemId != GI_ICE_TRAP)) && + if ((!Flags_GetEventChkInf(0xC1) || (player->getItemId == getItemEntry.getItemId && getItemEntry.getItemId != GI_ICE_TRAP)) && player != NULL && !Player_InBlockingCsMode(globalCtx, player)) { - GiveItemWithoutActor(globalCtx, getItemId); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetEventChkInf(0xC1); } } diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index d368e8d94..6e58af4d0 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -417,9 +417,9 @@ void GiveLinkDungeonReward(uint16_t getItemId) { } void GiveLinksPocketMedallion() { - RandomizerGet getItemId = Randomizer_GetItemIdFromKnownCheck(RC_LINKS_POCKET, RG_NONE); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LINKS_POCKET, RG_NONE); - GiveLinkDungeonReward(getItemId); + GiveLinkDungeonReward(getItemEntry.getItemId); } /** diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 0f1713ba8..e04755a34 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -70,14 +70,14 @@ const ActorInit Bg_Dy_Yoseizo_InitVars = { void GivePlayerRandoRewardGreatFairy(BgDyYoseizo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - GetItemID getItemId = Randomizer_GetRandomizedItemId(GI_NONE, this->actor.id, this->fountainType + 1, globalCtx->sceneNum); + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_NONE, this->actor.id, this->fountainType + 1, globalCtx->sceneNum); if (this->actor.parent == GET_PLAYER(globalCtx) && !Flags_GetTreasure(globalCtx, this->fountainType + 1) && !Player_InBlockingCsMode(globalCtx, GET_PLAYER(globalCtx))) { Flags_SetTreasure(globalCtx, this->fountainType + 1); Actor_Kill(&this->actor); } else if (!Flags_GetTreasure(globalCtx, this->fountainType + 1)) { - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } } diff --git a/soh/src/overlays/actors/ovl_Demo_Im/z_demo_im.c b/soh/src/overlays/actors/ovl_Demo_Im/z_demo_im.c index 7526ac2ea..93007f547 100644 --- a/soh/src/overlays/actors/ovl_Demo_Im/z_demo_im.c +++ b/soh/src/overlays/actors/ovl_Demo_Im/z_demo_im.c @@ -899,13 +899,13 @@ void func_80986BF8(DemoIm* this, GlobalContext* globalCtx) { } void GivePlayerRandoRewardImpa(Actor* impa, GlobalContext* globalCtx, RandomizerCheck check) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_ZELDAS_LULLABY); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_ZELDAS_LULLABY); if (impa->parent != NULL && impa->parent->id == GET_PLAYER(globalCtx)->actor.id && !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F) && !Randomizer_GetSettingValue(RSK_SKIP_CHILD_ZELDA)) { - func_8002F434(impa, globalCtx, getItemId, 75.0f, 50.0f); + GiveItemEntryFromActor(impa, globalCtx, getItemEntry, 75.0f, 50.0f); } else if (!Player_InBlockingCsMode(globalCtx, GET_PLAYER(globalCtx))) { gSaveContext.eventChkInf[5] |= 0x200; globalCtx->sceneLoadFlag = 0x14; diff --git a/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 291208752..5130f1ca8 100644 --- a/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/soh/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -462,13 +462,13 @@ s32 DoorWarp1_PlayerInRange(DoorWarp1* this, GlobalContext* globalCtx) { } void GivePlayerRandoReward(DoorWarp1* this, Player* player, GlobalContext* globalCtx, u8 ruto, u8 adult) { - GetItemID getItemId = Randomizer_GetRandomizedItemId(GI_NONE, this->actor.id, this->actor.params, globalCtx->sceneNum); + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_NONE, this->actor.id, this->actor.params, globalCtx->sceneNum); if (this->actor.parent != NULL && this->actor.parent->id == GET_PLAYER(globalCtx)->actor.id && !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } else if (!Player_InBlockingCsMode(globalCtx, GET_PLAYER(globalCtx))) { if (adult) { OnePointCutscene_Init(globalCtx, 0x25E8, 999, &this->actor, MAIN_CAM); diff --git a/soh/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/soh/src/overlays/actors/ovl_En_Ani/z_en_ani.c index b5c7d8a4a..5debc658e 100644 --- a/soh/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/soh/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -126,11 +126,11 @@ void func_809B0558(EnAni* this, GlobalContext* globalCtx) { } gSaveContext.itemGetInf[1] |= 0x20; } else { - if (gSaveContext.n64ddFlag) { - s32 getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_MAN_ON_ROOF, GI_HEART_PIECE); - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 200.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 200.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_MAN_ON_ROOF, GI_HEART_PIECE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 200.0f); } } } @@ -140,11 +140,11 @@ void func_809B05F0(EnAni* this, GlobalContext* globalCtx) { EnAni_SetupAction(this, func_809B0558); } - if (gSaveContext.n64ddFlag) { - s32 getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_MAN_ON_ROOF, GI_HEART_PIECE); - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 200.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 200.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_MAN_ON_ROOF, GI_HEART_PIECE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 200.0f); } } diff --git a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c index ee9ce1329..321f76810 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c +++ b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c @@ -177,6 +177,7 @@ void EnBomBowlPit_GivePrize(EnBomBowlPit* this, GlobalContext* globalCtx) { func_8002DF54(globalCtx, NULL, 7); this->getItemId = sGetItemIds[this->prizeIndex]; + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; if ((this->getItemId == GI_BOMB_BAG_30) && (CUR_CAPACITY(UPG_BOMB_BAG) == 30)) { this->getItemId = GI_BOMB_BAG_40; @@ -185,22 +186,27 @@ void EnBomBowlPit_GivePrize(EnBomBowlPit* this, GlobalContext* globalCtx) { if (gSaveContext.n64ddFlag) { switch (this->prizeIndex) { case EXITEM_BOMB_BAG_BOWLING: - this->getItemId = - Randomizer_GetItemIdFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_FIRST_PRIZE, GI_BOMB_BAG_20); + this->getItemId = this->getItemEntry.getItemId; break; case EXITEM_HEART_PIECE_BOWLING: - this->getItemId = - Randomizer_GetItemIdFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE); + this->getItemId = this->getItemEntry.getItemId; break; case EXITEM_BOMBCHUS_BOWLING: - this->getItemId = Randomizer_GetItemIdFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS, GI_BOMBCHUS_10); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_BOMBCHUS, GI_BOMBCHUS_10); + this->getItemId = this->getItemEntry.getItemId; break; } } player->stateFlags1 &= ~0x20000000; this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, 2000.0f, 1000.0f); + } player->stateFlags1 |= 0x20000000; this->actionFunc = EnBomBowlPit_WaitTillPrizeGiven; } @@ -209,7 +215,11 @@ void EnBomBowlPit_WaitTillPrizeGiven(EnBomBowlPit* this, GlobalContext* globalCt if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = EnBomBowlPit_Reset; } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, 2000.0f, 1000.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h index af5d8d3e1..fd7c03be4 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h +++ b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.h @@ -33,6 +33,7 @@ typedef struct EnBomBowlPit { /* 0x01D4 */ Vec3f unk_1D4; // camera eye (maxsteps) /* 0x01E0 */ EnExItem* exItem; /* 0x01E4 */ char unk_1E4[0x3520]; + /* */ GetItemEntry getItemEntry; } EnBomBowlPit; // size = 0x3704 #endif diff --git a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c index b6c110581..a3e384ec5 100644 --- a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -446,7 +446,7 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { func_8002DBD0(&this->dyna.actor, &sp4C, &player->actor.world.pos); if (sp4C.z > -50.0f && sp4C.z < 0.0f && fabsf(sp4C.y) < 10.0f && fabsf(sp4C.x) < 20.0f && Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { - sItem = Randomizer_GetRandomizedItemId(this->dyna.actor.params >> 5 & 0x7F, this->dyna.actor.id, this->dyna.actor.params, globalCtx->sceneNum); + sItem = Randomizer_GetRandomizedItem(this->dyna.actor.params >> 5 & 0x7F, this->dyna.actor.id, this->dyna.actor.params, globalCtx->sceneNum).getItemId; // RANDOTODO treasure chest game rando if (Randomizer_GetSettingValue(RSK_SHUFFLE_CHEST_MINIGAME)) { diff --git a/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c b/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c index 9f43a5f54..1f0d47d7a 100644 --- a/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c +++ b/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c @@ -453,7 +453,12 @@ void func_809EEA00(EnDivingGame* this, GlobalContext* globalCtx) { if ((this->unk_292 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx))) { Message_CloseTextbox(globalCtx); this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_ZD_DIVING_MINIGAME, GI_SCALE_SILVER) : GI_SCALE_SILVER, 90.0f, 10.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_DIVING_MINIGAME, GI_SCALE_SILVER); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 90.0f, 10.0f); + } this->actionFunc = func_809EEA90; } } @@ -463,7 +468,12 @@ void func_809EEA90(EnDivingGame* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_809EEAF8; } else { - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_ZD_DIVING_MINIGAME, GI_SCALE_SILVER) : GI_SCALE_SILVER, 90.0f, 10.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_DIVING_MINIGAME, GI_SCALE_SILVER); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 90.0f, 10.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c index a89d583ae..d3a924356 100644 --- a/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -371,7 +371,8 @@ void EnDns_Talk(EnDns* this, GlobalContext* globalCtx) { void func_809EFDD0(EnDns* this, GlobalContext* globalCtx) { if (this->actor.params == 0x9) { if (gSaveContext.n64ddFlag) { - func_8002F434(&this->actor, globalCtx, Randomizer_GetRandomizedItemId(GI_STICK_UPGRADE_30, this->actor.id, this->actor.params, globalCtx->sceneNum), 130.0f, 100.0f); + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_STICK_UPGRADE_30, this->actor.id, this->actor.params, globalCtx->sceneNum); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 130.0f, 100.0f); } else if (CUR_UPG_VALUE(UPG_STICKS) < 2) { func_8002F434(&this->actor, globalCtx, GI_STICK_UPGRADE_20, 130.0f, 100.0f); } else { @@ -379,14 +380,20 @@ void func_809EFDD0(EnDns* this, GlobalContext* globalCtx) { } } else if (this->actor.params == 0xA) { if (gSaveContext.n64ddFlag) { - func_8002F434(&this->actor, globalCtx, Randomizer_GetRandomizedItemId(GI_NUT_UPGRADE_40, this->actor.id, this->actor.params, globalCtx->sceneNum), 130.0f, 100.0f); + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_NUT_UPGRADE_40, this->actor.id, this->actor.params, globalCtx->sceneNum); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 130.0f, 100.0f); } else if (CUR_UPG_VALUE(UPG_NUTS) < 2) { func_8002F434(&this->actor, globalCtx, GI_NUT_UPGRADE_30, 130.0f, 100.0f); } else { func_8002F434(&this->actor, globalCtx, GI_NUT_UPGRADE_40, 130.0f, 100.0f); } } else { - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetRandomizedItemId(this->dnsItemEntry->getItemId, this->actor.id, this->actor.params, globalCtx->sceneNum) : this->dnsItemEntry->getItemId, 130.0f, 100.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, this->dnsItemEntry->getItemId, 130.0f, 100.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(this->dnsItemEntry->getItemId, this->actor.id, this->actor.params, globalCtx->sceneNum); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 130.0f, 100.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c b/soh/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c index 6d3a4accd..c50e1ec77 100644 --- a/soh/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c +++ b/soh/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c @@ -139,13 +139,15 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_SKULL: if (!Flags_GetTreasure(globalCtx, 0x1F)) { - GiveItemWithoutActor(globalCtx, Randomizer_GetItemIdFromKnownCheck(RC_DEKU_THEATER_SKULL_MASK, GI_STICK_UPGRADE_30)); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_DEKU_THEATER_SKULL_MASK, GI_STICK_UPGRADE_30); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetTreasure(globalCtx, 0x1F); } break; case PLAYER_MASK_TRUTH: if (!Flags_GetTreasure(globalCtx, 0x1E)) { - GiveItemWithoutActor(globalCtx, Randomizer_GetItemIdFromKnownCheck(RC_DEKU_THEATER_MASK_OF_TRUTH, GI_NUT_UPGRADE_40)); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_DEKU_THEATER_MASK_OF_TRUTH, GI_NUT_UPGRADE_40); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetTreasure(globalCtx, 0x1E); } break; diff --git a/soh/src/overlays/actors/ovl_En_Du/z_en_du.c b/soh/src/overlays/actors/ovl_En_Du/z_en_du.c index e7f9b51aa..b1953bc74 100644 --- a/soh/src/overlays/actors/ovl_En_Du/z_en_du.c +++ b/soh/src/overlays/actors/ovl_En_Du/z_en_du.c @@ -548,7 +548,12 @@ void func_809FEC70(EnDu* this, GlobalContext* globalCtx) { EnDu_SetupAction(this, func_809FECE4); } else { f32 xzRange = this->actor.xzDistToPlayer + 1.0f; - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_GC_DARUNIAS_JOY, GI_BRACELET) : GI_BRACELET, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_BRACELET, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GC_DARUNIAS_JOY, GI_BRACELET); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c b/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c index 34f16e8df..b8396a573 100644 --- a/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c +++ b/soh/src/overlays/actors/ovl_En_Ex_Item/z_en_ex_item.c @@ -399,6 +399,7 @@ void EnExItem_TargetPrizeApproach(EnExItem* this, GlobalContext* globalCtx) { this->actor.world.pos.z += (tmpf3 / tmpf4) * 5.0f; } } else { + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; s32 getItemId; this->actor.draw = NULL; @@ -406,7 +407,8 @@ void EnExItem_TargetPrizeApproach(EnExItem* this, GlobalContext* globalCtx) { this->actor.parent = NULL; if (gSaveContext.n64ddFlag) { GET_PLAYER(globalCtx)->stateFlags1 &= ~(PLAYER_STATE1_10 | PLAYER_STATE1_11); - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50); + getItemId = getItemEntry.getItemId; } else { if (CUR_UPG_VALUE(UPG_BULLET_BAG) == 1) { getItemId = GI_BULLET_BAG_40; @@ -414,24 +416,28 @@ void EnExItem_TargetPrizeApproach(EnExItem* this, GlobalContext* globalCtx) { getItemId = GI_BULLET_BAG_50; } } - func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 2000.0f, 1000.0f); + } this->actionFunc = EnExItem_TargetPrizeGive; } } void EnExItem_TargetPrizeGive(EnExItem* this, GlobalContext* globalCtx) { - s32 getItemId; - if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = EnExItem_TargetPrizeFinish; } else { - if (gSaveContext.n64ddFlag) { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50); + if (!gSaveContext.n64ddFlag) { + s32 getItemId = (CUR_UPG_VALUE(UPG_BULLET_BAG) == 2) ? GI_BULLET_BAG_50 : GI_BULLET_BAG_40; + func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); } else { - getItemId = (CUR_UPG_VALUE(UPG_BULLET_BAG) == 2) ? GI_BULLET_BAG_50 : GI_BULLET_BAG_40; + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LW_TARGET_IN_WOODS, GI_BULLET_BAG_50); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 2000.0f, 1000.0f); } - func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); } } diff --git a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c index e6a85b331..9f945a51f 100644 --- a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -601,6 +601,7 @@ void EnFr_Idle(EnFr* this, GlobalContext* globalCtx) { player->actor.world.pos.z = this->actor.world.pos.z; // z = -1220.0f player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; this->reward = GI_NONE; + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; this->actionFunc = EnFr_Activate; } else if (EnFr_IsAboveAndWithin30DistXZ(player, this)) { player->unk_6A8 = &this->actor; @@ -836,6 +837,7 @@ s32 EnFr_IsFrogSongComplete(EnFr* this, GlobalContext* globalCtx) { void EnFr_OcarinaMistake(EnFr* this, GlobalContext* globalCtx) { Message_CloseTextbox(globalCtx); this->reward = GI_NONE; + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; func_80078884(NA_SE_SY_OCARINA_ERROR); Audio_OcaSetInstrument(0); sEnFrPointers.flags = 12; @@ -927,6 +929,7 @@ void EnFr_SetReward(EnFr* this, GlobalContext* globalCtx) { songIndex = this->songIndex; this->actionFunc = EnFr_Deactivate; this->reward = GI_NONE; + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; if ((songIndex >= FROG_ZL) && (songIndex <= FROG_SOT)) { if (!(gSaveContext.eventChkInf[13] & sSongIndex[songIndex])) { gSaveContext.eventChkInf[13] |= sSongIndex[songIndex]; @@ -940,7 +943,8 @@ void EnFr_SetReward(EnFr* this, GlobalContext* globalCtx) { if (!gSaveContext.n64ddFlag) { this->reward = GI_HEART_PIECE; } else { - this->reward = Randomizer_GetItemIdFromKnownCheck(RC_ZR_FROGS_IN_THE_RAIN, GI_HEART_PIECE); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZR_FROGS_IN_THE_RAIN, GI_HEART_PIECE); + this->reward = this->getItemEntry.getItemId; } } else { this->reward = GI_RUPEE_BLUE; @@ -951,7 +955,8 @@ void EnFr_SetReward(EnFr* this, GlobalContext* globalCtx) { if (!gSaveContext.n64ddFlag) { this->reward = GI_HEART_PIECE; } else { - this->reward = Randomizer_GetItemIdFromKnownCheck(RC_ZR_FROGS_OCARINA_GAME, GI_HEART_PIECE); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZR_FROGS_OCARINA_GAME, GI_HEART_PIECE); + this->reward = this->getItemEntry.getItemId; } } else { this->reward = GI_RUPEE_PURPLE; @@ -1002,7 +1007,11 @@ void EnFr_Deactivate(EnFr* this, GlobalContext* globalCtx) { this->actionFunc = EnFr_Idle; } else { this->actionFunc = EnFr_GiveReward; - func_8002F434(&this->actor, globalCtx, this->reward, 30.0f, 100.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->reward, 30.0f, 100.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, 30.0f, 100.0f); + } } } @@ -1011,7 +1020,11 @@ void EnFr_GiveReward(EnFr* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnFr_SetIdle; } else { - func_8002F434(&this->actor, globalCtx, this->reward, 30.0f, 100.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->reward, 30.0f, 100.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, 30.0f, 100.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h index 154aefc17..972c32e49 100644 --- a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h +++ b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.h @@ -73,6 +73,7 @@ typedef struct EnFr { /* 0x03AA */ s16 xyAngleButterfly; // Butterfly Travels along random angles in the x-y plane /* 0x03AC */ Vec3f posButterfly; // Position/Coordinates of the Butterfly /* 0x03B8 */ Vec3f posButterflyLight; // Used in Lights_PointNoGlowSetInfo() + /* */ GetItemEntry getItemEntry; } EnFr; // size = 0x03C4 typedef struct { diff --git a/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 54977add1..28aa94c0e 100644 --- a/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -154,8 +154,8 @@ void GivePlayerRandoRewardSongOfStorms(EnFu* windmillGuy, GlobalContext* globalC Flags_SetTreasure(globalCtx, 0x1F); windmillGuy->actionFunc = func_80A1DBD4; } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_SONG_OF_STORMS); - func_8002F434(&windmillGuy->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_STORMS); + GiveItemEntryFromActor(&windmillGuy->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } } diff --git a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c index 31fe04e90..f2b6c8638 100644 --- a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c +++ b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c @@ -353,7 +353,12 @@ void func_80A2FA50(EnGb* this, GlobalContext* globalCtx) { void func_80A2FB40(EnGb* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE && Message_ShouldAdvance(globalCtx)) { - func_8002F434(&this->dyna.actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE) : GI_BOTTLE, 100.0f, 10.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE); + GiveItemEntryFromActor(&this->dyna.actor, globalCtx, getItemEntry, 100.0f, 10.0f); + } this->actionFunc = func_80A2FBB0; } } @@ -363,7 +368,12 @@ void func_80A2FBB0(EnGb* this, GlobalContext* globalCtx) { this->dyna.actor.parent = NULL; this->actionFunc = func_80A2FC0C; } else { - func_8002F434(&this->dyna.actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE) : GI_BOTTLE, 100.0f, 10.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE); + GiveItemEntryFromActor(&this->dyna.actor, globalCtx, getItemEntry, 100.0f, 10.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index d34fb977b..1c57922b1 100644 --- a/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -502,6 +502,7 @@ void EnGe1_SetupWait_Archery(EnGe1* this, GlobalContext* globalCtx) { } void EnGe1_WaitTillItemGiven_Archery(EnGe1* this, GlobalContext* globalCtx) { + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; s32 getItemId; if (Actor_HasParent(&this->actor, globalCtx)) { @@ -533,21 +534,28 @@ void EnGe1_WaitTillItemGiven_Archery(EnGe1* this, GlobalContext* globalCtx) { break; } } else { - getItemId = Randomizer_GetItemIdFromKnownCheck( - RC_GF_HBA_1500_POINTS, CUR_UPG_VALUE(UPG_QUIVER) == 1 ? GI_QUIVER_40 : GI_QUIVER_50); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_HBA_1500_POINTS, CUR_UPG_VALUE(UPG_QUIVER) == 1 ? GI_QUIVER_40 : GI_QUIVER_50); + getItemId = getItemEntry.getItemId; } } else { if (!gSaveContext.n64ddFlag) { getItemId = GI_HEART_PIECE; } else { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_GF_HBA_1000_POINTS, GI_HEART_PIECE); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_HBA_1000_POINTS, GI_HEART_PIECE); + getItemId = getItemEntry.getItemId; } } - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); + + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId != GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } void EnGe1_BeginGiveItem_Archery(EnGe1* this, GlobalContext* globalCtx) { + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; s32 getItemId; if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { @@ -567,18 +575,23 @@ void EnGe1_BeginGiveItem_Archery(EnGe1* this, GlobalContext* globalCtx) { break; } } else { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_GF_HBA_1500_POINTS, - CUR_UPG_VALUE(UPG_QUIVER) == 1 ? GI_QUIVER_40 : GI_QUIVER_50); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_HBA_1500_POINTS, CUR_UPG_VALUE(UPG_QUIVER) == 1 ? GI_QUIVER_40 : GI_QUIVER_50); + getItemId = getItemEntry.getItemId; } } else { if (!gSaveContext.n64ddFlag) { getItemId = GI_HEART_PIECE; } else { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_GF_HBA_1000_POINTS, GI_HEART_PIECE); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_HBA_1000_POINTS, GI_HEART_PIECE); + getItemId = getItemEntry.getItemId; } } - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId != GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } void EnGe1_TalkWinPrize_Archery(EnGe1* this, GlobalContext* globalCtx) { diff --git a/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index 5310fc65e..9fc4ce295 100644 --- a/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -457,7 +457,12 @@ void EnGe2_WaitTillCardGiven(EnGe2* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnGe2_SetActionAfterTalk; } else { - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD) : GI_GERUDO_CARD, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } @@ -466,7 +471,12 @@ void EnGe2_GiveCard(EnGe2* this, GlobalContext* globalCtx) { Message_CloseTextbox(globalCtx); this->actor.flags &= ~ACTOR_FLAG_16; this->actionFunc = EnGe2_WaitTillCardGiven; - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD) : GI_GERUDO_CARD, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/soh/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index 556e7c203..261ce49ec 100644 --- a/soh/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/soh/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -142,7 +142,12 @@ void EnGe3_WaitTillCardGiven(EnGe3* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnGe3_Wait; } else { - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD) : GI_GERUDO_CARD, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } @@ -151,7 +156,12 @@ void EnGe3_GiveCard(EnGe3* this, GlobalContext* globalCtx) { Message_CloseTextbox(globalCtx); this->actor.flags &= ~ACTOR_FLAG_16; this->actionFunc = EnGe3_WaitTillCardGiven; - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD) : GI_GERUDO_CARD, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_GERUDO_CARD, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_GF_GERUDO_MEMBERSHIP_CARD, GI_GERUDO_CARD); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Go/z_en_go.c b/soh/src/overlays/actors/ovl_En_Go/z_en_go.c index e1179fe1b..832f4ac4d 100644 --- a/soh/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/soh/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -946,6 +946,7 @@ void func_80A40B1C(EnGo* this, GlobalContext* globalCtx) { void EnGo_GetItem(EnGo* this, GlobalContext* globalCtx) { f32 xzDist; f32 yDist; + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; s32 getItemId; if (Actor_HasParent(&this->actor, globalCtx)) { @@ -956,7 +957,12 @@ void EnGo_GetItem(EnGo* this, GlobalContext* globalCtx) { this->unk_20C = 0; if ((this->actor.params & 0xF0) == 0x90) { if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_CLAIM_CHECK) { - getItemId = gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_DMT_TRADE_CLAIM_CHECK, GI_SWORD_BGS) : GI_SWORD_BGS; + if (!gSaveContext.n64ddFlag) { + getItemId = GI_SWORD_BGS; + } else { + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_DMT_TRADE_CLAIM_CHECK, GI_SWORD_BGS); + getItemId = getItemEntry.getItemId; + } this->unk_20C = 1; } if (INV_CONTENT(ITEM_TRADE_ADULT) == ITEM_EYEDROPS) { @@ -973,7 +979,11 @@ void EnGo_GetItem(EnGo* this, GlobalContext* globalCtx) { yDist = fabsf(this->actor.yDistToPlayer) + 1.0f; xzDist = this->actor.xzDistToPlayer + 1.0f; - func_8002F434(&this->actor, globalCtx, getItemId, xzDist, yDist); + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, xzDist, yDist); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, xzDist, yDist); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c index 22c19f5f0..c9b97c8a9 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -286,6 +286,13 @@ void EnGo2_GetItem(EnGo2* this, GlobalContext* globalCtx, s32 getItemId) { fabsf(this->actor.yDistToPlayer) + 1.0f); } +void EnGo2_GetItemEntry(EnGo2* this, GlobalContext* globalCtx, GetItemEntry getItemEntry) { + this->getItemId = getItemEntry.getItemId; + this->getItemEntry = getItemEntry; + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, this->actor.xzDistToPlayer + 1.0f, + fabsf(this->actor.yDistToPlayer) + 1.0f); +} + s32 EnGo2_GetDialogState(EnGo2* this, GlobalContext* globalCtx) { s16 dialogState = Message_GetState(&globalCtx->msgCtx); @@ -334,8 +341,6 @@ u16 EnGo2_GetTextIdGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* this) { } s16 EnGo2_GetStateGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* this) { - s32 bombBagUpgrade; - switch (Message_GetState(&globalCtx->msgCtx)) { case TEXT_STATE_CLOSING: return 2; @@ -344,11 +349,10 @@ s16 EnGo2_GetStateGoronCityRollingBig(GlobalContext* globalCtx, EnGo2* this) { if (this->actor.textId == 0x3012) { this->actionFunc = EnGo2_SetupGetItem; if(!gSaveContext.n64ddFlag) { - bombBagUpgrade = CUR_CAPACITY(UPG_BOMB_BAG) == 30 ? GI_BOMB_BAG_40 : GI_BOMB_BAG_30; + EnGo2_GetItem(this, globalCtx, CUR_CAPACITY(UPG_BOMB_BAG) == 30 ? GI_BOMB_BAG_40 : GI_BOMB_BAG_30); } else { - bombBagUpgrade = Randomizer_GetItemIdFromKnownCheck(RC_GC_ROLLING_GORON_AS_CHILD, GI_BOMB_BAG_40); + EnGo2_GetItemEntry(this, globalCtx, Randomizer_GetItemFromKnownCheck(RC_GC_ROLLING_GORON_AS_CHILD, GI_BOMB_BAG_40)); } - EnGo2_GetItem(this, globalCtx, bombBagUpgrade); Message_CloseTextbox(globalCtx); gSaveContext.infTable[17] |= 0x4000; return 2; @@ -542,7 +546,7 @@ s16 EnGo2_GetStateGoronCityLink(GlobalContext* globalCtx, EnGo2* this) { } gSaveContext.infTable[16] |= 0x200; - EnGo2_GetItem(this, globalCtx, Randomizer_GetItemIdFromKnownCheck(RC_GC_ROLLING_GORON_AS_ADULT, GI_TUNIC_GORON)); + EnGo2_GetItemEntry(this, globalCtx, Randomizer_GetItemFromKnownCheck(RC_GC_ROLLING_GORON_AS_ADULT, GI_TUNIC_GORON)); this->actionFunc = EnGo2_SetupGetItem; Flags_SetTreasure(globalCtx, 0x1F); return 2; @@ -621,7 +625,7 @@ s16 EnGo2_GetStateGoronDmtBiggoron(GlobalContext* globalCtx, EnGo2* this) { return 0; } - EnGo2_GetItem(this, globalCtx, Randomizer_GetItemIdFromKnownCheck(RC_DMT_TRADE_CLAIM_CHECK, GI_SWORD_BGS)); + EnGo2_GetItemEntry(this, globalCtx, Randomizer_GetItemFromKnownCheck(RC_DMT_TRADE_CLAIM_CHECK, GI_SWORD_BGS)); Flags_SetTreasure(globalCtx, 0x1F); } else { EnGo2_GetItem(this, globalCtx, GI_SWORD_BGS); @@ -1569,6 +1573,7 @@ void EnGo2_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_216 = this->actor.shape.rot.z; this->unk_26E = 1; this->path = Path_GetByIndex(globalCtx, (this->actor.params & 0x3E0) >> 5, 0x1F); + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; switch (this->actor.params & 0x1F) { case GORON_CITY_ENTRANCE: case GORON_CITY_ISLAND: @@ -1808,8 +1813,11 @@ void EnGo2_SetupGetItem(EnGo2* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = EnGo2_SetGetItem; } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, this->actor.xzDistToPlayer + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->getItemId, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.h b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.h index d31eb7678..1618005f9 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.h +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.h @@ -104,6 +104,7 @@ typedef struct EnGo2 { /* 0x0598 */ char unk_598[0x02]; /* 0x059A */ s16 camId; /* 0x059C */ s16 unk_59C; + /* */ GetItemEntry getItemEntry; } EnGo2; // size = 0x05A0 #endif diff --git a/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.c b/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.c index af4eb8ef4..5c2340ce7 100644 --- a/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.c +++ b/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.c @@ -659,7 +659,18 @@ s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) { gSaveContext.dogParams = 0; break; case 0x709F: - func_80A6F7CC(this, globalCtx, (gSaveContext.infTable[25] & 2) ? GI_RUPEE_BLUE : gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_MARKET_LOST_DOG, GI_HEART_PIECE) : GI_HEART_PIECE); + if (gSaveContext.infTable[25] & 2) { // Already brought the lost dog back + func_80A6F7CC(this, globalCtx, GI_RUPEE_BLUE); + } else { + if (!gSaveContext.n64ddFlag) { + func_80A6F7CC(this, globalCtx, GI_HEART_PIECE); + } else { + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_LOST_DOG, GI_HEART_PIECE); + // The follownig line and last arguments of GiveItemEntryFromActor are copied from func_80A6F7CC + this->unkGetItemId = this->getItemEntry.getItemId; + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); + } + } this->actionFunc = func_80A714C4; break; } @@ -883,6 +894,7 @@ void EnHy_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Kill(&this->actor); } + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; this->actionFunc = EnHy_InitImpl; } @@ -1050,8 +1062,11 @@ void func_80A714C4(EnHy* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80A71530; } else { - func_8002F434(&this->actor, globalCtx, this->unkGetItemId, this->actor.xzDistToPlayer + 1.0f, - fabsf(this->actor.yDistToPlayer) + 1.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->unkGetItemId, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.h b/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.h index f7e66544d..253d8df7d 100644 --- a/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.h +++ b/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.h @@ -59,6 +59,7 @@ typedef struct EnHy { /* 0x0270 */ Vec3s jointTable[16]; /* 0x02D0 */ Vec3s morphTable[16]; /* 0x0330 */ u16 unk_330; + /* */ GetItemEntry getItemEntry; } EnHy; // size = 0x0334 #endif diff --git a/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c b/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c index cda6e476d..b65f4f74a 100644 --- a/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c +++ b/soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c @@ -453,6 +453,7 @@ void EnKz_Wait(EnKz* this, GlobalContext* globalCtx) { } void EnKz_SetupGetItem(EnKz* this, GlobalContext* globalCtx) { + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; s32 getItemId; f32 xzRange; f32 yRange; @@ -464,17 +465,23 @@ void EnKz_SetupGetItem(EnKz* this, GlobalContext* globalCtx) { } else { if (gSaveContext.n64ddFlag) { if (this->isTrading) { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_ZD_TRADE_PRESCRIPTION, GI_FROG); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_TRADE_PRESCRIPTION, GI_FROG); + getItemId = getItemEntry.getItemId; Flags_SetTreasure(globalCtx, 0x1F); } else { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_ZD_KING_ZORA_THAWED, GI_TUNIC_ZORA); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_KING_ZORA_THAWED, GI_TUNIC_ZORA); + getItemId = getItemEntry.getItemId; } } else { getItemId = this->isTrading ? GI_FROG : GI_TUNIC_ZORA; } yRange = fabsf(this->actor.yDistToPlayer) + 1.0f; xzRange = this->actor.xzDistToPlayer + 1.0f; - func_8002F434(&this->actor, globalCtx, getItemId, xzRange, yRange); + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, xzRange, yRange); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, xzRange, yRange); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c b/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c index fe66cff68..88c5b0724 100644 --- a/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c +++ b/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c @@ -338,11 +338,11 @@ void func_80AA0EA0(EnMa1* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_80AA0EFC; } else { - if (gSaveContext.n64ddFlag) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(RC_HC_MALON_EGG, GI_WEIRD_EGG); - func_8002F434(&this->actor, globalCtx, getItemId, 120.0f, 10.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, GI_WEIRD_EGG, 120.0f, 10.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_HC_MALON_EGG, GI_WEIRD_EGG); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 120.0f, 10.0f); } } } @@ -357,7 +357,7 @@ void func_80AA0EFC(EnMa1* this, GlobalContext* globalCtx) { } void GivePlayerRandoRewardMalon(EnMa1* malon, GlobalContext* globalCtx, RandomizerCheck check) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, RG_EPONAS_SONG); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_EPONAS_SONG); // Prevents flag from getting set if we weren't able to get the item (i.e. Player is holding shield // when closing the textbox). if (malon->actor.parent != NULL && malon->actor.parent->id == GET_PLAYER(globalCtx)->actor.id && @@ -367,7 +367,7 @@ void GivePlayerRandoRewardMalon(EnMa1* malon, GlobalContext* globalCtx, Randomiz // (confirmed via breakpoints in a vanilla save). malon->actionFunc = func_80AA0D88; } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - func_8002F434(&malon->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GiveItemEntryFromActor(&malon->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } // make malon sing again after giving the item. malon->unk_1E8.unk_00 = 0; diff --git a/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c index f42e09522..a53aeadf9 100644 --- a/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -198,14 +198,24 @@ void func_80AACFA0(EnMk* this, GlobalContext* globalCtx) { gSaveContext.itemGetInf[1] |= 1; } else { // not sure when/how/if this is getting called - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_LH_LAB_DIVE, GI_HEART_PIECE) : GI_HEART_PIECE, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_LAB_DIVE, GI_HEART_PIECE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } void func_80AAD014(EnMk* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80AACFA0; - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_LH_LAB_DIVE, GI_HEART_PIECE) : GI_HEART_PIECE, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_LAB_DIVE, GI_HEART_PIECE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } this->flags |= 1; diff --git a/soh/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/soh/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c index c31f2b923..8de4ff44b 100644 --- a/soh/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ b/soh/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c @@ -304,12 +304,13 @@ void func_80ABA654(EnNiwLady* this, GlobalContext* globalCtx) { if (!(gSaveContext.itemGetInf[0] & 0x1000)) { this->actor.parent = NULL; - if (gSaveContext.n64ddFlag) { - s32 itemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_ANJU_AS_CHILD, GI_BOTTLE); - func_8002F434(&this->actor, globalCtx, itemId, 100.0f, 50.0f); - } else { + if (!gSaveContext.n64ddFlag) { this->getItemId = GI_BOTTLE; func_8002F434(&this->actor, globalCtx, GI_BOTTLE, 100.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_ANJU_AS_CHILD, GI_BOTTLE); + this->getItemId = getItemEntry.getItemId; + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 100.0f, 50.0f); } this->actionFunc = func_80ABAC00; @@ -394,11 +395,12 @@ void func_80ABA9B8(EnNiwLady* this, GlobalContext* globalCtx) { Message_CloseTextbox(globalCtx); this->actor.parent = NULL; - if (gSaveContext.n64ddFlag) { - s32 itemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_ANJU_AS_ADULT, GI_POCKET_EGG); - func_8002F434(&this->actor, globalCtx, itemId, 200.0f, 100.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, GI_POCKET_EGG, 200.0f, 100.0f); + } else { + // TODO: get-item-rework Adult trade sequence + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_ANJU_AS_ADULT, GI_POCKET_EGG); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 200.0f, 100.0f); } this->actionFunc = func_80ABAC00; @@ -455,7 +457,8 @@ void func_80ABAC00(EnNiwLady* this, GlobalContext* globalCtx) { getItemId = !(gSaveContext.itemGetInf[2] & 0x1000) ? GI_POCKET_EGG : GI_COJIRO; if (gSaveContext.n64ddFlag && getItemId == GI_POCKET_EGG) { - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_ANJU_AS_ADULT, GI_POCKET_EGG); + // TODO: get-item-rework Adult trade sequence + getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_ANJU_AS_ADULT, GI_POCKET_EGG).getItemId; } } func_8002F434(&this->actor, globalCtx, getItemId, 200.0f, 100.0f); diff --git a/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index cc7360c0a..dc082ec0f 100644 --- a/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -327,8 +327,8 @@ void GivePlayerRandoRewardSunSong(EnOkarinaTag* song, GlobalContext* globalCtx, !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, GI_LETTER_ZELDA); - func_8002F434(&song->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, GI_LETTER_ZELDA); + GiveItemEntryFromActor(&song->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } } diff --git a/soh/src/overlays/actors/ovl_En_Sa/z_en_sa.c b/soh/src/overlays/actors/ovl_En_Sa/z_en_sa.c index 95fdd9b23..6d9c160a8 100644 --- a/soh/src/overlays/actors/ovl_En_Sa/z_en_sa.c +++ b/soh/src/overlays/actors/ovl_En_Sa/z_en_sa.c @@ -618,14 +618,12 @@ void func_80AF67D0(EnSa* this, GlobalContext* globalCtx) { } void GivePlayerRandoRewardSaria(EnSa* saria, GlobalContext* globalCtx, RandomizerCheck check) { - GetItemID getItemId = - Randomizer_GetItemIdFromKnownCheck(check, RG_SARIAS_SONG); - + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SARIAS_SONG); if (saria->actor.parent != NULL && saria->actor.parent->id == GET_PLAYER(globalCtx)->actor.id && !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - func_8002F434(&saria->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GiveItemEntryFromActor(&saria->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } } diff --git a/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c b/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c index 2d42c191e..facb0343a 100644 --- a/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c +++ b/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c @@ -1035,8 +1035,12 @@ void EnSkj_SariaSongTalk(EnSkj* this, GlobalContext* globalCtx) { EnSkj_SetupWaitInRange(this); } else { func_80AFFE24(this); - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_LW_SKULL_KID, GI_HEART_PIECE) : GI_HEART_PIECE, EnSkj_GetItemXzRange(this), - EnSkj_GetItemYRange(this)); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, EnSkj_GetItemXzRange(this), EnSkj_GetItemYRange(this)); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LW_SKULL_KID, GI_HEART_PIECE); + func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, EnSkj_GetItemXzRange(this), EnSkj_GetItemYRange(this)); + } } } } @@ -1050,7 +1054,12 @@ void func_80AFFE44(EnSkj* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnSkj_SetupPostSariasSong(this); } else { - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_LW_SKULL_KID, GI_HEART_PIECE) : GI_HEART_PIECE, EnSkj_GetItemXzRange(this), EnSkj_GetItemYRange(this)); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, EnSkj_GetItemXzRange(this), EnSkj_GetItemYRange(this)); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LW_SKULL_KID, GI_HEART_PIECE); + func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, EnSkj_GetItemXzRange(this), EnSkj_GetItemYRange(this)); + } } } @@ -1529,7 +1538,7 @@ void EnSkj_WaitToGiveReward(EnSkj* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(globalCtx)) { func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag && gSaveContext.ocarinaGameRoundNum != 3 - ? Randomizer_GetItemIdFromKnownCheck(RC_LW_OCARINA_MEMORY_GAME, GI_HEART_PIECE) + ? Randomizer_GetItemFromKnownCheck(RC_LW_OCARINA_MEMORY_GAME, GI_HEART_PIECE).getItemId : sOcarinaGameRewards[gSaveContext.ocarinaGameRoundNum], 26.0f, 26.0f); @@ -1544,7 +1553,7 @@ void EnSkj_GiveOcarinaGameReward(EnSkj* this, GlobalContext* globalCtx) { } else { func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag && gSaveContext.ocarinaGameRoundNum != 3 - ? Randomizer_GetItemIdFromKnownCheck(RC_LW_OCARINA_MEMORY_GAME, GI_HEART_PIECE) + ? Randomizer_GetItemFromKnownCheck(RC_LW_OCARINA_MEMORY_GAME, GI_HEART_PIECE).getItemId : sOcarinaGameRewards[gSaveContext.ocarinaGameRoundNum], 26.0f, 26.0f); } diff --git a/soh/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/soh/src/overlays/actors/ovl_En_Sth/z_en_sth.c index b01c6b8c4..bfaf4188f 100644 --- a/soh/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/soh/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -239,27 +239,29 @@ void EnSth_ParentRewardObtainedWait(EnSth* this, GlobalContext* globalCtx) { void EnSth_GivePlayerItem(EnSth* this, GlobalContext* globalCtx) { u16 getItemId = sGetItemIds[this->actor.params]; + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; if (gSaveContext.n64ddFlag) { switch (getItemId) { case GI_RUPEE_GOLD: break; case GI_WALLET_ADULT: - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_10_GOLD_SKULLTULA_REWARD, GI_WALLET_ADULT); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_10_GOLD_SKULLTULA_REWARD, GI_WALLET_ADULT); break; case GI_STONE_OF_AGONY: - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_20_GOLD_SKULLTULA_REWARD, GI_STONE_OF_AGONY); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_20_GOLD_SKULLTULA_REWARD, GI_STONE_OF_AGONY); break; case GI_WALLET_GIANT: - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_30_GOLD_SKULLTULA_REWARD, GI_WALLET_GIANT); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_30_GOLD_SKULLTULA_REWARD, GI_WALLET_GIANT); break; case GI_BOMBCHUS_10: - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_40_GOLD_SKULLTULA_REWARD, GI_BOMBCHUS_10); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_40_GOLD_SKULLTULA_REWARD, GI_BOMBCHUS_10); break; case GI_HEART_PIECE: - getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_50_GOLD_SKULLTULA_REWARD, GI_HEART_PIECE); + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_50_GOLD_SKULLTULA_REWARD, GI_HEART_PIECE); break; } + getItemId = getItemEntry.getItemId; } else { switch (this->actor.params) { case 1: @@ -277,7 +279,11 @@ void EnSth_GivePlayerItem(EnSth* this, GlobalContext* globalCtx) { } } - func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, 10000.0f, 50.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } void EnSth_GiveReward(EnSth* this, GlobalContext* globalCtx) { diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 7b57bea89..a6ddb5844 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -169,6 +169,7 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->blinkFunc = EnSyatekiMan_BlinkWait; this->actor.colChkInfo.cylRadius = 100; this->actionFunc = EnSyatekiMan_Start; + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; } void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -336,7 +337,8 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actor.parent = NULL; if (!LINK_IS_ADULT) { if(gSaveContext.n64ddFlag && !Flags_GetTreasure(globalCtx, 0x1E)) { - this->getItemId = Randomizer_GetItemIdFromKnownCheck(RC_MARKET_SHOOTING_GALLERY_REWARD, GI_BULLET_BAG_50); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_SHOOTING_GALLERY_REWARD, GI_BULLET_BAG_50); + this->getItemId = this->getItemEntry.getItemId; Flags_SetTreasure(globalCtx, 0x1E); } else if (!gSaveContext.n64ddFlag && !(gSaveContext.itemGetInf[0] & 0x2000)) { osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ Equip_Pachinko ☆☆☆☆☆ %d\n" VT_RST, @@ -351,7 +353,8 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { } } else { if(gSaveContext.n64ddFlag && !Flags_GetTreasure(globalCtx, 0x1F)) { - this->getItemId = Randomizer_GetItemIdFromKnownCheck(RC_KAK_SHOOTING_GALLERY_REWARD, GI_QUIVER_50); + this->getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_SHOOTING_GALLERY_REWARD, GI_QUIVER_50); + this->getItemId = this->getItemEntry.getItemId; Flags_SetTreasure(globalCtx, 0x1F); } else if (!gSaveContext.n64ddFlag && !(gSaveContext.itemGetInf[0] & 0x4000)) { osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ Equip_Bow ☆☆☆☆☆ %d\n" VT_RST, @@ -371,7 +374,11 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { this->getItemId = GI_RUPEE_PURPLE; } } - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, 2000.0f, 1000.0f); + } this->actionFunc = EnSyatekiMan_GivePrize; break; case SYATEKI_RESULT_ALMOST: @@ -400,7 +407,11 @@ void EnSyatekiMan_GivePrize(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = EnSyatekiMan_FinishPrize; } else { - func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + if (!gSaveContext.n64ddFlag || this->getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, this->getItemId, 2000.0f, 1000.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, this->getItemEntry, 2000.0f, 1000.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h index d82cdf9c7..9caa7c88f 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h +++ b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h @@ -28,6 +28,7 @@ typedef struct EnSyatekiMan { /* 0x0220 */ Actor* tempGallery; /* 0x0224 */ EnSyatekiManOtherFunc blinkFunc; // Seems to be part of a blink system with unk_20C and unk_20E, but it's unused. /* 0x0228 */ s16 csCam; + /* */ GetItemEntry getItemEntry; } EnSyatekiMan; // size = 0x022C #endif diff --git a/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c b/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c index 85e47a7e7..b7b964272 100644 --- a/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c +++ b/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c @@ -876,7 +876,12 @@ void func_80B15E80(EnTa* this, GlobalContext* globalCtx) { } else if (this->unk_2E0 & 2) { func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 50.0f); } else { - func_8002F434(&this->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LLR_TALONS_CHICKENS, GI_MILK_BOTTLE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } this->unk_2E0 |= 1; } @@ -886,7 +891,12 @@ void func_80B15F54(EnTa* this, GlobalContext* globalCtx) { Message_CloseTextbox(globalCtx); this->unk_2E0 &= ~0x2; func_80B13AA0(this, func_80B15E80, func_80B16938); - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? Randomizer_GetItemIdFromKnownCheck(RC_LLR_TALONS_CHICKENS, GI_MILK_BOTTLE) : GI_MILK_BOTTLE, 10000.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LLR_TALONS_CHICKENS, GI_MILK_BOTTLE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); + } } } diff --git a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c index 3aa000b4c..90e401f06 100644 --- a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -292,14 +292,12 @@ void GivePlayerRandoRewardSheikSong(EnXc* sheik, GlobalContext* globalCtx, Rando if (!(gSaveContext.eventChkInf[5] & sheikType)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, ogSongId); if (check == RC_SHEIK_AT_TEMPLE && !Flags_GetTreasure(globalCtx, 0x1F)) { - if (func_8002F434(&sheik->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 100.0f)) { - player->getItemEntry = getItemEntry; + if (GiveItemEntryFromActor(&sheik->actor, globalCtx, getItemEntry, 10000.0f, 100.0f)) { player->pendingFlag.flagID = 0x1F; player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } } else if (check != RC_SHEIK_AT_TEMPLE) { - if (func_8002F434(&sheik->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 100.0f)) { - player->getItemEntry = getItemEntry; + if (GiveItemEntryFromActor(&sheik->actor, globalCtx, getItemEntry, 10000.0f, 100.0f)) { player->pendingFlag.flagID = 0x55; player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF; } diff --git a/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index d4250fca2..96bf18aef 100644 --- a/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -233,8 +233,8 @@ void GivePlayerRandoRewardZeldaChild(EnZl4* zelda, GlobalContext* globalCtx, Ran Flags_SetTreasure(globalCtx, 0x1E); } else if (!Flags_GetTreasure(globalCtx, 0x1E) && !Randomizer_GetSettingValue(RSK_SKIP_CHILD_ZELDA) && Actor_TextboxIsClosing(&zelda->actor, globalCtx) && (globalCtx->msgCtx.textId == 0x703C || globalCtx->msgCtx.textId == 0x703D)) { - GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, GI_LETTER_ZELDA); - func_8002F434(&zelda->actor, globalCtx, getItemId, 10000.0f, 100.0f); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, GI_LETTER_ZELDA); + GiveItemEntryFromActor(&zelda->actor, globalCtx, getItemEntry, 10000.0f, 100.0f); } else if (Flags_GetTreasure(globalCtx, 0x1E) && !Player_InBlockingCsMode(globalCtx, GET_PLAYER(globalCtx))) { gSaveContext.unk_13EE = 0x32; gSaveContext.eventChkInf[4] |= 1; diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index 1cb3b53e9..f01fcec21 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -5002,6 +5002,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_NONE)) && Message_ShouldAdvance(globalCtx)) { s32 getItemId; + GetItemEntry getItemEntry = (GetItemEntry)GET_ITEM_NONE; Message_CloseTextbox(globalCtx); @@ -5056,9 +5057,12 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (D_80B7E078 >= Fishing_GetMinimumRequiredScore()) { HIGH_SCORE(HS_FISHING) |= 0x400; sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; - getItemId = gSaveContext.n64ddFlag ? - Randomizer_GetItemIdFromKnownCheck(RC_LH_CHILD_FISHING, GI_HEART_PIECE) : - GI_HEART_PIECE; + if (!gSaveContext.n64ddFlag) { + getItemId = GI_HEART_PIECE; + } else { + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_CHILD_FISHING, GI_HEART_PIECE); + getItemId = getItemEntry.getItemId; + } } } } else { @@ -5066,9 +5070,12 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (D_80B7E078 >= Fishing_GetMinimumRequiredScore()) { HIGH_SCORE(HS_FISHING) |= 0x800; sSinkingLureLocation = (u8)Rand_ZeroFloat(3.999f) + 1; - getItemId = gSaveContext.n64ddFlag ? - Randomizer_GetItemIdFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD) : - GI_SCALE_GOLD; + if (!gSaveContext.n64ddFlag) { + getItemId = GI_SCALE_GOLD; + } else { + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD); + getItemId = getItemEntry.getItemId; + } } } } @@ -5078,7 +5085,11 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { } this->actor.parent = NULL; - func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + if (!gSaveContext.n64ddFlag || getItemEntry.getItemId == GI_NONE) { + func_8002F434(&this->actor, globalCtx, getItemId, 2000.0f, 1000.0f); + } else { + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 2000.0f, 1000.0f); + } this->unk_15C = 23; } break; @@ -5142,9 +5153,8 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); } else { - func_8002F434(&this->actor, globalCtx, - Randomizer_GetItemIdFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD), 2000.0f, - 1000.0f); + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 2000.0f, 1000.0f); } } break; diff --git a/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c b/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c index 0c6e3dedc..304c3053d 100644 --- a/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c +++ b/soh/src/overlays/actors/ovl_Item_B_Heart/z_item_b_heart.c @@ -59,11 +59,11 @@ void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx) { Flags_SetCollectible(globalCtx, 0x1F); Actor_Kill(&this->actor); } else { - if (gSaveContext.n64ddFlag) { - s32 getItemId = Randomizer_GetRandomizedItemId(GI_HEART_CONTAINER_2, this->actor.id, this->actor.params, globalCtx->sceneNum); - func_8002F434(&this->actor, globalCtx, getItemId, 30.0f, 40.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, GI_HEART_CONTAINER_2, 30.0f, 40.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_HEART_CONTAINER_2, this->actor.id, this->actor.params, globalCtx->sceneNum); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 30.0f, 40.0f); } } } diff --git a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index 7b8f97ae6..e638001cb 100644 --- a/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/soh/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -133,11 +133,11 @@ void func_80B85824(ItemEtcetera* this, GlobalContext* globalCtx) { } Actor_Kill(&this->actor); } else { - if (gSaveContext.n64ddFlag) { - s32 getItemId = Randomizer_GetItemIdFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); - func_8002F434(&this->actor, globalCtx, getItemId, 30.0f, 50.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 30.0f, 50.0f); } } } @@ -156,11 +156,11 @@ void func_80B858B4(ItemEtcetera* this, GlobalContext* globalCtx) { } else { if (0) {} // Necessary to match - if (gSaveContext.n64ddFlag) { - s32 getItemId = Randomizer_GetItemIdFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO); - func_8002F434(&this->actor, globalCtx, getItemId, 30.0f, 50.0f); - } else { + if (!gSaveContext.n64ddFlag) { func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 30.0f, 50.0f); } if ((globalCtx->gameplayFrames & 0xD) == 0) { diff --git a/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c b/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c index 5e415b06c..7acfa4b62 100644 --- a/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c +++ b/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c @@ -190,11 +190,12 @@ void ItemOcarina_WaitInWater(ItemOcarina* this, GlobalContext* globalCtx) { this->actionFunc = ItemOcarina_StartSoTCutscene; this->actor.draw = NULL; } else { - func_8002F434(&this->actor, globalCtx, - gSaveContext.n64ddFlag - ? Randomizer_GetItemIdFromKnownCheck(RC_HF_OCARINA_OF_TIME_ITEM, GI_OCARINA_OOT) - : GI_OCARINA_OOT, - 30.0f, 50.0f); + if (!gSaveContext.n64ddFlag) { + func_8002F434(&this->actor, globalCtx, GI_OCARINA_OOT, 30.0f, 50.0f); + } else { + GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_HF_OCARINA_OF_TIME_ITEM, GI_OCARINA_OOT); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 30.0f, 50.0f); + } if ((globalCtx->gameplayFrames & 13) == 0) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f);