2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-09-30 00:18:46 +00:00
|
|
|
#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
#define FLAGS 0x00000000
|
|
|
|
|
2020-05-04 19:02:51 +00:00
|
|
|
#define THIS ((EnItem00*)thisx)
|
|
|
|
|
|
|
|
void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx);
|
|
|
|
void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
|
|
|
void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx);
|
|
|
|
void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx);
|
2020-05-01 18:26:16 +00:00
|
|
|
|
|
|
|
void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
void func_8001E304(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
|
|
|
|
const ActorInit En_Item00_InitVars = {
|
|
|
|
ACTOR_EN_ITEM00,
|
|
|
|
ACTORTYPE_MISC,
|
|
|
|
FLAGS,
|
|
|
|
OBJECT_GAMEPLAY_KEEP,
|
|
|
|
sizeof(EnItem00),
|
|
|
|
(ActorFunc)EnItem00_Init,
|
|
|
|
(ActorFunc)EnItem00_Destroy,
|
|
|
|
(ActorFunc)EnItem00_Update,
|
|
|
|
(ActorFunc)EnItem00_Draw,
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Define this section of .data here and rename the symbols
|
2020-05-31 09:55:48 +00:00
|
|
|
extern ColliderCylinderInit D_801154E0; // rename to sCylinderInit when data is moved
|
|
|
|
extern InitChainEntry D_8011550C[]; // rename to sInitChain when data is moved
|
2020-03-17 04:31:30 +00:00
|
|
|
extern Color_RGB8 D_80115510;
|
|
|
|
extern Color_RGB8 D_80115514;
|
|
|
|
extern UNK_TYPE D_80115518;
|
|
|
|
extern UNK_TYPE D_80115524;
|
|
|
|
extern u32 D_80115530[];
|
|
|
|
extern u32 D_80115544[];
|
|
|
|
extern u8 D_80115574[];
|
|
|
|
extern u8 D_80115664[];
|
|
|
|
|
|
|
|
// Internal Actor Functions
|
|
|
|
|
2020-05-05 22:53:15 +00:00
|
|
|
void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc) {
|
2020-05-01 18:26:16 +00:00
|
|
|
this->actionFunc = actionFunc;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-04 19:02:51 +00:00
|
|
|
void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
|
|
|
|
EnItem00* this = THIS;
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 pad2;
|
|
|
|
f32 sp34;
|
|
|
|
f32 sp30;
|
2020-05-03 21:04:11 +00:00
|
|
|
s32 getItemId;
|
2020-03-17 04:31:30 +00:00
|
|
|
s16 spawnParam8000;
|
|
|
|
s32 pad3;
|
|
|
|
|
|
|
|
sp34 = 980.0f;
|
|
|
|
sp30 = 6.0f;
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = 0;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
spawnParam8000 = this->actor.params & 0x8000;
|
|
|
|
this->collectibleFlag = (this->actor.params & 0x3F00) >> 8;
|
|
|
|
|
2020-05-03 21:04:11 +00:00
|
|
|
this->actor.params &= 0xFF;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Actor_ProcessInitChain(&this->actor, D_8011550C);
|
2020-05-01 18:26:16 +00:00
|
|
|
Collider_InitCylinder(globalCtx, &this->collider);
|
|
|
|
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_801154E0);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
this->unk_158 = 1;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
switch (this->actor.params) {
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_GREEN:
|
|
|
|
case ITEM00_RUPEE_BLUE:
|
|
|
|
case ITEM00_RUPEE_RED:
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_SetScale(&this->actor, 0.015f);
|
|
|
|
this->unk_15C = 0.015f;
|
|
|
|
sp34 = 750.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SMALL_KEY:
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_158 = 0;
|
|
|
|
Actor_SetScale(&this->actor, 0.03f);
|
|
|
|
this->unk_15C = 0.03f;
|
|
|
|
sp34 = 350.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_PIECE:
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_158 = 0;
|
|
|
|
sp34 = 650.0f;
|
|
|
|
Actor_SetScale(&this->actor, 0.02f);
|
|
|
|
this->unk_15C = 0.02f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART:
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.initPosRot.rot.z = Math_Rand_CenteredFloat(65535.0f);
|
|
|
|
sp34 = 430.0f;
|
|
|
|
Actor_SetScale(&this->actor, 0.02f);
|
|
|
|
this->unk_15C = 0.02f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_CONTAINER:
|
2020-03-17 04:31:30 +00:00
|
|
|
sp34 = 430.0f;
|
|
|
|
this->unk_158 = 0;
|
|
|
|
Actor_SetScale(&this->actor, 0.02f);
|
|
|
|
this->unk_15C = 0.02f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_SINGLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
sp34 = 400.0f;
|
|
|
|
Actor_SetScale(&this->actor, 0.02f);
|
|
|
|
this->unk_15C = 0.02f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_SMALL:
|
|
|
|
case ITEM00_ARROWS_MEDIUM:
|
|
|
|
case ITEM00_ARROWS_LARGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_SetScale(&this->actor, 0.035f);
|
|
|
|
this->unk_15C = 0.035f;
|
|
|
|
sp34 = 250.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_BOMBS_A:
|
|
|
|
case ITEM00_BOMBS_B:
|
|
|
|
case ITEM00_NUTS:
|
|
|
|
case ITEM00_STICK:
|
|
|
|
case ITEM00_MAGIC_SMALL:
|
|
|
|
case ITEM00_SEEDS:
|
|
|
|
case ITEM00_BOMBS_SPECIAL:
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_SetScale(&this->actor, 0.03f);
|
|
|
|
this->unk_15C = 0.03f;
|
|
|
|
sp34 = 320.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_MAGIC_LARGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_SetScale(&this->actor, 0.045 - 1e-10);
|
|
|
|
this->unk_15C = 0.045 - 1e-10;
|
|
|
|
sp34 = 320.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_ORANGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_SetScale(&this->actor, 0.045 - 1e-10);
|
|
|
|
this->unk_15C = 0.045 - 1e-10;
|
|
|
|
sp34 = 750.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_PURPLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_SetScale(&this->actor, 0.03f);
|
|
|
|
this->unk_15C = 0.03f;
|
|
|
|
sp34 = 750.0f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_FLEXIBLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
sp34 = 500.0f;
|
|
|
|
Actor_SetScale(&this->actor, 0.01f);
|
|
|
|
this->unk_15C = 0.01f;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SHIELD_DEKU:
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_1);
|
|
|
|
Actor_SetObjectDependency(globalCtx, &this->actor);
|
|
|
|
Actor_SetScale(&this->actor, 0.5f);
|
|
|
|
this->unk_15C = 0.5f;
|
|
|
|
sp34 = 0.0f;
|
|
|
|
sp30 = 0.6f;
|
|
|
|
this->actor.posRot.rot.x = 0x4000;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SHIELD_HYLIAN:
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2);
|
|
|
|
Actor_SetObjectDependency(globalCtx, &this->actor);
|
|
|
|
Actor_SetScale(&this->actor, 0.5f);
|
|
|
|
this->unk_15C = 0.5f;
|
|
|
|
sp34 = 0.0f;
|
|
|
|
sp30 = 0.6f;
|
|
|
|
this->actor.posRot.rot.x = 0x4000;
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_TUNIC_ZORA:
|
|
|
|
case ITEM00_TUNIC_GORON:
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_CLOTHES);
|
|
|
|
Actor_SetObjectDependency(globalCtx, &this->actor);
|
|
|
|
Actor_SetScale(&this->actor, 0.5f);
|
|
|
|
this->unk_15C = 0.5f;
|
|
|
|
sp34 = 0.0f;
|
|
|
|
sp30 = 0.6f;
|
|
|
|
this->actor.posRot.rot.x = 0x4000;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->unk_156 = 0;
|
|
|
|
ActorShape_Init(&this->actor.shape, sp34, ActorShadow_DrawFunc_Circle, sp30);
|
|
|
|
this->actor.shape.unk_14 = 0xB4;
|
|
|
|
this->actor.posRot2.pos = this->actor.posRot.pos;
|
|
|
|
this->unk_152 = 0;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (!spawnParam8000) {
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(this, func_8001DFC8);
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_15A = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->unk_15A = 15;
|
|
|
|
this->unk_154 = 35;
|
|
|
|
|
|
|
|
this->actor.speedXZ = 0.0f;
|
|
|
|
this->actor.velocity.y = 0.0f;
|
|
|
|
this->actor.gravity = 0.0f;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
switch (this->actor.params) {
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_GREEN:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_GREEN);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_BLUE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_BLUE);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_RED:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_RED);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_PURPLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_PURPLE);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_ORANGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_GOLD);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_HEART);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_FLEXIBLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Health_ChangeBy(globalCtx, 0x70);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_BOMBS_A:
|
|
|
|
case ITEM00_BOMBS_B:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_BOMBS_5);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_SINGLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_BOW);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_SMALL:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_ARROWS_SMALL);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_MEDIUM:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_ARROWS_MEDIUM);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_LARGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_ARROWS_LARGE);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_MAGIC_LARGE:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_MAGIC_SMALL;
|
|
|
|
break;
|
|
|
|
case ITEM00_MAGIC_SMALL:
|
|
|
|
getItemId = GI_MAGIC_LARGE;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SMALL_KEY:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_KEY_SMALL);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SEEDS:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_SEEDS_5;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_NUTS:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_NUTS_5;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_STICK:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_STICKS_1;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_PIECE:
|
|
|
|
case ITEM00_HEART_CONTAINER:
|
|
|
|
case ITEM00_SHIELD_DEKU:
|
|
|
|
case ITEM00_SHIELD_HYLIAN:
|
|
|
|
case ITEM00_TUNIC_ZORA:
|
|
|
|
case ITEM00_TUNIC_GORON:
|
|
|
|
case ITEM00_BOMBS_SPECIAL:
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-08-29 22:25:16 +00:00
|
|
|
if ((getItemId != 0) && !Actor_HasParent(&this->actor, globalCtx)) {
|
2020-05-03 21:04:11 +00:00
|
|
|
func_8002F554(&this->actor, globalCtx, getItemId);
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(this, func_8001E5C8);
|
2020-05-01 18:26:16 +00:00
|
|
|
this->actionFunc(this, globalCtx);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-04 19:02:51 +00:00
|
|
|
void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
|
|
|
EnItem00* this = THIS;
|
|
|
|
|
|
|
|
Collider_DestroyCylinder(globalCtx, &this->collider);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) {
|
|
|
|
if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk_15A < 0)) ||
|
|
|
|
(this->actor.params == ITEM00_HEART_PIECE)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.y += 960;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-05-01 18:26:16 +00:00
|
|
|
if ((this->actor.params >= ITEM00_SHIELD_DEKU) && (this->actor.params != ITEM00_BOMBS_SPECIAL)) {
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->unk_15A == -1) {
|
|
|
|
if (!Math_SmoothScaleMaxMinS(&this->actor.shape.rot.x, this->actor.posRot.rot.x - 0x4000, 2, 3000,
|
|
|
|
1500)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_15A = -2;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!Math_SmoothScaleMaxMinS(&this->actor.shape.rot.x, -this->actor.posRot.rot.x - 0x4000, 2, 3000,
|
|
|
|
1500)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_15A = -1;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
Math_SmoothScaleMaxMinS(&this->actor.posRot.rot.x, 0, 2, 2500, 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params == ITEM00_HEART_PIECE) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.unk_08 = Math_Sins(this->actor.shape.rot.y) * 150.0f + 850.0f;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
Math_SmoothScaleMaxMinF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f);
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->unk_154 == 0) {
|
2020-05-01 18:26:16 +00:00
|
|
|
if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) &&
|
|
|
|
(this->actor.params != ITEM00_HEART_CONTAINER)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_154 = -1;
|
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->unk_15A == 0) {
|
2020-05-01 18:26:16 +00:00
|
|
|
if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) &&
|
|
|
|
(this->actor.params != ITEM00_HEART_CONTAINER)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 0x0001)) {
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(this, func_8001E1C8);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) {
|
2020-03-17 04:31:30 +00:00
|
|
|
f32 originalVelocity;
|
|
|
|
Vec3f pos;
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params <= ITEM00_RUPEE_RED) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.y += 960;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (globalCtx->gameplayFrames & 1) {
|
2020-03-17 04:31:30 +00:00
|
|
|
pos.x = this->actor.posRot.pos.x + Math_Rand_CenteredFloat(10.0f);
|
|
|
|
pos.y = this->actor.posRot.pos.y + Math_Rand_CenteredFloat(10.0f);
|
|
|
|
pos.z = this->actor.posRot.pos.z + Math_Rand_CenteredFloat(10.0f);
|
2020-09-30 00:18:46 +00:00
|
|
|
EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_80115518, &D_80115524, &D_80115510, &D_80115514);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->actor.bgCheckFlags & 0x0003) {
|
2020-03-17 04:31:30 +00:00
|
|
|
originalVelocity = this->actor.velocity.y;
|
2020-03-22 21:19:43 +00:00
|
|
|
if (originalVelocity > -2.0f) {
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(this, func_8001DFC8);
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.velocity.y = 0.0f;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.velocity.y = originalVelocity * -0.8f;
|
|
|
|
this->actor.bgCheckFlags = this->actor.bgCheckFlags & 0xFFFE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001E304(EnItem00* this, GlobalContext* globalCtx) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 pad;
|
|
|
|
Vec3f pos;
|
|
|
|
s32 var1;
|
|
|
|
|
|
|
|
this->unk_15A++;
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params == ITEM00_HEART) {
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->actor.velocity.y < 0.0f) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.speedXZ = 0.0f;
|
|
|
|
this->actor.gravity = -0.4f;
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->actor.velocity.y < -1.5f) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.velocity.y = -1.5f;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
|
|
|
this->actor.initPosRot.rot.z += (s16)((this->actor.velocity.y + 3.0f) * 1000.0f);
|
|
|
|
this->actor.posRot.pos.x +=
|
2020-06-14 04:09:51 +00:00
|
|
|
Math_Coss(this->actor.yawTowardsLink) * (-3.0f * Math_Coss(this->actor.initPosRot.rot.z));
|
2020-03-22 21:19:43 +00:00
|
|
|
this->actor.posRot.pos.z +=
|
2020-06-14 04:09:51 +00:00
|
|
|
Math_Sins(this->actor.yawTowardsLink) * (-3.0f * Math_Coss(this->actor.initPosRot.rot.z));
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params <= ITEM00_RUPEE_RED) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.y += 960;
|
2020-05-01 18:26:16 +00:00
|
|
|
} else if ((this->actor.params >= ITEM00_SHIELD_DEKU) && (this->actor.params != ITEM00_BOMBS_SPECIAL)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.posRot.rot.x -= 700;
|
|
|
|
this->actor.shape.rot.y += 400;
|
|
|
|
this->actor.shape.rot.x = this->actor.posRot.rot.x - 0x4000;
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->actor.velocity.y <= 2.0f) {
|
2020-03-17 04:31:30 +00:00
|
|
|
var1 = (u16)this->actor.shape.rot.z + 10000;
|
2020-03-22 21:19:43 +00:00
|
|
|
if (var1 < 65535) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.z += 10000;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.z = -1;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (!(globalCtx->gameplayFrames & 1)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
pos.x = this->actor.posRot.pos.x + (Math_Rand_ZeroOne() - 0.5f) * 10.0f;
|
|
|
|
pos.y = this->actor.posRot.pos.y + (Math_Rand_ZeroOne() - 0.5f) * 10.0f;
|
|
|
|
pos.z = this->actor.posRot.pos.z + (Math_Rand_ZeroOne() - 0.5f) * 10.0f;
|
2020-09-30 00:18:46 +00:00
|
|
|
EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_80115518, &D_80115524, &D_80115510, &D_80115514);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->actor.bgCheckFlags & 0x0003) {
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(this, func_8001DFC8);
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.z = 0;
|
|
|
|
this->actor.velocity.y = 0.0f;
|
|
|
|
this->actor.speedXZ = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Player* player = PLAYER;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->unk_152 != 0) {
|
2020-08-29 22:25:16 +00:00
|
|
|
if (!Actor_HasParent(&this->actor, globalCtx)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
func_8002F434(&this->actor, globalCtx, this->unk_152, 50.0f, 80.0f);
|
|
|
|
this->unk_15A++;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_152 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->unk_15A == 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->actor.posRot.pos = player->actor.posRot.pos;
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params <= ITEM00_RUPEE_RED) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.y += 960;
|
2020-05-01 18:26:16 +00:00
|
|
|
} else if (this->actor.params == ITEM00_HEART) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.rot.y = 0;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
this->actor.posRot.pos.y += 40.0f + Math_Sins(this->unk_15A * 15000) * (this->unk_15A * 0.3f);
|
|
|
|
|
2020-05-30 13:33:29 +00:00
|
|
|
if (LINK_IS_ADULT) {
|
2020-05-29 21:20:00 +00:00
|
|
|
this->actor.posRot.pos.y += 20.0f;
|
2020-05-30 13:33:29 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern s32 D_80157D90;
|
2020-05-01 18:26:16 +00:00
|
|
|
extern u32 D_80157D90_; // these must be defined separately for EnItem00_Update to match
|
2020-03-17 04:31:30 +00:00
|
|
|
extern s16 D_80157D94;
|
|
|
|
|
2020-05-04 19:02:51 +00:00
|
|
|
void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
|
|
|
|
EnItem00* this = THIS;
|
2020-05-03 21:04:11 +00:00
|
|
|
s16* params;
|
|
|
|
s32 getItemId;
|
2020-03-17 04:31:30 +00:00
|
|
|
s16 sp3A;
|
|
|
|
Actor* dynaActor;
|
|
|
|
s16 i;
|
|
|
|
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = 0;
|
2020-03-17 04:31:30 +00:00
|
|
|
sp3A = 0;
|
|
|
|
|
2020-03-23 23:11:21 +00:00
|
|
|
if (this->unk_15A > 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_15A--;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-23 23:11:21 +00:00
|
|
|
if ((this->unk_15A > 0) && (this->unk_15A < 41) && (this->unk_154 <= 0)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->unk_156 = this->unk_15A;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
this->actionFunc(this, globalCtx);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
Math_SmoothScaleMaxMinF(&this->actor.scale.x, this->unk_15C, 0.1f, this->unk_15C * 0.1f, 0.0f);
|
|
|
|
this->actor.scale.z = this->actor.scale.x;
|
|
|
|
this->actor.scale.y = this->actor.scale.x;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->actor.gravity) {
|
|
|
|
if (this->actor.bgCheckFlags & 0x0003) {
|
2020-03-17 04:31:30 +00:00
|
|
|
// Separate symbols seem to be used here for 0x80157D90 since the loads and stores are completely separate
|
2020-03-22 21:19:43 +00:00
|
|
|
if (D_80157D90 != globalCtx->gameplayFrames) {
|
2020-03-17 04:31:30 +00:00
|
|
|
D_80157D90_ = globalCtx->gameplayFrames;
|
|
|
|
D_80157D94 = 0;
|
2020-03-22 21:19:43 +00:00
|
|
|
for (i = 0; i < 50; i++) {
|
|
|
|
if (globalCtx->colCtx.dyna.flags[i] & 1) {
|
2020-03-17 04:31:30 +00:00
|
|
|
dynaActor = globalCtx->colCtx.dyna.actorMeshArr[i].actor;
|
|
|
|
if ((dynaActor != NULL) && (dynaActor->update != NULL) &&
|
|
|
|
((dynaActor->posRot.pos.x != dynaActor->pos4.x) ||
|
|
|
|
(dynaActor->posRot.pos.y != dynaActor->pos4.y) ||
|
2020-03-22 21:19:43 +00:00
|
|
|
(dynaActor->posRot.pos.z != dynaActor->pos4.z))) {
|
2020-03-17 04:31:30 +00:00
|
|
|
D_80157D94++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
sp3A = 1;
|
|
|
|
Actor_MoveForward(&this->actor);
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (sp3A || D_80157D94) {
|
2020-03-17 04:31:30 +00:00
|
|
|
func_8002E4B4(globalCtx, &this->actor, 10.0f, 15.0f, 15.0f, 0x1D);
|
|
|
|
|
2020-06-14 04:09:51 +00:00
|
|
|
if (this->actor.groundY <= -10000.0f) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
Collider_CylinderUpdate(&this->actor, &this->collider);
|
|
|
|
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if ((this->actor.params == ITEM00_SHIELD_DEKU) || (this->actor.params == ITEM00_SHIELD_HYLIAN) ||
|
|
|
|
(this->actor.params == ITEM00_TUNIC_ZORA) || (this->actor.params == ITEM00_TUNIC_GORON)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
f32 newUnkBC = Math_Coss(this->actor.shape.rot.x) * 37.0f;
|
|
|
|
this->actor.shape.unk_08 = newUnkBC;
|
2020-03-23 23:11:21 +00:00
|
|
|
if (newUnkBC >= 0.0f) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.unk_08 = this->actor.shape.unk_08;
|
2020-03-23 23:11:21 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.shape.unk_08 = -this->actor.shape.unk_08;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-23 23:11:21 +00:00
|
|
|
if (this->unk_154 > 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-06-14 04:09:51 +00:00
|
|
|
if (!((this->actor.xzDistFromLink <= 30.0f) && (this->actor.yDistFromLink >= -50.0f) &&
|
|
|
|
(this->actor.yDistFromLink <= 50.0f))) {
|
2020-08-29 22:25:16 +00:00
|
|
|
if (!Actor_HasParent(&this->actor, globalCtx)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-23 23:11:21 +00:00
|
|
|
if (globalCtx->unk_10A20 != 0) {
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
switch (this->actor.params) {
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_GREEN:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_GREEN);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_BLUE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_BLUE);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_RED:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_RED);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_PURPLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_PURPLE);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_ORANGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_RUPEE_GOLD);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_STICK:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_STICKS_1;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_NUTS:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_NUTS_5;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_HEART);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_FLEXIBLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Health_ChangeBy(globalCtx, 0x70);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_BOMBS_A:
|
|
|
|
case ITEM00_BOMBS_B:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_BOMBS_5);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_SINGLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_BOW);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_SMALL:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_ARROWS_SMALL);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_MEDIUM:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_ARROWS_MEDIUM);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_ARROWS_LARGE:
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_Give(globalCtx, ITEM_ARROWS_LARGE);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SEEDS:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_SEEDS_5;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SMALL_KEY:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_KEY_SMALL;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_PIECE:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_HEART_PIECE;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_CONTAINER:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_HEART_CONTAINER;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_MAGIC_LARGE:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_MAGIC_LARGE;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_MAGIC_SMALL:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_MAGIC_SMALL;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SHIELD_DEKU:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_SHIELD_DEKU;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SHIELD_HYLIAN:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_SHIELD_HYLIAN;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_TUNIC_ZORA:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_TUNIC_ZORA;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_TUNIC_GORON:
|
2020-05-03 21:04:11 +00:00
|
|
|
getItemId = GI_TUNIC_GORON;
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_BOMBS_SPECIAL:
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-03 21:04:11 +00:00
|
|
|
params = &this->actor.params;
|
|
|
|
|
2020-08-29 22:25:16 +00:00
|
|
|
if ((getItemId != 0) && !Actor_HasParent(&this->actor, globalCtx)) {
|
2020-05-03 21:04:11 +00:00
|
|
|
func_8002F554(&this->actor, globalCtx, getItemId);
|
2020-03-23 23:11:21 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-03 21:04:11 +00:00
|
|
|
switch (*params) {
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_PIECE:
|
|
|
|
case ITEM00_HEART_CONTAINER:
|
|
|
|
case ITEM00_SMALL_KEY:
|
|
|
|
case ITEM00_SHIELD_DEKU:
|
|
|
|
case ITEM00_SHIELD_HYLIAN:
|
|
|
|
case ITEM00_TUNIC_ZORA:
|
|
|
|
case ITEM00_TUNIC_GORON:
|
2020-08-29 22:25:16 +00:00
|
|
|
if (Actor_HasParent(&this->actor, globalCtx)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Flags_SetCollectible(globalCtx, this->collectibleFlag);
|
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-03 21:04:11 +00:00
|
|
|
if ((*params <= ITEM00_RUPEE_RED) || (*params == ITEM00_RUPEE_ORANGE)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
2020-05-03 21:04:11 +00:00
|
|
|
} else if (getItemId != 0) {
|
2020-08-29 22:25:16 +00:00
|
|
|
if (Actor_HasParent(&this->actor, globalCtx)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
Flags_SetCollectible(globalCtx, this->collectibleFlag);
|
|
|
|
Actor_Kill(&this->actor);
|
|
|
|
}
|
|
|
|
return;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
Audio_PlaySoundGeneral(NA_SE_SY_GET_ITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
|
|
|
}
|
|
|
|
|
|
|
|
Flags_SetCollectible(globalCtx, this->collectibleFlag);
|
|
|
|
|
|
|
|
this->unk_15A = 15;
|
|
|
|
this->unk_154 = 35;
|
|
|
|
this->actor.shape.rot.z = 0;
|
|
|
|
this->actor.speedXZ = 0;
|
|
|
|
this->actor.velocity.y = 0;
|
|
|
|
this->actor.gravity = 0;
|
|
|
|
|
|
|
|
Actor_SetScale(&this->actor, this->unk_15C);
|
|
|
|
|
|
|
|
this->unk_152 = 0;
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(this, func_8001E5C8);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
// Draw Function prototypes (used in EnItem00_Draw)
|
|
|
|
void func_8001EF30(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
void func_8001F080(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
void func_8001F1F4(EnItem00* this, GlobalContext* globalCtx);
|
|
|
|
void func_8001F334(EnItem00* this, GlobalContext* globalCtx);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-04 19:02:51 +00:00
|
|
|
void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
|
|
|
EnItem00* this = THIS;
|
2020-03-17 04:31:30 +00:00
|
|
|
f32 unkFloat;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (!(this->unk_156 & this->unk_158)) {
|
|
|
|
switch (this->actor.params) {
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_RUPEE_GREEN:
|
|
|
|
case ITEM00_RUPEE_BLUE:
|
|
|
|
case ITEM00_RUPEE_RED:
|
|
|
|
case ITEM00_RUPEE_ORANGE:
|
|
|
|
case ITEM00_RUPEE_PURPLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_8001EF30(this, globalCtx);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_PIECE:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_8001F334(this, globalCtx);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART_CONTAINER:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_8001F1F4(this, globalCtx);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_HEART:
|
2020-03-22 21:19:43 +00:00
|
|
|
if (this->unk_15A < 0) {
|
|
|
|
if (this->unk_15A == -1) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART);
|
2020-03-22 21:19:43 +00:00
|
|
|
if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
this->actor.objBankIndex = bankIndex;
|
|
|
|
Actor_SetObjectDependency(globalCtx, &this->actor);
|
|
|
|
this->unk_15A = -2;
|
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
unkFloat = 16.0f;
|
|
|
|
Matrix_Scale(unkFloat, unkFloat, unkFloat, MTXMODE_APPLY);
|
|
|
|
func_800694A0(globalCtx, 0x08);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_BOMBS_A:
|
|
|
|
case ITEM00_BOMBS_B:
|
|
|
|
case ITEM00_BOMBS_SPECIAL:
|
|
|
|
case ITEM00_ARROWS_SINGLE:
|
|
|
|
case ITEM00_ARROWS_SMALL:
|
|
|
|
case ITEM00_ARROWS_MEDIUM:
|
|
|
|
case ITEM00_ARROWS_LARGE:
|
|
|
|
case ITEM00_NUTS:
|
|
|
|
case ITEM00_STICK:
|
|
|
|
case ITEM00_MAGIC_LARGE:
|
|
|
|
case ITEM00_MAGIC_SMALL:
|
|
|
|
case ITEM00_SEEDS:
|
|
|
|
case ITEM00_SMALL_KEY:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_8001F080(this, globalCtx);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SHIELD_DEKU:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_800694A0(globalCtx, 0x1C);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_SHIELD_HYLIAN:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_800694A0(globalCtx, 0x2B);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_TUNIC_ZORA:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_800694A0(globalCtx, 0x3C);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_TUNIC_GORON:
|
2020-03-17 04:31:30 +00:00
|
|
|
func_800694A0(globalCtx, 0x3B);
|
|
|
|
break;
|
2020-05-01 18:26:16 +00:00
|
|
|
case ITEM00_FLEXIBLE:
|
2020-03-17 04:31:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw Function used for Rupee types of En_Item00.
|
|
|
|
*/
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001EF30(EnItem00* this, GlobalContext* globalCtx) {
|
2020-08-29 23:00:17 +00:00
|
|
|
s32 pad;
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 iconNb;
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1546);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
func_80093D18(globalCtx->state.gfxCtx);
|
|
|
|
func_8002EBCC(&this->actor, globalCtx, 0);
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (1) { // Necessary to match
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params <= ITEM00_RUPEE_RED) {
|
2020-03-17 04:31:30 +00:00
|
|
|
iconNb = this->actor.params;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
iconNb = this->actor.params - 0x10;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPMatrix(oGfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1562),
|
2020-03-22 21:19:43 +00:00
|
|
|
G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPSegment(oGfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(D_80115530[iconNb]));
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPDisplayList(oGfxCtx->polyOpa.p++, &D_04042440);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1568);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw Function used for most collectible types of En_Item00 (ammo, bombs, sticks, nuts, magic...).
|
|
|
|
*/
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001F080(EnItem00* this, GlobalContext* globalCtx) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 iconNb;
|
|
|
|
|
|
|
|
iconNb = this->actor.params - 3;
|
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1594);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
oGfxCtx->polyOpa.p = func_800BC8A0(globalCtx, oGfxCtx->polyOpa.p);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (this->actor.params == ITEM00_BOMBS_SPECIAL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
iconNb = 1;
|
2020-05-01 18:26:16 +00:00
|
|
|
} else if (this->actor.params >= ITEM00_ARROWS_SMALL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
iconNb -= 3;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
oGfxCtx->polyOpa.p = func_800946E4(oGfxCtx->polyOpa.p);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPSegment(oGfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(D_80115544[iconNb]));
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPMatrix(oGfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1607),
|
2020-03-22 21:19:43 +00:00
|
|
|
G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPDisplayList(oGfxCtx->polyOpa.p++, &D_0403F070);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1611);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw Function used for the Heart Container type of En_Item00.
|
|
|
|
*/
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001F1F4(EnItem00* this, GlobalContext* globalCtx) {
|
2020-08-29 23:00:17 +00:00
|
|
|
s32 pad;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1623);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
func_80093D18(globalCtx->state.gfxCtx);
|
|
|
|
func_8002EBCC(&this->actor, globalCtx, 0);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPMatrix(oGfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1634),
|
2020-03-22 21:19:43 +00:00
|
|
|
G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPDisplayList(oGfxCtx->polyOpa.p++, &D_0403BBA0);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
func_80093D84(globalCtx->state.gfxCtx);
|
|
|
|
func_8002ED80(&this->actor, globalCtx, 0);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPMatrix(oGfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1644),
|
2020-03-22 21:19:43 +00:00
|
|
|
G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPDisplayList(oGfxCtx->polyXlu.p++, &D_0403BCD8);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1647);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw Function used for the Piece of Heart type of En_Item00.
|
|
|
|
*/
|
2020-05-01 18:26:16 +00:00
|
|
|
void func_8001F334(EnItem00* this, GlobalContext* globalCtx) {
|
2020-08-29 23:00:17 +00:00
|
|
|
s32 pad;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1658);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
func_80093D84(globalCtx->state.gfxCtx);
|
|
|
|
func_8002ED80(&this->actor, globalCtx, 0);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPMatrix(oGfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1670),
|
2020-03-22 21:19:43 +00:00
|
|
|
G_MTX_MODELVIEW | G_MTX_LOAD);
|
2020-08-29 23:00:17 +00:00
|
|
|
gSPDisplayList(oGfxCtx->polyXlu.p++, &D_0403B030);
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-08-29 23:00:17 +00:00
|
|
|
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1673);
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a given drop type ID based on link's current age, health and owned items.
|
|
|
|
* Returns a new drop type ID or -1 to cancel the drop.
|
|
|
|
*/
|
2020-03-22 21:19:43 +00:00
|
|
|
s16 func_8001F404(s16 dropId) {
|
|
|
|
if (LINK_IS_ADULT) {
|
2020-05-01 18:26:16 +00:00
|
|
|
if (dropId == ITEM00_SEEDS) {
|
|
|
|
dropId = ITEM00_ARROWS_SMALL;
|
|
|
|
} else if (dropId == ITEM00_STICK) {
|
|
|
|
dropId = ITEM00_RUPEE_GREEN;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-05-01 18:26:16 +00:00
|
|
|
if (dropId == ITEM00_ARROWS_SMALL || dropId == ITEM00_ARROWS_MEDIUM || dropId == ITEM00_ARROWS_LARGE) {
|
|
|
|
dropId = ITEM00_SEEDS;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is convoluted but it seems like it must be a single condition to match
|
2020-03-22 21:19:43 +00:00
|
|
|
// clang-format off
|
2020-05-01 18:26:16 +00:00
|
|
|
if (((dropId == ITEM00_BOMBS_A || dropId == ITEM00_BOMBS_SPECIAL || dropId == ITEM00_BOMBS_B) && INV_CONTENT(ITEM_BOMB) == ITEM_NONE) ||
|
|
|
|
((dropId == ITEM00_ARROWS_SMALL || dropId == ITEM00_ARROWS_MEDIUM || dropId == ITEM00_ARROWS_LARGE) && INV_CONTENT(ITEM_BOW) == ITEM_NONE) ||
|
|
|
|
((dropId == ITEM00_MAGIC_LARGE || dropId == ITEM00_MAGIC_SMALL) && gSaveContext.magicLevel == 0) ||
|
|
|
|
((dropId == ITEM00_SEEDS) && INV_CONTENT(ITEM_SLINGSHOT) == ITEM_NONE)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
return -1;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
|
|
|
// clang-format on
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (dropId == ITEM00_HEART && gSaveContext.healthCapacity == gSaveContext.health) {
|
|
|
|
return ITEM00_RUPEE_GREEN;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
return dropId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// External functions used by other actors to drop collectibles, which usually results in spawning an En_Item00 actor.
|
|
|
|
|
2020-07-12 23:03:38 +00:00
|
|
|
EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 pad[2];
|
2020-05-01 18:26:16 +00:00
|
|
|
EnItem00* spawnedActor = NULL;
|
2020-03-17 04:31:30 +00:00
|
|
|
s16 param4000 = params & 0x4000;
|
|
|
|
s16 param8000 = params & 0x8000;
|
|
|
|
s16 param3F00 = params & 0x3F00;
|
|
|
|
|
|
|
|
params = params & 0x3FFF;
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) {
|
|
|
|
// TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf)
|
|
|
|
spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x,
|
|
|
|
spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 0x0002);
|
2020-09-30 00:18:46 +00:00
|
|
|
EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true,
|
|
|
|
DEADSOUND_REPEAT_MODE_OFF, 40);
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
|
|
|
if (!param8000) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = func_8001F404(params & 0x00FF);
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (params != -1) {
|
2020-05-01 18:26:16 +00:00
|
|
|
spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x,
|
|
|
|
spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param3F00);
|
2020-03-22 21:19:43 +00:00
|
|
|
if ((spawnedActor != NULL) && !param8000) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->actor.velocity.y = !param4000 ? 8.0f : -2.0f;
|
|
|
|
spawnedActor->actor.speedXZ = 2.0f;
|
|
|
|
spawnedActor->actor.gravity = -0.9f;
|
|
|
|
spawnedActor->actor.posRot.rot.y = Math_Rand_CenteredFloat(65536.0f);
|
|
|
|
Actor_SetScale(&spawnedActor->actor, 0.0f);
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(spawnedActor, func_8001E304);
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->unk_15A = 220;
|
2020-05-01 18:26:16 +00:00
|
|
|
if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) &&
|
|
|
|
(spawnedActor->actor.params != ITEM00_HEART_PIECE) &&
|
|
|
|
(spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->actor.room = -1;
|
|
|
|
}
|
|
|
|
spawnedActor->actor.flags |= 0x0010;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 23:03:38 +00:00
|
|
|
return spawnedActor;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 23:03:38 +00:00
|
|
|
EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params) {
|
2020-05-01 18:26:16 +00:00
|
|
|
EnItem00* spawnedActor = NULL;
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 pad;
|
|
|
|
s16 param4000 = params & 0x4000;
|
|
|
|
s16 param8000 = params & 0x8000;
|
|
|
|
s16 param3F00 = params & 0x3F00;
|
|
|
|
|
|
|
|
params = params & 0x3FFF;
|
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) {
|
|
|
|
// TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf)
|
|
|
|
spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x,
|
|
|
|
spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 0x0002);
|
2020-09-30 00:18:46 +00:00
|
|
|
EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true,
|
|
|
|
DEADSOUND_REPEAT_MODE_OFF, 40);
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = func_8001F404(params & 0x00FF);
|
2020-03-22 21:19:43 +00:00
|
|
|
if (params != -1) {
|
2020-05-01 18:26:16 +00:00
|
|
|
spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x,
|
|
|
|
spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param3F00);
|
2020-03-22 21:19:43 +00:00
|
|
|
if ((spawnedActor != NULL) && !param8000) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->actor.velocity.y = 0.0f;
|
|
|
|
spawnedActor->actor.speedXZ = 0.0f;
|
|
|
|
spawnedActor->actor.gravity = param4000 ? 0.0f : -0.9f;
|
|
|
|
spawnedActor->actor.posRot.rot.y = Math_Rand_CenteredFloat(65536.0f);
|
|
|
|
spawnedActor->actor.flags |= 0x0010;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 23:03:38 +00:00
|
|
|
return spawnedActor;
|
2020-03-17 04:31:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 pad;
|
2020-05-01 18:26:16 +00:00
|
|
|
EnItem00* spawnedActor;
|
2020-03-17 04:31:30 +00:00
|
|
|
s16 dropQuantity;
|
|
|
|
s16 param8000;
|
|
|
|
s16 dropTableIndex;
|
|
|
|
u8 dropId;
|
|
|
|
|
|
|
|
dropTableIndex = Math_Rand_ZeroOne() * 16.0f;
|
|
|
|
param8000 = params & 0x8000;
|
|
|
|
params = params & 0x7FFF;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (fromActor != NULL) {
|
|
|
|
if (fromActor->unk_116) {
|
|
|
|
if (fromActor->unk_116 & 0x01) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 1 * 0x10;
|
|
|
|
dropTableIndex = 0xB;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (fromActor->unk_116 & 0x02) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 1 * 0x10;
|
|
|
|
dropTableIndex = 0x6;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (fromActor->unk_116 & 0x04) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 6 * 0x10;
|
|
|
|
dropTableIndex = 0x9;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (fromActor->unk_116 & 0x08) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 3 * 0x10;
|
|
|
|
dropTableIndex = 0xB;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (fromActor->unk_116 & 0x10) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 6 * 0x10;
|
|
|
|
dropTableIndex = 0xC;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (fromActor->unk_116 & 0x20) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0 * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (fromActor->unk_116 & 0x40) {
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0 * 0x10;
|
|
|
|
dropTableIndex = 0x1;
|
|
|
|
}
|
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
if (fromActor->unk_116 & 0x20) {
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_RUPEE_PURPLE;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
dropId = D_80115574[params + dropTableIndex];
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
dropId = D_80115574[params + dropTableIndex];
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-01 18:26:16 +00:00
|
|
|
if (dropId == ITEM00_FLEXIBLE) {
|
2020-03-22 21:19:43 +00:00
|
|
|
if (gSaveContext.health <= 0x10) { // 1 heart or less
|
|
|
|
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0,
|
|
|
|
0, 0, 0x0002);
|
2020-09-30 00:18:46 +00:00
|
|
|
EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true,
|
|
|
|
DEADSOUND_REPEAT_MODE_OFF, 40);
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (gSaveContext.health <= 0x30) { // 3 hearts or less
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xB * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_HEART;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (gSaveContext.health <= 0x50) { // 5 hearts or less
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xA * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_HEART;
|
2020-04-16 21:36:12 +00:00
|
|
|
} else if ((gSaveContext.magicLevel != 0) && (gSaveContext.magic == 0)) { // Empty magic meter
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xA * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_MAGIC_LARGE;
|
2020-04-16 21:36:12 +00:00
|
|
|
} else if ((gSaveContext.magicLevel != 0) &&
|
|
|
|
(gSaveContext.magic <= (gSaveContext.magicLevel >> 1))) { // Half magic or less
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xA * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_MAGIC_SMALL;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (LINK_IS_CHILD && (AMMO(ITEM_SLINGSHOT) < 6)) { // Child and less then 6 deku seeds
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xA * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_SEEDS;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (LINK_IS_ADULT && (AMMO(ITEM_BOW) < 6)) { // Adult and less than 6 arrows
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xA * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_ARROWS_MEDIUM;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (AMMO(ITEM_BOMB) < 6) { // Less than 6 bombs
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xD * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_BOMBS_A;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else if (gSaveContext.rupees < 11) { // Less than 11 Rupees
|
2020-03-17 04:31:30 +00:00
|
|
|
params = 0xA * 0x10;
|
|
|
|
dropTableIndex = 0x0;
|
2020-05-01 18:26:16 +00:00
|
|
|
dropId = ITEM00_RUPEE_RED;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (dropId != 0xFF) {
|
2020-03-17 04:31:30 +00:00
|
|
|
dropQuantity = D_80115664[params + dropTableIndex];
|
2020-03-22 21:19:43 +00:00
|
|
|
while (dropQuantity > 0) {
|
|
|
|
if (!param8000) {
|
2020-03-17 04:31:30 +00:00
|
|
|
dropId = func_8001F404(dropId);
|
2020-03-22 21:19:43 +00:00
|
|
|
if (dropId != 0xFF) {
|
2020-05-01 18:26:16 +00:00
|
|
|
spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x,
|
|
|
|
spawnPos->y, spawnPos->z, 0, 0, 0, dropId);
|
2020-03-22 21:19:43 +00:00
|
|
|
if ((spawnedActor != NULL) && (dropId != 0xFF)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->actor.velocity.y = 8.0f;
|
|
|
|
spawnedActor->actor.speedXZ = 2.0f;
|
|
|
|
spawnedActor->actor.gravity = -0.9f;
|
|
|
|
spawnedActor->actor.posRot.rot.y = Math_Rand_ZeroOne() * 40000.0f;
|
|
|
|
Actor_SetScale(&spawnedActor->actor, 0.0f);
|
2020-05-05 22:53:15 +00:00
|
|
|
EnItem00_SetupAction(spawnedActor, func_8001E304);
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->actor.flags |= 0x0010;
|
2020-05-01 18:26:16 +00:00
|
|
|
if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) &&
|
|
|
|
(spawnedActor->actor.params != ITEM00_HEART_PIECE) &&
|
|
|
|
(spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) {
|
2020-03-17 04:31:30 +00:00
|
|
|
spawnedActor->actor.room = -1;
|
|
|
|
}
|
|
|
|
spawnedActor->unk_15A = 220;
|
|
|
|
}
|
|
|
|
}
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
Item_DropCollectible(globalCtx, spawnPos, params | 0x8000);
|
|
|
|
}
|
|
|
|
dropQuantity--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|