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.
This commit is contained in:
aMannus 2022-07-17 16:02:27 +02:00
parent 0f1f8c15f2
commit 4ccd4d5895
4 changed files with 26 additions and 20 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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),