Skip to content

Commit

Permalink
Few updates to context.
Browse files Browse the repository at this point in the history
Update item override to give map pieces if found in the wild.
  • Loading branch information
PhlexPlexico committed Sep 5, 2023
1 parent a91b65b commit d32cf34
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion code/include/game/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ namespace game {
act::Actor* messageActor;
u16 field_8380;
u16 field_8382;
u8 gap_8384[74]; // ocaeffSpawned in here.
u8 gap_8384[4]; // ocaeffSpawned in here.
int item_cost;
int another_item_cost_maybe;
u8 gap_8390[62];
u16 field_83CE; // frame counter for notebook?
u8 field_83CD;
u8 gap_83D0[10];
Expand Down Expand Up @@ -459,6 +462,7 @@ namespace game {
static_assert(offsetof(GlobalContext, ocarina_song) == 0x836A);
static_assert(offsetof(GlobalContext, hide_hud) == 0x825E);
static_assert(offsetof(GlobalContext, field_836E) == 0x836E);
static_assert(offsetof(GlobalContext, gap_8390) == 0x8390);
static_assert(offsetof(GlobalContext, field_C4C8) == 0xC4C8);
static_assert(offsetof(GlobalContext, field_83CE) == 0x83CE);
static_assert(offsetof(GlobalContext, gap_8384) == 0x8384);
Expand Down
1 change: 1 addition & 0 deletions code/include/rnd/item_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ namespace rnd {
void ItemOverride_CheckStartingItem();
void ItemOverride_Init();
void ItemOverride_Update();
void ItemOverride_RevealMapBasedOnId(u8);
extern "C" bool ItemOverride_CheckAromaGivenItem();
extern "C" bool ItemOverride_CheckMikauGivenItem();
extern "C" bool ItemOverride_CheckDarmaniGivenItem();
Expand Down
36 changes: 36 additions & 0 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,39 @@ namespace rnd {
return;
}

void ItemOverride_RevealMapBasedOnId(u8 getItemMapId) {
game::SaveData& saveData = game::GetCommonData().save;
switch (getItemMapId) {
case 0xB4:
saveData.overworld_map_get_flags_0x3F_for_all = saveData.overworld_map_get_flags_0x3F_for_all | 1;
saveData.anonymous_162 = saveData.anonymous_162 | 3;
break;
case 0xB5:
saveData.overworld_map_get_flags_0x3F_for_all = saveData.overworld_map_get_flags_0x3F_for_all | 2;
saveData.anonymous_162 = saveData.anonymous_162 | 0x1C;
break;
case 0xB6:
saveData.overworld_map_get_flags_0x3F_for_all = saveData.overworld_map_get_flags_0x3F_for_all | 4;
saveData.anonymous_162 = saveData.anonymous_162 | 0xE0;
break;
case 0xB7:
saveData.overworld_map_get_flags_0x3F_for_all = saveData.overworld_map_get_flags_0x3F_for_all | 8;
saveData.anonymous_162 = saveData.anonymous_162 | 0x100;
break;
case 0xB8:
saveData.overworld_map_get_flags_0x3F_for_all = saveData.overworld_map_get_flags_0x3F_for_all | 0x10;
saveData.anonymous_162 = saveData.anonymous_162 | 0x1E00;
break;
case 0xB9:
saveData.overworld_map_get_flags_0x3F_for_all = saveData.overworld_map_get_flags_0x3F_for_all | 0x20;
saveData.anonymous_162 = saveData.anonymous_162 | 0x6000;
break;
default:
break;
}
return;
}

extern "C" {
bool ItemOverride_CheckAromaGivenItem() {
if (gExtSaveData.givenItemChecks.enAlGivenItem > 0)
Expand Down Expand Up @@ -485,6 +518,9 @@ namespace rnd {
// Get_Item_Handler. Don't give ice traps, since it may cause UB.
if (itemId != (u8)game::ItemId::None) {
rnd::util::GetPointer<int(game::GlobalContext*, game::ItemId)>(0x233BEC)(gctx, (game::ItemId)itemId);
// Since the regular get item handler does not take care of this situation, we need to do it manually.
if (rActiveItemOverride.value.getItemId > 0xB3 && rActiveItemOverride.value.getItemId < 0xBA)
ItemOverride_RevealMapBasedOnId(rActiveItemOverride.value.getItemId);
}
ItemOverride_AfterItemReceived();
}
Expand Down
1 change: 1 addition & 0 deletions code/source/rnd/savefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace rnd {
#ifdef ENABLE_DEBUG
saveData.player.razor_sword_hp = 0x64;
saveData.skulltulas_collected.swamp_count = 30;
saveData.anonymous_162 = saveData.anonymous_162 | 0x6000;
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::MaskOfTruth);
rnd::util::GetPointer<void(game::ItemId)>(0x22b14c)(game::ItemId::PictographBox);
// saveData.inventory.inventory_count_register.quiver_upgrade = game::Quiver::Quiver50;
Expand Down

0 comments on commit d32cf34

Please sign in to comment.