1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-23 23:41:24 +00:00

Clean up NPC player interaction usages (#1458)

* Clean up player tracking related things in NPCs

* Cleanup Npc_UpdateTalking usages and related things

* Reformat

* Minor fixes based on review comments

* Remove unneeded declarations

* More consistent function names
This commit is contained in:
Lauri Koskela 2022-12-19 02:11:16 +02:00 committed by GitHub
parent 934d488420
commit 2ae64683a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 471 additions and 487 deletions

View file

@ -121,7 +121,7 @@ static EnGo2DataStruct2 D_80A481F8[14] = {
{ 28.0f, 0.01f, 6, 30.0f }, { 28.0f, 0.01f, 6, 30.0f },
};
static f32 D_80A482D8[14][2] = {
static f32 sPlayerTrackingYOffsets[14][2] = {
{ 80.0f, 80.0f }, { -10.0f, -10.0f }, { 800.0f, 800.0f }, { 0.0f, 0.0f }, { 20.0f, 40.0f },
{ 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f },
{ 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f }, { 20.0f, 20.0f },
@ -819,8 +819,8 @@ s16 EnGo2_UpdateTalkState(PlayState* play, Actor* thisx) {
s32 func_80A44790(EnGo2* this, PlayState* play) {
if ((this->actor.params & 0x1F) != GORON_DMT_BIGGORON && (this->actor.params & 0x1F) != GORON_CITY_ROLLING_BIG) {
return Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->unk_218, EnGo2_GetTextId,
EnGo2_UpdateTalkState);
return Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->interactRange,
EnGo2_GetTextId, EnGo2_UpdateTalkState);
} else if (((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) &&
!(this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) {
return false;
@ -831,7 +831,7 @@ s32 func_80A44790(EnGo2* this, PlayState* play) {
} else if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) {
this->interactInfo.talkState = EnGo2_UpdateTalkState(play, &this->actor);
return false;
} else if (func_8002F2CC(&this->actor, play, this->unk_218)) {
} else if (func_8002F2CC(&this->actor, play, this->interactRange)) {
this->actor.textId = EnGo2_GetTextId(play, &this->actor);
}
return false;
@ -851,8 +851,8 @@ void EnGo2_SetShape(EnGo2* this) {
this->actor.shape.shadowScale = D_80A481F8[index].shape_unk_10;
Actor_SetScale(&this->actor, D_80A481F8[index].scale);
this->actor.targetMode = D_80A481F8[index].actor_unk_1F;
this->unk_218 = D_80A481F8[index].unk_218;
this->unk_218 += this->collider.dim.radius;
this->interactRange = D_80A481F8[index].interactRange;
this->interactRange += this->collider.dim.radius;
}
void EnGo2_CheckCollision(EnGo2* this, PlayState* play) {
@ -1091,7 +1091,8 @@ void func_80A45288(EnGo2* this, PlayState* play) {
if (this->actionFunc != EnGo2_GoronFireGenericAction) {
this->interactInfo.trackPos = player->actor.world.pos;
this->interactInfo.yOffset = D_80A482D8[this->actor.params & 0x1F][((void)0, gSaveContext.linkAge)];
this->interactInfo.yOffset =
sPlayerTrackingYOffsets[this->actor.params & 0x1F][((void)0, gSaveContext.linkAge)];
Npc_TrackPoint(&this->actor, &this->interactInfo, 4, this->trackingMode);
}
if ((this->actionFunc != EnGo2_SetGetItem) && (this->isAwake == true)) {
@ -1899,7 +1900,7 @@ void EnGo2_GoronLinkStopRolling(EnGo2* this, PlayState* play) {
void EnGo2_GoronFireGenericAction(EnGo2* this, PlayState* play) {
Player* player = GET_PLAYER(play);
Vec3s D_80A4854C = { 0x00, 0x00, 0x00 };
Vec3s zeroVec = { 0x00, 0x00, 0x00 };
switch (this->goronState) {
case 0: // Wake up
@ -1914,8 +1915,8 @@ void EnGo2_GoronFireGenericAction(EnGo2* this, PlayState* play) {
this->animTimer = 60;
this->actor.gravity = 0.0f;
this->actor.speedXZ = 2.0f;
this->interactInfo.headRot = D_80A4854C;
this->interactInfo.torsoRot = D_80A4854C;
this->interactInfo.headRot = zeroVec;
this->interactInfo.torsoRot = zeroVec;
this->goronState++;
this->goronState++;
player->actor.world.rot.y = this->actor.world.rot.y;
@ -2023,30 +2024,23 @@ s32 EnGo2_DrawRolling(EnGo2* this, PlayState* play) {
s32 EnGo2_OverrideLimbDraw(PlayState* play, s32 limb, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) {
EnGo2* this = (EnGo2*)thisx;
Vec3s vec1;
f32 float1;
Vec3s limbRot;
if (limb == 17) {
Matrix_Translate(2800.0f, 0.0f, 0.0f, MTXMODE_APPLY);
vec1 = this->interactInfo.headRot;
float1 = BINANG_TO_RAD_ALT(vec1.y);
Matrix_RotateX(float1, MTXMODE_APPLY);
float1 = BINANG_TO_RAD_ALT(vec1.x);
Matrix_RotateZ(float1, MTXMODE_APPLY);
limbRot = this->interactInfo.headRot;
Matrix_RotateX(BINANG_TO_RAD_ALT(limbRot.y), MTXMODE_APPLY);
Matrix_RotateZ(BINANG_TO_RAD_ALT(limbRot.x), MTXMODE_APPLY);
Matrix_Translate(-2800.0f, 0.0f, 0.0f, MTXMODE_APPLY);
}
if (limb == 10) {
vec1 = this->interactInfo.torsoRot;
float1 = BINANG_TO_RAD_ALT(vec1.y);
Matrix_RotateY(float1, MTXMODE_APPLY);
float1 = BINANG_TO_RAD_ALT(vec1.x);
Matrix_RotateX(float1, MTXMODE_APPLY);
limbRot = this->interactInfo.torsoRot;
Matrix_RotateY(BINANG_TO_RAD_ALT(limbRot.y), MTXMODE_APPLY);
Matrix_RotateX(BINANG_TO_RAD_ALT(limbRot.x), MTXMODE_APPLY);
}
if ((limb == 10) || (limb == 11) || (limb == 14)) {
float1 = Math_SinS(this->unk_226[limb]);
rot->y += float1 * 200.0f;
float1 = Math_CosS(this->unk_24A[limb]);
rot->z += float1 * 200.0f;
rot->y += Math_SinS(this->unk_226[limb]) * 200.0f;
rot->z += Math_CosS(this->unk_24A[limb]) * 200.0f;
}
return 0;
}

View file

@ -53,7 +53,7 @@ typedef struct {
f32 shape_unk_10;
f32 scale;
s8 actor_unk_1F;
f32 unk_218;
f32 interactRange;
} EnGo2DataStruct2; // size = 0x10
typedef struct {
@ -88,7 +88,7 @@ typedef struct EnGo2 {
/* 0x0214 */ u8 eyeTexIndex;
/* 0x0215 */ u8 mouthTexIndex;
/* 0x0216 */ u8 unk_216; // Set to z rotation, checked by waypoint
/* 0x0218 */ f32 unk_218;
/* 0x0218 */ f32 interactRange;
/* 0x021C */ char unk_21C[0x04];
/* 0x0220 */ f32 alpha; // Set to 0, used by func_80A45360, smoothed to this->actor.shape.shadowAlpha from either 0 or 255.0f
/* 0x0224 */ s16 blinkTimer;