mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-06 14:20:11 +00:00
z_obj_kibako2 (large wooden crate) OK (#582)
* Migrate data to C * Partially decompile Init * func_80B959D0 OK * ObjKibako2_Destroy OK * ObjKibako2_Update OK * ObjKibako2_Draw OK * func_80B95CA4 OK * ObjKibako2_Init OK * func_80B95DFC * func_80B95ED4 OK * func_80B95A28 OK * Name functions * Delete unused asm and update spec * Fixup math post rebase * Name statics * Clean up variable names * Run formatter * xzDistFromLink -> xzDistToLink * Respond to feedback in ObjKibako2_Break * Type sp2C as a CollisionHeader* and initalize it when declaring it * Respond to remaining review feedback * Respond to review feedback from Roman
This commit is contained in:
parent
3e5f6b3485
commit
3b4a1c23d6
14 changed files with 140 additions and 488 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "z_obj_kibako2.h"
|
||||
#include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h"
|
||||
|
||||
#define FLAGS 0x00000000
|
||||
|
||||
|
@ -14,12 +15,13 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx);
|
|||
void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx);
|
||||
void ObjKibako2_Kill(ObjKibako2* this, GlobalContext* globalCtx);
|
||||
|
||||
extern UNK_TYPE D_06000960;
|
||||
extern Gfx D_06000960[];
|
||||
extern UNK_TYPE D_06000B70;
|
||||
extern UNK_TYPE D_06001000;
|
||||
extern Gfx D_06001000[];
|
||||
|
||||
/*
|
||||
const ActorInit Obj_Kibako2_InitVars = {
|
||||
ACTOR_OBJ_KIBAKO2,
|
||||
ACTORTYPE_BG,
|
||||
|
@ -31,21 +33,140 @@ const ActorInit Obj_Kibako2_InitVars = {
|
|||
(ActorFunc)ObjKibako2_Update,
|
||||
(ActorFunc)ObjKibako2_Draw,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/func_80B959D0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/func_80B95A28.s")
|
||||
static ColliderCylinderInit sCylinderInit = {
|
||||
{ COLTYPE_UNK10, 0x00, 0x09, 0x00, 0x20, COLSHAPE_CYLINDER },
|
||||
{ 0x00, { 0x00000000, 0x00, 0x00 }, { 0x40000040, 0x00, 0x00 }, 0x00, 0x01, 0x00 },
|
||||
{ 31, 48, 0, { 0, 0, 0 } },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/func_80B95CA4.s")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/ObjKibako2_Init.s")
|
||||
void ObjKibako2_InitCollider(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjKibako2* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/ObjKibako2_Destroy.s")
|
||||
Collider_InitCylinder(globalCtx, &this->collider);
|
||||
Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit);
|
||||
Collider_CylinderUpdate(&this->dyna.actor, &this->collider);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/func_80B95DFC.s")
|
||||
void ObjKibako2_Break(ObjKibako2* this, GlobalContext* globalCtx) {
|
||||
s32 pad[2];
|
||||
Vec3f* thisPos;
|
||||
Vec3f pos;
|
||||
Vec3f velocity;
|
||||
s16 angle;
|
||||
s32 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/func_80B95ED4.s")
|
||||
thisPos = &this->dyna.actor.posRot.pos;
|
||||
for (i = 0, angle = 0; i < 0x10; i++, angle += 0x4E20) {
|
||||
f32 sn = Math_SinS(angle);
|
||||
f32 cs = Math_CosS(angle);
|
||||
f32 temp_rand;
|
||||
s32 phi_s0;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/ObjKibako2_Update.s")
|
||||
temp_rand = Rand_ZeroOne() * 30.0f;
|
||||
pos.x = sn * temp_rand;
|
||||
pos.y = (Rand_ZeroOne() * 10.0f) + 2.0f;
|
||||
pos.z = cs * temp_rand;
|
||||
velocity.x = pos.x * 0.2f;
|
||||
velocity.y = (Rand_ZeroOne() * 10.0f) + 2.0f;
|
||||
velocity.z = pos.z * 0.2f;
|
||||
pos.x += thisPos->x;
|
||||
pos.y += thisPos->y;
|
||||
pos.z += thisPos->z;
|
||||
temp_rand = Rand_ZeroOne();
|
||||
if (temp_rand < 0.05f) {
|
||||
phi_s0 = 0x60;
|
||||
} else if (temp_rand < 0.7f) {
|
||||
phi_s0 = 0x40;
|
||||
} else {
|
||||
phi_s0 = 0x20;
|
||||
}
|
||||
EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -200, phi_s0, 28, 2, 0, (Rand_ZeroOne() * 30.0f) + 5.0f,
|
||||
0, 0, 70, KAKERA_COLOR_NONE, OBJECT_KIBAKO2, D_06001000);
|
||||
}
|
||||
func_80033480(globalCtx, thisPos, 90.0f, 6, 100, 160, 1);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Kibako2/ObjKibako2_Draw.s")
|
||||
void ObjKibako2_SpawnCollectible(ObjKibako2* this, GlobalContext* globalCtx) {
|
||||
s16 itemDropped;
|
||||
s16 collectibleFlagTemp;
|
||||
|
||||
collectibleFlagTemp = this->collectibleFlag;
|
||||
itemDropped = this->dyna.actor.initPosRot.rot.x;
|
||||
if (itemDropped >= 0 && itemDropped < 0x1A) {
|
||||
Item_DropCollectible(globalCtx, &this->dyna.actor.posRot.pos, itemDropped | (collectibleFlagTemp << 8));
|
||||
}
|
||||
}
|
||||
|
||||
void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjKibako2* this = THIS;
|
||||
s16 pad;
|
||||
CollisionHeader* colHeader = NULL;
|
||||
u32 bgId;
|
||||
|
||||
DynaPolyActor_Init(&this->dyna, 0);
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
ObjKibako2_InitCollider(thisx, globalCtx);
|
||||
CollisionHeader_GetVirtual(&D_06000B70, &colHeader);
|
||||
bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
|
||||
this->collectibleFlag = this->dyna.actor.initPosRot.rot.z & 0x3F;
|
||||
this->dyna.bgId = bgId;
|
||||
this->actionFunc = ObjKibako2_Idle;
|
||||
this->dyna.actor.initPosRot.rot.z = this->dyna.actor.posRot.rot.z = this->dyna.actor.shape.rot.z =
|
||||
this->dyna.actor.posRot.rot.x = this->dyna.actor.shape.rot.x = 0;
|
||||
// Wooden box (stationary)
|
||||
osSyncPrintf("木箱(据置)(arg %04xH)(item %04xH %d)\n", this->dyna.actor.params, this->collectibleFlag,
|
||||
this->dyna.actor.initPosRot.rot.x);
|
||||
}
|
||||
|
||||
void ObjKibako2_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjKibako2* this = THIS;
|
||||
|
||||
Collider_DestroyCylinder(globalCtx, &this->collider);
|
||||
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
|
||||
void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) {
|
||||
if ((this->collider.base.acFlags & 2) || this->dyna.actor.initPosRot.rot.z != 0 ||
|
||||
func_80033684(globalCtx, &this->dyna.actor) != 0) {
|
||||
ObjKibako2_Break(this, globalCtx);
|
||||
Audio_PlaySoundAtPosition(globalCtx, &this->dyna.actor.posRot.pos, 20, NA_SE_EV_WOODBOX_BREAK);
|
||||
this->dyna.actor.flags |= 0x10;
|
||||
func_8003EBF8(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
this->dyna.actor.draw = NULL;
|
||||
this->actionFunc = ObjKibako2_Kill;
|
||||
return;
|
||||
}
|
||||
if (this->dyna.actor.xzDistToLink < 600.0f) {
|
||||
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjKibako2_Kill(ObjKibako2* this, GlobalContext* globalCtx) {
|
||||
s16 params = this->dyna.actor.params;
|
||||
|
||||
if ((params & 0x8000) == 0) {
|
||||
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->dyna.actor.posRot.pos.x,
|
||||
this->dyna.actor.posRot.pos.y, this->dyna.actor.posRot.pos.z, 0, this->dyna.actor.shape.rot.y, 0,
|
||||
params | 0x8000);
|
||||
}
|
||||
ObjKibako2_SpawnCollectible(this, globalCtx);
|
||||
Actor_Kill(&this->dyna.actor);
|
||||
}
|
||||
|
||||
void ObjKibako2_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjKibako2* this = THIS;
|
||||
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
||||
void ObjKibako2_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
Gfx_DrawDListOpa(globalCtx, D_06000960);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
|
||||
struct ObjKibako2;
|
||||
|
||||
typedef void (*ObjKibako2ActionFunc)(struct ObjKibako2*, GlobalContext*);
|
||||
|
||||
typedef struct ObjKibako2 {
|
||||
/* 0x0000 */ DynaPolyActor dyna;
|
||||
/* 0x0164 */ char unk_164[0x54];
|
||||
/* 0x0164 */ ColliderCylinder collider;
|
||||
/* 0x01B0 */ ObjKibako2ActionFunc actionFunc;
|
||||
/* 0x01B4 */ s16 collectibleFlag;
|
||||
} ObjKibako2; // size = 0x01B8
|
||||
|
||||
extern const ActorInit Obj_Kibako2_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue