1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-29 00:06:33 +00:00

Document zTargetActiveTimer (#2200)

* document zTargetActiveTimer

* edit comments

* Update src/overlays/actors/ovl_player_actor/z_player.c

Co-authored-by: cadmic <cadmic24@gmail.com>

* capitalization

---------

Co-authored-by: cadmic <cadmic24@gmail.com>
This commit is contained in:
fig02 2024-09-16 12:34:23 -04:00 committed by GitHub
parent 2740bb020e
commit c91e62f000
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 14 deletions

View file

@ -797,7 +797,7 @@ typedef struct Player {
/* 0x05E4 */ ColliderQuad shieldQuad;
/* 0x0664 */ Actor* focusActor; // Actor that Player and the camera are looking at; Used for lock-on, talking, and more
/* 0x0668 */ char unk_668[0x004];
/* 0x066C */ s32 unk_66C;
/* 0x066C */ s32 zTargetActiveTimer; // Non-zero values indicate Z-Targeting should update; Values under 5 indicate lock-on is releasing
/* 0x0670 */ s32 meleeWeaponEffectIndex;
/* 0x0674 */ PlayerActionFunc actionFunc;
/* 0x0678 */ PlayerAgeProperties* ageProperties;

View file

@ -2413,7 +2413,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
func_8008EDF0(player);
}
if ((actor == NULL) || (player->unk_66C < 5)) {
if ((actor == NULL) || (player->zTargetActiveTimer < 5)) {
actor = NULL;
if (actorCtx->attention.reticleSpinCounter != 0) {

View file

@ -3609,26 +3609,39 @@ void func_80836BEC(Player* this, PlayState* play) {
if ((play->csCtx.state != CS_STATE_IDLE) || (this->csAction != PLAYER_CSACTION_NONE) ||
(this->stateFlags1 & (PLAYER_STATE1_7 | PLAYER_STATE1_29)) ||
(this->stateFlags3 & PLAYER_STATE3_FLYING_WITH_HOOKSHOT)) {
this->unk_66C = 0;
// Don't allow Z-Targeting in various states
this->zTargetActiveTimer = 0;
} else if (zButtonHeld || (this->stateFlags2 & PLAYER_STATE2_LOCK_ON_WITH_SWITCH) || (this->unk_684 != NULL)) {
if (this->unk_66C <= 5) {
this->unk_66C = 5;
// While a lock-on is active, decrement the timer and hold it at 5.
// Values under 5 indicate a lock-on has ended and will make the reticle release.
// See usage toward the end of `Actor_UpdateAll`.
//
// `zButtonHeld` will also be true for Parallel. This is necessary because the timer
// needs to be non-zero for `Player_SetParallel` to be able to run below.
if (this->zTargetActiveTimer <= 5) {
this->zTargetActiveTimer = 5;
} else {
this->unk_66C--;
this->zTargetActiveTimer--;
}
} else if (this->stateFlags1 & PLAYER_STATE1_PARALLEL) {
this->unk_66C = 0;
} else if (this->unk_66C != 0) {
this->unk_66C--;
}
if (this->unk_66C >= 6) {
// If the above code block which checks `zButtonHeld` is not taken, that means Z has been released.
// In that case, setting `zTargetActiveTimer` to 0 will stop Parallel if it is currently active.
this->zTargetActiveTimer = 0;
} else if (this->zTargetActiveTimer != 0) {
this->zTargetActiveTimer--;
}
if (this->zTargetActiveTimer >= 6) {
// When a lock-on is started, `zTargetActiveTimer` will be set to 15 and then immediately start decrementing
// down to 5. During this 10 frame period, set `ignoreLeash` so that the lock-on will temporarily
// have an infinite leash distance.
// This gives time for the reticle to settle while it locks on, even if the player leaves the leash range.
ignoreLeash = true;
}
isTalking = func_8083224C(play);
if (isTalking || (this->unk_66C != 0) ||
if (isTalking || (this->zTargetActiveTimer != 0) ||
(this->stateFlags1 & (PLAYER_STATE1_12 | PLAYER_STATE1_BOOMERANG_THROWN))) {
if (!isTalking) {
if (!(this->stateFlags1 & PLAYER_STATE1_BOOMERANG_THROWN) &&
@ -3666,7 +3679,7 @@ void func_80836BEC(Player* this, PlayState* play) {
}
this->focusActor = nextLockOnActor;
this->unk_66C = 15;
this->zTargetActiveTimer = 15;
this->stateFlags2 &= ~(PLAYER_STATE2_1 | PLAYER_STATE2_21);
} else {
if (!usingHoldTargeting) {
@ -3676,6 +3689,7 @@ void func_80836BEC(Player* this, PlayState* play) {
this->stateFlags1 &= ~PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE;
} else {
// Lock-on was not started above. Set Parallel Mode.
if (!(this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE))) {
Player_SetParallel(this);
}