Skip to content

Commit

Permalink
Fix grog not giving the bunnyhood hopefully.
Browse files Browse the repository at this point in the history
Fix dungeon items messing every other collectible up.
  • Loading branch information
PhlexPlexico committed Dec 20, 2023
1 parent d5034d4 commit 646a3ac
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 14 deletions.
1 change: 1 addition & 0 deletions code/include/rnd/item_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ namespace rnd {
extern "C" int ItemOverride_CheckInventoryItemOverride(game::ItemId);
extern "C" void ItemOverride_SwapSoHGetItemText(game::GlobalContext*, u16, game::act::Actor*);
extern "C" bool ItemOverride_CheckTingleMaps(u16, game::GlobalContext*);
extern "C" void ItemOverride_SetGrogExtData();
extern "C" u32 rActiveItemGraphicId;
extern "C" ItemOverride rItemOverrides[640];
extern "C" u16 rStoredTextId;
Expand Down
8 changes: 6 additions & 2 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ SECTIONS{
*(.patch_SecondZoraSwimCheck)
}

/* .patch_CheckDungeonItems 0x233E0C : {
.patch_CheckDungeonItems 0x233F30 : {
*(.patch_CheckDungeonItems)
} */
}

.patch_DisableMilkTimer 0x234BFC : {
*(.patch_DisableMilkTimer)
Expand Down Expand Up @@ -363,6 +363,10 @@ SECTIONS{
*(.patch_IncomingGetItemID)
}

.patch_FixGrogFishingPass 0x58465C : {
*(.patch_FixGrogFishingPass)
}

.patch_ReadGamePad 0x59BA10 : {
*(.patch_ReadGamePad)
}
Expand Down
11 changes: 10 additions & 1 deletion code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ hook_CheckDungeonItems:
ldr r1,[r1]
cmp r1,#0x1
pop {r0-r12, lr}
bne 0x233F60
beq 0x233F60
ldrh r2, [r2, #82]
bx lr

.global hook_SaveFile_Load
Expand All @@ -128,6 +129,14 @@ hook_SaveFile_Load:
str r5,[r1,#0x61C]
b 0x48C764

.global hook_FixGrogFishingPass
hook_FixGrogFishingPass:
push {r0-r12, lr}
bl ItemOverride_SetGrogExtData
pop {r0-r12, lr}
cmp r0,#0x39
bx lr

.global hook_SaveFile_Init
hook_SaveFile_Init:
push {r0-r12, lr}
Expand Down
5 changes: 5 additions & 0 deletions code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ patch_DisableMilkTimer:
patch_LoadExtData:
bl hook_SaveFile_Load

.section .patch_FixGrogFishingPass
.global patch_FixGrogFishingPass
patch_FixGrogFishingPass:
bl hook_FixGrogFishingPass

.section .patch_SaveFile_init
.global patch_SaveFile_init
patch_SaveFile_init:
Expand Down
24 changes: 19 additions & 5 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace rnd {
rItemOverrides[0].value.looksLikeItemId = 0x26;
rItemOverrides[1].key.scene = 0x26;
rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[1].value.getItemId = 0x77;
rItemOverrides[1].value.looksLikeItemId = 0x77;
rItemOverrides[1].value.getItemId = 0x42;
rItemOverrides[1].value.looksLikeItemId = 0x42;
rItemOverrides[2].key.scene = 0x12;
rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[2].value.getItemId = 0x37;
Expand Down Expand Up @@ -420,9 +420,14 @@ namespace rnd {
getItemId = incomingNegative ? -0x01 : 0x01;
} else if (actorId == game::act::Id::EnIn) {
gExtSaveData.givenItemChecks.enInGivenItem = 1;
} else if (actorId == game::act::Id::EnHs) {
gExtSaveData.givenItemChecks.enHsGivenItem = 1;
} else if (actorId == game::act::Id::EnHgo) {
} /*else if (actorId == game::act::Id::EnHs) {
// This has some weird side effects for when the item is given. Need to override in a different function I
suppose.
// See below for actual function where we set 1. This is now hooked after the item check to ensure we get the
bunny hood.
// gExtSaveData.givenItemChecks.enHsGivenItem = 1;
}*/
else if (actorId == game::act::Id::EnHgo) {
gExtSaveData.givenItemChecks.enHgoGivenItem = 1;
} else if (getItemId == static_cast<s16>(rnd::GetItemID::GI_MASK_CAPTAINS_HAT)) {
gExtSaveData.givenItemChecks.enOskGivenItem = 1;
Expand Down Expand Up @@ -651,6 +656,10 @@ namespace rnd {
return (int)0xFF;
} else if (currentItem == game::ItemId::BunnyHood && gExtSaveData.givenItemChecks.enHsGivenItem == 0) {
return (int)0xFF;
} else if (currentItem == game::ItemId::BunnyHood && gExtSaveData.givenItemChecks.enHsGivenItem == 1) {
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: Our enHsValue is one?\n", __func__);
#endif
} else if (currentItem == game::ItemId::GibdoMask && gExtSaveData.givenItemChecks.enHgoGivenItem == 0) {
return (int)0xFF;
} else if (currentItem == game::ItemId::RomaniMask && gExtSaveData.givenItemChecks.enMaYtoGivenItem == 0) {
Expand Down Expand Up @@ -715,5 +724,10 @@ namespace rnd {
}
return false;
}

void ItemOverride_SetGrogExtData() {
gExtSaveData.givenItemChecks.enHsGivenItem = 1;
return;
}
}
} // namespace rnd
4 changes: 0 additions & 4 deletions code/source/rnd/item_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,10 +1213,6 @@ namespace rnd {

void ItemTable_CallEffect(ItemRow* itemRow) {
game::CommonData& commonData = game::GetCommonData();
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: Item ID is %u\n rCustomDungeonItemRetrieved is %u", __func__, itemRow->itemId,
rCustomDungeonItemRetrieved);
#endif
if (itemRow->itemId > 0x73 && itemRow->itemId < 0x79) {
rCustomDungeonItemRetrieved = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions code/source/rnd/savefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ namespace rnd {
saveData.inventory.items[10] = game::ItemId::MagicBean;
saveData.inventory.items[12] = game::ItemId::PowderKeg;
// saveData.inventory.items[13] = game::ItemId::PictographBox;
saveData.inventory.items[14] = game::ItemId::LensOfTruth;
// saveData.inventory.items[14] = game::ItemId::LensOfTruth;
saveData.inventory.items[15] = game::ItemId::Hookshot;
saveData.inventory.items[20] = game::ItemId::LandTitleDeed;

saveData.inventory.masks[5] = game::ItemId::DekuMask;
// rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::DekuMask);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::BremenMask);
saveData.inventory.masks[11] = game::ItemId::GoronMask;
saveData.inventory.masks[17] = game::ItemId::ZoraMask;
saveData.inventory.masks[23] = game::ItemId::FierceDeityMask;
Expand Down

0 comments on commit 646a3ac

Please sign in to comment.