1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-02-20 22:05:21 +00:00

Polish up docs on EnDaiku and EnDaikuKakariko (#2463)

This commit is contained in:
Dragorn421 2025-02-11 15:02:05 +01:00 committed by GitHub
parent 3dd893c210
commit ae89a8e47b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 42 deletions

View file

@ -5,6 +5,8 @@
#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_CULLING_DISABLED) #define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_CULLING_DISABLED)
#define ENDAIKU_GET_TYPE(thisx) PARAMS_GET_U((thisx)->params, 0, 2) #define ENDAIKU_GET_TYPE(thisx) PARAMS_GET_U((thisx)->params, 0, 2)
#define ENDAIKU_GET_PATH_INDEX(thisx) PARAMS_GET_U((thisx)->params, 4, 4)
#define ENDAIKU_GET_DOOR_SWITCH_FLAG(thisx) PARAMS_GET_U((thisx)->params, 8, 6)
typedef struct EnDaikuEscapeSubCamParam { typedef struct EnDaikuEscapeSubCamParam {
Vec3f eyePosDeltaLocal; Vec3f eyePosDeltaLocal;
@ -13,10 +15,10 @@ typedef struct EnDaikuEscapeSubCamParam {
// state flags // state flags
// probably related to animating torso and head to look towards the player // the carpenter tracks the player position
#define ENDAIKU_STATEFLAG_1 (1 << 1) #define ENDAIKU_STATEFLAG_TRACK_PLAYER (1 << 1)
// same // if tracking the player, track with the carpenter's full body
#define ENDAIKU_STATEFLAG_2 (1 << 2) #define ENDAIKU_STATEFLAG_TRACK_WITH_FULL_BODY (1 << 2)
// the gerudo guard appeared (after talking to the carpenter) // the gerudo guard appeared (after talking to the carpenter)
#define ENDAIKU_STATEFLAG_GERUDOFIGHTING (1 << 3) #define ENDAIKU_STATEFLAG_GERUDOFIGHTING (1 << 3)
// the gerudo guard was defeated // the gerudo guard was defeated
@ -121,9 +123,9 @@ typedef enum EnDaikuAnimation {
} EnDaikuAnimation; } EnDaikuAnimation;
static AnimationFrameCountInfo sAnimationInfo[] = { static AnimationFrameCountInfo sAnimationInfo[] = {
{ &object_daiku_Anim_001AB0, 1.0f, 0, 0 }, { &object_daiku_Anim_007DE0, 1.0f, 0, 0 }, { &object_daiku_Anim_001AB0, 1.0f, ANIMMODE_LOOP, 0 }, { &object_daiku_Anim_007DE0, 1.0f, ANIMMODE_LOOP, 0 },
{ &object_daiku_Anim_00885C, 1.0f, 0, 0 }, { &object_daiku_Anim_000C44, 1.0f, 0, 0 }, { &object_daiku_Anim_00885C, 1.0f, ANIMMODE_LOOP, 0 }, { &object_daiku_Anim_000C44, 1.0f, ANIMMODE_LOOP, 0 },
{ &object_daiku_Anim_008164, 1.0f, 0, 0 }, { &object_daiku_Anim_008164, 1.0f, ANIMMODE_LOOP, 0 },
}; };
static EnDaikuEscapeSubCamParam sEscapeSubCamParams[] = { static EnDaikuEscapeSubCamParam sEscapeSubCamParams[] = {
@ -199,15 +201,15 @@ void EnDaiku_Init(Actor* thisx, PlayState* play) {
if (play->sceneId == SCENE_THIEVES_HIDEOUT) { if (play->sceneId == SCENE_THIEVES_HIDEOUT) {
EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_STAND, &this->currentAnimIndex); EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_STAND, &this->currentAnimIndex);
this->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; this->stateFlags |= ENDAIKU_STATEFLAG_TRACK_PLAYER | ENDAIKU_STATEFLAG_TRACK_WITH_FULL_BODY;
this->actionFunc = EnDaiku_Jailed; this->actionFunc = EnDaiku_Jailed;
} else { } else {
if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE1 || ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE3) { if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE1 || ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE3) {
EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_SIT, &this->currentAnimIndex); EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_SIT, &this->currentAnimIndex);
this->stateFlags |= ENDAIKU_STATEFLAG_1; this->stateFlags |= ENDAIKU_STATEFLAG_TRACK_PLAYER;
} else { } else {
EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_SHOUT, &this->currentAnimIndex); EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_SHOUT, &this->currentAnimIndex);
this->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; this->stateFlags |= ENDAIKU_STATEFLAG_TRACK_PLAYER | ENDAIKU_STATEFLAG_TRACK_WITH_FULL_BODY;
} }
this->skelAnime.curFrame = (s32)(Rand_ZeroOne() * this->skelAnime.endFrame); this->skelAnime.curFrame = (s32)(Rand_ZeroOne() * this->skelAnime.endFrame);
@ -257,17 +259,17 @@ s32 EnDaiku_UpdateTalking(EnDaiku* this, PlayState* play) {
void EnDaiku_UpdateText(EnDaiku* this, PlayState* play) { void EnDaiku_UpdateText(EnDaiku* this, PlayState* play) {
s32 carpenterType; s32 carpenterType;
s32 rescuedCount; s32 rescuedCount;
s16 sp2E; s16 screenX;
s16 sp2C; s16 screenY;
if (this->talkState == ENDAIKU_STATE_TALKING) { if (this->talkState == ENDAIKU_STATE_TALKING) {
this->talkState = EnDaiku_UpdateTalking(this, play); this->talkState = EnDaiku_UpdateTalking(this, play);
} else if (Actor_TalkOfferAccepted(&this->actor, play)) { } else if (Actor_TalkOfferAccepted(&this->actor, play)) {
this->talkState = ENDAIKU_STATE_TALKING; this->talkState = ENDAIKU_STATE_TALKING;
} else { } else {
Actor_GetScreenPos(play, &this->actor, &sp2E, &sp2C); Actor_GetScreenPos(play, &this->actor, &screenX, &screenY);
if (sp2E >= 0 && sp2E <= 320 && sp2C >= 0 && sp2C <= 240 && this->talkState == ENDAIKU_STATE_CAN_TALK && if ((screenX >= 0) && (screenX <= SCREEN_WIDTH) && (screenY >= 0) && (screenY <= SCREEN_HEIGHT) &&
Actor_OfferTalk(&this->actor, play, 100.0f) == 1) { (this->talkState == ENDAIKU_STATE_CAN_TALK) && (Actor_OfferTalk(&this->actor, play, 100.0f) == true)) {
if (play->sceneId == SCENE_THIEVES_HIDEOUT) { if (play->sceneId == SCENE_THIEVES_HIDEOUT) {
if (this->stateFlags & ENDAIKU_STATEFLAG_GERUDODEFEATED) { if (this->stateFlags & ENDAIKU_STATEFLAG_GERUDODEFEATED) {
rescuedCount = 0; rescuedCount = 0;
@ -352,8 +354,6 @@ void EnDaiku_TentIdle(EnDaiku* this, PlayState* play) {
*/ */
void EnDaiku_Jailed(EnDaiku* this, PlayState* play) { void EnDaiku_Jailed(EnDaiku* this, PlayState* play) {
EnGeldB* gerudo; EnGeldB* gerudo;
s32 temp_t9;
s32 temp_v1;
if (!(this->stateFlags & ENDAIKU_STATEFLAG_GERUDOFIGHTING)) { if (!(this->stateFlags & ENDAIKU_STATEFLAG_GERUDOFIGHTING)) {
EnDaiku_UpdateText(this, play); EnDaiku_UpdateText(this, play);
@ -379,7 +379,7 @@ void EnDaiku_Jailed(EnDaiku* this, PlayState* play) {
void EnDaiku_WaitFreedom(EnDaiku* this, PlayState* play) { void EnDaiku_WaitFreedom(EnDaiku* this, PlayState* play) {
SkelAnime_Update(&this->skelAnime); SkelAnime_Update(&this->skelAnime);
if (Flags_GetSwitch(play, PARAMS_GET_U(this->actor.params, 8, 6))) { if (Flags_GetSwitch(play, ENDAIKU_GET_DOOR_SWITCH_FLAG(&this->actor))) {
this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY; this->actor.flags |= ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY;
EnDaiku_UpdateText(this, play); EnDaiku_UpdateText(this, play);
} }
@ -398,7 +398,7 @@ void EnDaiku_InitEscape(EnDaiku* this, PlayState* play) {
Audio_PlayFanfare(NA_BGM_APPEAR); Audio_PlayFanfare(NA_BGM_APPEAR);
EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_RUN, &this->currentAnimIndex); EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_RUN, &this->currentAnimIndex);
this->stateFlags &= ~(ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2); this->stateFlags &= ~(ENDAIKU_STATEFLAG_TRACK_PLAYER | ENDAIKU_STATEFLAG_TRACK_WITH_FULL_BODY);
ENDAIKU_SET_CARPENTER_RESCUED(ENDAIKU_GET_TYPE(&this->actor)); ENDAIKU_SET_CARPENTER_RESCUED(ENDAIKU_GET_TYPE(&this->actor));
@ -407,7 +407,7 @@ void EnDaiku_InitEscape(EnDaiku* this, PlayState* play) {
EnDaiku_InitSubCamera(this, play); EnDaiku_InitSubCamera(this, play);
exitLoop = false; exitLoop = false;
path = &play->pathList[PARAMS_GET_U(this->actor.params, 4, 4)]; path = &play->pathList[ENDAIKU_GET_PATH_INDEX(&this->actor)];
while (!exitLoop) { while (!exitLoop) {
pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint;
dx = pointPos->x - this->actor.world.pos.x; dx = pointPos->x - this->actor.world.pos.x;
@ -524,7 +524,7 @@ void EnDaiku_EscapeRun(EnDaiku* this, PlayState* play) {
f32 dxz; f32 dxz;
Vec3s* pointPos; Vec3s* pointPos;
path = &play->pathList[PARAMS_GET_U(this->actor.params, 4, 4)]; path = &play->pathList[ENDAIKU_GET_PATH_INDEX(&this->actor)];
pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint; pointPos = (Vec3s*)SEGMENTED_TO_VIRTUAL(path->points) + this->waypoint;
dx = pointPos->x - this->actor.world.pos.x; dx = pointPos->x - this->actor.world.pos.x;
dz = pointPos->z - this->actor.world.pos.z; dz = pointPos->z - this->actor.world.pos.z;
@ -574,12 +574,12 @@ void EnDaiku_Update(Actor* thisx, PlayState* play) {
this->actionFunc(this, play); this->actionFunc(this, play);
if (this->stateFlags & ENDAIKU_STATEFLAG_1) { if (this->stateFlags & ENDAIKU_STATEFLAG_TRACK_PLAYER) {
this->interactInfo.trackPos.x = player->actor.focus.pos.x; this->interactInfo.trackPos.x = player->actor.focus.pos.x;
this->interactInfo.trackPos.y = player->actor.focus.pos.y; this->interactInfo.trackPos.y = player->actor.focus.pos.y;
this->interactInfo.trackPos.z = player->actor.focus.pos.z; this->interactInfo.trackPos.z = player->actor.focus.pos.z;
if (this->stateFlags & ENDAIKU_STATEFLAG_2) { if (this->stateFlags & ENDAIKU_STATEFLAG_TRACK_WITH_FULL_BODY) {
Npc_TrackPoint(&this->actor, &this->interactInfo, 0, NPC_TRACKING_FULL_BODY); Npc_TrackPoint(&this->actor, &this->interactInfo, 0, NPC_TRACKING_FULL_BODY);
} else { } else {
Npc_TrackPoint(&this->actor, &this->interactInfo, 0, NPC_TRACKING_HEAD_AND_TORSO); Npc_TrackPoint(&this->actor, &this->interactInfo, 0, NPC_TRACKING_HEAD_AND_TORSO);

View file

@ -9,6 +9,9 @@
#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_CULLING_DISABLED) #define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_UPDATE_CULLING_DISABLED)
#define ENDAIKUKAKARIKO_GET_TYPE(thisx) PARAMS_GET_U((thisx)->params, 0, 2)
#define ENDAIKUKAKARIKO_GET_PATH_INDEX(thisx) PARAMS_GET_U((thisx)->params, 8, 8)
typedef enum KakarikoCarpenterType { typedef enum KakarikoCarpenterType {
/* 0x0 */ CARPENTER_ICHIRO, // Red and purple pants, normal hair /* 0x0 */ CARPENTER_ICHIRO, // Red and purple pants, normal hair
/* 0x1 */ CARPENTER_SABOORO, // Light blue pants /* 0x1 */ CARPENTER_SABOORO, // Light blue pants
@ -103,9 +106,12 @@ typedef enum EnDaikuKakarikoAnimation {
} EnDaikuKakarikoAnimation; } EnDaikuKakarikoAnimation;
static AnimationFrameCountInfo sAnimationInfo[] = { static AnimationFrameCountInfo sAnimationInfo[] = {
{ &object_daiku_Anim_001AB0, 1.0f, 2, -7.0f }, { &object_daiku_Anim_007DE0, 1.0f, 0, -7.0f }, { &object_daiku_Anim_001AB0, 1.0f, ANIMMODE_ONCE, -7.0f },
{ &object_daiku_Anim_00885C, 1.0f, 0, -7.0f }, { &object_daiku_Anim_000C44, 1.0f, 0, -7.0f }, { &object_daiku_Anim_007DE0, 1.0f, ANIMMODE_LOOP, -7.0f },
{ &object_daiku_Anim_000600, 1.0f, 0, -7.0f }, { &object_daiku_Anim_008164, 1.0f, 0, -7.0f }, { &object_daiku_Anim_00885C, 1.0f, ANIMMODE_LOOP, -7.0f },
{ &object_daiku_Anim_000C44, 1.0f, ANIMMODE_LOOP, -7.0f },
{ &object_daiku_Anim_000600, 1.0f, ANIMMODE_LOOP, -7.0f },
{ &object_daiku_Anim_008164, 1.0f, ANIMMODE_LOOP, -7.0f },
}; };
void EnDaikuKakariko_ChangeAnim(EnDaikuKakariko* this, s32 index, s32* currentIndex) { void EnDaikuKakariko_ChangeAnim(EnDaikuKakariko* this, s32 index, s32* currentIndex) {
@ -133,7 +139,7 @@ void EnDaikuKakariko_Init(Actor* thisx, PlayState* play) {
case SCENE_KAKARIKO_VILLAGE: case SCENE_KAKARIKO_VILLAGE:
if (IS_DAY) { if (IS_DAY) {
this->flags |= 1; this->flags |= 1;
this->flags |= initFlags[PARAMS_GET_U(this->actor.params, 0, 2)]; this->flags |= initFlags[ENDAIKUKAKARIKO_GET_TYPE(&this->actor)];
} }
break; break;
case SCENE_KAKARIKO_CENTER_GUEST_HOUSE: case SCENE_KAKARIKO_CENTER_GUEST_HOUSE:
@ -184,8 +190,8 @@ void EnDaikuKakariko_Init(Actor* thisx, PlayState* play) {
this->actionFunc = EnDaikuKakariko_Run; this->actionFunc = EnDaikuKakariko_Run;
} else { } else {
if (this->flags & 8) { if (this->flags & 8) {
if ((PARAMS_GET_U(this->actor.params, 0, 2) == CARPENTER_SABOORO) || if ((ENDAIKUKAKARIKO_GET_TYPE(&this->actor) == CARPENTER_SABOORO) ||
(PARAMS_GET_U(this->actor.params, 0, 2) == CARPENTER_SHIRO)) { (ENDAIKUKAKARIKO_GET_TYPE(&this->actor) == CARPENTER_SHIRO)) {
EnDaikuKakariko_ChangeAnim(this, ENDAIKUKAKARIKO_ANIM_5, &this->currentAnimIndex); EnDaikuKakariko_ChangeAnim(this, ENDAIKUKAKARIKO_ANIM_5, &this->currentAnimIndex);
this->flags |= 0x800; this->flags |= 0x800;
} else { } else {
@ -233,23 +239,23 @@ void EnDaikuKakariko_HandleTalking(EnDaikuKakariko* this, PlayState* play) {
MASK_REACTION_SET_CARPENTER_3, MASK_REACTION_SET_CARPENTER_3,
MASK_REACTION_SET_CARPENTER_4, MASK_REACTION_SET_CARPENTER_4,
}; };
s16 sp26; s16 screenX;
s16 sp24; s16 screenY;
if (this->talkState == 2) { if (this->talkState == 2) {
this->talkState = EnDaikuKakariko_GetTalkState(this, play); this->talkState = EnDaikuKakariko_GetTalkState(this, play);
} else if (Actor_TalkOfferAccepted(&this->actor, play)) { } else if (Actor_TalkOfferAccepted(&this->actor, play)) {
this->talkState = 2; this->talkState = 2;
} else { } else {
Actor_GetScreenPos(play, &this->actor, &sp26, &sp24); Actor_GetScreenPos(play, &this->actor, &screenX, &screenY);
if ((sp26 >= 0) && (sp26 <= 320) && (sp24 >= 0) && (sp24 <= 240) && (this->talkState == 0) && if ((screenX >= 0) && (screenX <= SCREEN_WIDTH) && (screenY >= 0) && (screenY <= SCREEN_HEIGHT) &&
(Actor_OfferTalk(&this->actor, play, 100.0f) == 1)) { (this->talkState == 0) && (Actor_OfferTalk(&this->actor, play, 100.0f) == true)) {
this->actor.textId = this->actor.textId =
MaskReaction_GetTextId(play, sMaskReactionSets[PARAMS_GET_U(this->actor.params, 0, 2)]); MaskReaction_GetTextId(play, sMaskReactionSets[ENDAIKUKAKARIKO_GET_TYPE(&this->actor)]);
if (this->actor.textId == 0) { if (this->actor.textId == 0) {
switch (PARAMS_GET_U(this->actor.params, 0, 2)) { switch (ENDAIKUKAKARIKO_GET_TYPE(&this->actor)) {
case 0: case 0:
if (this->flags & 8) { if (this->flags & 8) {
this->actor.textId = 0x5076; this->actor.textId = 0x5076;
@ -366,7 +372,7 @@ void EnDaikuKakariko_Run(EnDaikuKakariko* this, PlayState* play) {
s32 run; s32 run;
do { do {
path = &play->pathList[PARAMS_GET_U(this->actor.params, 8, 8)]; path = &play->pathList[ENDAIKUKAKARIKO_GET_PATH_INDEX(&this->actor)];
pathPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->waypoint]; pathPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[this->waypoint];
xDist = pathPos->x - this->actor.world.pos.x; xDist = pathPos->x - this->actor.world.pos.x;
zDist = pathPos->z - this->actor.world.pos.z; zDist = pathPos->z - this->actor.world.pos.z;
@ -538,7 +544,7 @@ void EnDaikuKakariko_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V
if (limbIndex == 15) { if (limbIndex == 15) {
Matrix_MultVec3f(&unkVec, &this->actor.focus.pos); Matrix_MultVec3f(&unkVec, &this->actor.focus.pos);
gSPDisplayList(POLY_OPA_DISP++, carpenterHeadDLists[PARAMS_GET_U(this->actor.params, 0, 2)]); gSPDisplayList(POLY_OPA_DISP++, carpenterHeadDLists[ENDAIKUKAKARIKO_GET_TYPE(&this->actor)]);
} }
CLOSE_DISPS(play->state.gfxCtx, "../z_en_daiku_kakariko.c", 1113); CLOSE_DISPS(play->state.gfxCtx, "../z_en_daiku_kakariko.c", 1113);
@ -551,13 +557,13 @@ void EnDaikuKakariko_Draw(Actor* thisx, PlayState* play) {
Gfx_SetupDL_25Opa(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx);
if (PARAMS_GET_U(thisx->params, 0, 2) == CARPENTER_ICHIRO) { if (ENDAIKUKAKARIKO_GET_TYPE(thisx) == CARPENTER_ICHIRO) {
gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255); gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255);
} else if (PARAMS_GET_U(thisx->params, 0, 2) == CARPENTER_SABOORO) { } else if (ENDAIKUKAKARIKO_GET_TYPE(thisx) == CARPENTER_SABOORO) {
gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255);
} else if (PARAMS_GET_U(thisx->params, 0, 2) == CARPENTER_JIRO) { } else if (ENDAIKUKAKARIKO_GET_TYPE(thisx) == CARPENTER_JIRO) {
gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255); gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255);
} else if (PARAMS_GET_U(thisx->params, 0, 2) == CARPENTER_SHIRO) { } else if (ENDAIKUKAKARIKO_GET_TYPE(thisx) == CARPENTER_SHIRO) {
gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255);
} }