From 170b297a7ab4124b5c111e3a72fdf5e05016bb38 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 15 Aug 2022 14:33:29 -0500 Subject: [PATCH] Introduce some new methods and migrate most actors to them --- soh/include/functions.h | 4 +- soh/src/code/z_actor.c | 44 ++++++++++++++++--- soh/src/code/z_play.c | 11 +++-- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 2 +- .../overlays/actors/ovl_Demo_Im/z_demo_im.c | 2 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 2 +- soh/src/overlays/actors/ovl_En_Ani/z_en_ani.c | 16 +++---- .../ovl_En_Diving_Game/z_en_diving_game.c | 4 +- soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c | 6 +-- .../actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c | 4 +- soh/src/overlays/actors/ovl_En_Du/z_en_du.c | 2 +- soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c | 4 +- soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 27 +++++++++--- soh/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 4 +- soh/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c | 4 +- soh/src/overlays/actors/ovl_En_Go/z_en_go.c | 14 +++++- soh/src/overlays/actors/ovl_En_Hy/z_en_hy.c | 3 +- soh/src/overlays/actors/ovl_En_Kz/z_en_kz.c | 13 ++++-- soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c | 10 ++--- soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c | 4 +- .../ovl_En_Okarina_Tag/z_en_okarina_tag.c | 2 +- soh/src/overlays/actors/ovl_En_Sa/z_en_sa.c | 2 +- soh/src/overlays/actors/ovl_En_Sth/z_en_sth.c | 18 +++++--- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 18 ++++++-- .../ovl_En_Syateki_Man/z_en_syateki_man.h | 1 + soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c | 2 +- soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c | 6 +-- soh/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c | 2 +- .../overlays/actors/ovl_Fishing/z_fishing.c | 15 +++++-- .../actors/ovl_Item_B_Heart/z_item_b_heart.c | 2 +- .../ovl_Item_Etcetera/z_item_etcetera.c | 4 +- .../actors/ovl_Item_Ocarina/z_item_ocarina.c | 2 +- 33 files changed, 173 insertions(+), 83 deletions(-) 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/src/code/z_actor.c b/soh/src/code/z_actor.c index 5bfa6572e..502e9bf18 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,37 @@ 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 +2030,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_play.c b/soh/src/code/z_play.c index 006fd37af..8156f06e6 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -202,7 +202,7 @@ void GivePlayerRandoRewardSongOfTime(GlobalContext* globalCtx, RandomizerCheck c if (gSaveContext.entranceIndex == 0x050F && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && !Flags_GetTreasure(globalCtx, 0x1F) && gSaveContext.nextTransition == 0xFF) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); - GiveItemWithoutActor(globalCtx, getItemEntry.getItemId); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); player->pendingFlag.flagID = 0x1F; player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } @@ -217,7 +217,7 @@ void GivePlayerRandoRewardNocturne(GlobalContext* globalCtx, RandomizerCheck che CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_QUEST_ITEM(QUEST_MEDALLION_WATER) && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && !Flags_GetEventChkInf(0xAA)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_NOCTURNE_OF_SHADOW); - GiveItemWithoutActor(globalCtx, getItemEntry.getItemId); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetEventChkInf(0xAA); } } @@ -229,7 +229,7 @@ void GivePlayerRandoRewardRequiem(GlobalContext* globalCtx, RandomizerCheck chec if ((gSaveContext.entranceIndex == 0x01E1) && !Flags_GetEventChkInf(0xAC) && player != NULL && !Player_InBlockingCsMode(globalCtx, player)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); - GiveItemWithoutActor(globalCtx, getItemEntry.getItemId); + 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; } @@ -258,7 +257,7 @@ void GivePlayerRandoRewardSariaGift(GlobalContext* globalCtx, RandomizerCheck ch if ((!Flags_GetEventChkInf(0xC1) || (player->getItemId == getItemEntry.getItemId && getItemEntry.getItemId != GI_ICE_TRAP)) && player != NULL && !Player_InBlockingCsMode(globalCtx, player)) { - GiveItemWithoutActor(globalCtx, getItemEntry.getItemId); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetEventChkInf(0xC1); } } 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 c0dc480b0..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 @@ -77,7 +77,7 @@ void GivePlayerRandoRewardGreatFairy(BgDyYoseizo* this, GlobalContext* globalCtx Flags_SetTreasure(globalCtx, this->fountainType + 1); Actor_Kill(&this->actor); } else if (!Flags_GetTreasure(globalCtx, this->fountainType + 1)) { - func_8002F434(&this->actor, globalCtx, getItemEntry.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 dc119f16a..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 @@ -905,7 +905,7 @@ void GivePlayerRandoRewardImpa(Actor* impa, GlobalContext* globalCtx, Randomizer !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F) && !Randomizer_GetSettingValue(RSK_SKIP_CHILD_ZELDA)) { - func_8002F434(impa, globalCtx, getItemEntry.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 4825c0943..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 @@ -468,7 +468,7 @@ void GivePlayerRandoReward(DoorWarp1* this, Player* player, GlobalContext* globa !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - func_8002F434(&this->actor, globalCtx, getItemEntry.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 aac0e0c30..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) { - GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_MAN_ON_ROOF, GI_HEART_PIECE); - func_8002F434(&this->actor, globalCtx, getItemEntry.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) { - GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_MAN_ON_ROOF, GI_HEART_PIECE); - func_8002F434(&this->actor, globalCtx, getItemEntry.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_Diving_Game/z_en_diving_game.c b/soh/src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c index ab724ec63..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 @@ -457,7 +457,7 @@ void func_809EEA00(EnDivingGame* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_DIVING_MINIGAME, GI_SCALE_SILVER); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 90.0f, 10.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 90.0f, 10.0f); } this->actionFunc = func_809EEA90; } @@ -472,7 +472,7 @@ void func_809EEA90(EnDivingGame* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_DIVING_MINIGAME, GI_SCALE_SILVER); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 90.0f, 10.0f); + 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 b2208de52..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 @@ -372,7 +372,7 @@ void func_809EFDD0(EnDns* this, GlobalContext* globalCtx) { if (this->actor.params == 0x9) { if (gSaveContext.n64ddFlag) { GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_STICK_UPGRADE_30, this->actor.id, this->actor.params, globalCtx->sceneNum); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 130.0f, 100.0f); + 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 { @@ -381,7 +381,7 @@ void func_809EFDD0(EnDns* this, GlobalContext* globalCtx) { } else if (this->actor.params == 0xA) { if (gSaveContext.n64ddFlag) { GetItemEntry getItemEntry = Randomizer_GetRandomizedItem(GI_NUT_UPGRADE_40, this->actor.id, this->actor.params, globalCtx->sceneNum); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 130.0f, 100.0f); + 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 { @@ -392,7 +392,7 @@ void func_809EFDD0(EnDns* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 130.0f, 100.0f); + 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 b6c61504d..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 @@ -140,14 +140,14 @@ void EnDntDemo_Judge(EnDntDemo* this, GlobalContext* globalCtx) { case PLAYER_MASK_SKULL: if (!Flags_GetTreasure(globalCtx, 0x1F)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_DEKU_THEATER_SKULL_MASK, GI_STICK_UPGRADE_30); - GiveItemWithoutActor(globalCtx, getItemEntry.getItemId); + GiveItemEntryWithoutActor(globalCtx, getItemEntry); Flags_SetTreasure(globalCtx, 0x1F); } break; case PLAYER_MASK_TRUTH: if (!Flags_GetTreasure(globalCtx, 0x1E)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_DEKU_THEATER_MASK_OF_TRUTH, GI_NUT_UPGRADE_40); - GiveItemWithoutActor(globalCtx, getItemEntry.getItemId); + 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 f003e4b99..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 @@ -552,7 +552,7 @@ void func_809FEC70(EnDu* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, xzRange, fabsf(this->actor.yDistToPlayer) + 1.0f); } } } 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 2acef3ee9..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 @@ -155,7 +155,7 @@ void GivePlayerRandoRewardSongOfStorms(EnFu* windmillGuy, GlobalContext* globalC windmillGuy->actionFunc = func_80A1DBD4; } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_STORMS); - func_8002F434(&windmillGuy->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 100.0f); + 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 602f1c98f..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 @@ -357,7 +357,7 @@ void func_80A2FB40(EnGb* this, GlobalContext* globalCtx) { func_8002F434(&this->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE); - func_8002F434(&this->dyna.actor, globalCtx, getItemEntry.getItemId, 100.0f, 10.0f); + GiveItemEntryFromActor(&this->dyna.actor, globalCtx, getItemEntry, 100.0f, 10.0f); } this->actionFunc = func_80A2FBB0; } @@ -372,7 +372,7 @@ void func_80A2FBB0(EnGb* this, GlobalContext* globalCtx) { func_8002F434(&this->dyna.actor, globalCtx, GI_BOTTLE, 100.0f, 10.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_10_BIG_POES, GI_BOTTLE); - func_8002F434(&this->dyna.actor, globalCtx, getItemEntry.getItemId, 100.0f, 10.0f); + 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 c1169ae22..d765f6ac8 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; s32 getItemId; if (Actor_HasParent(&this->actor, globalCtx)) { @@ -533,20 +534,28 @@ void EnGe1_WaitTillItemGiven_Archery(EnGe1* this, GlobalContext* globalCtx) { break; } } else { - getItemId = Randomizer_GetItemFromKnownCheck(RC_GF_HBA_1500_POINTS, CUR_UPG_VALUE(UPG_QUIVER) == 1 ? GI_QUIVER_40 : GI_QUIVER_50).getItemId; + 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_GetItemFromKnownCheck(RC_GF_HBA_1000_POINTS, GI_HEART_PIECE).getItemId; + 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) { + 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; s32 getItemId; if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { @@ -566,17 +575,23 @@ void EnGe1_BeginGiveItem_Archery(EnGe1* this, GlobalContext* globalCtx) { break; } } else { - getItemId = Randomizer_GetItemFromKnownCheck(RC_GF_HBA_1500_POINTS, CUR_UPG_VALUE(UPG_QUIVER) == 1 ? GI_QUIVER_40 : GI_QUIVER_50).getItemId; + 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_GetItemFromKnownCheck(RC_GF_HBA_1000_POINTS, GI_HEART_PIECE).getItemId; + 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) { + 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 7687b74f3..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 @@ -461,7 +461,7 @@ void EnGe2_WaitTillCardGiven(EnGe2* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); } } } @@ -475,7 +475,7 @@ void EnGe2_GiveCard(EnGe2* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + 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 c9ee52d53..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 @@ -146,7 +146,7 @@ void EnGe3_WaitTillCardGiven(EnGe3* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); } } } @@ -160,7 +160,7 @@ void EnGe3_GiveCard(EnGe3* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + 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 04b1f9b1e..27fc87922 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; 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_GetItemFromKnownCheck(RC_DMT_TRADE_CLAIM_CHECK, GI_SWORD_BGS).getItemId : 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) { + 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_Hy/z_en_hy.c b/soh/src/overlays/actors/ovl_En_Hy/z_en_hy.c index 7c6d35269..a0f95d2e3 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 @@ -666,7 +666,8 @@ s16 func_80A70058(GlobalContext* globalCtx, Actor* thisx) { func_80A6F7CC(this, globalCtx, GI_HEART_PIECE); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_MARKET_LOST_DOG, GI_HEART_PIECE); - func_80A6F7CC(this, globalCtx, getItemEntry.getItemId); + this->unkGetItemId = getItemEntry.getItemId; + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, this->actor.xzDistToPlayer + 1.0f, fabsf(this->actor.yDistToPlayer) + 1.0f); } } this->actionFunc = func_80A714C4; 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 0babcaf42..0a937a53d 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; 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_GetItemFromKnownCheck(RC_ZD_TRADE_PRESCRIPTION, GI_FROG).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_ZD_TRADE_PRESCRIPTION, GI_FROG); + getItemId = getItemEntry.getItemId; Flags_SetTreasure(globalCtx, 0x1F); } else { - getItemId = Randomizer_GetItemFromKnownCheck(RC_ZD_KING_ZORA_THAWED, GI_TUNIC_ZORA).getItemId; + 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) { + 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 ae243b916..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) { - GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_HC_MALON_EGG, GI_WEIRD_EGG); - func_8002F434(&this->actor, globalCtx, getItemEntry.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); } } } @@ -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, getItemEntry.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 3516b4024..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 @@ -202,7 +202,7 @@ void func_80AACFA0(EnMk* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_LAB_DIVE, GI_HEART_PIECE); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.0f); } } } @@ -214,7 +214,7 @@ void func_80AAD014(EnMk* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_LAB_DIVE, GI_HEART_PIECE); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 10000.0f, 50.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 0cafd58af..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 @@ -328,7 +328,7 @@ void GivePlayerRandoRewardSunSong(EnOkarinaTag* song, GlobalContext* globalCtx, Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, GI_LETTER_ZELDA); - func_8002F434(&song->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 100.0f); + 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 6d42a2c90..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 @@ -623,7 +623,7 @@ void GivePlayerRandoRewardSaria(EnSa* saria, GlobalContext* globalCtx, Randomize !Flags_GetTreasure(globalCtx, 0x1F)) { Flags_SetTreasure(globalCtx, 0x1F); } else if (!Flags_GetTreasure(globalCtx, 0x1F)) { - func_8002F434(&saria->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 100.0f); + GiveItemEntryFromActor(&saria->actor, globalCtx, getItemEntry, 10000.0f, 100.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 fe7e7897c..8705bfa6d 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; if (gSaveContext.n64ddFlag) { switch (getItemId) { case GI_RUPEE_GOLD: break; case GI_WALLET_ADULT: - getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_10_GOLD_SKULLTULA_REWARD, GI_WALLET_ADULT).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_10_GOLD_SKULLTULA_REWARD, GI_WALLET_ADULT); break; case GI_STONE_OF_AGONY: - getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_20_GOLD_SKULLTULA_REWARD, GI_STONE_OF_AGONY).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_20_GOLD_SKULLTULA_REWARD, GI_STONE_OF_AGONY); break; case GI_WALLET_GIANT: - getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_30_GOLD_SKULLTULA_REWARD, GI_WALLET_GIANT).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_30_GOLD_SKULLTULA_REWARD, GI_WALLET_GIANT); break; case GI_BOMBCHUS_10: - getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_40_GOLD_SKULLTULA_REWARD, GI_BOMBCHUS_10).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_KAK_40_GOLD_SKULLTULA_REWARD, GI_BOMBCHUS_10); break; case GI_HEART_PIECE: - getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_50_GOLD_SKULLTULA_REWARD, GI_HEART_PIECE).getItemId; + 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) { + 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 9ca940d91..63f8662bc 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 @@ -336,7 +336,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_GetItemFromKnownCheck(RC_MARKET_SHOOTING_GALLERY_REWARD, GI_BULLET_BAG_50).getItemId; + 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 +352,8 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { } } else { if(gSaveContext.n64ddFlag && !Flags_GetTreasure(globalCtx, 0x1F)) { - this->getItemId = Randomizer_GetItemFromKnownCheck(RC_KAK_SHOOTING_GALLERY_REWARD, GI_QUIVER_50).getItemId; + 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 +373,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) { + 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 +406,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) { + 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 79e910f98..3b9cf80bd 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 @@ -890,7 +890,7 @@ void func_80B15F54(EnTa* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, GI_MILK_BOTTLE, 10000.0f, 50.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LLR_TALONS_CHICKENS, GI_MILK_BOTTLE); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 50.0f); + 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 f6ccda23e..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 @@ -234,7 +234,7 @@ void GivePlayerRandoRewardZeldaChild(EnZl4* zelda, GlobalContext* globalCtx, Ran } 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)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, GI_LETTER_ZELDA); - func_8002F434(&zelda->actor, globalCtx, getItemEntry.getItemId, 10000.0f, 100.0f); + 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 5f622e947..2e653aeeb 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; Message_CloseTextbox(globalCtx); @@ -5059,7 +5060,8 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (!gSaveContext.n64ddFlag) { getItemId = GI_HEART_PIECE; } else { - getItemId = Randomizer_GetItemFromKnownCheck(RC_LH_CHILD_FISHING, GI_HEART_PIECE).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_CHILD_FISHING, GI_HEART_PIECE); + getItemId = getItemEntry.getItemId; } } } @@ -5071,7 +5073,8 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { if (!gSaveContext.n64ddFlag) { getItemId = GI_SCALE_GOLD; } else { - getItemId = Randomizer_GetItemFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD).getItemId; + getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD); + getItemId = getItemEntry.getItemId; } } } @@ -5082,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) { + 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; @@ -5147,7 +5154,7 @@ void Fishing_HandleOwnerDialog(Fishing* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, GI_SCALE_GOLD, 2000.0f, 1000.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_ADULT_FISHING, GI_SCALE_GOLD); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 2000.0f, 1000.0f); + 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 897c2e9ff..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 @@ -63,7 +63,7 @@ void ItemBHeart_Update(Actor* thisx, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 30.0f, 40.0f); + 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 297ac112d..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 @@ -137,7 +137,7 @@ void func_80B85824(ItemEtcetera* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_SUN, GI_ARROW_FIRE); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 30.0f, 50.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 30.0f, 50.0f); } } } @@ -160,7 +160,7 @@ void func_80B858B4(ItemEtcetera* this, GlobalContext* globalCtx) { func_8002F434(&this->actor, globalCtx, this->getItemId, 30.0f, 50.0f); } else { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LH_UNDERWATER_ITEM, GI_LETTER_RUTO); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 30.0f, 50.0f); + 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 5ed63f96c..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 @@ -194,7 +194,7 @@ void ItemOcarina_WaitInWater(ItemOcarina* this, GlobalContext* globalCtx) { 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); - func_8002F434(&this->actor, globalCtx, getItemEntry.getItemId, 30.0f, 50.0f); + GiveItemEntryFromActor(&this->actor, globalCtx, getItemEntry, 30.0f, 50.0f); } if ((globalCtx->gameplayFrames & 13) == 0) {