summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorengineer124 <47598039+engineer124@users.noreply.github.com>2024-11-08 11:54:21 +1100
committerGitHub <noreply@github.com>2024-11-07 16:54:21 -0800
commit9cd9099a0431b369be39f111bf57051f544bead3 (patch)
tree53b87def1d4845e71284c638793c3aa93965df1a /src/code
parent318e39127243263b93da5e3b02cbfbb4152ae743 (diff)
Player Docs: Z Targeting (#1736)
* z target docs * Player_UpdateZTargeting * func docs * more cleanup
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c2
-rw-r--r--src/code/z_player_lib.c33
2 files changed, 27 insertions, 8 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 621b4856a..dbc28a11b 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -2738,7 +2738,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
Player_ReleaseLockOn(player);
}
- if ((actor == NULL) || (player->unk_738 < 5)) {
+ if ((actor == NULL) || (player->zTargetActiveTimer < 5)) {
actor = NULL;
if (actorCtx->attention.reticleSpinCounter != 0) {
actorCtx->attention.reticleSpinCounter = 0;
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 88e2a57c3..5f799e822 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -668,8 +668,25 @@ bool Player_CheckHostileLockOn(Player* player) {
return player->stateFlags3 & PLAYER_STATE3_HOSTILE_LOCK_ON;
}
-bool func_80123434(Player* player) {
- return player->stateFlags1 & (PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000);
+/**
+ * This function checks for friendly (non-hostile) Z-Target related states.
+ * For hostile related lock-on states, see `Player_UpdateHostileLockOn` and `Player_CheckHostileLockOn`.
+ *
+ * Note that `PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS` will include all `focusActor` use cases that relate to
+ * friendly actors. This function can return true when talking to an actor, for example.
+ * Despite that, this function is only relevant in the context of actor lock-on, which is a subset of actor focus.
+ * This is why the function name states `FriendlyLockOn` instead of `FriendlyActorFocus`.
+ *
+ * There is a special case that allows hostile actors to be treated as "friendly" if Player is carrying another actor
+ * See relevant code in `Player_UpdateZTargeting` for more details.
+ *
+ * Additionally, `PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE` will be set very briefly in some conditions when
+ * a lock-on is forced to release. In these niche cases, this function will apply to both friendly and hostile actors.
+ * Overall, it is safe to assume that this specific state flag is not very relevant for this function's use cases.
+ */
+bool Player_FriendlyLockOnOrParallel(Player* player) {
+ return player->stateFlags1 &
+ (PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE);
}
// Unused
@@ -677,7 +694,8 @@ 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->focusActor == NULL));
+ ((player->transformation != PLAYER_FORM_HUMAN) ||
+ (!Player_FriendlyLockOnOrParallel(player) && (player->focusActor == NULL)));
}
// TODO: Player_IsGoronOrDeku is a temporary name until we have more info on this function.
@@ -1497,13 +1515,14 @@ void Player_ClearZTargeting(Player* player) {
(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_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000 |
- PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000000);
+ player->stateFlags1 &=
+ ~(PLAYER_STATE1_Z_TARGETING | PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_PARALLEL |
+ PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE);
} 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_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000);
+ player->stateFlags1 &= ~(PLAYER_STATE1_Z_TARGETING | PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS |
+ PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE);
}
Player_ReleaseLockOn(player);