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

@ -449,13 +449,13 @@ s16 func_80B61298(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_CLOSING:
switch (thisx->textId) {
case 0x4020:
case 0x4021:
return 0;
return NPC_TALK_STATE_IDLE;
case 0x4008:
SET_INFTABLE(INFTABLE_124);
break;
@ -464,12 +464,12 @@ s16 func_80B61298(PlayState* play, Actor* thisx) {
break;
}
SET_EVENTCHKINF(EVENTCHKINF_30);
return 0;
return NPC_TALK_STATE_IDLE;
case TEXT_STATE_CHOICE:
switch (Message_ShouldAdvance(play)) {
case 0:
return 1;
return NPC_TALK_STATE_TALKING;
default:
if (thisx->textId == 0x400C) {
thisx->textId = (play->msgCtx.choiceIndex == 0) ? 0x400D : 0x400E;
@ -477,18 +477,19 @@ s16 func_80B61298(PlayState* play, Actor* thisx) {
}
break;
}
return 1;
return NPC_TALK_STATE_TALKING;
case TEXT_STATE_EVENT:
switch (Message_ShouldAdvance(play)) {
case 0:
return 1;
return NPC_TALK_STATE_TALKING;
default:
return 2;
return NPC_TALK_STATE_ACTION;
}
return NPC_TALK_STATE_TALKING;
}
return 1;
return NPC_TALK_STATE_TALKING;
}
void EnZo_Blink(EnZo* this) {
@ -504,16 +505,17 @@ void EnZo_Blink(EnZo* this) {
void EnZo_Dialog(EnZo* this, PlayState* play) {
Player* player = GET_PLAYER(play);
this->unk_194.unk_18 = player->actor.world.pos;
this->interactInfo.trackPos = player->actor.world.pos;
if (this->actionFunc == EnZo_Standing) {
// Look down at link if child, look up if adult
this->unk_194.unk_14 = !LINK_IS_ADULT ? 10.0f : -10.0f;
this->interactInfo.yOffset = !LINK_IS_ADULT ? 10.0f : -10.0f;
} else {
this->unk_194.unk_18.y = this->actor.world.pos.y;
this->interactInfo.trackPos.y = this->actor.world.pos.y;
}
func_80034A14(&this->actor, &this->unk_194, 11, this->unk_64C);
Npc_TrackPoint(&this->actor, &this->interactInfo, 11, this->trackingMode);
if (this->canSpeak == true) {
func_800343CC(play, &this->actor, &this->unk_194.unk_00, this->dialogRadius, func_80B61024, func_80B61298);
Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->dialogRadius, func_80B61024,
func_80B61298);
}
}
@ -541,7 +543,7 @@ void EnZo_SetAnimation(EnZo* this) {
if (this->skelAnime.animation == &gZoraHandsOnHipsTappingFootAnim ||
this->skelAnime.animation == &gZoraOpenArmsAnim) {
if (this->unk_194.unk_00 == 0) {
if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) {
if (this->actionFunc == EnZo_Standing) {
animId = ENZO_ANIM_0;
} else {
@ -550,12 +552,13 @@ void EnZo_SetAnimation(EnZo* this) {
}
}
if (this->unk_194.unk_00 != 0 && this->actor.textId == 0x4006 &&
if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE && this->actor.textId == 0x4006 &&
this->skelAnime.animation != &gZoraHandsOnHipsTappingFootAnim) {
animId = ENZO_ANIM_6;
}
if (this->unk_194.unk_00 != 0 && this->actor.textId == 0x4007 && this->skelAnime.animation != &gZoraOpenArmsAnim) {
if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE && this->actor.textId == 0x4007 &&
this->skelAnime.animation != &gZoraOpenArmsAnim) {
animId = ENZO_ANIM_7;
}
@ -586,9 +589,9 @@ void EnZo_Init(Actor* thisx, PlayState* play) {
Actor_SetScale(&this->actor, 0.01f);
this->actor.targetMode = 6;
this->dialogRadius = this->collider.dim.radius + 30.0f;
this->unk_64C = 1;
this->trackingMode = NPC_TRACKING_NONE;
this->canSpeak = false;
this->unk_194.unk_00 = 0;
this->interactInfo.talkState = NPC_TALK_STATE_IDLE;
Actor_UpdateBgCheckInfo(play, &this->actor, this->collider.dim.height * 0.5f, this->collider.dim.radius, 0.0f,
UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2);
@ -613,20 +616,20 @@ void EnZo_Standing(EnZo* this, PlayState* play) {
func_80034F54(play, this->unk_656, this->unk_67E, 20);
EnZo_SetAnimation(this);
if (this->unk_194.unk_00 != 0) {
this->unk_64C = 4;
if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) {
this->trackingMode = NPC_TRACKING_FULL_BODY;
return;
}
angle = ABS((s16)((f32)this->actor.yawTowardsPlayer - (f32)this->actor.shape.rot.y));
if (angle < 0x4718) {
if (EnZo_PlayerInProximity(this, play)) {
this->unk_64C = 2;
this->trackingMode = NPC_TRACKING_HEAD_AND_TORSO;
} else {
this->unk_64C = 1;
this->trackingMode = NPC_TRACKING_NONE;
}
} else {
this->unk_64C = 1;
this->trackingMode = NPC_TRACKING_NONE;
}
}
@ -656,7 +659,7 @@ void EnZo_TreadWater(EnZo* this, PlayState* play) {
func_80034F54(play, this->unk_656, this->unk_67E, 20);
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
this->canSpeak = true;
this->unk_64C = 4;
this->trackingMode = NPC_TRACKING_FULL_BODY;
this->skelAnime.playSpeed = 0.0f;
}
EnZo_SetAnimation(this);
@ -678,7 +681,7 @@ void EnZo_TreadWater(EnZo* this, PlayState* play) {
f32 startFrame;
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENZO_ANIM_4);
this->canSpeak = false;
this->unk_64C = 1;
this->trackingMode = NPC_TRACKING_NONE;
this->actionFunc = EnZo_Dive;
startFrame = this->skelAnime.startFrame;
this->skelAnime.startFrame = this->skelAnime.endFrame;
@ -756,14 +759,14 @@ s32 EnZo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po
if (limbIndex == 15) {
Matrix_Translate(1800.0f, 0.0f, 0.0f, MTXMODE_APPLY);
vec = this->unk_194.unk_08;
vec = this->interactInfo.headRot;
Matrix_RotateX(BINANG_TO_RAD_ALT(vec.y), MTXMODE_APPLY);
Matrix_RotateZ(BINANG_TO_RAD_ALT(vec.x), MTXMODE_APPLY);
Matrix_Translate(-1800.0f, 0.0f, 0.0f, MTXMODE_APPLY);
}
if (limbIndex == 8) {
vec = this->unk_194.unk_0E;
vec = this->interactInfo.torsoRot;
Matrix_RotateX(BINANG_TO_RAD_ALT(-vec.y), MTXMODE_APPLY);
Matrix_RotateZ(BINANG_TO_RAD_ALT(vec.x), MTXMODE_APPLY);
}

View file

@ -25,7 +25,7 @@ typedef struct EnZo {
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime;
/* 0x0190 */ EnZoActionFunc actionFunc;
/* 0x0194 */ struct_80034A14_arg1 unk_194;
/* 0x0194 */ NpcInteractInfo interactInfo;
/* 0x01BC */ ColliderCylinder collider;
/* 0x0208 */ u8 canSpeak;
/* 0x020A */ Vec3s jointTable[20];
@ -33,7 +33,7 @@ typedef struct EnZo {
/* 0x02FC */ EnZoEffect effects[EN_ZO_EFFECT_COUNT];
/* 0x0644 */ f32 dialogRadius;
/* 0x0648 */ f32 alpha;
/* 0x064C */ s16 unk_64C;
/* 0x064C */ s16 trackingMode;
/* 0x064E */ s16 rippleTimer;
/* 0x0650 */ s16 timeToDive;
/* 0x0652 */ s16 blinkTimer;