From 1789e5dddd03a3b023cde7a1ef07ccd29a44bc34 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 4 Aug 2022 20:59:46 -0500 Subject: [PATCH] Fix ice traps for cow shuffle --- soh/src/overlays/actors/ovl_En_Cow/z_en_cow.c | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/soh/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 5f6db31fb..8a050c4ae 100644 --- a/soh/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/soh/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -20,7 +20,7 @@ void func_809DF494(EnCow* this, GlobalContext* globalCtx); void func_809DF6BC(EnCow* this, GlobalContext* globalCtx); struct CowInfo EnCow_GetCowInfo(EnCow* this, GlobalContext* globalCtx); void EnCow_MoveCowsForRandomizer(EnCow* this, GlobalContext* globalCtx); -GetItemID EnCow_GetRandomizerItemFromCow(EnCow* this, GlobalContext* globalCtx, bool setFlag); +GetItemID EnCow_GetRandomizerItemFromCow(EnCow* this, GlobalContext* globalCtx); void func_809DF778(EnCow* this, GlobalContext* globalCtx); void func_809DF7D8(EnCow* this, GlobalContext* globalCtx); void func_809DF870(EnCow* this, GlobalContext* globalCtx); @@ -306,16 +306,17 @@ void EnCow_MoveCowsForRandomizer(EnCow* this, GlobalContext* globalCtx) { } } -GetItemID EnCow_GetRandomizerItemFromCow(EnCow* this, GlobalContext* globalCtx, bool setFlag) { +void EnCow_SetCowMilked(EnCow* this, GlobalContext* globalCtx) { + struct CowInfo cowInfo = EnCow_GetCowInfo(this, globalCtx); + gSaveContext.cowsMilked[cowInfo.cowId] = 1; +} + +GetItemID EnCow_GetRandomizerItemFromCow(EnCow* this, GlobalContext* globalCtx) { GetItemID itemId = ITEM_NONE; struct CowInfo cowInfo = EnCow_GetCowInfo(this, globalCtx); if (!gSaveContext.cowsMilked[cowInfo.cowId]) { itemId = Randomizer_GetItemIdFromKnownCheck(cowInfo.randomizerCheck, GI_MILK); - - if (setFlag) { - gSaveContext.cowsMilked[cowInfo.cowId] = 1; - } } else if (Inventory_HasEmptyBottle()) { itemId = GI_MILK; } @@ -328,7 +329,16 @@ void func_809DF778(EnCow* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_809DF730; } else { - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? EnCow_GetRandomizerItemFromCow(this, globalCtx, true) : GI_MILK, 10000.0f, 100.0f); + if (gSaveContext.n64ddFlag) { + GetItemID itemId = EnCow_GetRandomizerItemFromCow(this, globalCtx); + func_8002F434(&this->actor, globalCtx, itemId, 10000.0f, 100.0f); + if (itemId == GI_ICE_TRAP) { + Message_StartTextbox(globalCtx, 0xF8, &this->actor); + EnCow_SetCowMilked(this, globalCtx); + } + } else { + func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + } } } @@ -337,13 +347,21 @@ void func_809DF7D8(EnCow* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_16; Message_CloseTextbox(globalCtx); this->actionFunc = func_809DF778; - func_8002F434(&this->actor, globalCtx, gSaveContext.n64ddFlag ? EnCow_GetRandomizerItemFromCow(this, globalCtx, true) : GI_MILK, 10000.0f, 100.0f); + if (gSaveContext.n64ddFlag) { + GetItemID itemId = EnCow_GetRandomizerItemFromCow(this, globalCtx); + if (itemId != GI_ICE_TRAP) { + func_8002F434(&this->actor, globalCtx, itemId, 10000.0f, 100.0f); + EnCow_SetCowMilked(this, globalCtx); + } + } else { + func_8002F434(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); + } } } void func_809DF870(EnCow* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(globalCtx)) { - if (Inventory_HasEmptyBottle() || (gSaveContext.n64ddFlag && EnCow_GetRandomizerItemFromCow(this, globalCtx, false) != ITEM_NONE)) { + if (Inventory_HasEmptyBottle() || (gSaveContext.n64ddFlag && EnCow_GetRandomizerItemFromCow(this, globalCtx) != ITEM_NONE)) { Message_ContinueTextbox(globalCtx, 0x2007); this->actionFunc = func_809DF7D8; } else {