diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml new file mode 100644 index 0000000000..0c2c30677d --- /dev/null +++ b/assets/xml/objects/object_hata.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 1a721526e3..b5947ff6bf 100644 --- a/spec +++ b/spec @@ -4194,7 +4194,8 @@ endseg beginseg name "object_hata" romalign 0x1000 - include "build/baserom/object_hata.o" + include "build/assets/objects/object_hata/object_hata.o" + number 6 endseg beginseg diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index 44fa131e9c..3f75b6bc05 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -5,6 +5,7 @@ */ #include "z_en_hata.h" +#include "objects/object_hata/object_hata.h" #define FLAGS 0x00000000 @@ -27,30 +28,40 @@ const ActorInit En_Hata_InitVars = { (ActorFunc)EnHata_Draw, }; -static UNK_TYPE sUnusedData[] = { - 0x0A000939, 0x20010000, 0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x00000000, - 0x00050100, 0x001000F6, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFF000000, +// Unused Collider and CollisionCheck data +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000080, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { 16, 246, 0, { 0, 0, 0 } }, }; -static Vec3f sVec = { 0, 0, 0 }; - -extern AnimationHeader D_06000444; -extern SkeletonHeader D_06002FD0; -extern CollisionHeader D_060000C0; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { EnHata* this = THIS; s32 pad; - CollisionHeader* colHeader; - f32 frameCount; + CollisionHeader* colHeader = NULL; + f32 frameCount = Animation_GetLastFrame(&gFlagpoleFlapAnim); - colHeader = NULL; - frameCount = Animation_GetLastFrame(&D_06000444); Actor_SetScale(&this->dyna.actor, 1.0f / 75.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &D_06002FD0, &D_06000444, NULL, NULL, 0); - Animation_Change(&this->skelAnime, &D_06000444, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gFlagpoleSkel, &gFlagpoleFlapAnim, NULL, NULL, 0); + Animation_Change(&this->skelAnime, &gFlagpoleFlapAnim, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); DynaPolyActor_Init(&this->dyna, DPM_UNK); - CollisionHeader_GetVirtual(&D_060000C0, &colHeader); + CollisionHeader_GetVirtual(&gFlagpoleCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.actor.uncullZoneScale = 500.0f; this->dyna.actor.uncullZoneDownward = 550.0f; @@ -58,11 +69,12 @@ void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { this->invScale = 6; this->maxStep = 1000; this->minStep = 1; - this->unk_278 = Rand_ZeroOne() * 65535.0f; + this->unk_278 = Rand_ZeroOne() * 0xFFFF; } void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnHata* this = THIS; + SkelAnime_Free(&this->skelAnime, globalCtx); DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } @@ -71,33 +83,41 @@ void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnHata* this = THIS; s32 pitch; - Vec3f sp48 = sVec; - Vec3f sp3C; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + Vec3f windVec; f32 sin; SkelAnime_Update(&this->skelAnime); - this->limbs[3].y = this->limbs[12].y = -0x4000; - sp3C.x = globalCtx->envCtx.unk_A8; - sp3C.y = globalCtx->envCtx.unk_AA; - sp3C.z = globalCtx->envCtx.unk_AC; + + // Rotate to hang down by default + this->limbs[FLAGPOLE_LIMB_FLAG_1_BASE].y = this->limbs[FLAGPOLE_LIMB_FLAG_2_BASE].y = -0x4000; + windVec.x = globalCtx->envCtx.unk_A8; + windVec.y = globalCtx->envCtx.unk_AA; + windVec.z = globalCtx->envCtx.unk_AC; + if (globalCtx->envCtx.unk_B0 > 255.0f) { globalCtx->envCtx.unk_B0 = 255.0f; } + if (globalCtx->envCtx.unk_B0 < 0.0f) { globalCtx->envCtx.unk_B0 = 0.0f; } + if (Rand_ZeroOne() > 0.5f) { this->unk_278 += 6000; } else { this->unk_278 += 3000; } + + // Mimic varying wind gusts sin = Math_SinS(this->unk_278) * 80.0f; - pitch = -Math_Vec3f_Pitch(&sp48, &sp3C); - pitch = ((s32)((0x3A98 - pitch) * (1.0f - (globalCtx->envCtx.unk_B0 / (255.0f - sin))))) + pitch; - Math_SmoothStepToS(&this->limbs[4].y, pitch, this->invScale, this->maxStep, this->minStep); - this->limbs[13].y = this->limbs[4].y; - this->limbs[4].z = -Math_Vec3f_Yaw(&sp48, &sp3C); - this->limbs[13].z = this->limbs[4].z; + pitch = -Math_Vec3f_Pitch(&zeroVec, &windVec); + pitch = ((s32)((15000 - pitch) * (1.0f - (globalCtx->envCtx.unk_B0 / (255.0f - sin))))) + pitch; + Math_SmoothStepToS(&this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y, pitch, this->invScale, this->maxStep, + this->minStep); + this->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].y = this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].y; + this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z = -Math_Vec3f_Yaw(&zeroVec, &windVec); + this->limbs[FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE].z = this->limbs[FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE].z; this->skelAnime.playSpeed = (Rand_ZeroFloat(1.25f) + 2.75f) * (globalCtx->envCtx.unk_B0 / 255.0f); } @@ -105,7 +125,8 @@ s32 EnHata_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList EnHata* this = THIS; Vec3s* limbs; - if (limbIndex == 12 || limbIndex == 3 || limbIndex == 13 || limbIndex == 4) { + if (limbIndex == FLAGPOLE_LIMB_FLAG_2_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_1_BASE || + limbIndex == FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE || limbIndex == FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE) { limbs = this->limbs; rot->x += limbs[limbIndex].x; rot->y += limbs[limbIndex].y; @@ -119,6 +140,7 @@ void EnHata_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHata* this = THIS; + func_800943C8(globalCtx->state.gfxCtx); Matrix_Scale(1.0f, 1.1f, 1.0f, MTXMODE_APPLY); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHata_OverrideLimbDraw, diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.h b/src/overlays/actors/ovl_En_Hata/z_en_hata.h index 09e81f3e17..f469d84a42 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.h +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.h @@ -4,11 +4,37 @@ #include "ultra64.h" #include "global.h" + +typedef enum { + /* 0x00 */ FLAGPOLE_LIMB_NONE, + /* 0x01 */ FLAGPOLE_LIMB_POLE_BASE, + /* 0x02 */ FLAGPOLE_LIMB_POLE, + /* 0x03 */ FLAGPOLE_LIMB_FLAG_1_BASE, + /* 0x04 */ FLAGPOLE_LIMB_FLAG_1_HOIST_END_BASE, + /* 0x05 */ FLAGPOLE_LIMB_FLAG_1_HOIST_MID_BASE, + /* 0x06 */ FLAGPOLE_LIMB_FLAG_1_FLY_MID_BASE, + /* 0x07 */ FLAGPOLE_LIMB_FLAG_1_FLY_END_BASE, + /* 0x08 */ FLAGPOLE_LIMB_FLAG_1_FLY_END, + /* 0x09 */ FLAGPOLE_LIMB_FLAG_1_FLY_MID, + /* 0x0A */ FLAGPOLE_LIMB_FLAG_1_HOIST_MID, + /* 0x0B */ FLAGPOLE_LIMB_FLAG_1_HOIST_END, + /* 0x0C */ FLAGPOLE_LIMB_FLAG_2_BASE, + /* 0x0D */ FLAGPOLE_LIMB_FLAG_2_HOIST_END_BASE, + /* 0x0E */ FLAGPOLE_LIMB_FLAG_2_HOIST_MID_BASE, + /* 0x0F */ FLAGPOLE_LIMB_FLAG_2_FLY_MID_BASE, + /* 0x10 */ FLAGPOLE_LIMB_FLAG_2_FLY_END_BASE, + /* 0x11 */ FLAGPOLE_LIMB_FLAG_2_FLY_END, + /* 0x12 */ FLAGPOLE_LIMB_FLAG_2_FLY_MID, + /* 0x13 */ FLAGPOLE_LIMB_FLAG_2_HOIST_MID, + /* 0x14 */ FLAGPOLE_LIMB_FLAG_2_HOIST_END, + /* 0x15 */ FLAGPOLE_LIMB_MAX +} EnHataLimb; + typedef struct { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ SkelAnime skelAnime; - /* 0x01A8 */ char unk_1A8[0x4C]; - /* 0x01F4 */ Vec3s limbs[0x15]; + /* 0x01A8 */ ColliderCylinder collider; // Unused, but indicated by the form of the unused data + /* 0x01F4 */ Vec3s limbs[FLAGPOLE_LIMB_MAX]; /* 0x0272 */ s16 invScale; /* 0x0274 */ s16 maxStep; /* 0x0276 */ s16 minStep; diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index c5ccca83ad..50ab329b01 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -110,15 +110,18 @@ s32 func_80AE6BC0(Vec3s* points, s32 numPoints, Vec3f* pos, Vec3f* res) { for (i = 0; i < numPoints; i++) { f32 d; + vec.x = points[i].x; vec.y = points[i].y; vec.z = points[i].z; d = Math_Vec3f_DistXYZ(pos, &vec); + if (d < pointDist) { pointDist = d; pointIdx = i; } } + if (pointDist >= 10000.0f) { return 0; } @@ -127,12 +130,14 @@ s32 func_80AE6BC0(Vec3s* points, s32 numPoints, Vec3f* pos, Vec3f* res) { pointLoc.x = point->x; pointLoc.y = point->y; pointLoc.z = point->z; + if (pointIdx != 0) { vec.x = point[-1].x; vec.y = point[-1].y; vec.z = point[-1].z; sp78[0] = func_80AE6A54(&vec, &pointLoc, pos, &sp54); } + if (pointIdx + 1 != numPoints) { vec.x = point[1].x; vec.y = point[1].y; @@ -240,9 +245,9 @@ void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { } else if (this->actor.params == 12) { func_800F4E30(&this->actor.projectedPos, this->actor.xzDistToPlayer); } else if (this->actor.params == 13) { - func_800F52A0(&this->actor.home, 62, 1000); + func_800F52A0(&this->actor.home.pos, 62, 1000); } else if (this->actor.params == 19) { - func_800F52A0(&this->actor.home, 40, 800); + func_800F52A0(&this->actor.home.pos, 40, 800); } else if (this->actor.params == 14 || this->actor.params == 16 || this->actor.params == 17 || this->actor.params == 18) { func_800788CC(D_80AE71F8[this->actor.params]);