mirror of
https://github.com/zeldaret/mm.git
synced 2026-08-17 21:03:30 -04:00
Bg_Numa_Hana (Wooden Flower in Woodfall Temple) OK and documented, partial documentation of object_numa_obj (#666)
* Import data to C * BgNumaHana_Init OK * BgNumaHana_Destroy OK * BgNumaHana_Update OK * func_80A1A500 OK * func_80A1AE08 and func_80A1AE1C OK * func_80A1AA14 and func_80A1AA28 OK * func_80A1AA38 and func_80A1AA4C OK * A few more functions * Finish most functions * func_80A1A56C OK * BgNumaHana_Draw OK * Use generated reloc * Use object symbols * Actor flags * Minor cleanup * Some initial documentation * More documentation * Document flower petal struct * Some more struct vars * Name everything else * Finish documenting the object for the flower * Final doc pass * UNK_TYPE * Respond to review and fix build
This commit is contained in:
@@ -5,8 +5,10 @@
|
||||
*/
|
||||
|
||||
#include "z_bg_numa_hana.h"
|
||||
#include "objects/object_numa_obj/object_numa_obj.h"
|
||||
#include "objects/object_syokudai/object_syokudai.h"
|
||||
|
||||
#define FLAGS 0x00000410
|
||||
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400)
|
||||
|
||||
#define THIS ((BgNumaHana*)thisx)
|
||||
|
||||
@@ -15,14 +17,19 @@ void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
void func_80A1AA28(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void func_80A1AA4C(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void func_80A1AB00(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void func_80A1ABF0(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void func_80A1ACE0(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void func_80A1AE1C(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void BgNumaHana_SetupDoNothing(BgNumaHana* this);
|
||||
void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void BgNumaHana_SetupClosedIdle(BgNumaHana* this);
|
||||
void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this);
|
||||
void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this);
|
||||
void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void BgNumaHana_SetupRaiseFlower(BgNumaHana* this);
|
||||
void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
void BgNumaHana_SetupOpenedIdle(BgNumaHana* this);
|
||||
void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx);
|
||||
|
||||
#if 0
|
||||
const ActorInit Bg_Numa_Hana_InitVars = {
|
||||
ACTOR_BG_NUMA_HANA,
|
||||
ACTORCAT_BG,
|
||||
@@ -35,63 +42,379 @@ const ActorInit Bg_Numa_Hana_InitVars = {
|
||||
(ActorFunc)BgNumaHana_Draw,
|
||||
};
|
||||
|
||||
// static ColliderCylinderInit sCylinderInit = {
|
||||
static ColliderCylinderInit D_80A1B260 = {
|
||||
{ COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, },
|
||||
{ ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x01CBFBB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, },
|
||||
static ColliderCylinderInit sCylinderInit = {
|
||||
{
|
||||
COLTYPE_METAL,
|
||||
AT_NONE,
|
||||
AC_ON | AC_HARD | AC_TYPE_PLAYER,
|
||||
OC1_ON | OC1_TYPE_ALL,
|
||||
OC2_TYPE_2,
|
||||
COLSHAPE_CYLINDER,
|
||||
},
|
||||
{
|
||||
ELEMTYPE_UNK2,
|
||||
{ 0x00000000, 0x00, 0x00 },
|
||||
{ 0x01CBFBB6, 0x00, 0x00 },
|
||||
TOUCH_NONE | TOUCH_SFX_NORMAL,
|
||||
BUMP_ON | BUMP_HOOKABLE,
|
||||
OCELEM_ON,
|
||||
},
|
||||
{ 18, 16, 0, { 0, 0, 0 } },
|
||||
};
|
||||
|
||||
// static InitChainEntry sInitChain[] = {
|
||||
static InitChainEntry D_80A1B2A8[] = {
|
||||
static FireObjInitParams sFireObjInit = {
|
||||
0.00405000010505f, 0.0500000007451f, 3, 1, 0, 0, 0,
|
||||
};
|
||||
|
||||
static s16 sInitialAnglePerPetal[] = { 0x0000, 0x2AAA, 0x5555, 0x8000, 0xAAAA, 0xD555 };
|
||||
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Spawns another wooden flower instance that handles the opened flower's collision.
|
||||
* Returns true if this wooden flower instance was succesfully spawned.
|
||||
*/
|
||||
s32 BgNumaHana_SpawnOpenFlowerCollisionChild(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
Actor* child;
|
||||
|
||||
extern ColliderCylinderInit D_80A1B260;
|
||||
extern InitChainEntry D_80A1B2A8[];
|
||||
child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_NUMA_HANA,
|
||||
this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z,
|
||||
this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z,
|
||||
BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION);
|
||||
|
||||
extern UNK_TYPE D_06009FE0;
|
||||
extern UNK_TYPE D_0600B928;
|
||||
return child != NULL;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A500.s")
|
||||
void BgNumaHana_UpdatePetalPosRots(BgNumaHana* this) {
|
||||
f32 outerPetalPosScale;
|
||||
f32 innerPetalYPos;
|
||||
f32 outerPetalYPos;
|
||||
s16 angle;
|
||||
WoodenFlowerPetalPosRot* innerPetalPosRot;
|
||||
WoodenFlowerPetalPosRot* outerPetalPosRot;
|
||||
s32 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A56C.s")
|
||||
innerPetalYPos = this->dyna.actor.world.pos.y + -10.0f;
|
||||
angle = this->petalZRotation - 0x2000;
|
||||
outerPetalPosScale = (Math_CosS(angle) * 77.42784f) + 74.95192f;
|
||||
outerPetalYPos = (Math_SinS(this->petalZRotation) * 77.42784f) + this->dyna.actor.world.pos.y + -64.74976f;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A750.s")
|
||||
for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) {
|
||||
innerPetalPosRot = &this->innerPetalPosRot[i];
|
||||
outerPetalPosRot = &this->outerPetalPosRot[i];
|
||||
angle = sInitialAnglePerPetal[i] + this->dyna.actor.shape.rot.y + 0x1555;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Init.s")
|
||||
innerPetalPosRot->pos.x = (Math_SinS(angle) * 74.95192f) + this->dyna.actor.world.pos.x;
|
||||
innerPetalPosRot->pos.y = innerPetalYPos;
|
||||
innerPetalPosRot->pos.z = (Math_CosS(angle) * 74.95192f) + this->dyna.actor.world.pos.z;
|
||||
innerPetalPosRot->rot.x = this->dyna.actor.shape.rot.x;
|
||||
innerPetalPosRot->rot.y = angle - 0x4000;
|
||||
innerPetalPosRot->rot.z = this->dyna.actor.shape.rot.z + this->petalZRotation;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Destroy.s")
|
||||
outerPetalPosRot->pos.x = (Math_SinS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.x;
|
||||
outerPetalPosRot->pos.y = outerPetalYPos;
|
||||
outerPetalPosRot->pos.z = (Math_CosS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.z;
|
||||
outerPetalPosRot->rot.x = innerPetalPosRot->rot.x;
|
||||
outerPetalPosRot->rot.y = innerPetalPosRot->rot.y;
|
||||
outerPetalPosRot->rot.z = innerPetalPosRot->rot.z + this->outerPetalZRotation;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA14.s")
|
||||
/**
|
||||
* As the pieces of the petals finish unfolding, they shake to appear
|
||||
* as if they are "settling" into place. This function is responsible
|
||||
* for computing the extra rotation for this "settling".
|
||||
*/
|
||||
void BgNumaHana_UpdateSettleRotation(s16* settleZRotation, s16* settleAngle, f32* settleScale, f32 scaleStep) {
|
||||
*settleAngle += 0x32C8;
|
||||
Math_StepToF(settleScale, 0.0f, scaleStep);
|
||||
*settleZRotation += (s16)(Math_SinS(*settleAngle) * *settleScale);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA28.s")
|
||||
void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
DynaPolyActor* child;
|
||||
s32 type;
|
||||
BgNumaHana* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA38.s")
|
||||
type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor);
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
DynaPolyActor_Init(&this->dyna, 3);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA4C.s")
|
||||
if (type == BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION) {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerOpenedFlowerCol);
|
||||
BgNumaHana_SetupDoNothing(this);
|
||||
this->dyna.actor.draw = NULL;
|
||||
} else {
|
||||
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerClosedFlowerCol);
|
||||
FireObj_Init(globalCtx, &this->fire, &sFireObjInit, &this->dyna.actor);
|
||||
Collider_InitCylinder(globalCtx, &this->torchCollider);
|
||||
Collider_SetCylinder(globalCtx, &this->torchCollider, &this->dyna.actor, &sCylinderInit);
|
||||
this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE;
|
||||
if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, globalCtx)) {
|
||||
Actor_MarkForDeath(&this->dyna.actor);
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AAE8.s")
|
||||
if (gSaveContext.weekEventReg[12] & 1) {
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AB00.s")
|
||||
this->petalZRotation = 0x2000;
|
||||
this->innerPetalZRotation = 0x2000;
|
||||
this->innerPetalZRotationalVelocity = 0;
|
||||
this->settleZRotation = 0;
|
||||
this->settleAngle = 0;
|
||||
this->settleScale = 0.0f;
|
||||
this->outerPetalZRotation = -0x4000;
|
||||
this->outerPetalZRotationalVelocity = 0;
|
||||
this->flowerRotationalVelocity = 0x147;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABD8.s")
|
||||
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 210.0f;
|
||||
FireObj_SetState2(&this->fire, 0.05f, 2);
|
||||
Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor));
|
||||
BgNumaHana_SetupOpenedIdle(this);
|
||||
} else {
|
||||
child = (DynaPolyActor*)this->dyna.actor.child;
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, child->bgId);
|
||||
Flags_UnsetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor));
|
||||
BgNumaHana_SetupClosedIdle(this);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABF0.s")
|
||||
BgNumaHana_UpdatePetalPosRots(this);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACCC.s")
|
||||
void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgNumaHana* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACE0.s")
|
||||
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
if (BG_NUMA_HANA_GET_TYPE(&this->dyna.actor) == BG_NUMA_HANA_TYPE_NORMAL) {
|
||||
FireObj_Destroy(globalCtx, &this->fire);
|
||||
Collider_DestroyCylinder(globalCtx, &this->torchCollider);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE08.s")
|
||||
void BgNumaHana_SetupDoNothing(BgNumaHana* this) {
|
||||
this->actionFunc = BgNumaHana_DoNothing;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE1C.s")
|
||||
void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Update.s")
|
||||
void BgNumaHana_SetupClosedIdle(BgNumaHana* this) {
|
||||
this->actionFunc = BgNumaHana_ClosedIdle;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Draw.s")
|
||||
/**
|
||||
* This function waits for the torch to be lit. Once it is, it starts
|
||||
* the cutscene where the petals unfold.
|
||||
*/
|
||||
void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
if (this->fire.state != 3) {
|
||||
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION);
|
||||
if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
|
||||
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
|
||||
gSaveContext.weekEventReg[12] |= 1;
|
||||
Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor));
|
||||
BgNumaHana_SetupUnfoldInnerPetals(this);
|
||||
} else {
|
||||
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this) {
|
||||
this->actionFunc = BgNumaHana_UnfoldInnerPetals;
|
||||
this->transitionTimer = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially moves the flower to the "open" position by raising the "inner"
|
||||
* parts of the petals that are closest to the stalk.
|
||||
*/
|
||||
void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
Math_StepToS(&this->innerPetalZRotationalVelocity, 240, 14);
|
||||
if (Math_ScaledStepToS(&this->innerPetalZRotation, 0x2000, this->innerPetalZRotationalVelocity)) {
|
||||
if (this->transitionTimer >= 11) {
|
||||
BgNumaHana_SetupUnfoldOuterPetals(this);
|
||||
} else {
|
||||
if (this->transitionTimer <= 0) {
|
||||
this->settleZRotation = 0;
|
||||
this->settleAngle = 0;
|
||||
this->settleScale = 420.0f;
|
||||
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP);
|
||||
}
|
||||
this->transitionTimer++;
|
||||
}
|
||||
} else {
|
||||
func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG);
|
||||
}
|
||||
|
||||
BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 20.0f);
|
||||
this->petalZRotation = this->innerPetalZRotation + this->settleZRotation;
|
||||
BgNumaHana_UpdatePetalPosRots(this);
|
||||
}
|
||||
|
||||
void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this) {
|
||||
this->actionFunc = BgNumaHana_UnfoldOuterPetals;
|
||||
this->transitionTimer = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partially moves the flower to the "open" position by lowering the "outer"
|
||||
* parts of the petals that are furthest to the stalk.
|
||||
*/
|
||||
void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
Math_StepToS(&this->outerPetalZRotationalVelocity, 240, 14);
|
||||
if (Math_ScaledStepToS(&this->outerPetalZRotation, -0x4000, this->outerPetalZRotationalVelocity)) {
|
||||
if (this->transitionTimer >= 11) {
|
||||
BgNumaHana_SetupRaiseFlower(this);
|
||||
} else {
|
||||
if (this->transitionTimer <= 0) {
|
||||
this->settleZRotation = 0;
|
||||
this->settleAngle = 0x5120;
|
||||
this->settleScale = 130.0f;
|
||||
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP);
|
||||
}
|
||||
this->transitionTimer++;
|
||||
}
|
||||
} else {
|
||||
func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG);
|
||||
}
|
||||
|
||||
BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 7.0f);
|
||||
this->petalZRotation = this->innerPetalZRotation + this->settleZRotation;
|
||||
BgNumaHana_UpdatePetalPosRots(this);
|
||||
}
|
||||
|
||||
void BgNumaHana_SetupRaiseFlower(BgNumaHana* this) {
|
||||
this->actionFunc = BgNumaHana_RaiseFlower;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function slowly raises the flower to its final height and makes it start spinning.
|
||||
*/
|
||||
void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
DynaPolyActor* child;
|
||||
|
||||
BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 10.0f);
|
||||
this->petalZRotation = this->innerPetalZRotation + this->settleZRotation;
|
||||
Math_StepToS(&this->flowerRotationalVelocity, 0x111, 0xA);
|
||||
this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity;
|
||||
Math_StepToF(&this->dyna.actor.velocity.y, 3.0f, 0.3f);
|
||||
|
||||
if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 210.0f,
|
||||
this->dyna.actor.velocity.y)) {
|
||||
child = (DynaPolyActor*)this->dyna.actor.child;
|
||||
|
||||
// Swaps out the "closed" flower collision for the "opened" collision.
|
||||
func_800C6314(globalCtx, &globalCtx->colCtx.dyna, child->bgId);
|
||||
func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
|
||||
this->petalZRotation = 0x2000;
|
||||
this->innerPetalZRotation = 0x2000;
|
||||
this->innerPetalZRotationalVelocity = 0;
|
||||
this->settleZRotation = 0;
|
||||
this->settleAngle = 0;
|
||||
this->outerPetalZRotation = -0x4000;
|
||||
this->outerPetalZRotationalVelocity = 0;
|
||||
this->flowerRotationalVelocity = 0x147;
|
||||
this->settleScale = 0.0f;
|
||||
|
||||
ActorCutscene_Stop(this->dyna.actor.cutscene);
|
||||
BgNumaHana_SetupOpenedIdle(this);
|
||||
}
|
||||
|
||||
BgNumaHana_UpdatePetalPosRots(this);
|
||||
func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG);
|
||||
}
|
||||
|
||||
void BgNumaHana_SetupOpenedIdle(BgNumaHana* this) {
|
||||
this->actionFunc = BgNumaHana_OpenedIdle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spins the "opened" flower around the y-axis.
|
||||
*/
|
||||
void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx) {
|
||||
this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity;
|
||||
this->petalZRotation = this->innerPetalZRotation + this->settleZRotation;
|
||||
BgNumaHana_UpdatePetalPosRots(this);
|
||||
func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG);
|
||||
}
|
||||
|
||||
void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
BgNumaHana* this = THIS;
|
||||
s32 type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor);
|
||||
Vec3f firePos;
|
||||
|
||||
if (type == BG_NUMA_HANA_TYPE_NORMAL) {
|
||||
firePos.x = this->dyna.actor.world.pos.x;
|
||||
firePos.y = this->dyna.actor.world.pos.y + 10.5f;
|
||||
firePos.z = this->dyna.actor.world.pos.z;
|
||||
FireObj_SetPosition(&this->fire, &firePos);
|
||||
FireObj_Update(globalCtx, &this->fire, &this->dyna.actor);
|
||||
}
|
||||
|
||||
this->actionFunc(this, globalCtx);
|
||||
|
||||
if (type == BG_NUMA_HANA_TYPE_NORMAL) {
|
||||
this->dyna.actor.child->shape.rot = this->dyna.actor.shape.rot;
|
||||
Collider_UpdateCylinder(&this->dyna.actor, &this->torchCollider);
|
||||
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base);
|
||||
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base);
|
||||
}
|
||||
}
|
||||
|
||||
void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) {
|
||||
GlobalContext* globalCtx = globalCtx2;
|
||||
BgNumaHana* this = THIS;
|
||||
WoodenFlowerPetalPosRot* innerPetalPosRot;
|
||||
WoodenFlowerPetalPosRot* outerPetalPosRot;
|
||||
s32 objectIndex;
|
||||
s32 i;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
func_8012C28C(globalCtx->state.gfxCtx);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerStalkDL);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) {
|
||||
innerPetalPosRot = &this->innerPetalPosRot[i];
|
||||
outerPetalPosRot = &this->outerPetalPosRot[i];
|
||||
|
||||
Matrix_SetStateRotationAndTranslation(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z,
|
||||
&innerPetalPosRot->rot);
|
||||
Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL);
|
||||
|
||||
Matrix_SetStateRotationAndTranslation(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z,
|
||||
&outerPetalPosRot->rot);
|
||||
Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL);
|
||||
}
|
||||
|
||||
objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI);
|
||||
if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) {
|
||||
Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f,
|
||||
this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot);
|
||||
Matrix_Scale(1.5f, 1.5f, 1.5f, MTXMODE_APPLY);
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment);
|
||||
gSPDisplayList(POLY_OPA_DISP++, gObjectSyokudaiTypeNoSwitchDL);
|
||||
}
|
||||
|
||||
FireObj_Draw(globalCtx, &this->fire);
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,41 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#define BG_NUMA_HANA_GET_TYPE(thisx) ((thisx)->params & 1)
|
||||
#define BG_NUMA_HANA_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0x7F)
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ BG_NUMA_HANA_TYPE_NORMAL,
|
||||
/* 1 */ BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION,
|
||||
} BgNumaHanaType;
|
||||
|
||||
struct BgNumaHana;
|
||||
|
||||
typedef void (*BgNumaHanaActionFunc)(struct BgNumaHana*, GlobalContext*);
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ Vec3f pos;
|
||||
/* 0x0C */ Vec3s rot;
|
||||
/* 0x12 */ UNK_TYPE1 unk_12[0x2];
|
||||
} WoodenFlowerPetalPosRot; // size = 0x14
|
||||
|
||||
typedef struct BgNumaHana {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x0144 */ char unk_144[0xF0];
|
||||
/* 0x0234 */ BgNumaHanaActionFunc actionFunc;
|
||||
/* 0x0238 */ char unk_238[0x108];
|
||||
/* 0x000 */ DynaPolyActor dyna;
|
||||
/* 0x15C */ FireObj fire;
|
||||
/* 0x1E8 */ ColliderCylinder torchCollider;
|
||||
/* 0x234 */ BgNumaHanaActionFunc actionFunc;
|
||||
/* 0x238 */ WoodenFlowerPetalPosRot innerPetalPosRot[6];
|
||||
/* 0x2B0 */ WoodenFlowerPetalPosRot outerPetalPosRot[6];
|
||||
/* 0x328 */ s16 petalZRotation;
|
||||
/* 0x32A */ s16 innerPetalZRotation;
|
||||
/* 0x32C */ s16 innerPetalZRotationalVelocity;
|
||||
/* 0x32E */ s16 settleZRotation;
|
||||
/* 0x330 */ s16 settleAngle;
|
||||
/* 0x334 */ f32 settleScale;
|
||||
/* 0x338 */ s16 outerPetalZRotation;
|
||||
/* 0x33A */ s16 outerPetalZRotationalVelocity;
|
||||
/* 0x33C */ s16 flowerRotationalVelocity;
|
||||
/* 0x33E */ s16 transitionTimer;
|
||||
} BgNumaHana; // size = 0x340
|
||||
|
||||
extern const ActorInit Bg_Numa_Hana_InitVars;
|
||||
|
||||
Reference in New Issue
Block a user