1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-29 03:34:07 +00:00

object_hata OK (#806)

* everything except limbs

* spec

* object_hata OK

* Replace symbols, unused data, enums, some cleanup

* Fix compiler warnings in EnRiverSound

* Address Roman's review

* Correct limbs name
This commit is contained in:
EllipticEllipsis 2021-05-17 19:57:59 +01:00 committed by GitHub
parent a597d71e54
commit d9a4a2079d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 138 additions and 34 deletions

View file

@ -0,0 +1,50 @@
<Root>
<File Name="object_hata" Segment="6">
<!-- Flagpole Collision -->
<Collision Name="gFlagpoleCol" Offset="0xC0"/>
<!-- Flagpole Animation -->
<Animation Name="gFlagpoleFlapAnim" Offset="0x444"/>
<!-- Flagpole Skeleton -->
<Skeleton Name="gFlagpoleSkel" Type="Normal" LimbType="Standard" Offset="0x2FD0"/>
<!-- Flagpole Limbs -->
<Limb Name="gFlagpolePoleBaseLimb" LimbType="Standard" Offset="0x2E90"/>
<Limb Name="gFlagpolePoleLimb" LimbType="Standard" Offset="0x2E9C"/>
<Limb Name="gFlagpoleFlag1BaseLimb" LimbType="Standard" Offset="0x2EA8"/>
<Limb Name="gFlagpoleFlag1HoistEndBaseLimb" LimbType="Standard" Offset="0x2EB4"/>
<Limb Name="gFlagpoleFlag1HoistMidBaseLimb" LimbType="Standard" Offset="0x2EC0"/>
<Limb Name="gFlagpoleFlag1FlyMidBaseLimb" LimbType="Standard" Offset="0x2ECC"/>
<Limb Name="gFlagpoleFlag1FlyEndBaseLimb" LimbType="Standard" Offset="0x2ED8"/>
<Limb Name="gFlagpoleFlag1FlyEndLimb" LimbType="Standard" Offset="0x2EE4"/>
<Limb Name="gFlagpoleFlag1FlyMidLimb" LimbType="Standard" Offset="0x2EF0"/>
<Limb Name="gFlagpoleFlag1HoistMidLimb" LimbType="Standard" Offset="0x2EFC"/>
<Limb Name="gFlagpoleFlag1HoistEndLimb" LimbType="Standard" Offset="0x2F08"/>
<Limb Name="gFlagpoleFlag2BaseLimb" LimbType="Standard" Offset="0x2F14"/>
<Limb Name="gFlagpoleFlag2HoistEndBaseLimb" LimbType="Standard" Offset="0x2F20"/>
<Limb Name="gFlagpoleFlag2HoistMidBaseLimb" LimbType="Standard" Offset="0x2F2C"/>
<Limb Name="gFlagpoleFlag2FlyMidBaseLimb" LimbType="Standard" Offset="0x2F38"/>
<Limb Name="gFlagpoleFlag2FlyEndBaseLimb" LimbType="Standard" Offset="0x2F44"/>
<Limb Name="gFlagpoleFlag2FlyEndLimb" LimbType="Standard" Offset="0x2F50"/>
<Limb Name="gFlagpoleFlag2FlyMidLimb" LimbType="Standard" Offset="0x2F5C"/>
<Limb Name="gFlagpoleFlag2HoistMidLimb" LimbType="Standard" Offset="0x2F68"/>
<Limb Name="gFlagpoleFlag2HoistEndLimb" LimbType="Standard" Offset="0x2F74"/>
<!-- Flagpole DLists -->
<DList Name="gFlagpolePoleDL" Offset="0x26D0"/>
<DList Name="gFlagpoleFlag1FlyEndDL" Offset="0x2AC0"/>
<DList Name="gFlagpoleFlag1FlyMidDL" Offset="0x29F0"/>
<DList Name="gFlagpoleFlag1HoistMidDL" Offset="0x2920"/>
<DList Name="gFlagpoleFlag1HoistEndDL" Offset="0x2850"/>
<DList Name="gFlagpoleFlag2FlyEndDL" Offset="0x2E00"/>
<DList Name="gFlagpoleFlag2FlyMidDL" Offset="0x2D30"/>
<DList Name="gFlagpoleFlag2HoistMidDL" Offset="0x2C60"/>
<DList Name="gFlagpoleFlag2HoistEndDL" Offset="0x2B90"/>
<!-- Flagpole Textures -->
<Texture Name="gFlagpolePoleTex" OutName="flagpole_pole_tex" Format="rgb5a1" Width="32" Height="32" Offset="0x460"/>
<Texture Name="gFlagpoleTopTex" OutName="flagpole_top_tex" Format="rgb5a1" Width="32" Height="32" Offset="0xC60"/>
<Texture Name="gFlagpoleFlagTex" OutName="flagpole_flag_tex" Format="ia8" Width="128" Height="32" Offset="0x1460"/>
</File>
</Root>

3
spec
View file

@ -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

View file

@ -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,

View file

@ -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;

View file

@ -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]);