1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-10 19:20:13 +00:00

z_en_horse_zelda doc (#1430)

* z_en_horse_zelda doc

Zelda's horse has been better documented. Horse seemed to follow a path around Hyrule Field

* `z_en_horse_zelda` revised based on feedback

* Update z_en_horse_zelda.c

EnHorseZelda_ResetAnimation -> EnHorseZelda_SetupStop

* z_horse_zelda: changes based on feedback
This commit is contained in:
blackgamma7 2022-11-16 02:14:11 -05:00 committed by GitHub
parent 6d5287ff12
commit 6451fbc24f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 58 deletions

View file

@ -14,9 +14,9 @@ void EnHorseZelda_Destroy(Actor* thisx, PlayState* play);
void EnHorseZelda_Update(Actor* thisx, PlayState* play); void EnHorseZelda_Update(Actor* thisx, PlayState* play);
void EnHorseZelda_Draw(Actor* thisx, PlayState* play); void EnHorseZelda_Draw(Actor* thisx, PlayState* play);
void func_80A6DCCC(EnHorseZelda* this, PlayState* play); void EnHorseZelda_Stop(EnHorseZelda* this, PlayState* play);
void func_80A6DDFC(EnHorseZelda* this, PlayState* play); void EnHorseZelda_Gallop(EnHorseZelda* this, PlayState* play);
void func_80A6DC7C(EnHorseZelda* this); void EnHorseZelda_SetupStop(EnHorseZelda* this);
ActorInit En_Horse_Zelda_InitVars = { ActorInit En_Horse_Zelda_InitVars = {
ACTOR_EN_HORSE_ZELDA, ACTOR_EN_HORSE_ZELDA,
@ -83,16 +83,17 @@ static ColliderJntSphInit sJntSphInit = {
static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY };
typedef struct { typedef struct {
/* 0x0 */ Vec3s unk_0; /* 0x0 */ Vec3s pos;
/* 0x6 */ u8 unk_6; /* 0x6 */ u8 speed;
} unknownStruct; // size = 0x8 } HorsePosSpeed; // size = 0x8
static unknownStruct D_80A6E240[] = { // these seem to be valid coords on Hyrule field, along with target speeds
{ -1682, -500, 12578, 0x07 }, { -3288, -500, 13013, 0x07 }, { -5142, -417, 11630, 0x07 }, static HorsePosSpeed sHorseFieldPositions[] = {
{ -5794, -473, 9573, 0x07 }, { -6765, -500, 8364, 0x07 }, { -6619, -393, 6919, 0x07 }, { {-1682, -500, 12578}, 7 }, { {-3288, -500, 13013}, 7 }, { {-5142, -417, 11630}, 7 },
{ -5193, 124, 5433, 0x07 }, { -2970, 2, 4537, 0x07 }, { -2949, -35, 4527, 0x07 }, { {-5794, -473, 9573}, 7 }, { {-6765, -500, 8364}, 7 }, { {-6619, -393, 6919}, 7 },
{ -1907, -47, 2978, 0x07 }, { 2488, 294, 3628, 0x07 }, { 3089, 378, 4713, 0x07 }, { {-5193, 124, 5433}, 7 }, { {-2970, 2, 4537}, 7 }, { {-2949, -35, 4527}, 7 },
{ 1614, -261, 7596, 0x07 }, { 754, -187, 9295, 0x07 }, { {-1907, -47, 2978}, 7 }, { {2488, 294, 3628}, 7 }, { {3089, 378, 4713}, 7 },
{ {1614, -261, 7596}, 7 }, { {754, -187, 9295}, 7 },
}; };
static InitChainEntry sInitChain[] = { static InitChainEntry sInitChain[] = {
@ -100,34 +101,34 @@ static InitChainEntry sInitChain[] = {
}; };
static EnHorseZeldaActionFunc sActionFuncs[] = { static EnHorseZeldaActionFunc sActionFuncs[] = {
func_80A6DCCC, EnHorseZelda_Stop,
func_80A6DDFC, EnHorseZelda_Gallop,
}; };
void func_80A6D8D0(unknownStruct* data, s32 index, Vec3f* vec) { void EnHorseZelda_GetFieldPosition(HorsePosSpeed* data, s32 index, Vec3f* fieldPos) {
vec->x = data[index].unk_0.x; fieldPos->x = data[index].pos.x;
vec->y = data[index].unk_0.y; fieldPos->y = data[index].pos.y;
vec->z = data[index].unk_0.z; fieldPos->z = data[index].pos.z;
} }
void func_80A6D918(EnHorseZelda* this, PlayState* play) { void EnHorseZelda_Move(EnHorseZelda* this, PlayState* play) {
s32 pad; s32 pad;
Vec3f sp28; Vec3f fieldPos;
s16 yawDiff; s16 yawDiff;
func_80A6D8D0(D_80A6E240, this->unk_1EC, &sp28); EnHorseZelda_GetFieldPosition(sHorseFieldPositions, this->fieldPosIndex, &fieldPos);
if (Math3D_Vec3f_DistXYZ(&sp28, &this->actor.world.pos) <= 400.0f) { if (Math3D_Vec3f_DistXYZ(&fieldPos, &this->actor.world.pos) <= 400.0f) {
this->unk_1EC++; this->fieldPosIndex++;
if (this->unk_1EC >= 14) { if (this->fieldPosIndex >= ARRAY_COUNT(sHorseFieldPositions)) {
this->unk_1EC = 0; this->fieldPosIndex = 0;
func_80A6D8D0(D_80A6E240, 0, &sp28); EnHorseZelda_GetFieldPosition(sHorseFieldPositions, 0, &fieldPos);
} }
} }
yawDiff = Math_Vec3f_Yaw(&this->actor.world.pos, &sp28) - this->actor.world.rot.y; yawDiff = Math_Vec3f_Yaw(&this->actor.world.pos, &fieldPos) - this->actor.world.rot.y;
if (yawDiff >= 0x12D) { if (yawDiff > 300) {
this->actor.world.rot.y += 0x12C; this->actor.world.rot.y += 300;
} else if (yawDiff < -0x12C) { } else if (yawDiff < -300) {
this->actor.world.rot.y -= 0x12C; this->actor.world.rot.y -= 300;
} else { } else {
this->actor.world.rot.y += yawDiff; this->actor.world.rot.y += yawDiff;
} }
@ -139,7 +140,7 @@ void func_80A6D918(EnHorseZelda* this, PlayState* play) {
} else { } else {
this->actor.speedXZ -= 1.0f; this->actor.speedXZ -= 1.0f;
} }
} else if (this->actor.speedXZ < D_80A6E240[this->unk_1EC].unk_6) { } else if (this->actor.speedXZ < sHorseFieldPositions[this->fieldPosIndex].speed) {
this->actor.speedXZ += 0.5f; this->actor.speedXZ += 0.5f;
} else { } else {
this->actor.speedXZ -= 0.5f; this->actor.speedXZ -= 0.5f;
@ -166,7 +167,7 @@ void EnHorseZelda_Init(Actor* thisx, PlayState* play) {
Collider_SetJntSph(play, &this->colliderSphere, &this->actor, &sJntSphInit, &this->colliderSphereItem); Collider_SetJntSph(play, &this->colliderSphere, &this->actor, &sJntSphInit, &this->colliderSphereItem);
CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit);
this->animationIndex = 0; this->animationIndex = 0;
func_80A6DC7C(this); EnHorseZelda_SetupStop(this);
} }
void EnHorseZelda_Destroy(Actor* thisx, PlayState* play) { void EnHorseZelda_Destroy(Actor* thisx, PlayState* play) {
@ -177,7 +178,7 @@ void EnHorseZelda_Destroy(Actor* thisx, PlayState* play) {
Skin_Free(play, &this->skin); Skin_Free(play, &this->skin);
} }
void func_80A6DC7C(EnHorseZelda* this) { void EnHorseZelda_SetupStop(EnHorseZelda* this) {
this->action = 0; this->action = 0;
this->animationIndex++; this->animationIndex++;
if (this->animationIndex > 0) { if (this->animationIndex > 0) {
@ -186,34 +187,34 @@ void func_80A6DC7C(EnHorseZelda* this) {
Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex]); Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex]);
} }
void func_80A6DCCC(EnHorseZelda* this, PlayState* play) { void EnHorseZelda_Stop(EnHorseZelda* this, PlayState* play) {
this->actor.speedXZ = 0.0f; this->actor.speedXZ = 0.0f;
if (SkelAnime_Update(&this->skin.skelAnime)) { if (SkelAnime_Update(&this->skin.skelAnime)) {
func_80A6DC7C(this); EnHorseZelda_SetupStop(this);
} }
} }
void func_80A6DD14(EnHorseZelda* this) { void EnHorseZelda_Spur(EnHorseZelda* this) {
f32 sp34; f32 speedMod;
this->action = 1; this->action = 1;
this->animationIndex = 0; this->animationIndex = 0;
sp34 = this->actor.speedXZ / 6.0f; speedMod = this->actor.speedXZ / 6.0f;
Audio_PlaySfxGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex], Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex],
splaySpeeds[this->animationIndex] * sp34 * 1.5f, 0.0f, splaySpeeds[this->animationIndex] * speedMod * 1.5f, 0.0f,
Animation_GetLastFrame(sAnimationHeaders[this->animationIndex]), ANIMMODE_ONCE, 0.0f); Animation_GetLastFrame(sAnimationHeaders[this->animationIndex]), ANIMMODE_ONCE, 0.0f);
} }
void func_80A6DDFC(EnHorseZelda* this, PlayState* play) { void EnHorseZelda_Gallop(EnHorseZelda* this, PlayState* play) {
func_80A6D918(this, play); EnHorseZelda_Move(this, play);
if (SkelAnime_Update(&this->skin.skelAnime)) { if (SkelAnime_Update(&this->skin.skelAnime)) {
func_80A6DD14(this); EnHorseZelda_Spur(this);
} }
} }
void func_80A6DE38(EnHorseZelda* this, PlayState* play) { void EnHorseZelda_SetRotate(EnHorseZelda* this, PlayState* play) {
s32 pad; s32 pad;
CollisionPoly* poly; CollisionPoly* poly;
s32 pad2; s32 pad2;
@ -223,8 +224,8 @@ void func_80A6DE38(EnHorseZelda* this, PlayState* play) {
checkPos.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x; checkPos.x = (Math_SinS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.x;
checkPos.y = this->actor.world.pos.y + 60.0f; checkPos.y = this->actor.world.pos.y + 60.0f;
checkPos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z; checkPos.z = (Math_CosS(this->actor.shape.rot.y) * 30.0f) + this->actor.world.pos.z;
this->unk_1F4 = BgCheck_EntityRaycastDown3(&play->colCtx, &poly, &bgId, &checkPos); this->floorYForwards = BgCheck_EntityRaycastDown3(&play->colCtx, &poly, &bgId, &checkPos);
this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->unk_1F4, 30.0f)); this->actor.shape.rot.x = RAD_TO_BINANG(Math_FAtan2F(this->actor.world.pos.y - this->floorYForwards, 30.0f));
} }
void EnHorseZelda_Update(Actor* thisx, PlayState* play) { void EnHorseZelda_Update(Actor* thisx, PlayState* play) {
@ -244,21 +245,21 @@ void EnHorseZelda_Update(Actor* thisx, PlayState* play) {
} }
void EnHorseZelda_PostDraw(Actor* thisx, PlayState* play, Skin* skin) { void EnHorseZelda_PostDraw(Actor* thisx, PlayState* play, Skin* skin) {
Vec3f sp4C; Vec3f offset;
Vec3f sp40; Vec3f dst;
EnHorseZelda* this = (EnHorseZelda*)thisx; EnHorseZelda* this = (EnHorseZelda*)thisx;
s32 i; s32 i;
for (i = 0; i < this->colliderSphere.count; i++) { for (i = 0; i < this->colliderSphere.count; i++) {
sp4C.x = this->colliderSphere.elements[i].dim.modelSphere.center.x; offset.x = this->colliderSphere.elements[i].dim.modelSphere.center.x;
sp4C.y = this->colliderSphere.elements[i].dim.modelSphere.center.y; offset.y = this->colliderSphere.elements[i].dim.modelSphere.center.y;
sp4C.z = this->colliderSphere.elements[i].dim.modelSphere.center.z; offset.z = this->colliderSphere.elements[i].dim.modelSphere.center.z;
Skin_GetLimbPos(skin, this->colliderSphere.elements[i].dim.limb, &sp4C, &sp40); Skin_GetLimbPos(skin, this->colliderSphere.elements[i].dim.limb, &offset, &dst);
this->colliderSphere.elements[i].dim.worldSphere.center.x = sp40.x; this->colliderSphere.elements[i].dim.worldSphere.center.x = dst.x;
this->colliderSphere.elements[i].dim.worldSphere.center.y = sp40.y; this->colliderSphere.elements[i].dim.worldSphere.center.y = dst.y;
this->colliderSphere.elements[i].dim.worldSphere.center.z = sp40.z; this->colliderSphere.elements[i].dim.worldSphere.center.z = dst.z;
this->colliderSphere.elements[i].dim.worldSphere.radius = this->colliderSphere.elements[i].dim.worldSphere.radius =
this->colliderSphere.elements[i].dim.modelSphere.radius * this->colliderSphere.elements[i].dim.scale; this->colliderSphere.elements[i].dim.modelSphere.radius * this->colliderSphere.elements[i].dim.scale;
@ -271,7 +272,7 @@ void EnHorseZelda_PostDraw(Actor* thisx, PlayState* play, Skin* skin) {
void EnHorseZelda_Draw(Actor* thisx, PlayState* play) { void EnHorseZelda_Draw(Actor* thisx, PlayState* play) {
EnHorseZelda* this = (EnHorseZelda*)thisx; EnHorseZelda* this = (EnHorseZelda*)thisx;
func_80A6DE38(this, play); EnHorseZelda_SetRotate(this, play);
Gfx_SetupDL_25Opa(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx);
func_800A6330(&this->actor, play, &this->skin, EnHorseZelda_PostDraw, true); func_800A6330(&this->actor, play, &this->skin, EnHorseZelda_PostDraw, true);
} }

View file

@ -14,9 +14,9 @@ typedef struct EnHorseZelda {
/* 0x0150 */ s32 animationIndex; /* 0x0150 */ s32 animationIndex;
/* 0x0154 */ Skin skin; /* 0x0154 */ Skin skin;
/* 0x01E4 */ char unk_1E4[0x8]; /* 0x01E4 */ char unk_1E4[0x8];
/* 0x01EC */ s32 unk_1EC; /* 0x01EC */ s32 fieldPosIndex;
/* 0x01F0 */ char unk_1F0[0x4]; /* 0x01F0 */ char unk_1F0[0x4];
/* 0x01F4 */ f32 unk_1F4; /* 0x01F4 */ f32 floorYForwards;
/* 0x01F8 */ char unk_1F8[0x4]; /* 0x01F8 */ char unk_1F8[0x4];
/* 0x01FC */ ColliderCylinder colliderCylinder; /* 0x01FC */ ColliderCylinder colliderCylinder;
/* 0x0248 */ ColliderJntSph colliderSphere; /* 0x0248 */ ColliderJntSph colliderSphere;