diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index d7c6a93753..7a22535ca8 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -910,7 +910,7 @@ - + @@ -1408,7 +1408,7 @@ - + diff --git a/include/z64actor.h b/include/z64actor.h index e06cd7a169..ac6084e5c7 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -280,27 +280,27 @@ typedef enum { #define ACTORCTX_FLAG_6 (1 << 6) #define ACTORCTX_FLAG_7 (1 << 7) -// A set of 4 triangles which appear around an actor when the player Z-Targets it -typedef struct LockOnTriangleSet { +// 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 + /* 0x0C */ f32 radius; // distance towards the center of the locked-on actor /* 0x10 */ Color_RGBA8 color; -} LockOnTriangleSet; // size = 0x14 +} LockOnReticle; // size = 0x14 typedef struct TargetContext { /* 0x00 */ Vec3f fairyPos; // Used by Tatl to indicate a targetable actor or general hint - /* 0x0C */ Vec3f lockOnPos; + /* 0x0C */ Vec3f reticlePos; // Main reticle pos which each `LockOnReticle` instance can reference /* 0x18 */ Color_RGBAf fairyInnerColor; /* 0x28 */ Color_RGBAf fairyOuterColor; /* 0x38 */ Actor* fairyActor; - /* 0x3C */ Actor* lockOnActor; + /* 0x3C */ Actor* reticleActor; // Actor to draw a reticle over /* 0x40 */ f32 fairyMoveProgressFactor; // Controls Tatl so she can smootly transition to the target actor - /* 0x44 */ f32 lockOnRadius; // Control the circle lock-on triangles coming in from offscreen when you first target - /* 0x48 */ s16 lockOnAlpha; + /* 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 fairyActorCategory; - /* 0x4B */ u8 rotZTick; - /* 0x4C */ s8 lockOnIndex; - /* 0x50 */ LockOnTriangleSet lockOnTriangleSets[3]; + /* 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* forcedTargetActor; // Never set to non-NULL /* 0x90 */ Actor* bgmEnemy; /* 0x94 */ Actor* arrowPointedActor; diff --git a/include/z64player.h b/include/z64player.h index 8aedeb04be..4d2d767766 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -894,8 +894,8 @@ typedef enum PlayerCueId { #define PLAYER_STATE1_4000 (1 << 14) // #define PLAYER_STATE1_8000 (1 << 15) -// -#define PLAYER_STATE1_10000 (1 << 16) +// Currently focusing on a friendly actor. Includes friendly lock-on, talking, and more. Usually does not include hostile actor lock-on, see `PLAYER_STATE3_HOSTILE_LOCK_ON`. +#define PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS (1 << 16) // #define PLAYER_STATE1_20000 (1 << 17) // @@ -954,8 +954,8 @@ typedef enum PlayerCueId { #define PLAYER_STATE2_800 (1 << 11) // #define PLAYER_STATE2_1000 (1 << 12) -// -#define PLAYER_STATE2_2000 (1 << 13) +// Actor lock-on is active, specifically with Switch Targeting. Hold Targeting checks the state of the Z button instead of this flag. +#define PLAYER_STATE2_LOCK_ON_WITH_SWITCH (1 << 13) // #define PLAYER_STATE2_4000 (1 << 14) // @@ -1193,7 +1193,7 @@ typedef struct Player { /* 0x564 */ ColliderQuad meleeWeaponQuads[2]; /* 0x664 */ ColliderQuad shieldQuad; /* 0x6E4 */ ColliderCylinder shieldCylinder; - /* 0x730 */ Actor* lockOnActor; // Z/L-Targeted actor + /* 0x730 */ Actor* focusActor; // Actor that Player and the camera are looking at; Used for lock-on, talking, and more /* 0x734 */ char unk_734[4]; /* 0x738 */ s32 unk_738; /* 0x73C */ s32 meleeWeaponEffectIndex[3]; @@ -1207,7 +1207,7 @@ typedef struct Player { /* 0xA6C */ u32 stateFlags1; /* 0xA70 */ u32 stateFlags2; /* 0xA74 */ u32 stateFlags3; - /* 0xA78 */ Actor* unk_A78; + /* 0xA78 */ Actor* autoLockOnActor; // Actor that is locked onto automatically without player input; see `Player_SetAutoLockOnActor` /* 0xA7C */ Actor* boomerangActor; /* 0xA80 */ Actor* tatlActor; /* 0xA84 */ s16 tatlTextId; @@ -1396,9 +1396,9 @@ void Player_SetModelGroup(Player* player, PlayerModelGroup modelGroup); void func_80123C58(Player* player); void Player_SetEquipmentData(struct PlayState* play, Player* player); void Player_UpdateBottleHeld(struct PlayState* play, Player* player, ItemId itemId, PlayerItemAction itemAction); -void Player_Untarget(Player* player); -void func_80123DC0(Player* player); -void func_80123E90(struct PlayState* play, Actor* actor); +void Player_ReleaseLockOn(Player* player); +void Player_ClearZTargeting(Player* player); +void Player_SetAutoLockOnActor(struct PlayState* play, Actor* actor); s32 Player_SetBButtonAmmo(struct PlayState* play, s32 ammo); bool Player_IsBurningStickInRange(struct PlayState* play, Vec3f* pos, f32 xzRange, f32 yRange); u8 Player_GetStrength(void); diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 76885f8525..3e21dd61de 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -426,11 +426,12 @@ void Actor_GetProjectedPos(PlayState* play, Vec3f* worldPos, Vec3f* projectedPos *invW = (*invW < 1.0f) ? 1.0f : (1.0f / *invW); } -void Target_SetLockOnPos(TargetContext* targetCtx, s32 index, f32 x, f32 y, f32 z) { - targetCtx->lockOnTriangleSets[index].pos.x = x; - targetCtx->lockOnTriangleSets[index].pos.y = y; - targetCtx->lockOnTriangleSets[index].pos.z = z; - targetCtx->lockOnTriangleSets[index].radius = targetCtx->lockOnRadius; +void Target_SetReticlePos(TargetContext* targetCtx, s32 reticleNum, f32 x, f32 y, f32 z) { + targetCtx->lockOnReticles[reticleNum].pos.x = x; + targetCtx->lockOnReticles[reticleNum].pos.y = y; + targetCtx->lockOnReticles[reticleNum].pos.z = z; + + targetCtx->lockOnReticles[reticleNum].radius = targetCtx->reticleRadius; } typedef struct { @@ -455,23 +456,23 @@ TatlColor sTatlColorList[] = { { { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }, // ACTORCAT_MAX }; -void Target_InitLockOn(TargetContext* targetCtx, ActorType type, PlayState* play) { +void Target_InitReticle(TargetContext* targetCtx, ActorType actorCategory, PlayState* play) { TatlColor* tatlColorEntry; s32 i; - LockOnTriangleSet* triangleSet; + LockOnReticle* reticle; - Math_Vec3f_Copy(&targetCtx->lockOnPos, &play->view.eye); - targetCtx->lockOnAlpha = 256; - tatlColorEntry = &sTatlColorList[type]; - targetCtx->lockOnRadius = 500.0f; + Math_Vec3f_Copy(&targetCtx->reticlePos, &play->view.eye); + targetCtx->reticleFadeAlphaControl = 256; + tatlColorEntry = &sTatlColorList[actorCategory]; + targetCtx->reticleRadius = 500.0f; - triangleSet = targetCtx->lockOnTriangleSets; - for (i = 0; i < ARRAY_COUNT(targetCtx->lockOnTriangleSets); i++, triangleSet++) { - Target_SetLockOnPos(targetCtx, i, 0.0f, 0.0f, 0.0f); + reticle = targetCtx->lockOnReticles; + for (i = 0; i < ARRAY_COUNT(targetCtx->lockOnReticles); i++, reticle++) { + Target_SetReticlePos(targetCtx, i, 0.0f, 0.0f, 0.0f); - triangleSet->color.r = tatlColorEntry->inner.r; - triangleSet->color.g = tatlColorEntry->inner.g; - triangleSet->color.b = tatlColorEntry->inner.b; + reticle->color.r = tatlColorEntry->inner.r; + reticle->color.g = tatlColorEntry->inner.g; + reticle->color.b = tatlColorEntry->inner.b; } } @@ -493,13 +494,13 @@ void Target_SetFairyState(TargetContext* targetCtx, Actor* actor, ActorType type void Target_Init(TargetContext* targetCtx, Actor* actor, PlayState* play) { targetCtx->bgmEnemy = NULL; targetCtx->forcedTargetActor = NULL; - targetCtx->lockOnActor = NULL; + targetCtx->reticleActor = NULL; targetCtx->fairyActor = NULL; - targetCtx->rotZTick = 0; - targetCtx->lockOnIndex = 0; + targetCtx->reticleSpinCounter = 0; + targetCtx->curReticle = 0; targetCtx->fairyMoveProgressFactor = 0.0f; Target_SetFairyState(targetCtx, actor, actor->category, play); - Target_InitLockOn(targetCtx, actor->category, play); + Target_InitReticle(targetCtx, actor->category, play); } void Target_Draw(TargetContext* targetCtx, PlayState* play) { @@ -511,41 +512,47 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { return; } - actor = targetCtx->lockOnActor; + actor = targetCtx->reticleActor; OPEN_DISPS(play->state.gfxCtx); - if (targetCtx->lockOnAlpha != 0) { - LockOnTriangleSet* entry; + if (targetCtx->reticleFadeAlphaControl != 0) { + LockOnReticle* reticle; s16 alpha = 255; f32 projectdPosScale = 1.0f; Vec3f projectedPos; - s32 totalEntries; + s32 numReticles; f32 invW; s32 i; - s32 index; + s32 curReticle; f32 lockOnScaleX; - if (targetCtx->rotZTick != 0) { - totalEntries = 1; + if (targetCtx->reticleSpinCounter != 0) { + // Reticle is spinning so it is active, only need to draw one + numReticles = 1; } else { - // Use multiple entries for the movement effect when the triangles are getting closer to the actor from the - // margin of the screen - totalEntries = ARRAY_COUNT(targetCtx->lockOnTriangleSets); + // Use multiple reticles for the motion blur effect from the reticle + // quickly zooming in on an actor from off screen + numReticles = ARRAY_COUNT(targetCtx->lockOnReticles); } if (actor != NULL) { - Math_Vec3f_Copy(&targetCtx->lockOnPos, &actor->focus.pos); - projectdPosScale = (500.0f - targetCtx->lockOnRadius) / 420.0f; + Math_Vec3f_Copy(&targetCtx->reticlePos, &actor->focus.pos); + projectdPosScale = (500.0f - targetCtx->reticleRadius) / 420.0f; } else { - targetCtx->lockOnAlpha -= 120; - if (targetCtx->lockOnAlpha < 0) { - targetCtx->lockOnAlpha = 0; + // Not locked on, start fading out + targetCtx->reticleFadeAlphaControl -= 120; + + if (targetCtx->reticleFadeAlphaControl < 0) { + targetCtx->reticleFadeAlphaControl = 0; } - alpha = targetCtx->lockOnAlpha; + + // `reticleFadeAlphaControl` is only used as an alpha when fading out. + // Otherwise it defaults to 255, set above. + alpha = targetCtx->reticleFadeAlphaControl; } - Actor_GetProjectedPos(play, &targetCtx->lockOnPos, &projectedPos, &invW); + Actor_GetProjectedPos(play, &targetCtx->reticlePos, &projectedPos, &invW); projectedPos.x = ((SCREEN_WIDTH / 2) * (projectedPos.x * invW)) * projectdPosScale; projectedPos.x = CLAMP(projectedPos.x, -SCREEN_WIDTH, SCREEN_WIDTH); @@ -555,48 +562,51 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { projectedPos.z *= projectdPosScale; - targetCtx->lockOnIndex--; - if (targetCtx->lockOnIndex < 0) { - targetCtx->lockOnIndex = ARRAY_COUNT(targetCtx->lockOnTriangleSets) - 1; + targetCtx->curReticle--; + + if (targetCtx->curReticle < 0) { + targetCtx->curReticle = ARRAY_COUNT(targetCtx->lockOnReticles) - 1; } - Target_SetLockOnPos(targetCtx, targetCtx->lockOnIndex, projectedPos.x, projectedPos.y, projectedPos.z); + Target_SetReticlePos(targetCtx, targetCtx->curReticle, projectedPos.x, projectedPos.y, projectedPos.z); - if (!(player->stateFlags1 & PLAYER_STATE1_40) || (actor != player->lockOnActor)) { + if (!(player->stateFlags1 & PLAYER_STATE1_40) || (actor != player->focusActor)) { OVERLAY_DISP = Gfx_SetupDL(OVERLAY_DISP, SETUPDL_57); - for (i = 0, index = targetCtx->lockOnIndex; i < totalEntries; - i++, index = (index + 1) % ARRAY_COUNT(targetCtx->lockOnTriangleSets)) { - entry = &targetCtx->lockOnTriangleSets[index]; + for (i = 0, curReticle = targetCtx->curReticle; i < numReticles; + i++, curReticle = (curReticle + 1) % ARRAY_COUNT(targetCtx->lockOnReticles)) { + reticle = &targetCtx->lockOnReticles[curReticle]; - if (entry->radius < 500.0f) { + if (reticle->radius < 500.0f) { s32 triangleIndex; - if (entry->radius <= 120.0f) { + if (reticle->radius <= 120.0f) { lockOnScaleX = 0.15f; } else { - lockOnScaleX = ((entry->radius - 120.0f) * 0.001f) + 0.15f; + lockOnScaleX = ((reticle->radius - 120.0f) * 0.001f) + 0.15f; } - Matrix_Translate(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); + Matrix_Translate(reticle->pos.x, reticle->pos.y, 0.0f, MTXMODE_NEW); Matrix_Scale(lockOnScaleX, 0.15f, 1.0f, MTXMODE_APPLY); - gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b, (u8)alpha); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, reticle->color.r, reticle->color.g, reticle->color.b, + (u8)alpha); - Matrix_RotateZS(targetCtx->rotZTick * 0x200, MTXMODE_APPLY); + Matrix_RotateZS(targetCtx->reticleSpinCounter * 0x200, MTXMODE_APPLY); - // Draw the 4 lock-on triangles + // Draw the 4 triangles that make up the reticle for (triangleIndex = 0; triangleIndex < 4; triangleIndex++) { Matrix_RotateZS(0x10000 / 4, MTXMODE_APPLY); Matrix_Push(); - Matrix_Translate(entry->radius, entry->radius, 0.0f, MTXMODE_APPLY); + Matrix_Translate(reticle->radius, reticle->radius, 0.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); + gSPDisplayList(OVERLAY_DISP++, gLockOnReticleTriangleDL); Matrix_Pop(); } } - alpha -= 255 / ARRAY_COUNT(targetCtx->lockOnTriangleSets); + alpha -= 255 / ARRAY_COUNT(targetCtx->lockOnReticles); + if (alpha < 0) { alpha = 0; } @@ -605,6 +615,7 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { } actor = targetCtx->arrowPointedActor; + if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_LOCK_ON_DISABLED)) { TatlColor* color = &sTatlColorList[actor->category]; @@ -617,14 +628,13 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color->inner.r, color->inner.g, color->inner.b, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); - gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); + gSPDisplayList(POLY_XLU_DISP++, gLockOnArrowDL); } CLOSE_DISPS(play->state.gfxCtx); } -// OoT: func_8002C7BC -void Target_Update(TargetContext* targetCtx, Player* player, Actor* lockOnActor, PlayState* play) { +void Target_Update(TargetContext* targetCtx, Player* player, Actor* playerFocusActor, PlayState* play) { s32 pad; Actor* actor = NULL; s32 category; @@ -633,7 +643,7 @@ void Target_Update(TargetContext* targetCtx, Player* player, Actor* lockOnActor, // If currently not locked on to an actor and not pressing down on the analog stick then try to find a targetable // actor - if ((player->lockOnActor != NULL) && (player->unk_AE3[player->unk_ADE] == 2)) { + if ((player->focusActor != NULL) && (player->unk_AE3[player->unk_ADE] == 2)) { targetCtx->arrowPointedActor = NULL; } else { Target_GetTargetActor(play, &play->actorCtx, &actor, &D_801ED920, player); @@ -643,8 +653,8 @@ void Target_Update(TargetContext* targetCtx, Player* player, Actor* lockOnActor, if (targetCtx->forcedTargetActor != NULL) { actor = targetCtx->forcedTargetActor; targetCtx->forcedTargetActor = NULL; - } else if (lockOnActor != NULL) { - actor = lockOnActor; + } else if (playerFocusActor != NULL) { + actor = playerFocusActor; } if (actor != NULL) { @@ -676,55 +686,56 @@ void Target_Update(TargetContext* targetCtx, Player* player, Actor* lockOnActor, Target_SetFairyState(targetCtx, actor, category, play); } - if ((lockOnActor != NULL) && (targetCtx->rotZTick == 0)) { - Actor_GetProjectedPos(play, &lockOnActor->focus.pos, &projectedPos, &invW); + if ((playerFocusActor != NULL) && (targetCtx->reticleSpinCounter == 0)) { + Actor_GetProjectedPos(play, &playerFocusActor->focus.pos, &projectedPos, &invW); if ((projectedPos.z <= 0.0f) || (fabsf(projectedPos.x * invW) >= 1.0f) || (fabsf(projectedPos.y * invW) >= 1.0f)) { - lockOnActor = NULL; + playerFocusActor = NULL; } } - if (lockOnActor != NULL) { - if (lockOnActor != targetCtx->lockOnActor) { + if (playerFocusActor != NULL) { + if (playerFocusActor != targetCtx->reticleActor) { s32 sfxId; // Lock On entries need to be re-initialized when changing the targeted actor - Target_InitLockOn(targetCtx, lockOnActor->category, play); + Target_InitReticle(targetCtx, playerFocusActor->category, play); - targetCtx->lockOnActor = lockOnActor; + targetCtx->reticleActor = playerFocusActor; - if (lockOnActor->id == ACTOR_EN_BOOM) { + if (playerFocusActor->id == ACTOR_EN_BOOM) { // Avoid drawing the lock on triangles on a zora boomerang - targetCtx->lockOnAlpha = 0; + targetCtx->reticleFadeAlphaControl = 0; } - sfxId = CHECK_FLAG_ALL(lockOnActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE) + sfxId = CHECK_FLAG_ALL(playerFocusActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE) ? NA_SE_SY_LOCK_ON : NA_SE_SY_LOCK_ON_HUMAN; Audio_PlaySfx(sfxId); } - targetCtx->lockOnPos.x = lockOnActor->world.pos.x; - targetCtx->lockOnPos.y = lockOnActor->world.pos.y - (lockOnActor->shape.yOffset * lockOnActor->scale.y); - targetCtx->lockOnPos.z = lockOnActor->world.pos.z; + targetCtx->reticlePos.x = playerFocusActor->world.pos.x; + targetCtx->reticlePos.y = + playerFocusActor->world.pos.y - (playerFocusActor->shape.yOffset * playerFocusActor->scale.y); + targetCtx->reticlePos.z = playerFocusActor->world.pos.z; - if (targetCtx->rotZTick == 0) { - f32 lockOnStep = (500.0f - targetCtx->lockOnRadius) * 3.0f; + if (targetCtx->reticleSpinCounter == 0) { + f32 lockOnStep = (500.0f - targetCtx->reticleRadius) * 3.0f; lockOnStep = CLAMP(lockOnStep, 30.0f, 100.0f); - if (Math_StepToF(&targetCtx->lockOnRadius, 80.0f, lockOnStep)) { - targetCtx->rotZTick++; + if (Math_StepToF(&targetCtx->reticleRadius, 80.0f, lockOnStep)) { + targetCtx->reticleSpinCounter++; } } else { // 0x80 is or'd to avoid getting this value be set to zero // This rotation value gets multiplied by 0x200, which multiplied by 0x80 gives a full turn (0x10000) - targetCtx->rotZTick = (targetCtx->rotZTick + 3) | 0x80; - targetCtx->lockOnRadius = 120.0f; + targetCtx->reticleSpinCounter = (targetCtx->reticleSpinCounter + 3) | 0x80; + targetCtx->reticleRadius = 120.0f; } } else { - targetCtx->lockOnActor = NULL; - Math_StepToF(&targetCtx->lockOnRadius, 500.0f, 80.0f); + targetCtx->reticleActor = NULL; + Math_StepToF(&targetCtx->reticleRadius, 500.0f, 80.0f); } } @@ -1854,7 +1865,7 @@ f32 Target_GetAdjustedDistSq(Actor* actor, Player* player, s16 playerShapeYaw) { // The yaw, with player as the origin, from where player is facing to where the actor is positioned yawDiff = ABS_ALT(BINANG_SUB(BINANG_SUB(actor->yawTowardsPlayer, 0x8000), playerShapeYaw)); - if (player->lockOnActor != NULL) { + if (player->focusActor != NULL) { if ((yawDiff > 0x4000) || (actor->flags & ACTOR_FLAG_LOCK_ON_DISABLED)) { return FLT_MAX; } @@ -1914,7 +1925,7 @@ s32 Target_OutsideLeashRange(Actor* actor, Player* player, s32 ignoreLeash) { // The yaw, with player as the origin, from where player is facing to where the actor is positioned yawDiff = ABS_ALT(BINANG_SUB(BINANG_SUB(actor->yawTowardsPlayer, 0x8000), player->actor.shape.rot.y)); - if ((player->lockOnActor == NULL) && (yawDiff > (0x10000 / 6))) { + if ((player->focusActor == NULL) && (yawDiff > (0x10000 / 6))) { distSq = FLT_MAX; } else { distSq = actor->xyzDistToPlayerSq; @@ -2045,7 +2056,7 @@ s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2) { if ((player->actor.flags & ACTOR_FLAG_TALK) && (talkActor != NULL)) { player->talkActor = actor2; - player->lockOnActor = actor2; + player->focusActor = actor2; return true; } @@ -2547,13 +2558,13 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { actor->flags &= ~ACTOR_FLAG_1000000; if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { - if (actor == params->player->lockOnActor) { + if (actor == params->player->focusActor) { actor->isLockedOn = true; } else { actor->isLockedOn = false; } - if ((actor->targetPriority != 0) && (params->player->lockOnActor == NULL)) { + if ((actor->targetPriority != 0) && (params->player->focusActor == NULL)) { actor->targetPriority = 0; } @@ -2682,16 +2693,16 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { } } - actor = player->lockOnActor; + actor = player->focusActor; if ((actor != NULL) && (actor->update == NULL)) { actor = NULL; - Player_Untarget(player); + Player_ReleaseLockOn(player); } if ((actor == NULL) || (player->unk_738 < 5)) { actor = NULL; - if (actorCtx->targetCtx.rotZTick != 0) { - actorCtx->targetCtx.rotZTick = 0; + if (actorCtx->targetCtx.reticleSpinCounter != 0) { + actorCtx->targetCtx.reticleSpinCounter = 0; Audio_PlaySfx(NA_SE_SY_LOCK_OFF); } } @@ -3475,8 +3486,8 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { Actor* newHead; ActorOverlay* overlayEntry = actor->overlayEntry; - if ((player != NULL) && (actor == player->lockOnActor)) { - Player_Untarget(player); + if ((player != NULL) && (actor == player->focusActor)) { + Player_ReleaseLockOn(player); Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), CAM_MODE_NORMAL); } @@ -3550,7 +3561,7 @@ void Target_FindTargetableActorForCategory(PlayState* play, ActorContext* actorC ActorType actorCategory) { f32 distSq; Actor* actor = actorCtx->actorLists[actorCategory].first; - Actor* lockOnActor = player->lockOnActor; + Actor* playerFocusActor = player->focusActor; s32 isNearestTargetableActor; s32 phi_s2_2; @@ -3574,7 +3585,7 @@ void Target_FindTargetableActorForCategory(PlayState* play, ActorContext* actorC } // If this actor is the currently targeted one, then ignore it unless it has the ACTOR_FLAG_80000 flag - if ((actor == lockOnActor) && !(actor->flags & ACTOR_FLAG_80000)) { + if ((actor == playerFocusActor) && !(actor->flags & ACTOR_FLAG_80000)) { continue; } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index c79d9d3632..a81acfc1d6 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -517,7 +517,7 @@ bool Player_CheckHostileLockOn(Player* player) { } bool func_80123434(Player* player) { - return player->stateFlags1 & (PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + return player->stateFlags1 & (PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); } // Unused @@ -525,13 +525,13 @@ bool func_80123448(PlayState* play) { Player* player = GET_PLAYER(play); return (player->stateFlags1 & PLAYER_STATE1_400000) && - (player->transformation != PLAYER_FORM_HUMAN || (!func_80123434(player) && player->lockOnActor == NULL)); + ((player->transformation != PLAYER_FORM_HUMAN) || (!func_80123434(player) && player->focusActor == NULL)); } // TODO: Player_IsGoronOrDeku is a temporary name until we have more info on this function. // Hypothesis: this function checks if the current form would crouch when he tries to use the shield bool Player_IsGoronOrDeku(Player* player) { - return player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_DEKU; + return (player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_DEKU); } bool func_801234D4(PlayState* play) { @@ -1331,35 +1331,53 @@ void Player_UpdateBottleHeld(PlayState* play, Player* player, ItemId itemId, Pla player->itemAction = itemAction; } -void Player_Untarget(Player* player) { - player->lockOnActor = NULL; - player->stateFlags2 &= ~PLAYER_STATE2_2000; +void Player_ReleaseLockOn(Player* player) { + player->focusActor = NULL; + player->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } -void func_80123DC0(Player* player) { +/** + * This function aims to clear Z-Target related state when it isn't in use. + * It also handles setting a specific free fall related state that is interntwined with Z-Targeting. + */ +void Player_ClearZTargeting(Player* player) { if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_800000 | PLAYER_STATE1_8000000)) || (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000)) && ((player->actor.world.pos.y - player->actor.floorHeight) < 100.0f))) { - player->stateFlags1 &= ~(PLAYER_STATE1_8000 | PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000 | - PLAYER_STATE1_80000 | PLAYER_STATE1_40000000); + player->stateFlags1 &= ~(PLAYER_STATE1_8000 | PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000 | + PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000000); } else if (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_200000))) { player->stateFlags1 |= PLAYER_STATE1_80000; } else if ((player->stateFlags1 & PLAYER_STATE1_40000) && (player->transformation == PLAYER_FORM_DEKU)) { player->stateFlags1 &= - ~(PLAYER_STATE1_8000 | PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + ~(PLAYER_STATE1_8000 | PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); } - Player_Untarget(player); + Player_ReleaseLockOn(player); } -void func_80123E90(PlayState* play, Actor* actor) { - Player* player = GET_PLAYER(play); +/** + * Sets the "auto lock-on actor" to lock onto an actor without Player's input. + * This function will first release any existing lock-on or (try to) release parallel. + * + * When using Switch Targeting, it is not possible to carry an auto lock-on actor into a normal + * lock-on when the auto lock-on is finished. + * This is because the `PLAYER_STATE2_LOCK_ON_WITH_SWITCH` flag is never set with an auto lock-on. + * With Hold Targeting it is possible to keep the auto lock-on going by keeping the Z button held down. + * + * The auto lock-on is considered "friendly" even if the actor is actually hostile. If the auto lock-on is hostile, + * Player's battle response will not occur (if he is actionable) and the camera behaves differently. + * When transitioning from auto lock-on to normal lock-on (with Hold Targeting) there will be a noticeable change + * when it switches from "friendly" mode to "hostile" mode. + */ +void Player_SetAutoLockOnActor(PlayState* play, Actor* actor) { + Player* this = GET_PLAYER(play); - func_80123DC0(player); - player->lockOnActor = actor; - player->unk_A78 = actor; - player->stateFlags1 |= PLAYER_STATE1_10000; + Player_ClearZTargeting(this); + this->focusActor = actor; + this->autoLockOnActor = actor; + this->stateFlags1 |= PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, actor); Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_FOLLOWTARGET); } diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index 4ce666d07b..0f450e3447 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -795,10 +795,10 @@ void Boss05_LilyPadWithHead_Move(Boss05* this, PlayState* play) { if (child != NULL) { Player* player2 = GET_PLAYER(play); - if (player2->lockOnActor == &this->dyna.actor) { - player2->lockOnActor = &child->dyna.actor; + if (player2->focusActor == &this->dyna.actor) { + player2->focusActor = &child->dyna.actor; play->actorCtx.targetCtx.fairyActor = &child->dyna.actor; - play->actorCtx.targetCtx.lockOnActor = &child->dyna.actor; + play->actorCtx.targetCtx.reticleActor = &child->dyna.actor; } for (i = 0; i < BIO_DEKU_BABA_LILY_PAD_LIMB_MAX; i++) { @@ -926,10 +926,10 @@ void Boss05_FallingHead_Fall(Boss05* this, PlayState* play) { if (walkingHead != NULL) { Player* player = GET_PLAYER(play); - if (player->lockOnActor == &this->dyna.actor) { - player->lockOnActor = &walkingHead->dyna.actor; + if (player->focusActor == &this->dyna.actor) { + player->focusActor = &walkingHead->dyna.actor; play->actorCtx.targetCtx.fairyActor = &walkingHead->dyna.actor; - play->actorCtx.targetCtx.lockOnActor = &walkingHead->dyna.actor; + play->actorCtx.targetCtx.reticleActor = &walkingHead->dyna.actor; } for (i = 0; i < BIO_DEKU_BABA_HEAD_LIMB_MAX; i++) { diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index cf88d57fef..aacf07e33f 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -636,7 +636,7 @@ void EnAob01_BeforeRace_Talk(EnAob01* this, PlayState* play) { if (this->stateFlags & ENAOB01_FLAG_TALKING_TO_PLAYER_HOLDING_DOG) { if (Actor_TalkOfferAccepted(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); if (this->stateFlags & ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG) { EnAob01_BeforeRace_HandleConversation(this, play); this->stateFlags &= ~ENAOB01_FLAG_PLAYER_TOLD_TO_PICK_A_DOG; @@ -846,7 +846,7 @@ void EnAob01_Race_StartCutscene(EnAob01* this, PlayState* play) { void EnAob01_AfterRace_GiveRaceResult(EnAob01* this, PlayState* play) { if (Actor_TalkOfferAccepted(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); this->rupeesBet = gSaveContext.unk_3F5C; switch (GET_EVENTINF_DOG_RACE_RACE_STANDING) { case 1: 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 00fd4264ec..5984e66d04 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1091,10 +1091,10 @@ void func_8088EFA4(EnElf* this, PlayState* play) { } if (this->fairyFlags & 1) { - if ((targetFairyActor == NULL) || (player->lockOnActor == NULL)) { + if ((targetFairyActor == NULL) || (player->focusActor == NULL)) { this->fairyFlags ^= 1; } - } else if ((targetFairyActor != NULL) && (player->lockOnActor != NULL)) { + } else if ((targetFairyActor != NULL) && (player->focusActor != NULL)) { u8 temp = this->unk_269; u16 targetSfxId = (this->unk_269 == 0) ? NA_SE_NONE : NA_SE_NONE; @@ -1287,8 +1287,8 @@ void func_8088FA38(EnElf* this, PlayState* play) { if (this->unk_234 != NULL) { refPos = this->unk_234->world.pos; } else { - if ((player->lockOnActor == NULL) || (&player->actor == player->lockOnActor) || - (&this->actor == player->lockOnActor) || (this->unk_264 & 4)) { + if ((player->focusActor == NULL) || (&player->actor == player->focusActor) || + (&this->actor == player->focusActor) || (this->unk_264 & 4)) { refPos.x = player->bodyPartsPos[PLAYER_BODYPART_HEAD].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); refPos.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 5.0f; @@ -1464,7 +1464,7 @@ void func_8089010C(Actor* thisx, PlayState* play) { gSaveContext.save.saveInfo.playerData.tatlTimer = 0; } - if ((player->tatlTextId == 0) && (player->lockOnActor == NULL)) { + if ((player->tatlTextId == 0) && (player->focusActor == NULL)) { if ((gSaveContext.save.saveInfo.playerData.tatlTimer >= 600) && (gSaveContext.save.saveInfo.playerData.tatlTimer <= 3000)) { player->tatlTextId = QuestHint_GetTatlTextId(play); diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index eb438457e0..9918341986 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -2178,9 +2178,9 @@ void EnKnight_FlyingHeadDone(EnKnight* this, PlayState* play) { Actor_Kill(&sIgosHeadInstance->actor); sIgosHeadInstance = NULL; this->actor.flags |= ACTOR_FLAG_TARGETABLE; - player->lockOnActor = &this->actor; + player->focusActor = &this->actor; play->actorCtx.targetCtx.fairyActor = &this->actor; - play->actorCtx.targetCtx.lockOnActor = &this->actor; + play->actorCtx.targetCtx.reticleActor = &this->actor; } if (this->timers[0] == 15) { @@ -3256,9 +3256,9 @@ void EnKnight_FlyingHead(EnKnight* this, PlayState* play) { this->actor.world.rot.x = KREG(39) * 0x1000 + 0x2000; this->timers[0] = 20; sIgosInstance->actor.flags &= ~ACTOR_FLAG_TARGETABLE; - player->lockOnActor = &this->actor; + player->focusActor = &this->actor; play->actorCtx.targetCtx.fairyActor = &this->actor; - play->actorCtx.targetCtx.lockOnActor = &this->actor; + play->actorCtx.targetCtx.reticleActor = &this->actor; Math_Vec3f_Copy(&this->actor.world.pos, &sIgosInstance->actor.world.pos); Math_Vec3s_Copy(&this->actor.world.rot, &sIgosInstance->actor.world.rot); Math_Vec3s_Copy(&this->actor.shape.rot, &sIgosInstance->actor.world.rot); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index f29d3e2166..4f778d1874 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -430,7 +430,7 @@ void func_80A6FBFC(EnMm3* this, PlayState* play) { func_80A6F9C8(this); } else { Actor_OfferTalk(&this->actor, play, this->actor.xzDistToPlayer + 10.0f); - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { Audio_PlaySfx(NA_SE_SY_STOPWATCH_TIMER_INF - SFX_FLAG); } else { diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index 9b7bfd026c..dce8b5c870 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -349,7 +349,7 @@ void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, PlayState* play) { if (ABS_ALT(yaw) < 0x2008) { player->actor.freezeTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnRailgibud_SetupWalkToPlayer(this); } @@ -394,7 +394,7 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, PlayState* play) { player->actor.freezeTimer = 40; this->playerStunWaitTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 577adfaecf..4d50257c67 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -661,8 +661,8 @@ void EnRd_WalkToPlayer(EnRd* this, PlayState* play) { if (this->playerStunWaitTimer == 0) { if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 40; - func_80123E90(play, &this->actor); - GET_PLAYER(play)->unk_A78 = &this->actor; + Player_SetAutoLockOnActor(play, &this->actor); + GET_PLAYER(play)->autoLockOnActor = &this->actor; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); } this->playerStunWaitTimer = 60; @@ -925,7 +925,7 @@ void EnRd_AttemptPlayerFreeze(EnRd* this, PlayState* play) { if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); } Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnRd_SetupWalkToPlayer(this, play); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index 677210781e..c6fd124df8 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -313,7 +313,7 @@ void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, PlayState* play) { if (ABS_ALT(yaw) < 0x2008) { player->actor.freezeTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } @@ -358,7 +358,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, PlayState* play) { player->actor.freezeTimer = 40; this->playerStunWaitTimer = 60; Rumble_Request(this->actor.xzDistToPlayer, 255, 20, 150); - func_80123E90(play, &this->actor); + Player_SetAutoLockOnActor(play, &this->actor); Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM); } else { this->playerStunWaitTimer--; diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index df3cec44a4..17886bff3b 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -429,10 +429,10 @@ void func_80BB7578(EnTanron2* this, PlayState* play) { func_80BB6B80(this); this->unk_158 = 1; Actor_PlaySfx(&this->actor, NA_SE_EN_IKURA_DAMAGE); - if ((player->lockOnActor != NULL) && (&this->actor != player->lockOnActor)) { - player->lockOnActor = &this->actor; + if ((player->focusActor != NULL) && (&this->actor != player->focusActor)) { + player->focusActor = &this->actor; play->actorCtx.targetCtx.fairyActor = &this->actor; - play->actorCtx.targetCtx.lockOnActor = &this->actor; + play->actorCtx.targetCtx.reticleActor = &this->actor; } } else { this->unk_154 = 15; diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index c4d79d00e9..fd7d2f40ce 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -325,7 +325,7 @@ s32 func_80A3EA30(EnTest3* this, PlayState* play) { Actor* hideoutDoor = SubS_FindActor(play, NULL, ACTORCAT_BG, ACTOR_BG_IKNV_OBJ); if (hideoutDoor != NULL) { - this->player.lockOnActor = hideoutDoor; + this->player.focusActor = hideoutDoor; } } if (this->unk_D78->unk_1 != 0) { @@ -349,7 +349,7 @@ s32 func_80A3EAF8(EnTest3* this, PlayState* play) { CutsceneManager_Stop(this->csId); this->csId = CS_ID_GLOBAL_TALK; CutsceneManager_Queue(this->csId); - this->player.lockOnActor = &GET_PLAYER(play)->actor; + this->player.focusActor = &GET_PLAYER(play)->actor; } return 1; } @@ -361,7 +361,7 @@ s32 func_80A3EB8C(EnTest3* this, PlayState* play) { Actor* hideoutObject = SubS_FindActor(play, NULL, ACTORCAT_ITEMACTION, ACTOR_OBJ_NOZOKI); if (hideoutObject != NULL) { - this->player.lockOnActor = hideoutObject; + this->player.focusActor = hideoutObject; } play->msgCtx.msgMode = MSGMODE_PAUSED; return 1; @@ -628,7 +628,7 @@ s32 func_80A3F62C(EnTest3* this, PlayState* play, struct_80A41828* arg2, Schedul s32 func_80A3F73C(EnTest3* this, PlayState* play) { if (Actor_TalkOfferAccepted(&this->player.actor, &play->state)) { func_80A3E7E0(this, func_80A4084C); - this->player.lockOnActor = &GET_PLAYER(play)->actor; + this->player.focusActor = &GET_PLAYER(play)->actor; this->player.stateFlags2 &= ~PLAYER_STATE2_40000; D_80A41D5C = true; if ((this->unk_D78->unk_0 == 4) && CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08)) { @@ -982,7 +982,7 @@ void func_80A4084C(EnTest3* this, PlayState* play) { } else { func_80A3E7E0(this, func_80A40678); } - this->player.lockOnActor = NULL; + this->player.focusActor = NULL; } } else if (func_80A3ED24(this, play)) { func_80A3E7E0(this, func_80A40908); @@ -992,7 +992,7 @@ void func_80A4084C(EnTest3* this, PlayState* play) { void func_80A40908(EnTest3* this, PlayState* play) { if (Actor_TalkOfferAccepted(&this->player.actor, &play->state)) { func_80A3E7E0(this, func_80A4084C); - this->player.lockOnActor = &GET_PLAYER(play)->actor; + this->player.focusActor = &GET_PLAYER(play)->actor; SET_WEEKEVENTREG(WEEKEVENTREG_51_08); Message_BombersNotebookQueueEvent(play, BOMBERS_NOTEBOOK_EVENT_RECEIVED_PENDANT_OF_MEMORIES); Message_BombersNotebookQueueEvent(play, BOMBERS_NOTEBOOK_EVENT_MET_KAFEI); @@ -1175,7 +1175,7 @@ void EnTest3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dL (this->player.bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].z + this->player.leftHandWorld.pos.z) / 2.0f; } } else if (limbIndex == KAFEI_LIMB_HEAD) { - Actor* actor730 = this->player.lockOnActor; + Actor* focusActor = this->player.focusActor; if ((*dList1 != NULL) && ((u32)this->player.currentMask != PLAYER_MASK_NONE) && !(this->player.stateFlags2 & PLAYER_STATE2_1000000)) { @@ -1191,8 +1191,8 @@ void EnTest3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dL } } } - if ((actor730 != NULL) && (actor730->id == ACTOR_BG_IKNV_OBJ)) { - Math_Vec3f_Copy(&this->player.actor.focus.pos, &actor730->focus.pos); + if ((focusActor != NULL) && (focusActor->id == ACTOR_BG_IKNV_OBJ)) { + Math_Vec3f_Copy(&this->player.actor.focus.pos, &focusActor->focus.pos); } else { static Vec3f D_80A418CC = { 1100.0f, -700.0f, 0.0f }; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index feb55dea0d..f233a2436d 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3577,7 +3577,7 @@ void func_8082FA5C(PlayState* play, Player* this, PlayerMeleeWeaponState meleeWe } /** - * Checks the current state of `lockOnActor` and if it is a hostile actor (if applicable). + * Checks the current state of `focusActor` and if it is a hostile actor (if applicable). * If so, sets `PLAYER_STATE3_HOSTILE_LOCK_ON` which will control Player's "battle" response to * hostile actors. This includes affecting how movement is handled, and enabling a "fighting" set * of animations. @@ -3588,8 +3588,8 @@ void func_8082FA5C(PlayState* play, Player* this, PlayerMeleeWeaponState meleeWe * @return true if there is curerntly a hostile lock-on actor, false otherwise */ s32 Player_UpdateHostileLockOn(Player* this) { - if ((this->lockOnActor != NULL) && - CHECK_FLAG_ALL(this->lockOnActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE)) { + if ((this->focusActor != NULL) && + CHECK_FLAG_ALL(this->focusActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE)) { this->stateFlags3 |= PLAYER_STATE3_HOSTILE_LOCK_ON; return true; } @@ -4125,7 +4125,7 @@ bool func_80830FD4(PlayState* play) { bool func_80831010(Player* this, PlayState* play) { if ((this->unk_AA5 == PLAYER_UNKAA5_0) || (this->unk_AA5 == PLAYER_UNKAA5_3)) { - if (func_8082FBE8(this) || (this->lockOnActor != NULL) || + if (func_8082FBE8(this) || (this->focusActor != NULL) || (Camera_CheckValidMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_BOWARROW) == 0)) { return true; } @@ -4679,12 +4679,13 @@ void Player_UpdateShapeYaw(Player* this, PlayState* play) { s16 previousYaw = this->actor.shape.rot.y; if (!(this->stateFlags2 & (PLAYER_STATE2_20 | PLAYER_STATE2_40))) { - Actor* lockOnActor = this->lockOnActor; + Actor* focusActor = this->focusActor; - if ((lockOnActor != NULL) && ((play->actorCtx.targetCtx.rotZTick != 0) || (this != GET_PLAYER(play))) && - (lockOnActor->id != ACTOR_OBJ_NOZOKI)) { - Math_ScaledStepToS(&this->actor.shape.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &lockOnActor->focus.pos), 0xFA0); + if ((focusActor != NULL) && + ((play->actorCtx.targetCtx.reticleSpinCounter != 0) || (this != GET_PLAYER(play))) && + (focusActor->id != ACTOR_OBJ_NOZOKI)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &focusActor->focus.pos), + 0xFA0); } else if ((this->stateFlags1 & PLAYER_STATE1_20000) && !(this->stateFlags2 & (PLAYER_STATE2_20 | PLAYER_STATE2_40))) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0xFA0); @@ -4772,7 +4773,7 @@ void func_80832888(Player* this, PlayState* play) { if ((play->csCtx.state != CS_STATE_IDLE) || (this->csAction != PLAYER_CSACTION_NONE) || (this->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) || (this->stateFlags3 & PLAYER_STATE3_80)) { this->unk_738 = 0; - } else if (heldZ || (this->stateFlags2 & PLAYER_STATE2_2000) || (this->unk_A78 != NULL)) { + } else if (heldZ || (this->stateFlags2 & PLAYER_STATE2_LOCK_ON_WITH_SWITCH) || (this->autoLockOnActor != NULL)) { if (this->unk_738 <= 5) { this->unk_738 = 5; } else { @@ -4800,21 +4801,21 @@ void func_80832888(Player* this, PlayState* play) { if ((this->currentMask != PLAYER_MASK_GIANT) && (var_v1_2 != NULL) && !(var_v1_2->flags & ACTOR_FLAG_LOCK_ON_DISABLED) && !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { - if ((var_v1_2 == this->lockOnActor) && (this == GET_PLAYER(play))) { + if ((var_v1_2 == this->focusActor) && (this == GET_PLAYER(play))) { var_v1_2 = play->actorCtx.targetCtx.arrowPointedActor; } if ((var_v1_2 != NULL) && - (((var_v1_2 != this->lockOnActor)) || (var_v1_2->flags & ACTOR_FLAG_80000))) { + (((var_v1_2 != this->focusActor)) || (var_v1_2->flags & ACTOR_FLAG_80000))) { var_v1_2->flags &= ~ACTOR_FLAG_80000; if (!var_a1) { - this->stateFlags2 |= PLAYER_STATE2_2000; + this->stateFlags2 |= PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } - this->lockOnActor = var_v1_2; + this->focusActor = var_v1_2; this->unk_738 = 0xF; this->stateFlags2 &= ~(PLAYER_STATE2_2 | PLAYER_STATE2_200000); } else if (!var_a1) { - Player_Untarget(this); + Player_ReleaseLockOn(this); } this->stateFlags1 &= ~PLAYER_STATE1_40000000; } else if (!(this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) && @@ -4823,32 +4824,32 @@ void func_80832888(Player* this, PlayState* play) { } } - if (this->lockOnActor != NULL) { - if ((this == GET_PLAYER(play)) && (this->lockOnActor != this->unk_A78) && - Target_OutsideLeashRange(this->lockOnActor, this, ignoreLeash)) { - Player_Untarget(this); + if (this->focusActor != NULL) { + if ((this == GET_PLAYER(play)) && (this->focusActor != this->autoLockOnActor) && + Target_OutsideLeashRange(this->focusActor, this, ignoreLeash)) { + Player_ReleaseLockOn(this); this->stateFlags1 |= PLAYER_STATE1_40000000; - } else if (this->lockOnActor != NULL) { - this->lockOnActor->targetPriority = 0x28; + } else if (this->focusActor != NULL) { + this->focusActor->targetPriority = 0x28; } - } else if (this->unk_A78 != NULL) { - this->lockOnActor = this->unk_A78; + } else if (this->autoLockOnActor != NULL) { + this->focusActor = this->autoLockOnActor; } } - if ((this->lockOnActor != NULL) && !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { - this->stateFlags1 &= ~(PLAYER_STATE1_10000 | PLAYER_STATE1_20000); + if ((this->focusActor != NULL) && !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { + this->stateFlags1 &= ~(PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000); if ((this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) || - !CHECK_FLAG_ALL(this->lockOnActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE)) { - this->stateFlags1 |= PLAYER_STATE1_10000; + !CHECK_FLAG_ALL(this->focusActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE)) { + this->stateFlags1 |= PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS; } } else if (this->stateFlags1 & PLAYER_STATE1_20000) { - this->stateFlags2 &= ~PLAYER_STATE2_2000; + this->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } else { - func_80123DC0(this); + Player_ClearZTargeting(this); } } else { - func_80123DC0(this); + Player_ClearZTargeting(this); } } @@ -4921,7 +4922,7 @@ s32 Player_CalcSpeedAndYawFromControlStick(PlayState* play, Player* this, f32* o f32 var_fa1; if (this->unk_AB8 != 0.0f) { - var_fa1 = (this->lockOnActor != NULL) ? 0.002f : 0.008f; + var_fa1 = (this->focusActor != NULL) ? 0.002f : 0.008f; speedCap -= this->unk_AB8 * var_fa1; speedCap = CLAMP_MIN(speedCap, 2.0f); @@ -4962,9 +4963,9 @@ s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYaw if (!Player_CalcSpeedAndYawFromControlStick(play, this, outSpeedTarget, outYawTarget, speedMode)) { *outYawTarget = this->actor.shape.rot.y; - if (this->lockOnActor != NULL) { - if ((play->actorCtx.targetCtx.rotZTick != 0) && !(this->stateFlags2 & PLAYER_STATE2_40)) { - *outYawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &this->lockOnActor->focus.pos); + if (this->focusActor != NULL) { + if ((play->actorCtx.targetCtx.reticleSpinCounter != 0) && !(this->stateFlags2 & PLAYER_STATE2_40)) { + *outYawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &this->focusActor->focus.pos); } } else if (func_80123434(this)) { *outYawTarget = this->targetYaw; @@ -5237,8 +5238,8 @@ void func_808332A0(PlayState* play, Player* this, s32 magicCost, s32 isSwordBeam Actor* thunder; if (isSwordBeam) { - if (this->lockOnActor != NULL) { - pitch = Math_Vec3f_Pitch(&this->bodyPartsPos[PLAYER_BODYPART_WAIST], &this->lockOnActor->focus.pos); + if (this->focusActor != NULL) { + pitch = Math_Vec3f_Pitch(&this->bodyPartsPos[PLAYER_BODYPART_WAIST], &this->focusActor->focus.pos); } if (gSaveContext.save.saveInfo.playerData.magic == 0) { return; @@ -7066,7 +7067,7 @@ void func_80837B60(PlayState* play, Player* this) { if (this->actor.textId != 0) { Message_StartTextbox(play, this->actor.textId, this->talkActor); } - this->lockOnActor = this->talkActor; + this->focusActor = this->talkActor; } void func_80837BD0(PlayState* play, Player* this) { @@ -7621,14 +7622,14 @@ s32 Player_ActionChange_13(Player* this, PlayState* play) { this->stateFlags1 |= PLAYER_STATE1_20000000; this->av2.actionVar2 = 80; this->av1.actionVar1 = -1; - this->lockOnActor = this->talkActor; + this->focusActor = this->talkActor; } else { this->csId = CS_ID_GLOBAL_TALK; } talkActor->flags |= ACTOR_FLAG_TALK; this->actor.textId = 0; - this->lockOnActor = this->talkActor; + this->focusActor = this->talkActor; } else { this->stateFlags1 |= (PLAYER_STATE1_20000000 | PLAYER_STATE1_10000000 | PLAYER_STATE1_40); this->csId = play->playerCsIds[PLAYER_CS_ID_ITEM_SHOW]; @@ -7720,7 +7721,7 @@ s32 Player_ActionChange_13(Player* this, PlayState* play) { s32 Player_ActionChange_4(Player* this, PlayState* play) { if (gSaveContext.save.saveInfo.playerData.health != 0) { Actor* talkActor = this->talkActor; - Actor* lockOnActor = this->lockOnActor; + Actor* lockOnActor = this->focusActor; Actor* var_a1 = NULL; s32 var_t1 = false; s32 var_t2 = false; @@ -7807,9 +7808,9 @@ s32 Player_ActionChange_0(Player* this, PlayState* play) { if (this->unk_AA5 != PLAYER_UNKAA5_0) { Player_ActionChange_13(this, play); return true; - } else if ((this->lockOnActor != NULL) && - (CHECK_FLAG_ALL(this->lockOnActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_40000) || - (this->lockOnActor->hintId != TATL_HINT_ID_NONE))) { + } else if ((this->focusActor != NULL) && + (CHECK_FLAG_ALL(this->focusActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_40000) || + (this->focusActor->hintId != TATL_HINT_ID_NONE))) { this->stateFlags2 |= PLAYER_STATE2_200000; } else if ((this->tatlTextId == 0) && !Player_CheckHostileLockOn(this) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_CUP) && @@ -8092,7 +8093,7 @@ s32 Player_ActionChange_11(Player* this, PlayState* play) { if (Player_IsGoronOrDeku(this) || ((((this->transformation == PLAYER_FORM_ZORA) && !(this->stateFlags1 & PLAYER_STATE1_2000000)) || ((this->transformation == PLAYER_FORM_HUMAN) && (this->currentShield != PLAYER_SHIELD_NONE))) && - !func_80123434(this) && (this->lockOnActor == NULL))) { + !func_80123434(this) && (this->focusActor == NULL))) { func_8082DC38(this); Player_DetachHeldActor(play, this); if (Player_SetAction(play, this, Player_Action_18, 0)) { @@ -8852,7 +8853,7 @@ void func_8083BF54(PlayState* play, Player* this) { } s32 func_8083C62C(Player* this, s32 arg1) { - Actor* lockOnActor = this->lockOnActor; + Actor* focusActor = this->focusActor; Vec3f headPos; s16 pitchTarget; s16 yawTarget; @@ -8861,8 +8862,8 @@ s32 func_8083C62C(Player* this, s32 arg1) { headPos.y = this->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; headPos.z = this->actor.world.pos.z; - pitchTarget = Math_Vec3f_Pitch(&headPos, &lockOnActor->focus.pos); - yawTarget = Math_Vec3f_Yaw(&headPos, &lockOnActor->focus.pos); + pitchTarget = Math_Vec3f_Pitch(&headPos, &focusActor->focus.pos); + yawTarget = Math_Vec3f_Yaw(&headPos, &focusActor->focus.pos); Math_SmoothStepToS(&this->actor.focus.rot.y, yawTarget, 4, 0x2710, 0); Math_SmoothStepToS(&this->actor.focus.rot.x, pitchTarget, 4, 0x2710, 0); @@ -8875,7 +8876,7 @@ s32 func_8083C62C(Player* this, s32 arg1) { Vec3f D_8085D218 = { 0.0f, 100.0f, 40.0f }; void func_8083C6E8(Player* this, PlayState* play) { - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { if (func_800B7128(this) || func_8082EF20(this)) { func_8083C62C(this, true); } else { @@ -9555,7 +9556,7 @@ s32 func_8083E404(Player* this, f32 arg1, s16 arg2) { f32 sp1C = BINANG_SUB(arg2, this->actor.shape.rot.y); f32 temp_fv1; - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { func_8083C62C(this, func_800B7128(this) || func_8082EF20(this)); } @@ -9574,7 +9575,7 @@ s32 func_8083E514(Player* this, f32* arg2, s16* arg3, PlayState* play) { s16 temp_v1 = *arg3 - this->targetYaw; u16 var_a2 = ABS_ALT(temp_v1); - if ((func_800B7128(this) || func_8082EF20(this)) && (this->lockOnActor == NULL)) { + if ((func_800B7128(this) || func_8082EF20(this)) && (this->focusActor == NULL)) { *arg2 *= Math_SinS(var_a2); if (*arg2 != 0.0f) { @@ -9583,14 +9584,14 @@ s32 func_8083E514(Player* this, f32* arg2, s16* arg3, PlayState* play) { *arg3 = this->actor.shape.rot.y; } - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { func_8083C62C(this, true); } else { Math_SmoothStepToS(&this->actor.focus.rot.x, (sPlayerControlInput->rel.stick_y * 240.0f), 0xE, 0xFA0, 0x1E); func_80832754(this, true); } } else { - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { return func_8083E404(this, *arg2, *arg3); } @@ -9715,7 +9716,7 @@ void Player_ChooseIdleAnim(PlayState* play, Player* this) { if (((this->actor.id != ACTOR_PLAYER) && !(healthIsCritical = (this->actor.colChkInfo.health < 0x64))) || ((this->actor.id == ACTOR_PLAYER) && - (((this->lockOnActor != NULL) || + (((this->focusActor != NULL) || ((this->transformation != PLAYER_FORM_FIERCE_DEITY) && (this->transformation != PLAYER_FORM_HUMAN)) || (this->currentMask == PLAYER_MASK_SCENTS)) || (!(healthIsCritical = LifeMeter_IsCritical()) && (this->unk_AA4 = ((this->unk_AA4 + 1) & 1)))))) { @@ -11229,7 +11230,7 @@ void Player_SetDoAction(PlayState* play, Player* this) { // Set Tatl state if (!Play_InCsMode(play) && (this->stateFlags2 & PLAYER_STATE2_200000) && !(this->stateFlags3 & PLAYER_STATE3_100)) { - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { Interface_SetTatlCall(play, TATL_STATE_2B); } else { Interface_SetTatlCall(play, TATL_STATE_2A); @@ -11605,10 +11606,10 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { } } else if (this->stateFlags2 & PLAYER_STATE2_100) { camMode = CAM_MODE_PUSHPULL; - } else if (this->lockOnActor != NULL) { + } else if (this->focusActor != NULL) { if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_TALK)) { camMode = CAM_MODE_TALK; - } else if (this->stateFlags1 & PLAYER_STATE1_10000) { + } else if (this->stateFlags1 & PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS) { if (this->stateFlags1 & PLAYER_STATE1_2000000) { camMode = CAM_MODE_FOLLOWBOOMERANG; } else { @@ -11617,7 +11618,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { } else { camMode = CAM_MODE_BATTLE; } - Camera_SetViewParam(camera, CAM_VIEW_TARGET, this->lockOnActor); + Camera_SetViewParam(camera, CAM_VIEW_TARGET, this->focusActor); } else if (this->stateFlags1 & PLAYER_STATE1_1000) { camMode = CAM_MODE_CHARGE; } else if (this->stateFlags3 & PLAYER_STATE3_100) { @@ -12284,8 +12285,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Lights_PointSetPosition(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z); - if (((this->lockOnActor == NULL) || (this->lockOnActor == this->talkActor) || - (this->lockOnActor->hintId == TATL_HINT_ID_NONE)) && + if (((this->focusActor == NULL) || (this->focusActor == this->talkActor) || + (this->focusActor->hintId == TATL_HINT_ID_NONE)) && (this->tatlTextId == 0)) { this->stateFlags2 &= ~(PLAYER_STATE2_2 | PLAYER_STATE2_200000); } @@ -12349,7 +12350,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->closestSecretDistSq = FLT_MAX; this->doorType = PLAYER_DOORTYPE_NONE; this->unk_B75 = 0; - this->unk_A78 = NULL; + this->autoLockOnActor = NULL; Math_StepToF(&this->windSpeed, 0.0f, 0.5f); if ((this->unk_B62 != 0) || @@ -13676,13 +13677,13 @@ s32 Player_UpperAction_14(Player* this, PlayState* play) { untargetedRotY = this->actor.shape.rot.y - 0x190; this->boomerangActor = Actor_Spawn( &play->actorCtx, play, ACTOR_EN_BOOM, pos.x, pos.y, pos.z, this->actor.focus.rot.x, - (this->lockOnActor != NULL) ? this->actor.shape.rot.y + 0x36B0 : untargetedRotY, 0, ZORA_BOOMERANG_LEFT); + (this->focusActor != NULL) ? this->actor.shape.rot.y + 0x36B0 : untargetedRotY, 0, ZORA_BOOMERANG_LEFT); if (this->boomerangActor != NULL) { EnBoom* leftBoomerang = (EnBoom*)this->boomerangActor; EnBoom* rightBoomerang; - leftBoomerang->moveTo = this->lockOnActor; + leftBoomerang->moveTo = this->focusActor; if (leftBoomerang->moveTo != NULL) { leftBoomerang->unk_1CF = 0x10; } @@ -13693,11 +13694,11 @@ s32 Player_UpperAction_14(Player* this, PlayState* play) { untargetedRotY = (this->actor.shape.rot.y + 0x190); rightBoomerang = (EnBoom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOOM, pos.x, pos.y, pos.z, this->actor.focus.rot.x, - (this->lockOnActor != NULL) ? this->actor.shape.rot.y - 0x36B0 : untargetedRotY, 0, + (this->focusActor != NULL) ? this->actor.shape.rot.y - 0x36B0 : untargetedRotY, 0, ZORA_BOOMERANG_RIGHT); if (rightBoomerang != NULL) { - rightBoomerang->moveTo = this->lockOnActor; + rightBoomerang->moveTo = this->focusActor; if (rightBoomerang->moveTo != NULL) { rightBoomerang->unk_1CF = 0x10; } @@ -14248,7 +14249,7 @@ void Player_Action_10(Player* this, PlayState* play) { Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_CURVED, play); - if ((this != GET_PLAYER(play)) && (this->lockOnActor == NULL)) { + if ((this != GET_PLAYER(play)) && (this->focusActor == NULL)) { yawTarget = this->actor.home.rot.y; } @@ -15586,7 +15587,7 @@ void Player_Action_43(Player* this, PlayState* play) { if (((this->unk_AA5 == PLAYER_UNKAA5_2) && !(play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON)) || ((this->unk_AA5 != PLAYER_UNKAA5_2) && ((((this->csAction != PLAYER_CSACTION_NONE) || ((u32)this->unk_AA5 == PLAYER_UNKAA5_0) || - (this->unk_AA5 >= PLAYER_UNKAA5_5) || Player_UpdateHostileLockOn(this) || (this->lockOnActor != NULL) || + (this->unk_AA5 >= PLAYER_UNKAA5_5) || Player_UpdateHostileLockOn(this) || (this->focusActor != NULL) || (func_8083868C(play, this) == CAM_MODE_NORMAL) || ((this->unk_AA5 == PLAYER_UNKAA5_3) && (((Player_ItemToItemAction(this, Inventory_GetBtnBItem(play)) != this->heldItemAction) && @@ -15618,7 +15619,7 @@ void Player_Action_44(Player* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actor.flags &= ~ACTOR_FLAG_TALK; if (!CHECK_FLAG_ALL(this->talkActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_HOSTILE)) { - this->stateFlags2 &= ~PLAYER_STATE2_2000; + this->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); @@ -15662,7 +15663,7 @@ void Player_Action_44(Player* this, PlayState* play) { } } - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { this->currentYaw = func_8083C62C(this, false); this->actor.shape.rot.y = this->currentYaw; if (this->av1.actionVar1 != 0) { @@ -16096,7 +16097,7 @@ void func_8084FD7C(PlayState* play, Player* this, Actor* actor) { } bool func_8084FE48(Player* this) { - return (this->lockOnActor == NULL) && !func_8082FC24(this); + return (this->focusActor == NULL) && !func_8082FC24(this); } PlayerAnimationHeader* D_8085D688[] = { @@ -16287,7 +16288,7 @@ void Player_Action_52(Player* this, PlayState* play) { } else if ((this->csAction != PLAYER_CSACTION_NONE) || (!func_8082DAFC(play) && ((rideActor->actor.speed != 0.0f) || !Player_ActionChange_4(this, play)) && !func_80847BF0(this, play) && !Player_ActionChange_13(this, play))) { - if (this->lockOnActor != NULL) { + if (this->focusActor != NULL) { if (func_800B7128(this)) { this->upperLimbRot.y = func_8083C62C(this, true) - this->actor.shape.rot.y; this->upperLimbRot.y = CLAMP(this->upperLimbRot.y, -0x4AAA, 0x4AAA); @@ -17565,7 +17566,7 @@ void Player_Action_71(Player* this, PlayState* play) { Player_PlayAnimSfx(this, D_8085D840); } - if ((this->av1.actionVar1 == 0) && (this->lockOnActor != NULL)) { + if ((this->av1.actionVar1 == 0) && (this->focusActor != NULL)) { this->currentYaw = func_8083C62C(this, 0); this->actor.shape.rot.y = this->currentYaw; } @@ -19575,7 +19576,7 @@ void func_80859248(Player* this) { if ((this->csActor == NULL) || (this->csActor->update == NULL)) { this->csActor = NULL; } - this->lockOnActor = this->csActor; + this->focusActor = this->csActor; if (this->csActor != NULL) { this->actor.shape.rot.y = func_8083C62C(this, 0); } @@ -20660,7 +20661,7 @@ void Player_TalkWithPlayer(PlayState* play, Actor* actor) { player->talkActor = actor; player->exchangeItemAction = PLAYER_IA_NONE; - player->lockOnActor = actor; + player->focusActor = actor; if (actor->textId == 0xFFFF) { Player_SetCsActionWithHaltedActors(play, actor, PLAYER_CSACTION_1); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6ce2fae6c7..9c20569560 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -669,8 +669,8 @@ 0x800B4AEC:("func_800B4AEC",), 0x800B4B50:("func_800B4B50",), 0x800B4EDC:("Actor_GetProjectedPos",), - 0x800B4F40:("Target_SetLockOnPos",), - 0x800B4F78:("Target_InitLockOn",), + 0x800B4F40:("Target_SetReticlePos",), + 0x800B4F78:("Target_InitReticle",), 0x800B5040:("Target_SetFairyState",), 0x800B51A4:("Target_Init",), 0x800B5208:("Target_Draw",), @@ -2208,9 +2208,9 @@ 0x80123C58:("func_80123C58",), 0x80123C90:("Player_SetEquipmentData",), 0x80123D50:("Player_UpdateBottleHeld",), - 0x80123DA4:("Player_Untarget",), - 0x80123DC0:("func_80123DC0",), - 0x80123E90:("func_80123E90",), + 0x80123DA4:("Player_ReleaseLockOn",), + 0x80123DC0:("Player_ClearZTargeting",), + 0x80123E90:("Player_SetAutoLockOnActor",), 0x80123F14:("func_80123F14",), 0x80123F2C:("Player_SetBButtonAmmo",), 0x80123F48:("Player_IsBurningStickInRange",), diff --git a/tools/namefixer.py b/tools/namefixer.py index df5bf72e5c..b5389b2725 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -127,7 +127,7 @@ wordReplace = { "func_800B78B8": "Actor_UpdateBgCheckInfo", "func_80123D50": "Player_UpdateBottleHeld", - "func_80123DA4": "Player_Untarget", + "func_80123DA4": "Player_ReleaseLockOn", "func_8012403C": "Player_GetMask", "func_8012404c": "Player_RemoveMask", "func_80123AA4": "Player_SetModels", @@ -1219,8 +1219,8 @@ wordReplace = { "player->unk_B84": "player->pushedYaw", "player->targetActor": "player->talkActor", "player->targetActorDistance": "player->talkActorDistance", - "player->unk_730": "player->lockOnActor", - "player->targetedActor": "player->lockOnActor", + "player->unk_730": "player->focusActor", + "player->targetedActor": "player->focusActor", "ageProperties->unk_04": "ageProperties->shadowScale", "ageProperties->unk_92": "ageProperties->voiceSfxOffset", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index d07ea2f7c5..527af4594d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -183,8 +183,8 @@ asm/non_matchings/code/z_actor/Actor_SetFeetPos.s,Actor_SetFeetPos,0x800B4A98,0x asm/non_matchings/code/z_actor/func_800B4AEC.s,func_800B4AEC,0x800B4AEC,0x19 asm/non_matchings/code/z_actor/func_800B4B50.s,func_800B4B50,0x800B4B50,0xE3 asm/non_matchings/code/z_actor/Actor_GetProjectedPos.s,Actor_GetProjectedPos,0x800B4EDC,0x19 -asm/non_matchings/code/z_actor/Target_SetLockOnPos.s,Target_SetLockOnPos,0x800B4F40,0xE -asm/non_matchings/code/z_actor/Target_InitLockOn.s,Target_InitLockOn,0x800B4F78,0x32 +asm/non_matchings/code/z_actor/Target_SetReticlePos.s,Target_SetReticlePos,0x800B4F40,0xE +asm/non_matchings/code/z_actor/Target_InitReticle.s,Target_InitReticle,0x800B4F78,0x32 asm/non_matchings/code/z_actor/Target_SetFairyState.s,Target_SetFairyState,0x800B5040,0x59 asm/non_matchings/code/z_actor/Target_Init.s,Target_Init,0x800B51A4,0x19 asm/non_matchings/code/z_actor/Target_Draw.s,Target_Draw,0x800B5208,0x183 @@ -1722,9 +1722,9 @@ asm/non_matchings/code/z_player_lib/Player_SetModelGroup.s,Player_SetModelGroup, asm/non_matchings/code/z_player_lib/func_80123C58.s,func_80123C58,0x80123C58,0xE asm/non_matchings/code/z_player_lib/Player_SetEquipmentData.s,Player_SetEquipmentData,0x80123C90,0x30 asm/non_matchings/code/z_player_lib/Player_UpdateBottleHeld.s,Player_UpdateBottleHeld,0x80123D50,0x15 -asm/non_matchings/code/z_player_lib/Player_Untarget.s,Player_Untarget,0x80123DA4,0x7 -asm/non_matchings/code/z_player_lib/func_80123DC0.s,func_80123DC0,0x80123DC0,0x34 -asm/non_matchings/code/z_player_lib/func_80123E90.s,func_80123E90,0x80123E90,0x21 +asm/non_matchings/code/z_player_lib/Player_ReleaseLockOn.s,Player_ReleaseLockOn,0x80123DA4,0x7 +asm/non_matchings/code/z_player_lib/Player_ClearZTargeting.s,Player_ClearZTargeting,0x80123DC0,0x34 +asm/non_matchings/code/z_player_lib/Player_SetAutoLockOnActor.s,Player_SetAutoLockOnActor,0x80123E90,0x21 asm/non_matchings/code/z_player_lib/func_80123F14.s,func_80123F14,0x80123F14,0x6 asm/non_matchings/code/z_player_lib/Player_SetBButtonAmmo.s,Player_SetBButtonAmmo,0x80123F2C,0x7 asm/non_matchings/code/z_player_lib/Player_IsBurningStickInRange.s,Player_IsBurningStickInRange,0x80123F48,0x36