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

Document NPC talking and player tracking (#1426)

* Rename npc dialog state variable

* Rename and doc NPC actor talking funtion

* Introduce NpcTalkState enum

* Rename NPC_TALK_STATE enum values

* Document NpcPlayerInteractionState and related functions

* Rename player tracking opt enum variants

* Rename npc functions, interact info

* Minor npc actor function tweaks

* Minor comment fixes for npc

* Generalize NPC player tracking to point tracking

* Change unused NpcInteractInfo field type and name

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Rename headRot and torsoRot

* Rename GetTalkState to UpdateTalkState

* Minor comment fixes

* Rename rotateActorShape and clarify related comments

* Remove unneeded parentheses in z_en_heishi4.c

* Reformat

* Remove unclear comment

* Rename yPosOffset to yOffset

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
This commit is contained in:
Lauri Koskela 2022-11-25 19:52:28 +02:00 committed by GitHub
parent 9c35716fe2
commit b57f2162ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 936 additions and 808 deletions

View file

@ -565,7 +565,7 @@ s16 func_80A70058(PlayState* play, Actor* thisx) {
case TEXT_STATE_SONG_DEMO_DONE:
case TEXT_STATE_8:
case TEXT_STATE_9:
return 1;
return NPC_TALK_STATE_TALKING;
case TEXT_STATE_DONE_FADING:
switch (this->actor.textId) {
case 0x709E:
@ -587,7 +587,7 @@ s16 func_80A70058(PlayState* play, Actor* thisx) {
}
break;
}
return 1;
return NPC_TALK_STATE_TALKING;
case TEXT_STATE_CLOSING:
switch (this->actor.textId) {
case 0x70F0:
@ -663,16 +663,16 @@ s16 func_80A70058(PlayState* play, Actor* thisx) {
this->actionFunc = func_80A714C4;
break;
}
return 0;
return NPC_TALK_STATE_IDLE;
case TEXT_STATE_EVENT:
if (!Message_ShouldAdvance(play)) {
return 1;
return NPC_TALK_STATE_TALKING;
} else {
return 2;
return NPC_TALK_STATE_ACTION;
}
}
return 1;
return NPC_TALK_STATE_TALKING;
}
void EnHy_UpdateEyes(EnHy* this) {
@ -762,42 +762,46 @@ void func_80A70834(EnHy* this, PlayState* play) {
void func_80A70978(EnHy* this, PlayState* play) {
Player* player = GET_PLAYER(play);
s16 phi_a3;
s16 trackingMode;
switch (this->actor.params & 0x7F) {
case ENHY_TYPE_BOJ_3:
case ENHY_TYPE_BJI_7:
case ENHY_TYPE_BOJ_9:
case ENHY_TYPE_BOJ_10:
phi_a3 = (this->unk_1E8.unk_00 == 0) ? 1 : 2;
trackingMode =
(this->interactInfo.talkState == NPC_TALK_STATE_IDLE) ? NPC_TRACKING_NONE : NPC_TRACKING_HEAD_AND_TORSO;
break;
case ENHY_TYPE_BOJ_12:
phi_a3 = 1;
trackingMode = NPC_TRACKING_NONE;
break;
case ENHY_TYPE_AHG_2:
case ENHY_TYPE_AHG_17:
phi_a3 = 4;
trackingMode = NPC_TRACKING_FULL_BODY;
break;
case ENHY_TYPE_AOB:
case ENHY_TYPE_BOB_18:
phi_a3 = (this->unk_1E8.unk_00 == 0) ? 2 : 4;
trackingMode = (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) ? NPC_TRACKING_HEAD_AND_TORSO
: NPC_TRACKING_FULL_BODY;
break;
default:
phi_a3 = 2;
trackingMode = NPC_TRACKING_HEAD_AND_TORSO;
break;
}
this->unk_1E8.unk_18 = player->actor.world.pos;
this->interactInfo.trackPos = player->actor.world.pos;
if (LINK_IS_ADULT) {
this->unk_1E8.unk_14 = sInit1Info[this->actor.params & 0x7F].unkValueAdult;
this->interactInfo.yOffset = sInit1Info[this->actor.params & 0x7F].unkValueAdult;
} else {
this->unk_1E8.unk_14 = sInit1Info[this->actor.params & 0x7F].unkValueChild;
this->interactInfo.yOffset = sInit1Info[this->actor.params & 0x7F].unkValueChild;
}
func_80034A14(&this->actor, &this->unk_1E8, sInit1Info[this->actor.params & 0x7F].unkPresetIndex, phi_a3);
Npc_TrackPoint(&this->actor, &this->interactInfo, sInit1Info[this->actor.params & 0x7F].unkPresetIndex,
trackingMode);
if (func_800343CC(play, &this->actor, &this->unk_1E8.unk_00, this->unkRange, func_80A6F810, func_80A70058)) {
if (Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->unkRange, func_80A6F810,
func_80A70058)) {
func_80A70834(this, play);
}
}
@ -966,7 +970,7 @@ void EnHy_InitImpl(EnHy* this, PlayState* play) {
}
void func_80A710F8(EnHy* this, PlayState* play) {
if (this->unk_1E8.unk_00 != 0) {
if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) {
if (this->skelAnime.animation != &gObjOsAnim_0BFC) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENHY_ANIM_26);
}
@ -1016,11 +1020,11 @@ void func_80A7134C(EnHy* this, PlayState* play) {
s16 yaw;
f32 distSq;
if ((this->skelAnime.animation == &gObjOsAnim_2160) && (this->unk_1E8.unk_00 != 0)) {
if ((this->skelAnime.animation == &gObjOsAnim_2160) && (this->interactInfo.talkState != NPC_TALK_STATE_IDLE)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENHY_ANIM_8);
}
if ((this->skelAnime.animation == &gObjOsAnim_265C) && (this->unk_1E8.unk_00 == 0)) {
if ((this->skelAnime.animation == &gObjOsAnim_265C) && (this->interactInfo.talkState == NPC_TALK_STATE_IDLE)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENHY_ANIM_7);
}
@ -1082,7 +1086,7 @@ void EnHy_Update(Actor* thisx, PlayState* play) {
SkelAnime_Update(&this->skelAnime);
EnHy_UpdateEyes(this);
if (this->unk_1E8.unk_00 == 0) {
if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) {
Actor_MoveForward(&this->actor);
}
@ -1121,14 +1125,14 @@ s32 EnHy_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po
if (limbIndex == 15) {
Matrix_Translate(1400.0f, 0.0f, 0.0f, MTXMODE_APPLY);
sp48 = this->unk_1E8.unk_08;
sp48 = this->interactInfo.headRot;
Matrix_RotateX(BINANG_TO_RAD_ALT(sp48.y), MTXMODE_APPLY);
Matrix_RotateZ(BINANG_TO_RAD_ALT(sp48.x), MTXMODE_APPLY);
Matrix_Translate(-1400.0f, 0.0f, 0.0f, MTXMODE_APPLY);
}
if (limbIndex == 8) {
sp48 = this->unk_1E8.unk_0E;
sp48 = this->interactInfo.torsoRot;
Matrix_RotateX(BINANG_TO_RAD_ALT(-sp48.y), MTXMODE_APPLY);
Matrix_RotateZ(BINANG_TO_RAD_ALT(sp48.x), MTXMODE_APPLY);
}

View file

@ -44,7 +44,7 @@ typedef struct EnHy {
/* 0x0198 */ s8 objBankIndexSkel1; // sets the object used when drawing the skeleton for limb <= 7 (lower part?)
/* 0x0199 */ s8 objBankIndexOsAnime;
/* 0x019C */ ColliderCylinder collider;
/* 0x01E8 */ struct_80034A14_arg1 unk_1E8;
/* 0x01E8 */ NpcInteractInfo interactInfo;
/* 0x0210 */ Path* path;
/* 0x0214 */ s8 waypoint;
/* 0x0215 */ s8 unk_215;