1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-06 06:10:21 +00:00

En_Horse OK (#554)

* En_Horse OK

* Remove reloc

* WIP

* Use EnIn

* Documentation

* Documentation

* Remove debug prints

* Warnings

* Cleanup

* Unused asm

* Review comment

* Review comments and reformat

* More review comments

* Rename flags

* Review changes

Co-authored-by: Fig02 <fig02srl@gmail.com>
This commit is contained in:
Synray 2021-04-11 18:23:40 -07:00 committed by GitHub
parent d22b746128
commit 7f94088a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
140 changed files with 3880 additions and 12777 deletions

File diff suppressed because it is too large Load diff

View file

@ -4,50 +4,187 @@
#include "ultra64.h"
#include "global.h"
typedef enum {
/* 0 */ ENHORSE_ACT_FROZEN,
/* 1 */ ENHORSE_ACT_INACTIVE,
/* 2 */ ENHORSE_ACT_IDLE,
/* 3 */ ENHORSE_ACT_FOLLOW_PLAYER,
/* 4 */ ENHORSE_ACT_INGO_RACE,
/* 5 */ ENHORSE_ACT_MOUNTED_IDLE,
/* 6 */ ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING,
/* 7 */ ENHORSE_ACT_MOUNTED_TURN,
/* 8 */ ENHORSE_ACT_MOUNTED_WALK,
/* 9 */ ENHORSE_ACT_MOUNTED_TROT,
/* 10 */ ENHORSE_ACT_MOUNTED_GALLOP,
/* 11 */ ENHORSE_ACT_MOUNTED_REARING,
/* 12 */ ENHORSE_ACT_STOPPING,
/* 13 */ ENHORSE_ACT_REVERSE,
/* 14 */ ENHORSE_ACT_LOW_JUMP,
/* 15 */ ENHORSE_ACT_HIGH_JUMP,
/* 16 */ ENHORSE_ACT_BRIDGE_JUMP,
/* 17 */ ENHORSE_ACT_CS_UPDATE,
/* 18 */ ENHORSE_ACT_HBA,
/* 19 */ ENHORSE_ACT_FLEE_PLAYER
} EnHorseAction;
#define ENHORSE_BOOST (1 << 0) /* 0x1 */
#define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */
#define ENHORSE_JUMPING (1 << 2) /* 0x4 */
#define ENHORSE_CALC_RIDER_POS (1 << 3) /* 0x8 */
#define ENHORSE_FORCE_REVERSING (1 << 4) /* 0x10 */
#define ENHORSE_FORCE_WALKING (1 << 5) /* 0x20 */
#define ENHORSE_FLAG_6 (1 << 6) /* 0x40 */
#define ENHORSE_FLAG_7 (1 << 7) /* 0x80 */
#define ENHORSE_FLAG_8 (1 << 8) /* 0x100 */
#define ENHORSE_FLAG_9 (1 << 9) /* 0x200 */
#define ENHORSE_STOPPING_NEIGH_SOUND (1 << 10) /* 0x400 */
#define ENHORSE_LAND2_SOUND (1 << 11) /* 0x800 */
#define ENHORSE_SANDDUST_SOUND (1 << 12) /* 0x1000 */
#define ENHORSE_INACTIVE (1 << 13) /* 0x2000 */
#define ENHORSE_OBSTACLE (1 << 14) /* 0x4000 */
#define ENHORSE_TURNING_TO_PLAYER (1 << 15) /* 0x8000 */
#define ENHORSE_UNRIDEABLE (1 << 16) /* 0x1 0000 */
#define ENHORSE_CANT_JUMP (1 << 17) /* 0x2 0000 */
#define ENHORSE_FLAG_18 (1 << 18) /* 0x4 0000 */
#define ENHORSE_FLAG_19 (1 << 19) /* 0x8 0000 */
#define ENHORSE_FLAG_20 (1 << 20) /* 0x10 0000 */
#define ENHORSE_FLAG_21 (1 << 21) /* 0x20 0000 */
#define ENHORSE_FIRST_BOOST_REGEN (1 << 22) /* 0x40 0000 */
#define ENHORSE_INGO_WON (1 << 23) /* 0x80 0000 */
#define ENHORSE_FLAG_24 (1 << 24) /* 0x100 0000 */
#define ENHORSE_FLAG_25 (1 << 25) /* 0x200 0000 */
#define ENHORSE_FLAG_26 (1 << 26) /* 0x400 0000 */
#define ENHORSE_DRAW (1 << 27) /* 0x800 0000 */
#define ENHORSE_FLAG_28 (1 << 28) /* 0x1000 0000 */
#define ENHORSE_FLAG_29 (1 << 29) /* 0x2000 0000 */
#define ENHORSE_FLAG_30 (1 << 30) /* 0x4000 0000 */
#define ENHORSE_FLAG_31 (1 << 31) /* 0x8000 0000 */
struct EnHorse;
typedef enum {
/* 0 */ PLAYER_DIR_FRONT_R,
/* 1 */ PLAYER_DIR_FRONT_L,
/* 2 */ PLAYER_DIR_BACK_R,
/* 3 */ PLAYER_DIR_BACK_L,
/* 4 */ PLAYER_DIR_SIDE_R,
/* 5 */ PLAYER_DIR_SIDE_L
} EnHorsePlayerDir;
typedef enum {
/* 0 */ ENHORSE_ANIM_IDLE,
/* 1 */ ENHORSE_ANIM_WHINNEY,
/* 2 */ ENHORSE_ANIM_STOPPING,
/* 3 */ ENHORSE_ANIM_REARING,
/* 4 */ ENHORSE_ANIM_WALK,
/* 5 */ ENHORSE_ANIM_TROT,
/* 6 */ ENHORSE_ANIM_GALLOP,
/* 7 */ ENHORSE_ANIM_LOW_JUMP,
/* 8 */ ENHORSE_ANIM_HIGH_JUMP
} EnHorseAnimationIndex;
typedef enum {
/* 0 */ HORSE_EPONA,
/* 1 */ HORSE_HNI
} HorseType;
typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, GlobalContext*);
typedef struct EnHorse {
/* 0x000 */ Actor actor;
/* 0x014C */ s32 unk_14C;
/* 0x0150 */ char unk_150[0x008];
/* 0x0150 */ s32 unk_158;
/* 0x0150 */ char unk_15C[0x094];
/* 0x01F0 */ u32 unk_1F0;
/* 0x01F4 */ char unk_1F4[0x01C];
/* 0x0210 */ s32 unk_210;
/* 0x0214 */ f32 unk_214;
/* 0x0218 */ char unk_218[0x040];
/* 0x0258 */ Vec3f unk_258;
/* 0x0264 */ char unk_264[0x124];
/* 0x0388 */ s32 unk_388;
/* 0x038C */ char unk_38C[0x14];
/* 0x03A0 */ s32 unk_3A0;
/* 0x03A4 */ char unk_3A4[0x58];
/* 0x0000 */ Actor actor;
/* 0x014C */ EnHorseAction action;
/* 0x0150 */ s32 noInputTimer;
/* 0x0154 */ s32 noInputTimerMax;
/* 0x0158 */ s32 type;
/* 0x015C */ s8 bankIndex;
/* 0x0160 */ PSkinAwb skin;
/* 0x01F0 */ u32 stateFlags;
/* 0x01F4 */ Vec3f lastPos;
/* 0x0200 */ s16 lastYaw;
/* 0x0204 */ s32 curRaceWaypoint;
/* 0x0208 */ s32 boostSpeed;
/* 0x020C */ s32 playerControlled;
/* 0x0210 */ s32 animationIdx;
/* 0x0214 */ f32 curFrame;
/* 0x0218 */ s32 soundTimer;
/* 0x021C */ Vec3f unk_21C;
/* 0x0228 */ Vec3f unk_228;
/* 0x0234 */ s32 unk_234;
/* 0x0238 */ u8 numBoosts;
/* 0x023C */ s32 boostRegenTime;
/* 0x0240 */ s32 boostTimer;
/* 0x0244 */ EnHorsePostdrawFunc postDrawFunc;
/* 0x0248 */ f32 yFront; // The y coordinate of the floor under the front feet
/* 0x024C */ f32 yBack; // The y coordinate of the floor under the back feet
/* 0x0250 */ s16 followTimer;
/* 0x0252 */ s16 unk_252;
/* 0x0254 */ EnHorseAction prevAction;
/* 0x0258 */ Vec3f riderPos;
/* 0x0264 */ Vec2f curStick;
/* 0x026C */ Vec2f lastStick;
/* 0x0274 */ f32 jumpStartY;
/* 0x0278 */ ColliderCylinder cyl1;
/* 0x02C4 */ ColliderCylinder cyl2;
/* 0x0310 */ ColliderJntSph jntSph;
/* 0x0330 */ ColliderJntSphElement jntSphList;
/* 0x0370 */ u32 playerDir;
/* 0x0374 */ s16 unk_374;
/* 0x0376 */ s16 angleToPlayer;
/* 0x0378 */ s16 followPlayerTurnSpeed;
/* 0x037A */ u8 blinkTimer;
/* 0x037C */ s16 waitTimer;
/* 0x037E */ s16 unk_37E;
/* 0x0380 */ s32 cutsceneAction;
/* 0x0384 */ u16 cutsceneFlags;
// struct {
/* 0x0388 */ s32 inRace;
/* 0x038C */ Actor* rider;
/* 0x0390 */ u32 unk_390;
/* 0x0394 */ u16 ingoRaceFlags;
/* 0x0398 */ f32 ingoHorseMaxSpeed;
// } race; //?
/* 0x039C */ s32 unk_39C; // probably hbaAction
/* 0x03A0 */ s32 hbaStarted;
/* 0x03A4 */ s32 hbaFlags;
/* 0x03A8 */ s32 hbaTimer;
/* 0x03AC */ u8 bridgeJumpIdx;
/* 0x03B0 */ Vec3f bridgeJumpStart;
/* 0x03BC */ s32 bridgeJumpTimer;
/* 0x03C0 */ f32 bridgeJumpYVel;
/* 0x03C4 */ s16 bridgeJumpRelAngle;
/* 0x03C6 */ s16 unk_3C6; // pad
// sub struct?
/* 0x03C8 */ u16 dustFlags;
/* 0x03CC */ Vec3f frontRightHoof;
/* 0x03D8 */ Vec3f frontLeftHoof;
/* 0x03E4 */ Vec3f backRightHoof;
/* 0x03F0 */ Vec3f backLeftHoof;
} EnHorse; // size = 0x03FC
#define EN_HORSE_CHECK_1(horseActor) \
(((horseActor)->unk_1F0 & 0x40) \
(((horseActor)->stateFlags & ENHORSE_FLAG_6) \
? true \
: false)
#define EN_HORSE_CHECK_2(horseActor) \
(((horseActor)->unk_1F0 & 0x100) \
(((horseActor)->stateFlags & ENHORSE_FLAG_8) \
? true \
: false)
#define EN_HORSE_CHECK_3(horseActor) \
(((horseActor)->unk_1F0 & 0x200) \
(((horseActor)->stateFlags & ENHORSE_FLAG_9) \
? true \
: false)
#define EN_HORSE_CHECK_4(horseActor) \
(((((horseActor)->unk_14C == 5) || ((horseActor)->unk_14C == 0) || ((horseActor)->unk_14C == 6)) && \
!((horseActor)->unk_1F0 & 0x80000) && !((horseActor)->unk_1F0 & 0x2000000)) \
? true \
#define EN_HORSE_CHECK_4(horseActor) \
(((((horseActor)->action == ENHORSE_ACT_MOUNTED_IDLE) || ((horseActor)->action == ENHORSE_ACT_FROZEN) || ((horseActor)->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) && \
!((horseActor)->stateFlags & ENHORSE_FLAG_19) && !((horseActor)->stateFlags & ENHORSE_FLAG_25)) \
? true \
: false)
#define EN_HORSE_CHECK_5(horseActor) \
(((horseActor)->unk_1F0 & 0x4) \
#define EN_HORSE_CHECK_JUMPING(horseActor) \
(((horseActor)->stateFlags & ENHORSE_JUMPING) \
? true \
: false)

View file

@ -146,11 +146,11 @@ s32 EnHorseGameCheck_UpdateIngoRace(EnHorseGameCheckBase* base, GlobalContext* g
} else if ((this->startTimer > 80) && (player->rideActor != NULL) && !(this->startFlags & INGORACE_PLAYER_MOVE)) {
this->startFlags |= INGORACE_PLAYER_MOVE;
horse = (EnHorse*)player->rideActor;
horse->unk_388 = 1;
horse->inRace = 1;
} else if ((this->startTimer > 81) && !(this->startFlags & INGORACE_INGO_MOVE)) {
ingoHorse = (EnHorse*)this->ingoHorse;
ingoHorse->unk_388 = 1;
ingoHorse->inRace = 1;
this->startFlags |= INGORACE_INGO_MOVE;
Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
@ -197,7 +197,7 @@ s32 EnHorseGameCheck_UpdateIngoRace(EnHorseGameCheckBase* base, GlobalContext* g
this->result = INGORACE_INGO_WIN;
this->finishTimer = 70;
ingoHorse->unk_1F0 |= 0x800000;
ingoHorse->stateFlags |= ENHORSE_INGO_WON;
Audio_SetBGM(0x41);
Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
@ -249,7 +249,7 @@ s32 EnHorseGameCheck_UpdateGerudoArchery(EnHorseGameCheckBase* base, GlobalConte
if (this->startTimer > 90) {
if (globalCtx) {}
horse->unk_3A0 = 1;
horse->hbaStarted = 1;
}
this->startTimer++;
return true;
@ -332,7 +332,7 @@ s32 EnHorseGameCheck_UpdateMalonRace(EnHorseGameCheckBase* base, GlobalContext*
this->raceFlags |= MALONRACE_PLAYER_MOVE;
horse = (EnHorse*)player->rideActor;
horse->unk_388 = 1;
horse->inRace = 1;
} else if ((this->startTimer > 81) && !(this->raceFlags & MALONRACE_START_SFX)) {
this->raceFlags |= MALONRACE_START_SFX;
Audio_PlaySoundGeneral(NA_SE_SY_START_SHOT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
@ -351,7 +351,7 @@ s32 EnHorseGameCheck_UpdateMalonRace(EnHorseGameCheckBase* base, GlobalContext*
if ((player->rideActor != NULL) && (dist < 250.0f)) {
horse = (EnHorse*)player2->rideActor;
if (horse->unk_1F0 & 4) {
if (horse->stateFlags & ENHORSE_JUMPING) {
if ((i > 0) && (this->fenceCheck[i - 1] == 1)) {
this->fenceCheck[i] = 1;
} else if (i == 0) {

View file

@ -334,10 +334,10 @@ s32 func_80A7975C(EnIn* this, GlobalContext* globalCtx) {
if (this->actor.params != 1 || this->actor.shape.rot.z != 1 || LINK_IS_CHILD) {
return 0;
}
this->unk_1E6 = 1;
this->animationIdx = 1;
this->collider.base.ocFlags1 &= ~OC1_ON;
Animation_Change(&this->skelAnime, D_80A7B918[this->unk_1E6], 1.0f, 0.0f,
Animation_GetLastFrame(D_80A7B918[this->unk_1E6]), 2, 0.0f);
Animation_Change(&this->skelAnime, D_80A7B918[this->animationIdx], 1.0f, 0.0f,
Animation_GetLastFrame(D_80A7B918[this->animationIdx]), 2, 0.0f);
this->actionFunc = func_80A7A304;
return 1;
}
@ -604,17 +604,17 @@ void func_80A7A304(EnIn* this, GlobalContext* globalCtx) {
Audio_PlayActorSound2(&this->actor, NA_SE_VO_IN_CRY_0);
}
if (SkelAnime_Update(&this->skelAnime) != 0) {
this->unk_1E6 %= 8;
this->unk_1E8 = this->unk_1E6;
if (this->unk_1E6 == 3 || this->unk_1E6 == 4) {
this->animationIdx %= 8;
this->unk_1E8 = this->animationIdx;
if (this->animationIdx == 3 || this->animationIdx == 4) {
Audio_PlaySoundGeneral(NA_SE_IT_LASH, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8);
if (Rand_ZeroOne() < 0.3f) {
Audio_PlaySoundGeneral(NA_SE_IT_INGO_HORSE_NEIGH, &this->actor.projectedPos, 4, &D_801333E0,
&D_801333E0, &D_801333E8);
}
}
Animation_Change(&this->skelAnime, D_80A7B918[this->unk_1E6], 1.0f, 0.0f,
Animation_GetLastFrame(D_80A7B918[this->unk_1E6]), 2, -10.0f);
Animation_Change(&this->skelAnime, D_80A7B918[this->animationIdx], 1.0f, 0.0f,
Animation_GetLastFrame(D_80A7B918[this->animationIdx]), 2, -10.0f);
}
}
@ -656,7 +656,7 @@ void func_80A7A568(EnIn* this, GlobalContext* globalCtx) {
return;
}
gSaveContext.eventInf[0] =
(gSaveContext.eventInf[0] & ~0x10) | (((EnHorse*)PLAYER->rideActor)->unk_158 << 4);
(gSaveContext.eventInf[0] & ~0x10) | (((EnHorse*)PLAYER->rideActor)->type << 4);
gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & ~0xF) | 2;
phi_a2 = 2;
phi_a3 = 2;

View file

@ -15,8 +15,8 @@ typedef struct EnIn {
/* 0x0194 */ ColliderCylinder collider;
/* 0x01E0 */ f32 unk_1E0;
/* 0x01E4 */ s8 ingoObjBankIndex;
/* 0x01E6 */ s16 unk_1E6;
/* 0x01E6 */ s16 unk_1E8;
/* 0x01E6 */ s16 animationIdx;
/* 0x01E8 */ s16 unk_1E8;
/* 0x01EA */ s16 unk_1EA;
/* 0x01EC */ s16 unk_1EC;
/* 0x01EE */ s16 unk_1EE;

View file

@ -5721,7 +5721,7 @@ s32 func_8083E0FC(Player* this, GlobalContext* globalCtx) {
this->stateFlags1 |= 0x800000;
this->actor.bgCheckFlags &= ~0x20;
if (this->unk_43C < 0) {
if (this->mountSide < 0) {
temp = 0;
} else {
temp = 1;
@ -5730,14 +5730,14 @@ s32 func_8083E0FC(Player* this, GlobalContext* globalCtx) {
unk_04 = D_80854578[temp].unk_04;
unk_08 = D_80854578[temp].unk_08;
this->actor.world.pos.x =
rideActor->actor.world.pos.x + rideActor->unk_258.x + ((unk_04 * sp38) + (unk_08 * sp34));
rideActor->actor.world.pos.x + rideActor->riderPos.x + ((unk_04 * sp38) + (unk_08 * sp34));
this->actor.world.pos.z =
rideActor->actor.world.pos.z + rideActor->unk_258.z + ((unk_08 * sp38) - (unk_04 * sp34));
rideActor->actor.world.pos.z + rideActor->riderPos.z + ((unk_08 * sp38) - (unk_04 * sp34));
this->unk_878 = rideActor->actor.world.pos.y - this->actor.world.pos.y;
this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y;
func_8002DECC(globalCtx, this, &rideActor->actor);
Actor_MountHorse(globalCtx, this, &rideActor->actor);
func_80832264(globalCtx, this, D_80854578[temp].anim);
func_80832F54(globalCtx, this, 0x9B);
this->actor.parent = this->rideActor;
@ -11176,13 +11176,13 @@ s32 func_8084C9BC(Player* this, GlobalContext* globalCtx) {
if (this->unk_850 < 0) {
this->unk_850 = 99;
} else {
sp38 = (this->unk_43C < 0) ? 0 : 1;
sp38 = (this->mountSide < 0) ? 0 : 1;
if (!func_8084C89C(globalCtx, this, sp38, &sp34)) {
sp38 ^= 1;
if (!func_8084C89C(globalCtx, this, sp38, &sp34)) {
return 0;
} else {
this->unk_43C = -this->unk_43C;
this->mountSide = -this->mountSide;
}
}
@ -11195,7 +11195,7 @@ s32 func_8084C9BC(Player* this, GlobalContext* globalCtx) {
rideActor->actor.child = NULL;
func_80835DAC(globalCtx, this, func_8084D3E4, 0);
this->unk_878 = sp34 - rideActor->actor.world.pos.y;
func_80832264(globalCtx, this, (this->unk_43C < 0) ? &gPlayerAnim_003390 : &gPlayerAnim_0033A0);
func_80832264(globalCtx, this, (this->mountSide < 0) ? &gPlayerAnim_003390 : &gPlayerAnim_0033A0);
return 1;
}
}
@ -11282,7 +11282,7 @@ void func_8084CC98(Player* this, GlobalContext* globalCtx) {
return;
}
arr = D_80854998[(this->unk_43C < 0) ? 0 : 1];
arr = D_80854998[(this->mountSide < 0) ? 0 : 1];
if (LinkAnimation_OnFrame(&this->skelAnime, arr[0])) {
func_8002F7DC(&this->actor, NA_SE_PL_CLIMB_CLIFF);
@ -11301,8 +11301,8 @@ void func_8084CC98(Player* this, GlobalContext* globalCtx) {
func_8002DE74(globalCtx, this);
this->skelAnime.prevTransl = D_8085499C;
if ((rideActor->unk_210 != this->unk_850) && ((rideActor->unk_210 >= 2) || (this->unk_850 >= 2))) {
if ((this->unk_850 = rideActor->unk_210) < 2) {
if ((rideActor->animationIdx != this->unk_850) && ((rideActor->animationIdx >= 2) || (this->unk_850 >= 2))) {
if ((this->unk_850 = rideActor->animationIdx) < 2) {
f32 rand = Rand_ZeroOne();
s32 temp = 0;
@ -11333,7 +11333,7 @@ void func_8084CC98(Player* this, GlobalContext* globalCtx) {
func_80832924(this, D_808549A4);
}
} else {
this->skelAnime.curFrame = rideActor->unk_214;
this->skelAnime.curFrame = rideActor->curFrame;
LinkAnimation_AnimateFrame(globalCtx, &this->skelAnime);
}
@ -11353,9 +11353,9 @@ void func_8084CC98(Player* this, GlobalContext* globalCtx) {
}
}
this->actor.world.pos.x = rideActor->actor.world.pos.x + rideActor->unk_258.x;
this->actor.world.pos.y = (rideActor->actor.world.pos.y + rideActor->unk_258.y) - 27.0f;
this->actor.world.pos.z = rideActor->actor.world.pos.z + rideActor->unk_258.z;
this->actor.world.pos.x = rideActor->actor.world.pos.x + rideActor->riderPos.x;
this->actor.world.pos.y = (rideActor->actor.world.pos.y + rideActor->riderPos.y) - 27.0f;
this->actor.world.pos.z = rideActor->actor.world.pos.z + rideActor->riderPos.z;
this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y;
@ -11365,7 +11365,7 @@ void func_8084CC98(Player* this, GlobalContext* globalCtx) {
if (D_808535E0 == 0) {
if (this->unk_84F != 0) {
if (LinkAnimation_Update(globalCtx, &this->skelAnime2)) {
rideActor->unk_1F0 &= ~0x100;
rideActor->stateFlags &= ~ENHORSE_FLAG_8;
this->unk_84F = 0;
}
@ -11466,7 +11466,7 @@ void func_8084D3E4(Player* this, GlobalContext* globalCtx) {
} else {
Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, 0), CAM_SET_NORMAL0);
if (this->unk_43C < 0) {
if (this->mountSide < 0) {
D_808549C4[0].field = 0x2828;
} else {
D_808549C4[0].field = 0x281D;