diff --git a/include/z64actor.h b/include/z64actor.h index 175d9ef22c..bbf0a55348 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -83,7 +83,7 @@ typedef struct { typedef struct { /* 0x0 */ s16 unk_0; // frame? - /* 0x2 */ Vec3s unk_2; // pos? + /* 0x2 */ Vec3s unk_2; // scale } struct_80124618; // size = 0x8 typedef struct { diff --git a/include/z64math.h b/include/z64math.h index 16ab72e8a3..323042b15b 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -101,6 +101,9 @@ typedef struct { #define BINANG_LERPIMP(v0, v1, t) ((v0) + (s16)(BINANG_SUB((v1), (v0)) * (t))) #define BINANG_LERPIMPINV(v0, v1, t) ((v0) + BINANG_SUB((v1), (v0)) / (t)) +#define LERPWEIGHT(val, prev, next) (((val) - (prev)) / ((next) - (prev))) +#define F32_LERPWEIGHT(val, prev, next) (((f32)(val) - (f32)(prev)) / ((f32)(next) - (f32)(prev))) + #define VEC3F_LERPIMPDST(dst, v0, v1, t){ \ (dst)->x = (v0)->x + (((v1)->x - (v0)->x) * t); \ (dst)->y = (v0)->y + (((v1)->y - (v0)->y) * t); \ diff --git a/spec b/spec index a1ca83eb22..cb56bb4718 100644 --- a/spec +++ b/spec @@ -3038,9 +3038,7 @@ beginseg name "ovl_En_Az" compress include "build/src/overlays/actors/ovl_En_Az/z_en_az.o" - include "build/data/ovl_En_Az/ovl_En_Az.data.o" - include "build/data/ovl_En_Az/ovl_En_Az.bss.o" - include "build/data/ovl_En_Az/ovl_En_Az.reloc.o" + include "build/src/overlays/actors/ovl_En_Az/ovl_En_Az_reloc.o" endseg beginseg @@ -3206,9 +3204,7 @@ beginseg name "ovl_En_Twig" compress include "build/src/overlays/actors/ovl_En_Twig/z_en_twig.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.data.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.bss.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.reloc.o" + include "build/src/overlays/actors/ovl_En_Twig/ovl_En_Twig_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index c025a6f777..a3594bec4d 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -5,28 +5,69 @@ */ #include "z_en_az.h" +#include "objects/object_az/object_az.h" +#include "overlays/actors/ovl_En_Twig/z_en_twig.h" +#include "overlays/actors/ovl_En_Fish/z_en_fish.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnAz*)thisx) +typedef struct { + /* 0x0 */ s16 unk_0; + /* 0x4 */ f32 unk_4; +} struct_80A98F94; // size = 0x8 + void EnAz_Init(Actor* thisx, PlayState* play); void EnAz_Destroy(Actor* thisx, PlayState* play); void EnAz_Update(Actor* thisx, PlayState* play); void EnAz_Draw(Actor* thisx, PlayState* play); +void func_80A982E0(PlayState* play, ActorPathing* actorPathing); +void func_80A98414(EnAz* this, PlayState* play); +s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 arg3, s32 arg4); +void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp); + +void func_80A95C5C(EnAz* this, PlayState* play); void func_80A95CEC(EnAz* this, PlayState* play); + +void func_80A95DA0(EnAz* this, PlayState* play); void func_80A95E88(EnAz* this, PlayState* play); + +void func_80A95F94(EnAz* this, PlayState* play); void func_80A95FE8(EnAz* this, PlayState* play); + +void func_80A979DC(EnAz* this, PlayState* play); void func_80A979F4(EnAz* this, PlayState* play); + +void func_80A97A28(EnAz* this, PlayState* play); void func_80A97A40(EnAz* this, PlayState* play); + +void func_80A97A9C(EnAz* this, PlayState* play); void func_80A97AB4(EnAz* this, PlayState* play); + +void func_80A97C0C(EnAz* this, PlayState* play); void func_80A97C24(EnAz* this, PlayState* play); void func_80A97C4C(EnAz* this, PlayState* play); + +void func_80A97D5C(EnAz* this, PlayState* play); void func_80A97E48(EnAz* this, PlayState* play); + +void func_80A97EAC(EnAz* this, PlayState* play); void func_80A97F9C(EnAz* this, PlayState* play); -#if 0 +static AnimationSpeedInfo sAnimationInfo[14] = { + { &object_az_Anim_00BCFC, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_az_Anim_00C94C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_008960, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_008BB4, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_00925C, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_009B4C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_0086AC, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_007D3C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_008EAC, 2.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00A25C, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_az_Anim_00AAEC, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00B94C, 1.0f, ANIMMODE_ONCE, -5.0f }, + { &object_az_Anim_00C0A0, 1.0f, ANIMMODE_LOOP, -5.0f }, { &object_az_Anim_00C47C, 1.0f, ANIMMODE_LOOP, -5.0f }, +}; + const ActorInit En_Az_InitVars = { ACTOR_EN_AZ, ACTORCAT_NPC, @@ -39,108 +80,1771 @@ const ActorInit En_Az_InitVars = { (ActorFunc)EnAz_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A99110 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 46, 0, { 0, 0, 0 } }, }; -#endif +static EnAz* D_80A9913C = NULL; -extern ColliderCylinderInit D_80A99110; +Vec3f D_80A99E80; // path point? +f32 D_80A99E8C; // player distance to path point? +f32 D_80A99E90[2]; // unused? -extern UNK_TYPE D_0600C94C; -extern UNK_TYPE D_0601ABF0; +void func_80A94A30(EnAz* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A30.s") +void func_80A94A64(EnAz* this) { + func_80A94A30(this); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A64.s") +s32 func_80A94A90(PlayState* play, ActorPathing* actorPathing) { + func_80A94A64((EnAz*)actorPathing->actor); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A90.s") +void func_80A94AB8(EnAz* this, PlayState* play, s32 spawnIndex) { + play->nextEntrance = Entrance_CreateFromSpawn(spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94AB8.s") +void func_80A94B20(PlayState* play) { + Actor* ring = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94B20.s") + do { + ring = SubS_FindActor(play, ring, ACTORCAT_MISC, ACTOR_EN_TWIG); + if (ring != NULL) { + if (RACERING_GET_PARAM_F(ring) == 1) { + Actor_MarkForDeath(ring); + } + ring = ring->next; + } + } while (ring != NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94B98.s") +s32 func_80A94B98(EnAz* this, PlayState* play) { + EnTwig* ring; + s32 ret = false; + Actor* misc = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Init.s") + do { + if (1) {} + ring = (EnTwig*)SubS_FindActor(play, misc, ACTORCAT_MISC, ACTOR_EN_TWIG); + if ((ring != NULL) && (RACERING_GET_PARAM_F(&ring->dyna.actor) == 1) && !(ring->unk_16C & 1)) { + ret = true; + break; + } + misc = ring->dyna.actor.next; + } while (misc != NULL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Destroy.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A954AC.s") +static InitChainEntry sInitChain[3] = { + ICHAIN_F32(uncullZoneScale, 80, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 80, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95534.s") +void EnAz_Init(Actor* thisx, PlayState* play2) { + static s16 D_80A9914C[7] = { 1, 0, 3, 2, 5, 4, -1 }; + static s16 D_80A9915C[7] = { 0, 1, 0, 1, 0, 1, 1 }; + EnAz* this = THIS; + PlayState* play = play2; + s16 sp4E; + s32 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A9565C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_374 = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + switch (BEAVER_GET_PARAM_F00(thisx)) { + case 0: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + (gSaveContext.save.weekEventReg[93] & 1); + phi_v1 = !phi_v1; + break; + case 2: + phi_v1 = (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) || + !(gSaveContext.save.weekEventReg[24] & 4); + break; + case 4: + phi_v1 = gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 2); + break; + case 1: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + (gSaveContext.save.weekEventReg[93] & 1); + phi_v1 = !phi_v1; + break; + case 3: + phi_v1 = (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) || + (gSaveContext.save.weekEventReg[24] & 4); + break; + case 5: + phi_v1 = gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 2); + break; + case 6: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + !(gSaveContext.save.weekEventReg[93] & 1); + phi_v1 = !phi_v1; + break; + default: + phi_v1 = true; + break; + } + if (phi_v1) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95730.s") + this->unk_2F8 = D_80A9915C[BEAVER_GET_PARAM_F00(thisx)]; + if (BEAVER_GET_PARAM_F00(thisx) >= 0) { + sp4E = D_80A9914C[BEAVER_GET_PARAM_F00(thisx)]; + } else { + sp4E = -1; + } + if (this->unk_2F8 == 0) { + this->unk_374 |= 2; + } + SubS_FillCutscenesList(&this->actor, this->unk_3D0, ARRAY_COUNT(this->unk_3D0)); + if (D_80A9913C == NULL) { + D_80A9913C = THIS; + this->unk_374 |= 1; + } + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + if (this->unk_374 & 2) { + SkelAnime_InitFlex(play, &this->skelAnime, &object_az_Skel_007438, &object_az_Anim_00C94C, this->jointTable, + this->morphTable, OBJECT_AZ_1_LIMB_MAX); + Actor_SetScale(&this->actor, 0.012f); + } else { + SkelAnime_InitFlex(play, &this->skelAnime, &object_az_Skel_017990, &object_az_Anim_00C94C, this->jointTable, + this->morphTable, OBJECT_AZ_2_LIMB_MAX); + } + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + if (this->unk_374 & 2) { + this->collider.dim.radius *= 1.2f; + this->collider.dim.height *= 1.2f; + this->collider.dim.yShift *= 1.2f; + } + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 5); + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + this->unk_374 |= 0x100; + this->unk_376 |= 0x100; + } + Animation_Change(&this->skelAnime, sAnimationInfo[0].animation, 1.0f, + Animation_GetLastFrame(sAnimationInfo[0].animation) * Rand_ZeroOne(), + Animation_GetLastFrame(sAnimationInfo[0].animation), sAnimationInfo[0].mode, + sAnimationInfo[0].morphFrames); + this->unk_37E = 0; + this->unk_380 = 0; + this->unk_384 = 0; + this->actor.gravity = -1.0f; + this->unk_376 = this->unk_374; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A958B0.s") + switch (gSaveContext.save.entrance) { + case ENTRANCE(WATERFALL_RAPIDS, 0): + if (gSaveContext.save.weekEventReg[93] & 1) { + this->unk_2FA = 5; + if (this->unk_374 & 2) { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_374 |= 0x20; + } + } else { + this->unk_2FA = 0; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_374 |= 0x20; + } + func_80A94B20(play); + if (this->unk_2FA == 5) { + func_80A97C0C(this, play); + } else { + func_80A95DA0(this, play); + } + break; + case ENTRANCE(WATERFALL_RAPIDS, 3): + this->unk_2FA = 0; + if (!(this->unk_374 & 2)) { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + } + if (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 3)) { + this->unk_2FA = 0xA; + } + func_80A97C0C(this, play); + break; + case ENTRANCE(WATERFALL_RAPIDS, 1): + if (gSaveContext.save.weekEventReg[93] & 1) { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 8; + } else { + this->unk_2FA = 6; + } + } else { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 3; + } else { + this->unk_2FA = 1; + } + } + if (this->unk_374 & 1) { + SubS_CopyPointFromPathList(play->setupPathList, BEAVER_GET_PARAM_FF(thisx), + play->setupPathList[BEAVER_GET_PARAM_FF(thisx)].count - 1, &D_80A99E80); + } + if (gSaveContext.save.weekEventReg[24] & 4) { + if (this->unk_374 & 2) { + func_80A97D5C(this, play); + } else { + func_80A979DC(this, play); + } + } else if (this->unk_374 & 2) { + func_80A979DC(this, play); + } else { + func_80A97D5C(this, play); + } + break; + case ENTRANCE(WATERFALL_RAPIDS, 2): + if (gSaveContext.save.weekEventReg[93] & 1) { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 9; + } else { + this->unk_2FA = 7; + } + } else { + if (gSaveContext.save.weekEventReg[24] & 4) { + this->unk_2FA = 4; + } else { + this->unk_2FA = 2; + } + } + if (this->unk_2FA == 2) { + if (!(this->unk_374 & 2)) { + this->unk_374 |= 0x20; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + this->actionFunc = func_80A97C24; + } else { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + func_80A95C5C(this, play); + } + } else { + if (this->unk_374 & 2) { + this->unk_374 |= 0x20; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + } else { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + this->actionFunc = func_80A97C24; + } + break; + } + if (sp4E >= 0) { + this->brother = NULL; + do { + this->brother = (EnAz*)SubS_FindActor(play, &this->brother->actor, ACTORCAT_NPC, ACTOR_EN_AZ); + if (this->brother != NULL) { + if (sp4E == BEAVER_GET_PARAM_F00(&this->brother->actor)) { + break; + } + this->brother = (EnAz*)this->brother->actor.next; + } + } while (this->brother != NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95B34.s") +void EnAz_Destroy(Actor* thisx, PlayState* play2) { + EnAz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95C5C.s") + if (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) { + gSaveContext.unk_3DD0[4] = 5; + } + Collider_DestroyCylinder(play2, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95CEC.s") +f32 func_80A954AC(EnAz* this) { + ActorPathing* pathing = &this->unk_300; + Vec3f sp28; + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95DA0.s") + sp28.x = pathing->curPoint.x - this->actor.world.pos.x; + sp28.y = pathing->curPoint.y - this->actor.world.pos.y; + sp28.z = pathing->curPoint.z - this->actor.world.pos.z; + sp1C.x = pathing->curPoint.x - pathing->prevPoint.x; + sp1C.y = pathing->curPoint.y - pathing->prevPoint.y; + sp1C.z = pathing->curPoint.z - pathing->prevPoint.z; + return Math3D_Parallel(&sp28, &sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95E88.s") +s32 func_80A95534(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95F94.s") + this->actor.world.rot.x = 0; + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, 0x71C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 2, 0x71C, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, 0xE38, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x71C, 0); + this->actor.gravity = -1.0f; + this->unk_36C = 1.5f; + if (actorPathing->curPointIndex == actorPathing->endPointIndex) { + if (actorPathing->distSqToCurPointXZ < this->unk_36C) { + this->unk_36C = actorPathing->distSqToCurPointXZ; + } + } + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + actorPathing->moveFunc = SubS_ActorPathing_MoveWithGravity; + if (actorPathing->distSqToCurPointXZ <= this->actor.speedXZ) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95FE8.s") +s32 func_80A9565C(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A9617C.s") + this->actor.gravity = -1.0f; + actorPathing->moveFunc = func_80A94A90; + this->unk_374 |= 0x2000; + temp_f0 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + ret = true; + } else { + this->unk_39E = this->actor.world.rot.x = + Math_Atan2S(-this->actor.velocity.y, Math_CosS(-this->actor.world.rot.x) * this->actor.speedXZ); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97114.s") +s32 func_80A95730(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp_f0; + f32 sp40; + s32 sp3C; + s32 sp38; + s32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97274.s") + this->actor.gravity = 0.0f; + temp_f0 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + ret = true; + } else { + sp40 = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp34 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A973B4.s") + sp3C = (s32)(sp34 * sp40) + 0xAAA; + sp34 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97410.s") + Math_SmoothStepToS(&this->actor.world.rot.x, actorPathing->rotToCurPoint.x, 1, sp3C, 0); + sp38 = (s32)(sp34 * sp40) + 0xAAA; + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, sp38, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A979DC.s") + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, sp3C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, sp38, 0); + } + actorPathing->moveFunc = SubS_ActorPathing_MoveWithoutGravityReverse; + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A979F4.s") +s32 func_80A958B0(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp; + f32 phi_f0; + f32 temp1; + f32 temp2; + f32 sp3C; + s32 sp2C; + s32 sp28; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A28.s") + this->actor.gravity = 0.0f; + temp2 = D_80A99E8C; + temp = D_80A99E90[this->unk_2F8]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A40.s") + if (temp <= temp2) { + phi_f0 = (this->unk_374 & 2) ? 480.0f : 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A9C.s") + if (this->actor.xzDistToPlayer < phi_f0) { + Math_SmoothStepToF(&this->unk_36C, 12.0f, 0.8f, 0.5f, 0.01f); + } else { + Math_SmoothStepToF(&this->unk_36C, 6.0f, 0.8f, 0.5f, 0.01f); + } + } else { + Math_SmoothStepToF(&this->unk_36C, 26.0f, 0.5f, 1.0f, 0.01f); + } + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + temp1 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp1 <= 0.0f)) { + ret = true; + } else { + sp3C = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp30 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); + sp2C = (s32)(sp30 * sp3C) + 0xAAA; + sp30 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97AB4.s") + Math_SmoothStepToS(&this->actor.world.rot.x, actorPathing->rotToCurPoint.x, 1, sp2C, 0); + sp28 = (s32)(sp30 * sp3C) + 0xAAA; + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, sp28, 0); + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, sp2C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, sp28, 0); + } + actorPathing->moveFunc = SubS_ActorPathing_MoveWithoutGravityReverse; + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C0C.s") +s32 func_80A95B34(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C24.s") + if (this->unk_374 & 0x100) { + if (!(this->unk_374 & 8)) { + if (this->unk_374 & 2) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 8, &this->animIndex); + } else { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + } + this->unk_374 |= 8; + } + if (this->unk_2FA == 0) { + ret = func_80A95730(play, actorPathing); + } else { + ret = func_80A958B0(play, actorPathing); + } + } else if (this->actor.bgCheckFlags & 1) { + if (this->unk_374 & 8) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 1, &this->animIndex); + this->unk_374 &= ~8; + } + ret = func_80A95534(play, actorPathing); + } else { + ret = func_80A9565C(play, actorPathing); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C4C.s") +void func_80A95C5C(EnAz* this, PlayState* play) { + this->actor.draw = NULL; + this->actor.world.pos.y = this->actor.home.pos.y + 120.0f; + this->actor.gravity = -1.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_3C0 = 0; + this->actionFunc = func_80A95CEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97D5C.s") +void func_80A95CEC(EnAz* this, PlayState* play) { + if (this->unk_374 & 0x8000) { + if (!(this->actor.bgCheckFlags & 1)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.draw = EnAz_Draw; + Actor_MoveWithGravity(&this->actor); + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } else { + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + } + if (SubS_StartActorCutscene(&this->actor, 0x7C, this->unk_3D0[0], SUBS_CUTSCENE_NORMAL)) { + func_80A97C0C(this, play); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97E48.s") +void func_80A95DA0(EnAz* this, PlayState* play) { + ActorPathing* sp40 = &this->unk_300; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97EAC.s") + SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, sp40, play->setupPathList, + BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 1); + this->unk_36C = 4.0f; + this->actor.speedXZ = 4.0f; + this->actor.gravity = 0.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_374 |= 0x1000; + Math_Vec3f_Copy(&this->actor.world.pos, &sp40->curPoint); + this->actionFunc = func_80A95E88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97F9C.s") +void func_80A95E88(EnAz* this, PlayState* play) { + SubS_ActorPathing_Update(play, &this->unk_300, func_80A982E0, func_80A95B34, SubS_ActorPathing_MoveWithGravity, + SubS_ActorPathing_SetNextPoint); + if (this->actor.depthInWater > 8.0f) { + if (this->unk_374 & 2) { + if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + } + } else { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + } + } + if (!(this->unk_374 & 0x2000)) { + SkelAnime_Update(&this->skelAnime); + } + this->unk_374 &= ~0x2000; + if (this->actor.isTargeted) { + func_80A95F94(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A982E0.s") +void func_80A95F94(EnAz* this, PlayState* play) { + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + this->unk_39E = 0; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80A95FE8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98414.s") +void func_80A95FE8(EnAz* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (ActorCutscene_GetCanPlayNext(this->unk_3D0[0])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_3D0[0], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_3D0[0]); + } + if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) > 20.0f) { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 3, 0xE38, 0x38E); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0xE38, 0x38E); + this->actor.shape.rot.z = 0; + Actor_MoveWithoutGravityReverse(&this->actor); + } else { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->unk_374 &= ~0x1000; + this->actor.gravity = -1.0f; + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 3, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1038, 0x100); + if (this->actor.bgCheckFlags & 1) { + this->actor.shape.rot.x = 0; + this->actor.gravity = 0.0f; + func_80A97C0C(this, play); + ActorCutscene_Stop(this->unk_3D0[0]); + } + Actor_MoveWithGravity(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Update.s") +s32 func_80A9617C(EnAz* this, PlayState* play) { + s32 pad[2]; + s32 ret = 2; + EnAz* brother = this->brother; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Draw.s") + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if ((play->msgCtx.currentTextId == 0x10DD) && (this->unk_374 & 0x8000)) { + if (SubS_StartActorCutscene(&brother->actor, brother->unk_3D0[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { + brother->unk_374 |= 0x8000; + play->msgCtx.msgMode = 0x44; + ret = 0; + } + } else if (Message_ShouldAdvance(play)) { + ret = 3; + switch (play->msgCtx.currentTextId) { + case 0x70: + case 0xCD: + gSaveContext.save.weekEventReg[24] &= (u8)~1; + this->actor.textId = 0x10F2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, &brother->animIndex); + break; + case 0x10CE: + this->actor.textId = 0x10CF; + gSaveContext.save.weekEventReg[16] |= 0x40; + break; + case 0x10CF: + this->actor.textId = 0x10D0; + break; + case 0x10D0: + this->actor.textId = 0x10D1; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + break; + case 0x10D1: + this->actor.textId = 0x10D2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10D2: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x10D6; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10D3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + } + break; + case 0x10D3: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10D4: + this->actor.textId = 0x10D2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10D6: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + func_80A979DC(this, play); + this->unk_2FA = 1; + ret = 0; + break; + case 0x10D7: + this->actor.textId = 0x10D8; + break; + case 0x10D8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + switch (this->unk_2FA) { + case 2: + this->unk_2FA = 1; + break; + case 4: + this->unk_2FA = 3; + break; + case 7: + this->unk_2FA = 6; + break; + case 9: + this->unk_2FA = 8; + break; + } + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10D9; + } + break; + case 0x10D9: + if ((this->unk_2FA == 3) || (this->unk_2FA == 8)) { + gSaveContext.save.weekEventReg[24] &= (u8)~4; + } + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10DA: + this->actor.textId = 0x10DB; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10DB: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + play->msgCtx.msgMode = 0x44; + this->unk_2FA = 1; + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10DC; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + } + break; + case 0x10DC: + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10DD: + func_80A98EFC(this, play, 0x10DE, 13, 9); + this->unk_374 |= 0x8000; + ret = 2; + break; + case 0x10DE: + func_80A98EFC(this, play, 0x10DF, 12, 10); + ret = 0; + break; + case 0x10DF: + func_80A98EFC(this, play, 0x10E0, 13, 9); + ret = 0; + break; + case 0x10E0: + func_80A98EFC(this, play, 0x10E1, 12, 10); + ret = 0; + break; + case 0x10E1: + func_80A98EFC(this, play, 0x10E2, 13, 9); + ret = 0; + break; + case 0x10E2: + this->actor.textId = 0x10E3; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10E3: + func_80A98EFC(this, play, 0x10E4, 0, 4); + ret = 0; + break; + case 0x10E4: + func_80A98EFC(this, play, 0x10E5, 0, 4); + ret = 0; + break; + case 0x10E5: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x10E8; + } else { + func_8019F230(); + this->actor.textId = 0x10E6; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, + &brother->animIndex); + } + break; + case 0x10E6: + this->actor.textId = 0x10E7; + func_80A98EFC(this, play, 0x10E7, 0, 10); + ret = 0; + break; + case 0x10E7: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + func_80A94AB8(this, play, 0); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10E8: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_2FA = 3; + ret = 0; + break; + case 0x10E9: + func_80A98EFC(this, play, 0x10EA, 12, 4); + ret = 0; + break; + case 0x10EA: + func_80A98EFC(this, play, 0x10EB, 0, 4); + ret = 0; + break; + case 0x10EB: + if (play->msgCtx.choiceIndex == 0) { + play->msgCtx.msgMode = 0x44; + func_8019F208(); + switch (this->unk_2FA) { + case 4: + this->unk_2FA = 3; + break; + case 7: + this->unk_2FA = 6; + break; + case 9: + default: + this->unk_2FA = 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98DA4.s") + break; + } + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10EC; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 7, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, + &brother->animIndex); + } + break; + case 0x10EC: + func_80A98EFC(this, play, 0x10ED, -1, 6); + ret = 0; + break; + case 0x10ED: + if ((this->unk_2FA == 4) || (this->unk_2FA == 9)) { + gSaveContext.save.weekEventReg[24] &= (u8)~4; + } + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10EE: + func_80A98EFC(this, play, 0x10EF, 12, 10); + ret = 0; + break; + case 0x10EF: + func_80A98EFC(this, play, 0x10F0, 13, 9); + ret = 0; + break; + case 0x10F0: + func_80A98EFC(this, play, 0x10F1, 12, 10); + ret = 0; + break; + case 0x10F1: + gSaveContext.save.weekEventReg[93] |= 1; + if (gSaveContext.save.weekEventReg[23] & 0x80) { + this->getItemId = GI_RUPEE_RED; + } else { + this->getItemId = GI_BOTTLE; + gSaveContext.save.weekEventReg[23] |= 0x80; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + ret = 7; + break; + case 0x10F2: + case 0x1109: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10F3: + func_80A98EFC(this, play, 0x10F4, 12, 10); + ret = 0; + break; + case 0x10F4: + func_80A98EFC(this, play, 0x10F5, 13, 9); + ret = 0; + break; + case 0x10F5: + func_80A98EFC(this, play, 0x10F6, 12, 10); + ret = 0; + break; + case 0x10F6: + func_80A98EFC(this, play, 0x10F7, 13, 5); + ret = 0; + break; + case 0x10F7: + this->actor.textId = 0x10F8; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10F8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.save.weekEventReg[25] & 1) { + this->actor.textId = 0x1107; + } else { + this->actor.textId = 0x10FA; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10F9; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, + &brother->animIndex); + } + break; + case 0x10F9: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10FA: + case 0x1107: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_2FA = 6; + ret = 0; + break; + case 0x10FB: + func_80A98EFC(this, play, 0x10FC, 12, 10); + ret = 0; + break; + case 0x10FC: + func_80A98EFC(this, play, 0x10FD, 13, 4); + ret = 0; + break; + case 0x10FD: + this->actor.textId = 0x10FE; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + break; + case 0x10FE: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + if (gSaveContext.save.weekEventReg[25] & 1) { + this->actor.textId = 0x1108; + } else { + this->actor.textId = 0x1101; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10FF; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, + &brother->animIndex); + } + break; + case 0x10FF: + func_80A98EFC(this, play, 0x1100, 12, 10); + ret = 0; + break; + case 0x1100: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x1101: + case 0x1108: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + this->unk_2FA = 8; + ret = 0; + break; + case 0x1102: + func_80A98EFC(this, play, 0x1103, 12, 10); + ret = 0; + break; + case 0x1103: + func_80A98EFC(this, play, 0x1104, 13, 9); + ret = 0; + break; + case 0x1104: + func_80A98EFC(this, play, 0x1105, 12, 10); + ret = 0; + break; + case 0x1105: + if (gSaveContext.save.weekEventReg[25] & 1) { + this->getItemId = GI_RUPEE_PURPLE; + } else { + this->getItemId = GI_HEART_PIECE; + gSaveContext.save.weekEventReg[25] |= 1; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + ret = 7; + break; + case 0x1106: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 0, &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10D5: + default: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + } + } + break; + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98E48.s") +void func_80A97114(EnAz* this, PlayState* play) { + EnAz* brother = this->brother; + s32 sp20 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98EFC.s") + this->actor.flags &= ~ACTOR_FLAG_10000; + switch (this->actor.textId) { + case 0x10DA: + case 0x10DD: + case 0x10E9: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10EE: + case 0x10F3: + case 0x10FB: + case 0x1102: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 9, &this->animIndex); + sp20 = true; + break; + case 0x10F2: + case 0x1106: + case 0x1109: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 11, &this->animIndex); + if (brother != NULL) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 11, &brother->animIndex); + } + break; + } + if ((brother != NULL) && sp20) { + if (this->unk_374 & 2) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 13, &brother->animIndex); + } else { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, 12, &brother->animIndex); + } + } + this->unk_374 &= ~0x20; + this->unk_378 = 2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98F94.s") +s32 func_80A97274(EnAz* this, PlayState* play) { + s32 textId; + + if (this->unk_374 & 0x4000) { + return 0x10D7; + } + switch (this->unk_2FA) { + case 0: + default: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + if (!(gSaveContext.save.weekEventReg[16] & 0x40)) { + textId = 0x10CE; + } else { + textId = 0x10D4; + } + break; + case 2: + if (gSaveContext.save.weekEventReg[24] & 1) { + gSaveContext.save.weekEventReg[24] |= 4; + this->unk_3C0 = 0; + textId = 0x10DD; + } else { + textId = 0x10DA; + } + break; + case 4: + if (gSaveContext.save.weekEventReg[24] & 1) { + textId = 0x10EE; + } else { + textId = 0x10E9; + } + break; + case 5: + gSaveContext.save.weekEventReg[24] &= (u8)~4; + textId = 0x10F3; + break; + case 7: + if (gSaveContext.save.weekEventReg[24] & 1) { + gSaveContext.save.weekEventReg[24] |= 4; + textId = 0x10FB; + } else { + textId = 0x10E9; + } + break; + case 9: + if (gSaveContext.save.weekEventReg[24] & 1) { + textId = 0x1102; + } else { + textId = 0x10E9; + } + break; + } + return textId; +} + +s32 func_80A973B4(EnAz* this, PlayState* play) { + s32 ret = 0; + + if (this->getItemId != GI_RUPEE_RED) { + if ((this->getItemId != GI_RUPEE_PURPLE) && (this->getItemId != GI_HEART_PIECE)) { + if (this->getItemId == GI_BOTTLE) { + ret = 0x10F2; + } + } else { + ret = 0x1106; + } + } else { + ret = 0x1109; + } + this->unk_374 |= 0x20; + + return ret; +} + +void func_80A97410(EnAz* this, PlayState* play) { + s16 sp56; + s16 sp54; + s32 temp_a0; + + if (this->unk_378 != 0) { + Vec3f* thisPos = &this->actor.world.pos; + + if ((this->unk_2FA == 0) && !(this->unk_374 & 2)) { + Math_SmoothStepToS(&this->unk_3D4, 0, 2, 0x71C, 0xA); + Math_SmoothStepToS(&this->unk_3D6, 0, 3, 0x71C, 0xA); + } + if (this->brother != NULL) { + Vec3f* broPos = &this->brother->actor.world.pos; + + if (this->unk_374 & 0x40) { + this->actor.focus.pos.x = (thisPos->x * 0.5f) + (broPos->x * 0.5f); + this->actor.focus.pos.y = (thisPos->y * 0.5f) + (broPos->y * 0.5f) + 45.0f; + this->actor.focus.pos.z = (thisPos->z * 0.5f) + (broPos->z * 0.5f); + } else { + this->actor.focus.pos.x = (thisPos->x * 0.7f) + (broPos->x * 0.3f); + this->actor.focus.pos.y = (thisPos->y * 0.7f) + (broPos->y * 0.3f) + 45.0f; + this->actor.focus.pos.z = (thisPos->z * 0.7f) + (broPos->z * 0.3f); + } + } else { + this->actor.focus.pos.x = thisPos->x; + this->actor.focus.pos.y = thisPos->y; + this->actor.focus.pos.z = thisPos->z; + } + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; + } + if (this->unk_378 == 2) { + this->unk_378 = func_80A9617C(this, play); + if (this->unk_378 == 0) { + this->actor.flags &= ~ACTOR_FLAG_10000; + } + } + if (this->unk_378 == 3) { + func_80151938(play, this->actor.textId); + this->unk_378 = 2; + } else if (this->unk_378 == 5) { + Message_StartTextbox(play, this->actor.textId, &this->actor); + this->unk_378 = 2; + } else { + if ((this->unk_378 == 6) || (this->unk_378 == 7)) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + if (this->unk_378 == 7) { + this->unk_378 = 1; + this->unk_374 |= 0x20; + } else { + this->unk_378 = 0; + } + } else { + Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); + } + } + if (this->unk_378 == 9) { + temp_a0 = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38, 0x222); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (temp_a0 == 0) { + switch (this->unk_3D2) { + case 0x10CE: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 4, &this->animIndex); + break; + case 0x10D4: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 5, &this->animIndex); + break; + } + Message_StartTextbox(play, this->unk_3D2, &this->actor); + this->actor.textId = this->unk_3D2; + this->unk_378 = 2; + } + } else if (((this->unk_378 == 0) || (this->unk_378 == 1)) && (this->unk_374 & 0x20)) { + if (this->unk_378 == 1) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A97114(this, play); + this->unk_378 = 2; + } else if (func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, + PLAYER_AP_MINUS1)) { + this->actor.textId = func_80A973B4(this, play); + } + } else { + if ((this->unk_2FA == 0) && !(this->unk_374 & 2)) { + Player* player = GET_PLAYER(play); + Vec3f sp38; + s16 temp_a1_2 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + s16 temp_v0_7; + + if (ABS(temp_a1_2) < 0x1800) { + Math_SmoothStepToS(&this->unk_3D4, temp_a1_2, 2, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_3D4, 0, 2, 0x71C, 0); + } + Math_Vec3f_Copy(&sp38, &player->actor.world.pos); + sp38.y = player->bodyPartsPos[7].y + 3.0f; + temp_v0_7 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp38); + if (ABS(temp_v0_7) < 0x800) { + Math_SmoothStepToS(&this->unk_3D6, temp_v0_7, 3, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_3D6, 0, 3, 0x71C, 0); + } + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A97114(this, play); + this->unk_378 = 2; + if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { + this->unk_378 = 9; + } + } else { + Actor_GetScreenPos(play, &this->actor, &sp56, &sp54); + if ((sp56 >= 0) && (sp56 <= SCREEN_WIDTH) && (sp54 >= 0) && (sp54 <= SCREEN_HEIGHT) && + func_800B8500(&this->actor, play, 120.0f, 120.0f, 0)) { + this->unk_3D2 = func_80A97274(this, play); + if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { + this->actor.textId = 0; + } else { + this->actor.textId = this->unk_3D2; + } + } + } + } + } + } +} + +void func_80A979DC(EnAz* this, PlayState* play) { + this->actionFunc = func_80A979F4; +} + +void func_80A979F4(EnAz* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Actor_MoveWithGravity(&this->actor); +} + +void func_80A97A28(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97A40; +} + +void func_80A97A40(EnAz* this, PlayState* play) { + if (SubS_StartActorCutscene(&this->actor, 0, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80A97A9C(this, play); + } +} + +void func_80A97A9C(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97AB4; +} + +void func_80A97AB4(EnAz* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + Message_StartTextbox(play, 0x10D7, NULL); + break; + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x10D7: + func_80151938(play, 0x10D8); + break; + case 0x10D8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + play->msgCtx.msgMode = 0x44; + func_800FD750(NA_BGM_MINI_GAME_2); + func_80A94AB8(this, play, 1); + func_80A979DC(this, play); + } else { + func_8019F230(); + if (gSaveContext.save.weekEventReg[24] & 4) { + gSaveContext.save.weekEventReg[24] &= (u8)~4; + } + func_80151938(play, 0x10D9); + } + break; + case 0x10D9: + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + break; + } + } + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + break; + } +} + +void func_80A97C0C(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97C4C; +} + +void func_80A97C24(EnAz* this, PlayState* play) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80A97C4C; +} + +void func_80A97C4C(EnAz* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == 0xB)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 0, &this->animIndex); + } + func_80A97410(this, play); + if ((this->unk_2FA == 1) || (this->unk_2FA == 3) || (this->unk_2FA == 6) || (this->unk_2FA == 8)) { + gSaveContext.save.weekEventReg[24] &= (u8)~1; + func_800FD750(NA_BGM_MINI_GAME_2); + play->nextEntrance = Entrance_CreateFromSpawn(1); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + func_80A979DC(this, play); + } else { + Actor_MoveWithGravity(&this->actor); + } +} + +void func_80A97D5C(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->stateFlags1 |= PLAYER_STATE1_20; + func_80112AFC(play); + gSaveContext.minigameScore = (this->unk_374 & 2) ? 25 : 20; + play->interfaceCtx.unk_280 = 1; + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + func_8010E9F0(4, 120); + } else if (gSaveContext.save.weekEventReg[25] & 1) { + func_8010E9F0(4, 100); + } else { + func_8010E9F0(4, 110); + } + this->actionFunc = func_80A97E48; +} + +void func_80A97E48(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (play->interfaceCtx.unk_280 >= 8) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80A97EAC(this, play); + } + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); +} + +void func_80A97EAC(EnAz* this, PlayState* play) { + SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, &this->unk_300, play->setupPathList, + BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 0); + this->unk_36C = 8.0f; + this->actor.speedXZ = 8.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 6.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, 2, &this->animIndex); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_374 |= 0x1000; + this->unk_3C2 = 0; + this->unk_3C4 = 0; + this->actionFunc = func_80A97F9C; +} + +void func_80A97F9C(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + D_80A99E8C = + Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, D_80A99E80.x, D_80A99E80.z); + if (Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, D_80A99E80.x, D_80A99E80.z) >= + SQ(1000.0f)) { + this->unk_374 |= 0x1000; + } + if (!(this->unk_300.flags & ACTOR_PATHING_REACHED_END_PERMANENT)) { + SubS_ActorPathing_Update(play, &this->unk_300, func_80A982E0, func_80A95B34, SubS_ActorPathing_MoveWithGravity, + SubS_ActorPathing_SetNextPoint); + } + if (!(this->unk_374 & 0x10) && + SurfaceType_IsHorseBlocked(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + this->unk_374 |= 0x10; + } + if (SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (func_80A94B98(this, play)) { + gSaveContext.save.weekEventReg[24] &= (u8)~1; + } else { + gSaveContext.save.weekEventReg[24] |= 1; + } + gSaveContext.unk_3DD0[4] = 5; + this->unk_374 &= ~0x10; + play->nextEntrance = Entrance_CreateFromSpawn(2); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + this->actor.speedXZ = 0.0f; + func_80A979DC(this, play); + } else { + if (gSaveContext.unk_3DE0[4] == 0) { + gSaveContext.unk_3DD0[4] = 5; + this->unk_374 |= 0x4000; + func_80A97A28(this, play); + } + if (this->unk_374 & 0x100) { + if (this->actor.flags & ACTOR_FLAG_40) { + func_80A98414(this, play); + } + if ((DECR(this->unk_37A) == 0) && (this->actor.flags & ACTOR_FLAG_40)) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 20.0f, 20.0f, 0.35f); + this->unk_37A = (Rand_ZeroOne() * 70.0f) + 10.0f; + } + } + if (this->actor.depthInWater > 8.0f) { + if (this->unk_374 & 2) { + if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + } + } else { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + } + } + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80A982E0(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + Vec3f sp28; + + actorPathing->curPoint.x = actorPathing->points[actorPathing->curPointIndex].x; + if (this->actor.bgCheckFlags & 1) { + actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y; + } else { + actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y - this->unk_3A4; + } + actorPathing->curPoint.z = actorPathing->points[actorPathing->curPointIndex].z; + sp28.x = actorPathing->curPoint.x - actorPathing->worldPos->x; + sp28.y = actorPathing->curPoint.y - actorPathing->worldPos->y; + sp28.z = actorPathing->curPoint.z - actorPathing->worldPos->z; + actorPathing->distSqToCurPointXZ = Math3D_XZLengthSquared(sp28.x, sp28.z); + actorPathing->distSqToCurPoint = Math3D_LengthSquared(&sp28); + actorPathing->rotToCurPoint.y = Math_FAtan2F(sp28.z, sp28.x); + actorPathing->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPathing->distSqToCurPointXZ), -sp28.y); + actorPathing->rotToCurPoint.z = 0; +} + +void func_80A98414(EnAz* this, PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_EN_FISH) { + EnFish* fish = (EnFish*)itemAction; + + if ((fish->actor.params < 0) && (fish->actor.room == this->actor.room) && + (Math3D_Vec3fDistSq(&this->actor.world.pos, &fish->actor.world.pos) < SQ(200.0f))) { + fish->unk_276 = 0x14; + fish->unk_274 = Actor_YawBetweenActors(&fish->actor, &this->actor); + } + } + itemAction = itemAction->next; + } +} + +void EnAz_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnAz* this = THIS; + + this->unk_374 &= ~0x100; + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + if (!(this->unk_376 & 0x100)) { + this->unk_374 |= 0x200; + } + this->unk_374 |= 0x100; + } else if (this->unk_376 & 0x100) { + this->unk_374 |= 0x400; + } + this->actionFunc(this, play); + Actor_SetFocus(&this->actor, 40.0f); + if (this->unk_374 & 0x200) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER); + } + if (this->unk_374 & 0x400) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + } + this->unk_37E++; + if (this->unk_37E >= 4) { + this->unk_37E = 0; + } + this->unk_380++; + if (this->unk_380 >= 3) { + this->unk_380 = 0; + } + this->unk_384--; + if (this->unk_384 < 0) { + this->unk_384 = 2; + } + this->unk_39C++; + if (this->unk_39C >= 16) { + this->unk_39C = 0; + } + if (!(this->unk_374 & 0x1000)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + } else { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 0x400); + this->unk_374 &= ~0x1000; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + + this->unk_376 = this->unk_374; + this->unk_374 &= ~0x600; + + if (GET_ACTIVE_CAM(play)->stateFlags & CAM_STATE_UNDERWATER) { + this->unk_374 |= 0x800; + } else { + this->unk_374 &= ~0x800; + } +} + +static Gfx* D_80A9916C[5] = { + object_az_DL_01A600, object_az_DL_01A730, object_az_DL_01A860, object_az_DL_01A990, object_az_DL_01AAC0, +}; +static AnimatedMaterial* D_80A99180[5] = { + object_az_Matanimheader_01A6E8, object_az_Matanimheader_01A818, object_az_Matanimheader_01A948, + object_az_Matanimheader_01AA78, object_az_Matanimheader_01ABA8, +}; +static u8 D_80A99194[5] = { + 95, 135, 175, 215, 255, +}; +static u8 D_80A9919C[5] = { + 31, 45, 58, 73, 85, +}; +static struct_80124618 D_80A991A4[5][9] = { + { + { 0, { 200, 160, 160 } }, + { 2, { 250, 210, 210 } }, + { 4, { 200, 160, 160 } }, + { 6, { 250, 210, 210 } }, + { 8, { 200, 160, 160 } }, + { 10, { 250, 210, 210 } }, + { 12, { 200, 160, 160 } }, + { 14, { 250, 210, 210 } }, + { 16, { 200, 160, 160 } }, + }, + { + { 0, { 330, 200, 200 } }, + { 2, { 280, 150, 150 } }, + { 4, { 330, 200, 200 } }, + { 6, { 280, 150, 150 } }, + { 8, { 330, 200, 200 } }, + { 10, { 280, 150, 150 } }, + { 12, { 330, 200, 200 } }, + { 14, { 280, 150, 150 } }, + { 16, { 330, 200, 200 } }, + }, + { + { 0, { 350, 170, 120 } }, + { 2, { 400, 220, 170 } }, + { 4, { 350, 170, 120 } }, + { 6, { 400, 220, 170 } }, + { 8, { 350, 170, 120 } }, + { 10, { 400, 220, 170 } }, + { 12, { 350, 170, 120 } }, + { 14, { 400, 220, 170 } }, + { 16, { 350, 170, 120 } }, + }, + { + { 0, { 480, 216, 156 } }, + { 2, { 540, 216, 156 } }, + { 4, { 450, 300, 216 } }, + { 6, { 540, 216, 156 } }, + { 8, { 450, 300, 216 } }, + { 10, { 540, 216, 156 } }, + { 12, { 450, 300, 216 } }, + { 14, { 540, 300, 156 } }, + { 16, { 450, 250, 216 } }, + }, + { + { 0, { 600, 375, 160 } }, + { 2, { 640, 510, 200 } }, + { 4, { 600, 375, 160 } }, + { 6, { 640, 510, 200 } }, + { 8, { 600, 375, 160 } }, + { 10, { 640, 510, 200 } }, + { 12, { 600, 375, 160 } }, + { 14, { 640, 510, 200 } }, + { 16, { 600, 375, 160 } }, + }, +}; +static struct_80A98F94 D_80A9930C[5][4] = { + { { 0, 2100.0f }, { 7, 1500.0f }, { 16, 2100.0f }, { 0, 0.0f } }, + { { 0, 1900.0f }, { 7, 2200.0f }, { 10, 1600.0f }, { 16, 1900.0f } }, + { { 0, 1700.0f }, { 7, 2200.0f }, { 16, 1700.0f }, { 0, 0.0f } }, + { { 0, 1900.0f }, { 4, 1600.0f }, { 10, 2200.0f }, { 16, 1900.0f } }, + { { 0, 1900.0f }, { 7, 1400.0f }, { 16, 1900.0f }, { 0, 0.0f } }, +}; +static Vec3f D_80A993AC[3] = { + { 1.0f, 1.0f, 0.0f }, + { 0.9f, 0.9f, 120.0f }, + { 0.95f, 0.95f, 240.0f }, +}; +static Vec3f D_80A993D0[3] = { + { 1.5f, 1.5f, 0.0f }, + { 1.2f, 1.2f, 120.0f }, + { 1.35f, 1.35f, 240.0f }, +}; +static TexturePtr D_80A993F4[4] = { + object_az_Tex_00F918, + object_az_Tex_010118, + object_az_Tex_010918, + object_az_Tex_011118, +}; +static TexturePtr D_80A99404[3] = { + object_az_Tex_016018, + object_az_Tex_016818, + object_az_Tex_017018, +}; + +void EnAz_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnAz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + CLOSE_DISPS(play->state.gfxCtx); + + if (this->unk_374 & 2) { + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A98DA4, func_80A98E48, &this->actor); + } else { + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A993F4[this->unk_37E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80A99404[this->unk_380])); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A98DA4, func_80A98E48, &this->actor); + CLOSE_DISPS(play->state.gfxCtx); + } + OPEN_DISPS(play->state.gfxCtx); + if ((this->actor.depthInWater >= 28.0f) && (this->actor.speedXZ > 0.5f)) { + Matrix_Translate(this->unk_3B4.x, this->unk_3B4.y, this->unk_3B4.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_39E, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + if (this->unk_374 & 2) { + s32 i; + Vec3f sp98; + f32 sp94; + + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(D_80A99180); i++) { + Matrix_Push(); + func_80A98F94(D_80A9930C[i], this->unk_39C, &sp94); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(D_80A99180[i])); + Matrix_Translate(0.0f, sp94 * 100.0f, i * -930.0f, MTXMODE_APPLY); + Matrix_Scale(1.1f, 0.95f, 1.0f, MTXMODE_APPLY); + func_80124618(D_80A991A4[i], this->unk_39C, &sp98); + Matrix_Scale(sp98.x, sp98.y, sp98.z, MTXMODE_APPLY); + if (this->unk_374 & 0x800) { + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, D_80A99194[i])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, D_80A9919C[i])); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80A9916C[i]); + Matrix_Pop(); + } + } else { + Matrix_Push(); + Matrix_Translate(0.0f, 2000.0f, -2000.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_Scale(D_80A993AC[this->unk_384].x, D_80A993AC[this->unk_384].y, 0.0f, MTXMODE_APPLY); + if (this->unk_374 & 0x800) { + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 255)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 85)); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_az_DL_01ABF0); + Matrix_Pop(); + Matrix_Translate(0.0f, 2000.0f, -2100.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_Scale(D_80A993D0[this->unk_384].x, D_80A993D0[this->unk_384].y, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_az_DL_01AD00); + } + } + CLOSE_DISPS(play->state.gfxCtx); +} + +s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnAz* this = THIS; + + if ((limbIndex == OBJECT_AZ_1_LIMB_NONE) && ((play->gameplayFrames % 2) != 0)) { + *dList = NULL; + } + if (limbIndex == OBJECT_AZ_1_LIMB_NONE) { + rot->x = rot->x; + rot->y = rot->y; + rot->z = rot->z; + } + if (limbIndex == OBJECT_AZ_1_LIMB_03) { + rot->y -= this->unk_39E; + } else { + // this space intentionally left blank + } + if (limbIndex == OBJECT_AZ_1_LIMB_05) { + rot->x += this->unk_3D4; + rot->y -= this->unk_3D6; + } + return false; +} + +void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80A99410 = { 700.0f, 0.0f, 0.0f }; + static Vec3f D_80A9941C = { -500.0f, 0.0f, 0.0f }; + static Vec3f D_80A99428 = { -1200.0f, 0.0f, 1000.0f }; + EnAz* this = THIS; + + if (limbIndex == OBJECT_AZ_1_LIMB_03) { + Matrix_MultVec3f(&D_80A99410, &this->unk_3A8); + Math_SmoothStepToF(&this->unk_3A4, this->unk_3A8.y - this->actor.world.pos.y, 0.8f, 10.0f, 0.01f); + if (this->unk_374 & 2) { + Matrix_MultVec3f(&D_80A9941C, &this->unk_3B4); + } else { + Matrix_MultVec3f(&D_80A99428, &this->unk_3B4); + } + } +} + +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 arg3, s32 arg4) { + EnAz* brother = this->brother; + + Actor_ChangeFocus(&this->actor, play, &brother->actor); + if (arg3 >= 0) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, arg3, &this->animIndex); + } + this->actor.textId = 0; + brother->actor.textId = textId; + brother->unk_378 = 5; + if ((arg4 >= 0) && (arg4 != brother->animIndex)) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, arg4, &brother->animIndex); + } + this->unk_378 = 0; +} + +void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp) { + f32 nextFrame; + f32 prevFrame; + f32 weight; + + do { + yData++; + nextFrame = yData[0].unk_0; + } while (nextFrame < frame); + prevFrame = yData[-1].unk_0; + weight = LERPWEIGHT(frame, prevFrame, nextFrame); + *yInterp = LERPIMP(yData[-1].unk_4, yData[0].unk_4, weight) * 0.01f; +} diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.h b/src/overlays/actors/ovl_En_Az/z_en_az.h index 5c302c6f3f..ffe094a932 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.h +++ b/src/overlays/actors/ovl_En_Az/z_en_az.h @@ -7,10 +7,48 @@ struct EnAz; typedef void (*EnAzActionFunc)(struct EnAz*, PlayState*); +#define BEAVER_GET_PARAM_F00(thisx) (((thisx)->params >> 8) & 0xF) +#define BEAVER_GET_PARAM_FF(thisx) ((thisx)->params & 0xFF) + typedef struct EnAz { /* 0x000 */ Actor actor; /* 0x144 */ EnAzActionFunc actionFunc; - /* 0x148 */ char unk_148[0x290]; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[24]; + /* 0x268 */ Vec3s morphTable[24]; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; // cutscene state? + /* 0x2FC */ s32 animIndex; + /* 0x300 */ ActorPathing unk_300; + /* 0x36C */ f32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk370[4]; + /* 0x374 */ u16 unk_374; // flags of some sort + /* 0x376 */ u16 unk_376; // flags of some sort + /* 0x378 */ u8 unk_378; // cutscene state? + /* 0x37A */ s16 unk_37A; + /* 0x37C */ s16 unk_37C; + /* 0x37E */ s16 unk_37E; + /* 0x380 */ s16 unk_380; + /* 0x382 */ s16 unk_382; + /* 0x384 */ s16 unk_384; + /* 0x388 */ struct EnAz* brother; + /* 0x38C */ UNK_TYPE1 unk38C[0x10]; + /* 0x39C */ s16 unk_39C; + /* 0x39E */ s16 unk_39E; // some sort of rotation + /* 0x3A0 */ UNK_TYPE1 unk3A0[4]; + /* 0x3A4 */ f32 unk_3A4; + /* 0x3A8 */ Vec3f unk_3A8; + /* 0x3B4 */ Vec3f unk_3B4; // translation + /* 0x3C0 */ s16 unk_3C0; // seems to do nothing + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ UNK_TYPE1 unk3C6[6]; + /* 0x3CC */ s32 getItemId; + /* 0x3D0 */ s16 unk_3D0[1]; + /* 0x3D2 */ u16 unk_3D2; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D6 */ s16 unk_3D6; } EnAz; // size = 0x3D8 extern const ActorInit En_Az_InitVars; diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index 182db56591..5df9cee3c5 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -5,6 +5,7 @@ */ #include "z_en_twig.h" +#include "objects/object_twig/object_twig.h" #define FLAGS (ACTOR_FLAG_10) @@ -12,10 +13,18 @@ void EnTwig_Init(Actor* thisx, PlayState* play); void EnTwig_Destroy(Actor* thisx, PlayState* play); -void EnTwig_Update(Actor* thisx, PlayState* play); -void EnTwig_Draw(Actor* thisx, PlayState* play); +void EnTwig_Update(Actor* this, PlayState* play); +void EnTwig_Draw(EnTwig* this, PlayState* play); + +void func_80AC0A54(EnTwig* this, PlayState* play); +void func_80AC0A6C(EnTwig* this, PlayState* play); + +void func_80AC0A7C(EnTwig* this, PlayState* play); +void func_80AC0AC8(EnTwig* this, PlayState* play); + +void func_80AC0CC4(EnTwig* this, PlayState* play); +void func_80AC0D2C(EnTwig* this, PlayState* play); -#if 0 const ActorInit En_Twig_InitVars = { ACTOR_EN_TWIG, ACTORCAT_MISC, @@ -28,36 +37,205 @@ const ActorInit En_Twig_InitVars = { (ActorFunc)EnTwig_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC10C0[] = { +static s32 sCurrentRing; +static s16 sRingCount; +static s16 sRingNotCollected[25]; + +static CollisionHeader* sColHeaders[] = { + NULL, + &object_twig_Colheader_0020A0, + &object_twig_Colheader_0016C0, +}; + +static s16 sRingsHaveSpawned = false; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +void EnTwig_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; + s32 i; -extern InitChainEntry D_80AC10C0[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = RACERING_GET_PARAM_F(&this->dyna.actor); + DynaPolyActor_Init(&this->dyna, 1); + if (sColHeaders[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[this->unk_160]); + } + this->dyna.actor.bgCheckFlags |= 0x400; + switch (this->unk_160) { + case 0: + Actor_MarkForDeath(&this->dyna.actor); + break; + case 1: + if (!sRingsHaveSpawned) { + sRingCount = (gSaveContext.save.weekEventReg[24] & 4) ? 25 : 20; + for (i = 0; i < sRingCount; i++) { + sRingNotCollected[i] = false; + } + sRingsHaveSpawned = true; + } + if (RACERING_GET_PARAM_1F0(&this->dyna.actor) != 0) { + if (!(gSaveContext.save.weekEventReg[24] & 4)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } else if (gSaveContext.save.weekEventReg[24] & 4) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + Actor_SetScale(&this->dyna.actor, 4.2f); + this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 60.0f; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + func_80AC0A7C(this, play); + break; + case 2: + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 880.0f; + func_80AC0A54(this, play); + break; + } +} -extern UNK_TYPE D_06001C38; +void EnTwig_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Destroy.s") +void func_80AC0A54(EnTwig* this, PlayState* play) { + this->actionFunc = func_80AC0A6C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A54.s") +void func_80AC0A6C(EnTwig* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A6C.s") +void func_80AC0A7C(EnTwig* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A7C.s") + Math_Vec3f_Copy(&this->unk_180, &player->bodyPartsPos[0]); + this->unk_178 = 0; + this->unk_17A = 0; + this->actionFunc = func_80AC0AC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0AC8.s") +void func_80AC0AC8(EnTwig* this, PlayState* play) { + static Vec3f D_80AC10D0 = { 0.0f, 0.0f, 1.0f }; + Player* player = GET_PLAYER(play); + Plane sp4C; + Vec3f sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0CC4.s") + if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { + if (this->unk_17A == 3) { + this->unk_17A = 0; + this->dyna.actor.shape.rot.z += 0x2000; + } else { + this->unk_17A++; + } + } + SubS_ConstructPlane(&this->dyna.actor.world.pos, &D_80AC10D0, &this->dyna.actor.shape.rot, &sp4C); + if ((sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) && + Math3D_LineSegVsPlane(sp4C.normal.x, sp4C.normal.y, sp4C.normal.z, sp4C.originDist, &this->unk_180, + &player->bodyPartsPos[0], &sp40, 0)) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &sp40) <= SQ(this->dyna.actor.scale.x * 0.345f * 40.0f)) { + func_80AC0CC4(this, play); + return; + } + } else { + if (this->dyna.actor.xyzDistToPlayerSq <= SQ((this->dyna.actor.scale.x * 40.0f) + 40)) { + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + } else { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } + if (this->dyna.actor.xyzDistToPlayerSq >= (this->dyna.actor.scale.x * 10.0f * 40.0f * 40.0f)) { + this->dyna.actor.shape.rot.y = this->dyna.actor.yawTowardsPlayer; + this->dyna.actor.world.rot.y = this->dyna.actor.yawTowardsPlayer; + } + } + Math_Vec3f_Copy(&this->unk_180, &player->bodyPartsPos[0]); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0D2C.s") +void func_80AC0CC4(EnTwig* this, PlayState* play) { + this->unk_170 = 3458.0f; + this->unk_174 = 0.2f; + this->unk_16C |= 1; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AC0D2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Update.s") +void func_80AC0D2C(EnTwig* this, PlayState* play) { + static Vec3f sKiraVel = { 0.0f, -0.05f, 0.0f }; + static Vec3f sKiraAccel = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 sColorWhite = { 255, 255, 255, 130 }; + static Color_RGBA8 sColorYellow = { 255, 255, 0, 0 }; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Draw.s") + Math_SmoothStepToF(&this->dyna.actor.world.pos.x, player->bodyPartsPos[0].x, 0.5f, 100.0f, 0.01f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, player->bodyPartsPos[0].y, 0.5f, 100.0f, 0.01f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.z, player->bodyPartsPos[0].z, 0.5f, 100.0f, 0.01f); + this->dyna.actor.shape.rot.z += (s16)this->unk_170; + this->dyna.actor.scale.x -= this->unk_174; + if (this->dyna.actor.scale.x < 0.0f) { + Actor_SetScale(&this->dyna.actor, 0.0f); + } else { + Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); + } + if (this->dyna.actor.scale.x <= 0.0f) { + s32 j; + Vec3f sp6C; + + for (j = 0; j < 7; j++) { + sp6C.x = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.x; + sp6C.y = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.y; + sp6C.z = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.z; + EffectSsKirakira_SpawnDispersed(play, &sp6C, &sKiraVel, &sKiraAccel, &sColorWhite, &sColorYellow, 1000, + (s32)(Rand_ZeroOne() * 10.0f) + 20); + } + play_sound(NA_SE_SY_GET_ITEM); + play->interfaceCtx.unk_25C--; + sRingNotCollected[RACERING_GET_PARAM_FE0(&this->dyna.actor)] = true; + if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { + s32 i; + + for (i = 0; i < sRingCount; i++) { + if (!sRingNotCollected[i]) { + sCurrentRing = i; + break; + } + } + if (i == sRingCount) { + sCurrentRing = -1; + } + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_170 += 180.0f / 0x10000; + this->unk_174 += 0.15f; +} + +void EnTwig_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; + + this->actionFunc(this, play); +} + +void EnTwig_Draw(EnTwig* thisx, PlayState* play) { + EnTwig* this = THIS; + + switch (this->unk_160) { + case 1: + Gfx_DrawDListOpa(play, object_twig_DL_001C38); + break; + case 2: + Gfx_DrawDListOpa(play, object_twig_DL_0014C8); + break; + } +} diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.h b/src/overlays/actors/ovl_En_Twig/z_en_twig.h index 2caebeb82c..3de7f8f4b9 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.h +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.h @@ -7,11 +7,22 @@ struct EnTwig; typedef void (*EnTwigActionFunc)(struct EnTwig*, PlayState*); +#define RACERING_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define RACERING_GET_PARAM_1F0(thisx) (((thisx)->params >> 4) & 0x1F) +#define RACERING_GET_PARAM_FE0(thisx) (((thisx)->params >> 9) & 0x7F) + typedef struct EnTwig { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ EnTwigActionFunc actionFunc; - /* 0x160 */ char unk_160[0x2C]; + /* 0x160 */ s32 unk_160; + /* 0x160 */ UNK_TYPE1 unk164[8]; + /* 0x16C */ s32 unk_16C; + /* 0x170 */ f32 unk_170; + /* 0x174 */ f32 unk_174; + /* 0x178 */ s16 unk_178; + /* 0x17A */ u16 unk_17A; + /* 0x17C */ UNK_TYPE1 unk17C[4]; + /* 0x180 */ Vec3f unk_180; } EnTwig; // size = 0x18C extern const ActorInit En_Twig_InitVars;