summaryrefslogtreecommitdiff
path: root/src/code/z_player_lib.c
diff options
context:
space:
mode:
authorengineer124 <47598039+engineer124@users.noreply.github.com>2024-10-16 11:52:45 +1100
committerGitHub <noreply@github.com>2024-10-15 17:52:45 -0700
commit86d8dc6a9fa722ffac83e01c57d4be37370c6a6d (patch)
tree2c2da64e50250b65678f3339cd9d78d1680d3c0b /src/code/z_player_lib.c
parent917d2149516e08531b6fc543b98caecec3dfc0ef (diff)
Player Docs: FocusActor and Lock-On Cleanup (#1711)
* focus actor docs * small cleanup * brackets * remaining lock-on docs * more cleanup/docs * more reticle docs * oops
Diffstat (limited to 'src/code/z_player_lib.c')
-rw-r--r--src/code/z_player_lib.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index c79d9d363..a81acfc1d 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);
}