From 45158f57d65b3ef894ac171bdcb7d6544fe55f61 Mon Sep 17 00:00:00 2001 From: fig02 Date: Tue, 3 Sep 2024 20:58:39 -0400 Subject: [PATCH] Document Target_Update [Target Docs 4/?] (#2123) * document Target_Update * add comments * try CLAMP (dbg is ok but ci will check retail) --- include/z64actor.h | 37 ++-- src/code/z_actor.c | 170 ++++++++++-------- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 54 +++--- .../actors/ovl_player_actor/z_player.c | 4 +- tools/disasm/ntsc-1.2/functions.txt | 2 +- 5 files changed, 147 insertions(+), 120 deletions(-) diff --git a/include/z64actor.h b/include/z64actor.h index 4a6185d6d5..a04a3f53a4 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -571,31 +571,30 @@ typedef enum NaviEnemy { /* 0xFF */ NAVI_ENEMY_NONE = 0xFF } NaviEnemy; -// A set of 4 triangles which appear as a ring around an actor when the player Z-Targets it +// A set of 4 triangles which appear as a ring around an actor when locked-on typedef struct LockOnReticle { /* 0x00 */ Vec3f pos; - /* 0x0C */ f32 radius; // distance towards the center of the locked on actor + /* 0x0C */ f32 radius; // distance towards the center of the locked-on actor /* 0x10 */ Color_RGB8 color; } LockOnReticle; // size = 0x14 typedef struct TargetContext { - /* 0x00 */ Vec3f naviRefPos; // possibly wrong - /* 0x0C */ Vec3f lockOnPos; - /* 0x18 */ Color_RGBAf naviInner; - /* 0x28 */ Color_RGBAf naviOuter; - /* 0x38 */ Actor* arrowPointedActor; - /* 0x3C */ Actor* lockOnActor; - /* 0x40 */ f32 unk_40; - /* 0x44 */ f32 reticleRadius; - /* 0x48 */ s16 reticleFadeAlphaControl; - /* 0x4A */ u8 activeCategory; - /* 0x4B */ u8 reticleSpinCounter; - /* 0x4C */ s8 curReticle; // indexes lockOnReticles[] - /* 0x4D */ char unk_4D[0x03]; - /* 0x50 */ LockOnReticle lockOnReticles[3]; - /* 0x8C */ Actor* unk_8C; - /* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY - /* 0x94 */ Actor* arrowHoverActor; + /* 0x00 */ Vec3f naviHoverPos; // Navi's current hover position + /* 0x0C */ Vec3f reticlePos; // Main reticle pos which each `LockOnReticle` instance can reference + /* 0x18 */ Color_RGBAf naviInnerColor; // Navi inner color, based on actor category + /* 0x28 */ Color_RGBAf naviOuterColor; // Navi outer color, based on actor category + /* 0x38 */ Actor* naviHoverActor; // The actor that Navi hovers over + /* 0x3C */ Actor* reticleActor; // Actor to draw a reticle over + /* 0x40 */ f32 naviMoveProgressFactor; // Controls Navi so she can smootly transition to an actor + /* 0x44 */ f32 reticleRadius; // Main reticle radius value which each `LockOnReticle` instance can reference + /* 0x48 */ s16 reticleFadeAlphaControl; // Set and fade the reticle alpha; Non-zero values control if it should draw + /* 0x4A */ u8 naviHoverActorCategory; // Category of the actor Navi is currently hovering over + /* 0x4B */ u8 reticleSpinCounter; // Counts up when a reticle is active, used for the spinning animation + /* 0x4C */ s8 curReticle; // Indexes lockOnReticles[] + /* 0x50 */ LockOnReticle lockOnReticles[3]; // Multiple reticles are used for a motion-blur effect + /* 0x8C */ Actor* forcedLockOnActor; // Forces lock-on to this actor when set (never used in practice) + /* 0x90 */ Actor* bgmEnemy; // The nearest actor which can trigger enemy background music + /* 0x94 */ Actor* arrowHoverActor; // Actor to draw an arrow over } TargetContext; // size = 0x98 typedef struct TitleCardContext { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index fe6a4f5cbc..a5c36daf94 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -275,9 +275,9 @@ void Target_InitReticle(TargetContext* targetCtx, s32 actorCategory, PlayState* TargetColor* reticleColor = &sTargetColorList[actorCategory]; s32 i; - Math_Vec3f_Copy(&targetCtx->lockOnPos, &play->view.eye); + Math_Vec3f_Copy(&targetCtx->reticlePos, &play->view.eye); - targetCtx->reticleRadius = 500.0f; + targetCtx->reticleRadius = 500.0f; // radius starts wide to zoom in on the actor targetCtx->reticleFadeAlphaControl = 256; reticle = &targetCtx->lockOnReticles[0]; @@ -294,34 +294,36 @@ void Target_InitReticle(TargetContext* targetCtx, s32 actorCategory, PlayState* void Target_SetNaviState(TargetContext* targetCtx, Actor* actor, s32 actorCategory, PlayState* play) { TargetColor* targetColor = &sTargetColorList[actorCategory]; - targetCtx->naviRefPos.x = actor->focus.pos.x; - targetCtx->naviRefPos.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); - targetCtx->naviRefPos.z = actor->focus.pos.z; + targetCtx->naviHoverPos.x = actor->focus.pos.x; + targetCtx->naviHoverPos.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); + targetCtx->naviHoverPos.z = actor->focus.pos.z; - targetCtx->naviInner.r = targetColor->inner.r; - targetCtx->naviInner.g = targetColor->inner.g; - targetCtx->naviInner.b = targetColor->inner.b; - targetCtx->naviInner.a = targetColor->inner.a; + targetCtx->naviInnerColor.r = targetColor->inner.r; + targetCtx->naviInnerColor.g = targetColor->inner.g; + targetCtx->naviInnerColor.b = targetColor->inner.b; + targetCtx->naviInnerColor.a = targetColor->inner.a; - targetCtx->naviOuter.r = targetColor->outer.r; - targetCtx->naviOuter.g = targetColor->outer.g; - targetCtx->naviOuter.b = targetColor->outer.b; - targetCtx->naviOuter.a = targetColor->outer.a; + targetCtx->naviOuterColor.r = targetColor->outer.r; + targetCtx->naviOuterColor.g = targetColor->outer.g; + targetCtx->naviOuterColor.b = targetColor->outer.b; + targetCtx->naviOuterColor.a = targetColor->outer.a; } void Target_Init(TargetContext* targetCtx, Actor* actor, PlayState* play) { - targetCtx->arrowPointedActor = targetCtx->lockOnActor = targetCtx->unk_8C = targetCtx->bgmEnemy = NULL; + targetCtx->naviHoverActor = targetCtx->reticleActor = targetCtx->forcedLockOnActor = targetCtx->bgmEnemy = NULL; targetCtx->reticleSpinCounter = 0; targetCtx->curReticle = 0; - targetCtx->unk_40 = 0.0f; + targetCtx->naviMoveProgressFactor = 0.0f; Target_SetNaviState(targetCtx, actor, actor->category, play); Target_InitReticle(targetCtx, actor->category, play); } void Target_Draw(TargetContext* targetCtx, PlayState* play) { - Actor* actor = targetCtx->lockOnActor; + Actor* actor; // used for both the reticle and arrow + + actor = targetCtx->reticleActor; OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2029); @@ -351,7 +353,7 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { } if (actor != NULL) { - Math_Vec3f_Copy(&targetCtx->lockOnPos, &actor->focus.pos); + Math_Vec3f_Copy(&targetCtx->reticlePos, &actor->focus.pos); projectdPosScale = (500.0f - targetCtx->reticleRadius) / 420.0f; } else { // Not locked on, start fading out @@ -366,7 +368,7 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { alpha = targetCtx->reticleFadeAlphaControl; } - Actor_ProjectPos(play, &targetCtx->lockOnPos, &projectedPos, &invW); + Actor_ProjectPos(play, &targetCtx->reticlePos, &projectedPos, &invW); projectedPos.x = ((SCREEN_WIDTH / 2) * (projectedPos.x * invW)) * projectdPosScale; projectedPos.x = CLAMP(projectedPos.x, -SCREEN_WIDTH, SCREEN_WIDTH); @@ -447,101 +449,128 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 2158); } -void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, PlayState* play) { +void Target_Update(TargetContext* targetCtx, Player* player, Actor* curLockOnActor, PlayState* play) { s32 pad; - Actor* unkActor; - s32 actorCategory; + Actor* actor; + s32 category; Vec3f projectedFocusPos; f32 cappedInvWDest; - unkActor = NULL; + actor = NULL; if ((player->unk_664 != NULL) && (player->controlStickDirections[player->controlStickDataIndex] == PLAYER_STICK_DIR_BACKWARD)) { + // Holding backward on the control stick prevents an arrow appearing over the next targetable actor. + // This helps escape a targeting loop when using Switch Targeting, but note that this still works for + // Hold Targeting as well. targetCtx->arrowHoverActor = NULL; } else { - Target_FindTargetableActor(play, &play->actorCtx, &unkActor, player); - targetCtx->arrowHoverActor = unkActor; + // Find the next targetable actor and draw an arrow over it + Target_FindTargetableActor(play, &play->actorCtx, &actor, player); + targetCtx->arrowHoverActor = actor; } - if (targetCtx->unk_8C != NULL) { - unkActor = targetCtx->unk_8C; - targetCtx->unk_8C = NULL; - } else if (actorArg != NULL) { - unkActor = actorArg; + if (targetCtx->forcedLockOnActor != NULL) { + // This lock-on actor takes precedence over anything else + // (this feature is never used in practice) + actor = targetCtx->forcedLockOnActor; + targetCtx->forcedLockOnActor = NULL; + } else if (curLockOnActor != NULL) { + // Stay locked-on to the same actor + actor = curLockOnActor; } - if (unkActor != NULL) { - actorCategory = unkActor->category; + if (actor != NULL) { + category = actor->category; } else { - actorCategory = player->actor.category; + category = player->actor.category; } - if ((unkActor != targetCtx->arrowPointedActor) || (actorCategory != targetCtx->activeCategory)) { - targetCtx->arrowPointedActor = unkActor; - targetCtx->activeCategory = actorCategory; - targetCtx->unk_40 = 1.0f; + if ((actor != targetCtx->naviHoverActor) || (category != targetCtx->naviHoverActorCategory)) { + // Set Navi to hover over a new actor + targetCtx->naviHoverActor = actor; + targetCtx->naviHoverActorCategory = category; + targetCtx->naviMoveProgressFactor = 1.0f; } - if (unkActor == NULL) { - unkActor = &player->actor; + if (actor == NULL) { + // Setting the actor to Player will make Navi return to him + actor = &player->actor; } - if (Math_StepToF(&targetCtx->unk_40, 0.0f, 0.25f) == 0) { - f32 temp1 = 0.25f / targetCtx->unk_40; - f32 temp2 = unkActor->world.pos.x - targetCtx->naviRefPos.x; - f32 temp3 = - (unkActor->world.pos.y + (unkActor->targetArrowOffset * unkActor->scale.y)) - targetCtx->naviRefPos.y; - f32 temp4 = unkActor->world.pos.z - targetCtx->naviRefPos.z; + if (!Math_StepToF(&targetCtx->naviMoveProgressFactor, 0.0f, 0.25f)) { + f32 moveScale = 0.25f / targetCtx->naviMoveProgressFactor; + f32 x = actor->world.pos.x - targetCtx->naviHoverPos.x; + f32 y = (actor->world.pos.y + (actor->targetArrowOffset * actor->scale.y)) - targetCtx->naviHoverPos.y; + f32 z = actor->world.pos.z - targetCtx->naviHoverPos.z; - targetCtx->naviRefPos.x += temp2 * temp1; - targetCtx->naviRefPos.y += temp3 * temp1; - targetCtx->naviRefPos.z += temp4 * temp1; + targetCtx->naviHoverPos.x += x * moveScale; + targetCtx->naviHoverPos.y += y * moveScale; + targetCtx->naviHoverPos.z += z * moveScale; } else { - Target_SetNaviState(targetCtx, unkActor, actorCategory, play); + // Set Navi pos and color after reaching destination + Target_SetNaviState(targetCtx, actor, category, play); } - if ((actorArg != NULL) && (targetCtx->reticleSpinCounter == 0)) { - Actor_ProjectPos(play, &actorArg->focus.pos, &projectedFocusPos, &cappedInvWDest); + // Release lock-on if the actor is off screen. + // The camera is always moving toward the locked-on actor, so it seems difficult + // to move the actor off screen, if its even possible. + if ((curLockOnActor != NULL) && (targetCtx->reticleSpinCounter == 0)) { + Actor_ProjectPos(play, &curLockOnActor->focus.pos, &projectedFocusPos, &cappedInvWDest); + if (((projectedFocusPos.z <= 0.0f) || (1.0f <= fabsf(projectedFocusPos.x * cappedInvWDest))) || (1.0f <= fabsf(projectedFocusPos.y * cappedInvWDest))) { - actorArg = NULL; + curLockOnActor = NULL; } } - if (actorArg != NULL) { - if (actorArg != targetCtx->lockOnActor) { + if (curLockOnActor != NULL) { + if (curLockOnActor != targetCtx->reticleActor) { s32 lockOnSfxId; - Target_InitReticle(targetCtx, actorArg->category, play); - targetCtx->lockOnActor = actorArg; + // Set up a new lock-on + Target_InitReticle(targetCtx, curLockOnActor->category, play); + targetCtx->reticleActor = curLockOnActor; - if (actorArg->id == ACTOR_EN_BOOM) { + if (curLockOnActor->id == ACTOR_EN_BOOM) { + // Don't draw the reticle when locked onto the boomerang. + // Note that it isn't possible to lock onto the boomerang, so this code doesn't do anything. + // This implies that the boomerang camera lock may have been implemented with Z-Targeting at one point, + // but was eventually implemented as its own camera mode instead. targetCtx->reticleFadeAlphaControl = 0; } - lockOnSfxId = CHECK_FLAG_ALL(actorArg->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2) ? NA_SE_SY_LOCK_ON - : NA_SE_SY_LOCK_ON_HUMAN; + lockOnSfxId = CHECK_FLAG_ALL(curLockOnActor->flags, ACTOR_FLAG_0 | ACTOR_FLAG_2) ? NA_SE_SY_LOCK_ON + : NA_SE_SY_LOCK_ON_HUMAN; Sfx_PlaySfxCentered(lockOnSfxId); } - targetCtx->lockOnPos.x = actorArg->world.pos.x; - targetCtx->lockOnPos.y = actorArg->world.pos.y - (actorArg->shape.yOffset * actorArg->scale.y); - targetCtx->lockOnPos.z = actorArg->world.pos.z; + // Update reticle + + targetCtx->reticlePos.x = curLockOnActor->world.pos.x; + targetCtx->reticlePos.y = + curLockOnActor->world.pos.y - (curLockOnActor->shape.yOffset * curLockOnActor->scale.y); + targetCtx->reticlePos.z = curLockOnActor->world.pos.z; if (targetCtx->reticleSpinCounter == 0) { - f32 temp5 = (500.0f - targetCtx->reticleRadius) * 3.0f; - f32 temp6 = (temp5 < 30.0f) ? 30.0f : ((100.0f < temp5) ? 100.0f : temp5); + f32 step = (500.0f - targetCtx->reticleRadius) * 3.0f; + f32 reticleZoomStep = CLAMP(step, 30.0f, 100.0f); - if (Math_StepToF(&targetCtx->reticleRadius, 80.0f, temp6) != 0) { + if (Math_StepToF(&targetCtx->reticleRadius, 80.0f, reticleZoomStep)) { + // Non-zero counter indicates the reticle is done zooming in targetCtx->reticleSpinCounter++; } } else { + // Finished zooming in, spin the reticle around the lock-on actor + + // 0x80 is or'd to avoid a value of zero. + // This rotation value gets multiplied by 0x200, which multiplied by 0x80 gives a full turn (0x10000) targetCtx->reticleSpinCounter = (targetCtx->reticleSpinCounter + 3) | 0x80; targetCtx->reticleRadius = 120.0f; } } else { - targetCtx->lockOnActor = NULL; + // Expand the reticle radius quickly as the lock-on is released + targetCtx->reticleActor = NULL; Math_StepToF(&targetCtx->reticleRadius, 500.0f, 80.0f); } } @@ -2339,13 +2368,14 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { if ((actor == NULL) || (player->unk_66C < 5)) { actor = NULL; + if (actorCtx->targetCtx.reticleSpinCounter != 0) { actorCtx->targetCtx.reticleSpinCounter = 0; Sfx_PlaySfxCentered(NA_SE_SY_LOCK_OFF); } } - func_8002C7BC(&actorCtx->targetCtx, player, actor, play); + Target_Update(&actorCtx->targetCtx, player, actor, play); TitleCard_Update(play, &actorCtx->titleCtx); DynaPoly_UpdateBgActorTransforms(play, &play->colCtx.dyna); } @@ -3085,12 +3115,12 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { Camera_RequestMode(Play_GetCamera(play, Play_GetActiveCamId(play)), CAM_MODE_NORMAL); } - if (actor == actorCtx->targetCtx.arrowPointedActor) { - actorCtx->targetCtx.arrowPointedActor = NULL; + if (actor == actorCtx->targetCtx.naviHoverActor) { + actorCtx->targetCtx.naviHoverActor = NULL; } - if (actor == actorCtx->targetCtx.unk_8C) { - actorCtx->targetCtx.unk_8C = NULL; + if (actor == actorCtx->targetCtx.forcedLockOnActor) { + actorCtx->targetCtx.forcedLockOnActor = NULL; } if (actor == actorCtx->targetCtx.bgmEnemy) { diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index b0f49228be..cc84d39fd6 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -838,7 +838,7 @@ void func_80A03CF8(EnElf* this, PlayState* play) { Vec3f nextPos; Vec3f prevPos; Player* player = GET_PLAYER(play); - Actor* arrowPointedActor; + Actor* naviHoverActor; f32 xScale; f32 distFromPlayerHat; @@ -935,11 +935,11 @@ void func_80A03CF8(EnElf* this, PlayState* play) { break; default: func_80A029A8(this, 1); - nextPos = play->actorCtx.targetCtx.naviRefPos; + nextPos = play->actorCtx.targetCtx.naviHoverPos; nextPos.y += (1500.0f * this->actor.scale.y); - arrowPointedActor = play->actorCtx.targetCtx.arrowPointedActor; + naviHoverActor = play->actorCtx.targetCtx.naviHoverActor; - if (arrowPointedActor != NULL) { + if (naviHoverActor != NULL) { func_80A03148(this, &nextPos, 0.0f, 20.0f, 0.2f); if (this->actor.speed >= 5.0f) { @@ -1000,12 +1000,12 @@ void EnElf_ChangeColor(Color_RGBAf* dest, Color_RGBAf* newColor, Color_RGBAf* cu } void func_80A04414(EnElf* this, PlayState* play) { - Actor* arrowPointedActor = play->actorCtx.targetCtx.arrowPointedActor; + Actor* naviHoverActor = play->actorCtx.targetCtx.naviHoverActor; Player* player = GET_PLAYER(play); f32 transitionRate; u16 sfxId; - if (play->actorCtx.targetCtx.unk_40 != 0.0f) { + if (play->actorCtx.targetCtx.naviMoveProgressFactor != 0.0f) { this->unk_2C6 = 0; this->unk_29C = 1.0f; @@ -1015,34 +1015,34 @@ void func_80A04414(EnElf* this, PlayState* play) { } else { if (this->unk_2C6 == 0) { - if ((arrowPointedActor == NULL) || - (Math_Vec3f_DistXYZ(&this->actor.world.pos, &play->actorCtx.targetCtx.naviRefPos) < 50.0f)) { + if ((naviHoverActor == NULL) || + (Math_Vec3f_DistXYZ(&this->actor.world.pos, &play->actorCtx.targetCtx.naviHoverPos) < 50.0f)) { this->unk_2C6 = 1; } } else if (this->unk_29C != 0.0f) { if (Math_StepToF(&this->unk_29C, 0.0f, 0.25f) != 0) { - this->innerColor = play->actorCtx.targetCtx.naviInner; - this->outerColor = play->actorCtx.targetCtx.naviOuter; + this->innerColor = play->actorCtx.targetCtx.naviInnerColor; + this->outerColor = play->actorCtx.targetCtx.naviOuterColor; } else { transitionRate = 0.25f / this->unk_29C; - EnElf_ChangeColor(&this->innerColor, &play->actorCtx.targetCtx.naviInner, &this->innerColor, + EnElf_ChangeColor(&this->innerColor, &play->actorCtx.targetCtx.naviInnerColor, &this->innerColor, transitionRate); - EnElf_ChangeColor(&this->outerColor, &play->actorCtx.targetCtx.naviOuter, &this->outerColor, + EnElf_ChangeColor(&this->outerColor, &play->actorCtx.targetCtx.naviOuterColor, &this->outerColor, transitionRate); } } } if (this->fairyFlags & 1) { - if ((arrowPointedActor == NULL) || (player->unk_664 == NULL)) { + if ((naviHoverActor == NULL) || (player->unk_664 == NULL)) { this->fairyFlags ^= 1; } } else { - if ((arrowPointedActor != NULL) && (player->unk_664 != NULL)) { - if (arrowPointedActor->category == ACTORCAT_NPC) { + if ((naviHoverActor != NULL) && (player->unk_664 != NULL)) { + if (naviHoverActor->category == ACTORCAT_NPC) { sfxId = NA_SE_VO_NAVY_HELLO; } else { - sfxId = (arrowPointedActor->category == ACTORCAT_ENEMY) ? NA_SE_VO_NAVY_ENEMY : NA_SE_VO_NAVY_HEAR; + sfxId = (naviHoverActor->category == ACTORCAT_ENEMY) ? NA_SE_VO_NAVY_ENEMY : NA_SE_VO_NAVY_HEAR; } if (this->unk_2C7 == 0) { @@ -1056,7 +1056,7 @@ void func_80A04414(EnElf* this, PlayState* play) { void func_80A0461C(EnElf* this, PlayState* play) { s32 temp; - Actor* arrowPointedActor; + Actor* naviHoverActor; Player* player = GET_PLAYER(play); if (play->csCtx.state != CS_STATE_IDLE) { @@ -1081,7 +1081,7 @@ void func_80A0461C(EnElf* this, PlayState* play) { } } else { - arrowPointedActor = play->actorCtx.targetCtx.arrowPointedActor; + naviHoverActor = play->actorCtx.targetCtx.naviHoverActor; // `R_SCENE_CAM_TYPE` is not a bit field, but this conditional checks for a specific bit. // This `& 0x10` check will pass for either `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT`, `SCENE_CAM_TYPE_FIXED`, or @@ -1092,8 +1092,8 @@ void func_80A0461C(EnElf* this, PlayState* play) { ((R_SCENE_CAM_TYPE & 0x10) && Play_CheckViewpoint(play, VIEWPOINT_PIVOT))) { temp = 12; this->unk_2C0 = 100; - } else if (arrowPointedActor == NULL || arrowPointedActor->category == ACTORCAT_NPC) { - if (arrowPointedActor != NULL) { + } else if (naviHoverActor == NULL || naviHoverActor->category == ACTORCAT_NPC) { + if (naviHoverActor != NULL) { this->unk_2C0 = 100; player->stateFlags2 |= PLAYER_STATE2_20; temp = 0; @@ -1219,20 +1219,18 @@ void func_80A04D90(EnElf* this, PlayState* play) { void func_80A04DE4(EnElf* this, PlayState* play) { Vec3f headCopy; Player* player = GET_PLAYER(play); - Vec3f naviRefPos; + Vec3f pos; if (this->fairyFlags & 0x10) { - naviRefPos = play->actorCtx.targetCtx.naviRefPos; + pos = play->actorCtx.targetCtx.naviHoverPos; if ((player->unk_664 == NULL) || (&player->actor == player->unk_664) || (&this->actor == player->unk_664)) { - naviRefPos.x = - player->bodyPartsPos[PLAYER_BODYPART_HEAD].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); - naviRefPos.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 5.0f; - naviRefPos.z = - player->bodyPartsPos[PLAYER_BODYPART_HEAD].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); + pos.x = player->bodyPartsPos[PLAYER_BODYPART_HEAD].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); + pos.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 5.0f; + pos.z = player->bodyPartsPos[PLAYER_BODYPART_HEAD].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); } - this->actor.focus.pos = naviRefPos; + this->actor.focus.pos = pos; this->fairyFlags &= ~0x10; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index bb16ecfdfb..7f56942755 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3578,7 +3578,7 @@ void func_80836BEC(Player* this, PlayState* play) { CHECK_BTN_ALL(sControlInput->press.button, BTN_Z)) { if (this->actor.category == ACTORCAT_PLAYER) { - actorToTarget = play->actorCtx.targetCtx.arrowPointedActor; + actorToTarget = play->actorCtx.targetCtx.naviHoverActor; } else { actorToTarget = &GET_PLAYER(play)->actor; } @@ -10360,7 +10360,7 @@ void Player_UpdateInterface(PlayState* play, Player* this) { doAction = DO_ACTION_JUMP; } else if ((this->heldItemAction >= PLAYER_IA_SWORD_MASTER) || ((this->stateFlags2 & PLAYER_STATE2_20) && - (play->actorCtx.targetCtx.arrowPointedActor == NULL))) { + (play->actorCtx.targetCtx.naviHoverActor == NULL))) { doAction = DO_ACTION_PUTAWAY; } } diff --git a/tools/disasm/ntsc-1.2/functions.txt b/tools/disasm/ntsc-1.2/functions.txt index 57ad65a3e1..bdbd2052ee 100644 --- a/tools/disasm/ntsc-1.2/functions.txt +++ b/tools/disasm/ntsc-1.2/functions.txt @@ -324,7 +324,7 @@ Target_InitReticle = 0x8001FE7C; // type:func Target_SetNaviState = 0x8001FF44; // type:func Target_Init = 0x800200A8; // type:func Target_Draw = 0x8002010C; // type:func -func_8002C7BC = 0x80020748; // type:func +Target_Update = 0x80020748; // type:func Flags_GetSwitch = 0x80020ADC; // type:func Flags_SetSwitch = 0x80020B10; // type:func Flags_UnsetSwitch = 0x80020B50; // type:func