From 4ccd4d58952851337ad171fce5732d0802dfcea9 Mon Sep 17 00:00:00 2001 From: aMannus Date: Sun, 17 Jul 2022 16:02:27 +0200 Subject: [PATCH] Exposed static table to change skulltokens This static table is normally only used within z_player.c, but is needed to switch the itemId to something Item_Give() can use and to set the correct TextId. --- soh/include/z64player.h | 10 ++++++++ soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 24 +++++++++++-------- soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c | 1 - .../actors/ovl_player_actor/z_player.c | 11 ++------- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/soh/include/z64player.h b/soh/include/z64player.h index 954c36c142..6128a57d85 100644 --- a/soh/include/z64player.h +++ b/soh/include/z64player.h @@ -5,6 +5,16 @@ struct Player; +typedef struct { + /* 0x00 */ u8 itemId; + /* 0x01 */ u8 field; // various bit-packed data + /* 0x02 */ s8 gi; // defines the draw id and chest opening animation + /* 0x03 */ u8 textId; + /* 0x04 */ u16 objectId; +} GetItemEntry; // size = 0x06 + +extern GetItemEntry sGetItemTable[160]; + typedef enum { /* 0 */ PLAYER_SWORD_NONE, /* 1 */ PLAYER_SWORD_KOKIRI, diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index d5abb04812..bf8a93c4c4 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -93,16 +93,18 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - s32 getItemId = ITEM_SKULL_TOKEN; + s32 textId = 0xB4; + s32 itemGiveId = ITEM_SKULL_TOKEN; if (gSaveContext.n64ddFlag) { - getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + s32 getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + textId = sGetItemTable[getItemId - 1].textId; + itemGiveId = sGetItemTable[getItemId - 1].itemId; } - //getItemId = ITEM_DINS_FIRE; - Item_Give(globalCtx, getItemId); + Item_Give(globalCtx, itemGiveId); if (CVar_GetS32("gSkulltulaFreeze", 0) != 1) { player->actor.freezeTimer = 20; } - Message_StartTextbox(globalCtx, 0xB4, NULL); + Message_StartTextbox(globalCtx, textId, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); this->actionFunc = func_80AFB950; } else { @@ -122,13 +124,15 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { this->actor.shape.rot.y += 0x400; if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) { - s32 getItemId = ITEM_SKULL_TOKEN; + s32 textId = 0xB4; + s32 itemGiveId = ITEM_SKULL_TOKEN; if (gSaveContext.n64ddFlag) { - getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + s32 getItemId = GetRandomizedItemId(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum); + textId = sGetItemTable[getItemId - 1].textId; + itemGiveId = sGetItemTable[getItemId - 1].itemId; } - //getItemId = ITEM_DINS_FIRE; - Item_Give(globalCtx, getItemId); - Message_StartTextbox(globalCtx, 0xB4, NULL); + Item_Give(globalCtx, itemGiveId); + Message_StartTextbox(globalCtx, textId, NULL); Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); this->actionFunc = func_80AFB950; } diff --git a/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 69fc0595ae..864fa22707 100644 --- a/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -616,7 +616,6 @@ void func_80B0D878(EnSw* this, GlobalContext* globalCtx) { temp_v0 = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_SI, this->actor.world.pos.x + x, this->actor.world.pos.y + y, this->actor.world.pos.z + z, 0, 0, 0, this->actor.params); - if (temp_v0 != NULL) { temp_v0->parent = NULL; } diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 1973a09a44..330c53738e 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -6,6 +6,7 @@ #include "ultra64.h" #include "global.h" +#include "z64player.h" #include "overlays/actors/ovl_Bg_Heavy_Block/z_bg_heavy_block.h" #include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" @@ -21,14 +22,6 @@ #include "objects/object_link_child/object_link_child.h" #include "textures/icon_item_24_static/icon_item_24_static.h" -typedef struct { - /* 0x00 */ u8 itemId; - /* 0x01 */ u8 field; // various bit-packed data - /* 0x02 */ s8 gi; // defines the draw id and chest opening animation - /* 0x03 */ u8 textId; - /* 0x04 */ u16 objectId; -} GetItemEntry; // size = 0x06 - #define GET_ITEM(itemId, objectId, drawId, textId, field, chestAnim) \ { itemId, field, (chestAnim != CHEST_ANIM_SHORT ? 1 : -1) * (drawId + 1), textId, objectId } @@ -496,7 +489,7 @@ static u16 D_8085361C[] = { NA_SE_VO_LI_FALL_L, }; -static GetItemEntry sGetItemTable[] = { +GetItemEntry sGetItemTable[] = { GET_ITEM(ITEM_BOMBS_5, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT), GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT), GET_ITEM(ITEM_BOMBCHU, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT),