Skip to content

Commit

Permalink
fix: Update en_st to allow for repeatable checks (#98)
Browse files Browse the repository at this point in the history
* Update skulltulas to respawn while giving only green rupee if item was collected.

* fix: Enable repeatable items in Skulltulas.

If an item is repeatable, it should respawn on cycle reset, and if the item is in inventory, it will only provide a blue rupee.
  • Loading branch information
PhlexPlexico authored Sep 30, 2024
1 parent b5082e7 commit 4176170
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 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 @@ -440,6 +440,7 @@ namespace rnd {
void ItemOverride_RevealMapBasedOnId(u8);
void SetExtData(void);
u8 ItemOverride_SetProgressiveItemDraw(ItemOverride);
bool ItemOverride_IsItemObtainedOrEmptyBottle(ItemOverride);
extern "C" {
bool ItemOverride_CheckAromaGivenItem();
bool ItemOverride_CheckMikauGivenItem();
Expand Down
4 changes: 2 additions & 2 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ SECTIONS{
*(.patch_RemoveGoronMaskCheckDarmani)
}

.patch_RemoveSkulltulaSpawnIfCollectedItem 0x2E8384 : {
/* .patch_RemoveSkulltulaSpawnIfCollectedItem 0x2E8384 : {
*(.patch_RemoveSkulltulaSpawnIfCollectedItem)
}
} */

.patch_SaveExtDataOnOwl 0x317004 : {
*(.patch_SaveExtDataOnOwl)
Expand Down
2 changes: 1 addition & 1 deletion code/source/rnd/actors/en_si.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace rnd {
extern "C" {
void En_Si_Init(game::act::Actor* actor, game::GlobalContext* gctx) {
util::GetPointer<void(game::act::Actor*, game::GlobalContext*)>(0x2E7FCC)(actor, gctx);
Model_SpawnByActor(actor, GetContext().gctx, 0x20);
Model_SpawnByActor(actor, gctx, 0x20);
}

void En_Si_Draw(game::act::Actor* actor, game::GlobalContext* gctx) {
Expand Down
21 changes: 12 additions & 9 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,6 @@ namespace rnd {
}

void SetExtData() {
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: STORED GET ITEM ID IS %#04x\n", __func__, storedGetItemId);
#endif
if (storedActorId == game::act::Id::NpcEnNb) {
gExtSaveData.givenItemChecks.enNbGivenItem = 1;
} else if (storedActorId == game::act::Id::NpcInvisibleGuard) {
Expand Down Expand Up @@ -727,6 +724,11 @@ namespace rnd {
override.value.getItemId = 0x02;
override.value.looksLikeItemId = 0x02;
}
} else if (override.key.type == ItemOverride_Type::OVR_SKULL &&
(gctx->scene == game::SceneId::SwampSpiderHouse || gctx->scene == game::SceneId::OceansideSpiderHouse) &&
ItemOverride_IsSkullCollected(fromActor, gctx->scene)) {
override.value.getItemId = 0x02;
override.value.looksLikeItemId = 0x02;
}

// This check is mainly to ensure we do not have repeatable progressive items within these base items.
Expand Down Expand Up @@ -1063,18 +1065,18 @@ namespace rnd {
return;
}
} else if (scene == game::SceneId::OceansideSpiderHouse) {
if (skulltulaMapOSH[i] == (params & 0xFF)) {
gExtSaveData.chestRewarded[(u8)game::SceneId::OceansideSpiderHouse][i] = 1;
// Special case - since OSH has one chest, let's remove
if ((i + 1) == 30)
break;
if (skulltulaMapOSH[i + 1] == (params & 0xFF)) {
gExtSaveData.chestRewarded[(u8)game::SceneId::OceansideSpiderHouse][i + 1] = 1;
return;
}
}
}
}

u8 ItemOverride_IsSkullCollected(game::act::Actor* actor, game::SceneId scene) {
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: Our scene is %#06x\n", __func__, scene);
#endif
for (u8 i = 0; i < 30; i++) {
if (scene == game::SceneId::SwampSpiderHouse) {
if (skulltulaMapSSH[i] == (actor->params & 0xFF)) {
Expand All @@ -1095,12 +1097,13 @@ namespace rnd {
u8 ItemOverride_OverrideSkullToken(game::act::Actor* actor) {
game::GlobalContext* gctx = GetContext().gctx;
s16 getItemId = gctx->scene == game::SceneId::SwampSpiderHouse ? 0x44 : 0x6D;
ItemOverride_SetSkullCollected(actor->params, gctx->scene);
ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), getItemId);
if (rActiveItemRow != NULL) {
ItemOverride_GetItemTextAndItemID(gctx->GetPlayerActor());
ItemOverride_SetSkullCollected(actor->params, gctx->scene);
return true;
}

return false;
}

Expand Down
7 changes: 4 additions & 3 deletions code/source/rnd/models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ namespace rnd {
objectBankIdx = ExtendedObject_Spawn(&globalCtx->object_context, model->itemRow->objectId);
}
storedObjId = model->itemRow->objectId;
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: storedObjId is %#04x\n", __func__, storedObjId);
#endif
model->objectBankIdx = objectBankIdx;
}

Expand Down Expand Up @@ -205,6 +202,10 @@ namespace rnd {
ItemOverride override = ItemOverride_Lookup(actor, (u16)globalCtx->scene, baseItemId);

if (override.key.all != 0) {
if (override.key.type == ItemOverride_Type::OVR_SKULL && ItemOverride_IsSkullCollected(actor, globalCtx->scene)) {
override.value.getItemId = 0x02;
override.value.looksLikeItemId = 0x02;
}
Model_LookupByOverride(model, override);
Model_GetObjectBankIndex(model, actor, globalCtx);
}
Expand Down

0 comments on commit 4176170

Please sign in to comment.