diff --git a/include/z64player.h b/include/z64player.h index bda016cb73..37055e4c75 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -899,12 +899,12 @@ typedef enum PlayerCueId { #define PLAYER_STATE1_2000 (1 << 13) // #define PLAYER_STATE1_4000 (1 << 14) -// -#define PLAYER_STATE1_8000 (1 << 15) +// Either lock-on or parallel is active. This flag is never checked for and is practically unused. +#define PLAYER_STATE1_Z_TARGETING (1 << 15) // 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) +// "Parallel" mode, Z-Target without an actor lock-on +#define PLAYER_STATE1_PARALLEL (1 << 17) // #define PLAYER_STATE1_40000 (1 << 18) // @@ -929,8 +929,8 @@ typedef enum PlayerCueId { #define PLAYER_STATE1_10000000 (1 << 28) // Time is stopped but Link & NPC animations continue #define PLAYER_STATE1_20000000 (1 << 29) -// -#define PLAYER_STATE1_40000000 (1 << 30) +// Lock-on was released automatically, for example by leaving the lock-on leash range +#define PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE (1 << 30) // Related to exit a grotto #define PLAYER_STATE1_80000000 (1 << 31) @@ -1202,7 +1202,7 @@ typedef struct Player { /* 0x6E4 */ ColliderCylinder shieldCylinder; /* 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; + /* 0x738 */ s32 zTargetActiveTimer; // Non-zero values indicate Z-Targeting should update; Values under 5 indicate lock-on is releasing /* 0x73C */ s32 meleeWeaponEffectIndex[3]; /* 0x748 */ PlayerActionFunc actionFunc; /* 0x74C */ u8 jointTableBuffer[PLAYER_LIMB_BUF_SIZE]; @@ -1390,7 +1390,7 @@ void func_80123140(struct PlayState* play, Player* player); bool Player_InBlockingCsMode(struct PlayState* play, Player* player); bool Player_InCsMode(struct PlayState* play); bool Player_CheckHostileLockOn(Player* player); -bool func_80123434(Player* player); +bool Player_FriendlyLockOnOrParallel(Player* player); bool func_80123448(struct PlayState* play); bool Player_IsGoronOrDeku(Player* player); bool func_801234D4(struct PlayState* play); diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 621b4856a0..dbc28a11ba 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 88e2a57c3f..5f799e822d 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); diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index d1ec573f0a..3e897b2546 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3708,7 +3708,7 @@ void func_8082FA5C(PlayState* play, Player* this, PlayerMeleeWeaponState meleeWe * Note that `Player_CheckHostileLockOn` also exists to check if there is currently a hostile lock-on actor. * This function differs in that it first updates the flag if appropriate, then returns the same information. * - * @return true if there is curerntly a hostile lock-on actor, false otherwise + * @return true if there is currently a hostile lock-on actor, false otherwise */ s32 Player_UpdateHostileLockOn(Player* this) { if ((this->focusActor != NULL) && @@ -3729,12 +3729,26 @@ s32 Player_UpdateHostileLockOn(Player* this) { return false; } -bool func_8082FBE8(Player* this) { - return Player_CheckHostileLockOn(this) || func_80123434(this); +/** + * Returns true if currently Z-Targeting, false if not. + * Z-Targeting here is a blanket term that covers both the "actor lock-on" and "parallel" states. + * + * This variant of the function calls `Player_CheckHostileLockOn`, which does not update the hostile + * lock-on actor state. + */ +bool Player_IsZTargeting(Player* this) { + return Player_CheckHostileLockOn(this) || Player_FriendlyLockOnOrParallel(this); } -bool func_8082FC24(Player* this) { - return Player_UpdateHostileLockOn(this) || func_80123434(this); +/** + * Returns true if currently Z-Targeting, false if not. + * Z-Targeting here is a blanket term that covers both the "actor lock-on" and "parallel" states. + * + * This variant of the function calls `Player_UpdateHostileLockOn`, which updates the hostile + * lock-on actor state before checking its state. + */ +bool Player_IsZTargetingWithHostileUpdate(Player* this) { + return Player_UpdateHostileLockOn(this) || Player_FriendlyLockOnOrParallel(this); } void func_8082FC60(Player* this) { @@ -4151,7 +4165,7 @@ s32 func_80830B88(PlayState* play, Player* this) { !(this->stateFlags1 & PLAYER_STATE1_2000000)) || ((this->transformation == PLAYER_FORM_HUMAN) && (this->currentShield != PLAYER_SHIELD_NONE))) && - func_8082FBE8(this))) { + Player_IsZTargeting(this))) { PlayerAnimationHeader* anim = func_80830A58(play, this); f32 endFrame = Animation_GetLastFrame(anim); @@ -4248,7 +4262,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->focusActor != NULL) || + if (Player_IsZTargeting(this) || (this->focusActor != NULL) || (Camera_CheckValidMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_BOWARROW) == 0)) { return true; } @@ -4321,11 +4335,12 @@ bool func_80831194(PlayState* play, Player* this) { return false; } -void func_8083133C(Player* this) { - this->stateFlags1 |= PLAYER_STATE1_20000; +void Player_SetParallel(Player* this) { + this->stateFlags1 |= PLAYER_STATE1_PARALLEL; if (!(this->skelAnime.moveFlags & ANIM_FLAG_80) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (sPlayerShapeYawToTouchedWall < 0x2000)) { + // snap to the wall this->yaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; } @@ -4809,7 +4824,7 @@ void Player_UpdateShapeYaw(Player* this, PlayState* 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) && + } else if ((this->stateFlags1 & PLAYER_STATE1_PARALLEL) && !(this->stateFlags2 & (PLAYER_STATE2_20 | PLAYER_STATE2_40))) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->parallelYaw, 0xFA0); } @@ -4882,69 +4897,131 @@ s16 func_80832754(Player* this, s32 arg1) { return yaw; } -void func_80832888(Player* this, PlayState* play) { +/** + * Updates state related to Z-Targeting. + * + * Z-Targeting is an umbrella term for two main states: + * - Actor Lock-on: Player has locked onto an actor, a reticle appears, both Player and the camera focus on the actor. + * - Parallel: Player and the camera keep facing the same angle from when Z was pressed. Can snap to walls. + * This state occurs when there are no actors available to lock onto. + * + * First this function updates `zTargetActiveTimer`. For most Z-Target related states to update, this + * timer has to have a non-zero value. Additionally, the timer must have a value of 5 or greater + * for the Attention system to recognize that an actor lock-on is active. + * + * Following this, a next lock-on actor is chosen. If there is currently no actor lock-on active, the actor + * Tatl is hovering over will be chosen. If there is an active lock-on, the next available + * lock-on will be the actor with an arrow hovering above it. + * + * If the above regarding actor lock-on does not occur, then Z-Parallel can begin. + * + * Lastly, the function handles updating general "actor focus" state. This applies to non Z-Target states + * like talking to an actor. If the current focus actor is not considered "hostile", then + * `PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS` can be set. This flag being set will trigger `Player_UpdateCamAndSeqModes` + * to make the camera focus on the current focus actor. + */ +void Player_UpdateZTargeting(Player* this, PlayState* play) { s32 ignoreLeash = false; - Actor* var_v1_2; - s32 heldZ = CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_Z); - s32 temp_v0_3; - s32 var_a1; + Actor* nextLockOnActor; + s32 zButtonHeld = CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_Z); + s32 isTalking; + s32 usingHoldTargeting; - if (!heldZ) { - this->stateFlags1 &= ~PLAYER_STATE1_40000000; + if (!zButtonHeld) { + this->stateFlags1 &= ~PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE; } if ((play->csCtx.state != CS_STATE_IDLE) || (this->csAction != PLAYER_CSACTION_NONE) || (this->stateFlags1 & (PLAYER_STATE1_DEAD | PLAYER_STATE1_20000000)) || (this->stateFlags3 & PLAYER_STATE3_80)) { - this->unk_738 = 0; - } else if (heldZ || (this->stateFlags2 & PLAYER_STATE2_LOCK_ON_WITH_SWITCH) || (this->autoLockOnActor != NULL)) { - if (this->unk_738 <= 5) { - this->unk_738 = 5; + // Don't allow Z-Targeting in various states + this->zTargetActiveTimer = 0; + } else if (zButtonHeld || (this->stateFlags2 & PLAYER_STATE2_LOCK_ON_WITH_SWITCH) || + (this->autoLockOnActor != NULL)) { + // 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_738--; + this->zTargetActiveTimer--; } - } else if (this->stateFlags1 & PLAYER_STATE1_20000) { - this->unk_738 = 0; - } else if (this->unk_738 != 0) { - this->unk_738--; + } else if (this->stateFlags1 & PLAYER_STATE1_PARALLEL) { + // 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->unk_738 > 5) { + 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; } - temp_v0_3 = func_8082DAFC(play); - if (temp_v0_3 || (this->unk_738 != 0) || (this->stateFlags1 & (PLAYER_STATE1_1000 | PLAYER_STATE1_2000000))) { - if (!temp_v0_3) { + isTalking = func_8082DAFC(play); + + if (isTalking || (this->zTargetActiveTimer != 0) || + (this->stateFlags1 & (PLAYER_STATE1_1000 | PLAYER_STATE1_2000000))) { + if (!isTalking) { if (!(this->stateFlags1 & PLAYER_STATE1_2000000) && ((this->heldItemAction != PLAYER_IA_FISHING_ROD) || (this->unk_B28 == 0)) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_Z)) { - var_v1_2 = - (this == GET_PLAYER(play)) ? play->actorCtx.attention.tatlHoverActor : &GET_PLAYER(play)->actor; - var_a1 = (gSaveContext.options.zTargetSetting != 0) || (this != GET_PLAYER(play)); - this->stateFlags1 |= PLAYER_STATE1_8000; - if ((this->currentMask != PLAYER_MASK_GIANT) && (var_v1_2 != NULL) && - !(var_v1_2->flags & ACTOR_FLAG_LOCK_ON_DISABLED) && + + if (this == GET_PLAYER(play)) { + // The next lock-on actor defaults to the actor Tatl is hovering over. + // This may change to the arrow hover actor below. + nextLockOnActor = play->actorCtx.attention.tatlHoverActor; + } else { + // Kafei will always lock onto the player. + nextLockOnActor = &GET_PLAYER(play)->actor; + } + + // Get saved Z Target setting. + // Kafei uses Hold Targeting. + usingHoldTargeting = (gSaveContext.options.zTargetSetting != 0) || (this != GET_PLAYER(play)); + + this->stateFlags1 |= PLAYER_STATE1_Z_TARGETING; + + if ((this->currentMask != PLAYER_MASK_GIANT) && (nextLockOnActor != NULL) && + !(nextLockOnActor->flags & ACTOR_FLAG_LOCK_ON_DISABLED) && !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { - if ((var_v1_2 == this->focusActor) && (this == GET_PLAYER(play))) { - var_v1_2 = play->actorCtx.attention.arrowHoverActor; + + // Tatl hovers over the current lock-on actor, so `nextLockOnActor` and `focusActor` + // will be the same if already locked on. + // In this case, `nextLockOnActor` will be the arrow hover actor instead. + if ((nextLockOnActor == this->focusActor) && (this == GET_PLAYER(play))) { + nextLockOnActor = play->actorCtx.attention.arrowHoverActor; } - if ((var_v1_2 != NULL) && - (((var_v1_2 != this->focusActor)) || (var_v1_2->flags & ACTOR_FLAG_FOCUS_ACTOR_REFINDABLE))) { - var_v1_2->flags &= ~ACTOR_FLAG_FOCUS_ACTOR_REFINDABLE; - if (!var_a1) { + if ((nextLockOnActor != NULL) && (((nextLockOnActor != this->focusActor)) || + (nextLockOnActor->flags & ACTOR_FLAG_FOCUS_ACTOR_REFINDABLE))) { + // Set new lock-on + + nextLockOnActor->flags &= ~ACTOR_FLAG_FOCUS_ACTOR_REFINDABLE; + + if (!usingHoldTargeting) { this->stateFlags2 |= PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } - this->focusActor = var_v1_2; - this->unk_738 = 0xF; + + this->focusActor = nextLockOnActor; + this->zTargetActiveTimer = 15; this->stateFlags2 &= ~(PLAYER_STATE2_2 | PLAYER_STATE2_200000); - } else if (!var_a1) { + } else if (!usingHoldTargeting) { Player_ReleaseLockOn(this); } - this->stateFlags1 &= ~PLAYER_STATE1_40000000; - } else if (!(this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) && - (Player_Action_95 != this->actionFunc)) { - func_8083133C(this); + 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_Action_95 != this->actionFunc)) { + Player_SetParallel(this); + } } } @@ -4952,22 +5029,32 @@ void func_80832888(Player* this, PlayState* play) { if ((this == GET_PLAYER(play)) && (this->focusActor != this->autoLockOnActor) && Attention_ShouldReleaseLockOn(this->focusActor, this, ignoreLeash)) { Player_ReleaseLockOn(this); - this->stateFlags1 |= PLAYER_STATE1_40000000; + this->stateFlags1 |= PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE; } else if (this->focusActor != NULL) { this->focusActor->targetPriority = 0x28; } } else if (this->autoLockOnActor != NULL) { + // Because of the previous if condition above, `autoLockOnActor` does not take precedence + // over `focusActor` if it already exists. + // However, `autoLockOnActor` is expected to be set with `Player_SetAutoLockOnActor` + // which will release any existing lock-on before setting the new one. this->focusActor = this->autoLockOnActor; } } if ((this->focusActor != NULL) && !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { - this->stateFlags1 &= ~(PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_20000); + this->stateFlags1 &= ~(PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS | PLAYER_STATE1_PARALLEL); + + // Check if an actor is not hostile, aka "friendly", to set `PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS`. + // + // When carrying another actor, `PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS` will be set even if the actor + // is hostile. This is a special case to allow Player to have more freedom of movement and be able + // to throw a carried actor at the lock-on actor, even if it is hostile. if ((this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) || !CHECK_FLAG_ALL(this->focusActor->flags, ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE)) { this->stateFlags1 |= PLAYER_STATE1_FRIENDLY_ACTOR_FOCUS; } - } else if (this->stateFlags1 & PLAYER_STATE1_20000) { + } else if (this->stateFlags1 & PLAYER_STATE1_PARALLEL) { this->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } else { Player_ClearZTargeting(this); @@ -5097,7 +5184,7 @@ s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYaw if ((play->actorCtx.attention.reticleSpinCounter != 0) && !(this->stateFlags2 & PLAYER_STATE2_40)) { *outYawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &this->focusActor->focus.pos); } - } else if (func_80123434(this)) { + } else if (Player_FriendlyLockOnOrParallel(this)) { *outYawTarget = this->parallelYaw; } @@ -5510,12 +5597,12 @@ PlayerMeleeWeaponAnimation func_808335F4(Player* this) { meleeWeaponAnim = PLAYER_MWA_SPIN_ATTACK_1H; } else { if (temp_a1 < 0) { - meleeWeaponAnim = func_8082FBE8(this) ? PLAYER_MWA_FORWARD_SLASH_1H : PLAYER_MWA_RIGHT_SLASH_1H; + meleeWeaponAnim = Player_IsZTargeting(this) ? PLAYER_MWA_FORWARD_SLASH_1H : PLAYER_MWA_RIGHT_SLASH_1H; } else { meleeWeaponAnim = D_8085D090[temp_a1]; if (meleeWeaponAnim == PLAYER_MWA_STAB_1H) { this->stateFlags2 |= PLAYER_STATE2_40000000; - if (!func_8082FBE8(this)) { + if (!Player_IsZTargeting(this)) { meleeWeaponAnim = PLAYER_MWA_FORWARD_SLASH_1H; } } @@ -6804,7 +6891,7 @@ void func_8083692C(Player* this, PlayState* play) { void func_80836988(Player* this, PlayState* play) { if (Player_CheckHostileLockOn(this)) { func_80836888(this, play); - } else if (func_80123434(this)) { + } else if (Player_FriendlyLockOnOrParallel(this)) { func_8083692C(this, play); } else { func_8085B384(this, play); @@ -6816,7 +6903,7 @@ void func_808369F4(Player* this, PlayState* play) { if (Player_CheckHostileLockOn(this)) { actionFunc = Player_Action_2; - } else if (func_80123434(this)) { + } else if (Player_FriendlyLockOnOrParallel(this)) { actionFunc = Player_Action_3; } else { actionFunc = Player_Action_Idle; @@ -6897,7 +6984,7 @@ void func_80836D8C(Player* this) { s32 func_80836DC0(PlayState* play, Player* this) { if ((MREG(48) != 0) || func_800C9DDC(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { Player_SetAction(play, this, Player_Action_93, 0); - this->stateFlags1 &= ~(PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + this->stateFlags1 &= ~(PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE); Player_Anim_PlayOnceMorph(play, this, &gPlayerAnim_pn_attack); Player_StopHorizontalMovement(this); func_80836D8C(this); @@ -7178,7 +7265,7 @@ s32 func_8083784C(Player* this) { } void func_808378FC(PlayState* play, Player* this) { - if (!func_8082FC24(this)) { + if (!Player_IsZTargetingWithHostileUpdate(this)) { this->stateFlags2 |= PLAYER_STATE2_20; } @@ -7361,7 +7448,7 @@ s32 func_80837DEC(Player* this, PlayState* play) { this->av1.actionVar1 = var_v1_2; } else { this->stateFlags1 |= PLAYER_STATE1_2000; - this->stateFlags1 &= ~PLAYER_STATE1_20000; + this->stateFlags1 &= ~PLAYER_STATE1_PARALLEL; } Player_PlaySfx(this, NA_SE_PL_SLIPDOWN); @@ -8094,7 +8181,7 @@ s32 func_80839A84(PlayState* play, Player* this) { } Player_SetAction(play, this, Player_Action_95, 0); - this->stateFlags1 &= ~(PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + this->stateFlags1 &= ~(PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE); this->unk_ADC = 4; func_808373A4(play, this); return true; @@ -8107,7 +8194,7 @@ s32 Player_ActionHandler_10(Player* this, PlayState* play) { s32 temp_a2 = this->unk_AE3[this->unk_ADE]; if (temp_a2 <= 0) { - if (func_8082FBE8(this)) { + if (Player_IsZTargeting(this)) { if (this->actor.category != ACTORCAT_PLAYER) { if (temp_a2 < 0) { func_80834DB8(this, &gPlayerAnim_link_normal_jump, REG(69) / 100.0f, play); @@ -8258,7 +8345,7 @@ s32 Player_ActionHandler_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->focusActor == NULL))) { + !Player_FriendlyLockOnOrParallel(this) && (this->focusActor == NULL))) { func_8082DC38(this); Player_DetachHeldActor(play, this); if (Player_SetAction(play, this, Player_Action_18, 0)) { @@ -8382,7 +8469,7 @@ void func_8083A794(Player* this, PlayState* play) { Player_Anim_PlayLoopMorph(play, this, D_8085BE84[PLAYER_ANIMGROUP_run][this->modelAnimType]); } - Player_SetAction(play, this, func_8082FBE8(this) ? Player_Action_14 : Player_Action_13, 1); + Player_SetAction(play, this, Player_IsZTargeting(this) ? Player_Action_14 : Player_Action_13, 1); } void func_8083A844(Player* this, PlayState* play, s16 yaw) { @@ -11385,7 +11472,7 @@ void Player_SetDoAction(PlayState* play, Player* this) { doActionA = DO_ACTION_JUMP; } else if (this->stateFlags3 & PLAYER_STATE3_1000) { doActionA = DO_ACTION_RETURN; - } else if (!func_8082FBE8(this) && (this->stateFlags1 & PLAYER_STATE1_8000000) && !sp38) { + } else if (!Player_IsZTargeting(this) && (this->stateFlags1 & PLAYER_STATE1_8000000) && !sp38) { doActionA = DO_ACTION_SURFACE; } else if (((this->transformation != PLAYER_FORM_DEKU) && (sp38 || ((this->stateFlags1 & PLAYER_STATE1_8000000) && @@ -11398,15 +11485,16 @@ void Player_SetDoAction(PlayState* play, Player* this) { ? DO_ACTION_GRAB : DO_ACTION_DIVE; } else { - sp24 = func_8082FBE8(this); + sp24 = Player_IsZTargeting(this); if ((sp24 && (this->transformation != PLAYER_FORM_DEKU)) || !(this->stateFlags1 & PLAYER_STATE1_400000) || !Player_IsGoronOrDeku(this)) { if ((this->transformation != PLAYER_FORM_GORON) && !(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_4000)) && (sp28 <= 0) && (Player_CheckHostileLockOn(this) || ((sPlayerFloorType != FLOOR_TYPE_7) && - (func_80123434(this) || ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && - !(this->stateFlags1 & PLAYER_STATE1_400000) && (sp28 == 0)))))) { + (Player_FriendlyLockOnOrParallel(this) || + ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && + !(this->stateFlags1 & PLAYER_STATE1_400000) && (sp28 == 0)))))) { doActionA = DO_ACTION_ATTACK; } else if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && sp24 && (sp28 > 0)) { doActionA = DO_ACTION_JUMP; @@ -11836,18 +11924,18 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { camMode = CAM_MODE_FOLLOWBOOMERANG; Camera_SetViewParam(camera, CAM_VIEW_TARGET, this->boomerangActor); } else if (this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000)) { - if (func_80123434(this)) { + if (Player_FriendlyLockOnOrParallel(this)) { camMode = CAM_MODE_HANGZ; } else { camMode = CAM_MODE_HANG; } } else if ((this->stateFlags3 & PLAYER_STATE3_2000) && (this->actor.velocity.y < 0.0f)) { - if (this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) { + if (this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE)) { camMode = CAM_MODE_DEKUFLYZ; } else { camMode = CAM_MODE_DEKUFLY; } - } else if (this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) { + } else if (this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE)) { if (func_800B7128(this) || func_8082EF20(this)) { camMode = CAM_MODE_BOWARROWZ; } else if (this->stateFlags1 & PLAYER_STATE1_200000) { @@ -12283,7 +12371,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } func_80122C20(play, &this->unk_3D0); - if ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && func_8082FBE8(this)) { + if ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && Player_IsZTargeting(this)) { func_80844D80(play, this); } if (this->transformation == PLAYER_FORM_ZORA) { @@ -12291,7 +12379,9 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Math_StepToF(&this->unk_B10[0], var_v0, D_8085D3FC[var_v0]); } - func_80832888(this, play); + + Player_UpdateZTargeting(this, play); + if (play->roomCtx.curRoom.enablePosLights) { Lights_PointSetColorAndRadius(&this->lightInfo, 255, 255, 255, 60); } else { @@ -13381,7 +13471,7 @@ void func_80847F1C(Player* this) { if (interactRangeActor->speed < 0.0f) { interactRangeActor->speed = 0.0f; } - func_8083133C(this); + Player_SetParallel(this); } } @@ -13543,7 +13633,7 @@ s32 Player_ActionHandler_7(Player* this, PlayState* play) { func_80833864(play, this, meleeWeaponAnim); if ((meleeWeaponAnim >= PLAYER_MWA_SPIN_ATTACK_1H) || - ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && func_8082FBE8(this))) { + ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && Player_IsZTargeting(this))) { this->stateFlags2 |= PLAYER_STATE2_20000; func_808332A0(play, this, 0, meleeWeaponAnim < PLAYER_MWA_SPIN_ATTACK_1H); } @@ -13783,7 +13873,8 @@ s32 Player_UpperAction_8(Player* this, PlayState* play) { this->unk_ACC--; } - if ((func_8082FBE8(this)) || (this->unk_AA5 != PLAYER_UNKAA5_0) || (this->stateFlags1 & PLAYER_STATE1_100000)) { + if ((Player_IsZTargeting(this)) || (this->unk_AA5 != PLAYER_UNKAA5_0) || + (this->stateFlags1 & PLAYER_STATE1_100000)) { if (this->unk_ACC == 0) { this->unk_ACC++; } @@ -13920,7 +14011,7 @@ s32 Player_UpperAction_14(Player* this, PlayState* play) { this->stateFlags1 |= PLAYER_STATE1_2000000; this->stateFlags3 &= ~PLAYER_STATE3_800000; if (!Player_CheckHostileLockOn(this)) { - func_8083133C(this); + Player_SetParallel(this); } this->unk_D57 = 20; @@ -14077,7 +14168,7 @@ void Player_Action_2(Player* this, PlayState* play) { } if (!Player_UpdateHostileLockOn(this) && - (!func_80123434(this) || (Player_UpperAction_3 != this->upperActionFunc))) { + (!Player_FriendlyLockOnOrParallel(this) || (Player_UpperAction_3 != this->upperActionFunc))) { func_8083B29C(this, play); return; } @@ -14137,7 +14228,7 @@ void Player_Action_3(Player* this, PlayState* play) { func_8083B23C(this, play); return; } - if (!func_80123434(this)) { + if (!Player_FriendlyLockOnOrParallel(this)) { Player_SetAction_PreserveMoveFlags(play, this, Player_Action_Idle, 1); this->yaw = this->actor.shape.rot.y; return; @@ -14219,7 +14310,7 @@ void Player_Action_Idle(Player* this, PlayState* play) { return; } - if (func_80123434(this)) { + if (Player_FriendlyLockOnOrParallel(this)) { func_8083692C(this, play); return; } @@ -14289,7 +14380,7 @@ void Player_Action_5(Player* this, PlayState* play) { func_8083B23C(this, play); return; } - if (!func_80123434(this)) { + if (!Player_FriendlyLockOnOrParallel(this)) { func_8085B384(this, play); return; } @@ -14337,7 +14428,7 @@ void Player_Action_6(Player* this, PlayState* play) { return; } - if (func_8082FC24(this) == 0) { + if (!Player_IsZTargetingWithHostileUpdate(this)) { func_8083A844(this, play, this->yaw); return; } @@ -14413,14 +14504,14 @@ void Player_Action_9(Player* this, PlayState* play) { return; } - if (!func_8082FC24(this)) { + if (!Player_IsZTargetingWithHostileUpdate(this)) { func_8083A794(this, play); return; } Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); - if (func_80123434(this)) { + if (Player_FriendlyLockOnOrParallel(this)) { var_v0 = func_8083E514(this, &speedTarget, &yawTarget, play); } else { var_v0 = func_8083E404(this, speedTarget, yawTarget); @@ -14429,13 +14520,13 @@ void Player_Action_9(Player* this, PlayState* play) { if (var_v0 > 0) { func_8083A794(this, play); } else if (var_v0 < 0) { - if (func_80123434(this)) { + if (Player_FriendlyLockOnOrParallel(this)) { func_8083AECC(this, yawTarget, play); } else { func_8083AF8C(this, yawTarget, play); } } else if ((this->speedXZ < 3.6f) && (speedTarget < 4.0f)) { - if (!Player_CheckHostileLockOn(this) && func_80123434(this)) { + if (!Player_CheckHostileLockOn(this) && Player_FriendlyLockOnOrParallel(this)) { func_8083AF30(this, play); } else { func_80836988(this, play); @@ -14579,7 +14670,7 @@ void Player_Action_13(Player* this, PlayState* play) { return; } - if (func_8082FC24(this)) { + if (Player_IsZTargetingWithHostileUpdate(this)) { func_8083A794(this, play); return; } @@ -14610,7 +14701,7 @@ void Player_Action_14(Player* this, PlayState* play) { return; } - if (!func_8082FC24(this)) { + if (!Player_IsZTargetingWithHostileUpdate(this)) { func_8083A794(this, play); return; } @@ -14618,8 +14709,9 @@ void Player_Action_14(Player* this, PlayState* play) { Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); if (!func_8083A4A4(this, &speedTarget, &yawTarget, R_DECELERATE_RATE / 100.0f)) { - if ((func_80123434(this) && (speedTarget != 0) && (func_8083E514(this, &speedTarget, &yawTarget, play) <= 0)) || - (!func_80123434(this) && (func_8083E404(this, speedTarget, yawTarget) <= 0))) { + if ((Player_FriendlyLockOnOrParallel(this) && (speedTarget != 0) && + (func_8083E514(this, &speedTarget, &yawTarget, play) <= 0)) || + (!Player_FriendlyLockOnOrParallel(this) && (func_8083E404(this, speedTarget, yawTarget) <= 0))) { func_80836988(this, play); } else { func_8083CB58(this, speedTarget, yawTarget); @@ -14640,7 +14732,7 @@ void Player_Action_15(Player* this, PlayState* play) { return; } - if (!func_8082FC24(this)) { + if (!Player_IsZTargetingWithHostileUpdate(this)) { func_8083A794(this, play); return; } @@ -15243,8 +15335,8 @@ void Player_Action_30(Player* this, PlayState* play) { this->stateFlags1 |= PLAYER_STATE1_1000; if (PlayerAnimation_Update(play, &this->skelAnime)) { Player_Anim_ResetMove(this); - func_8083133C(this); - this->stateFlags1 &= ~PLAYER_STATE1_20000; + Player_SetParallel(this); + this->stateFlags1 &= ~PLAYER_STATE1_PARALLEL; Player_Anim_PlayLoop(play, this, D_8085CF60[Player_IsHoldingTwoHandedWeapon(this)]); this->av2.actionVar2 = -1; } @@ -15849,8 +15941,8 @@ void Player_Action_43(Player* this, PlayState* play) { ((this->unk_AA5 == PLAYER_UNKAA5_3) && (((Player_ItemToItemAction(this, Inventory_GetBtnBItem(play)) != this->heldItemAction) && CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_B)) || - CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_R | BTN_A) || func_80123434(this) || - (!func_800B7128(this) && !func_8082EF20(this))))) || + CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_R | BTN_A) || + Player_FriendlyLockOnOrParallel(this) || (!func_800B7128(this) && !func_8082EF20(this))))) || ((this->unk_AA5 == PLAYER_UNKAA5_1) && CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_R | BTN_B | BTN_A))) || @@ -16356,7 +16448,7 @@ void func_8084FD7C(PlayState* play, Player* this, Actor* actor) { } bool func_8084FE48(Player* this) { - return (this->focusActor == NULL) && !func_8082FC24(this); + return (this->focusActor == NULL) && !Player_IsZTargetingWithHostileUpdate(this); } PlayerAnimationHeader* D_8085D688[] = { @@ -16683,7 +16775,7 @@ void Player_Action_54(Player* this, PlayState* play) { return; } - if (func_8082FC24(this) || func_80847ED4(this)) { + if (Player_IsZTargetingWithHostileUpdate(this) || func_80847ED4(this)) { func_80848048(play, this); } else { func_8083B73C(play, this, yawTarget); @@ -16881,7 +16973,7 @@ void Player_Action_57(Player* this, PlayState* play) { } sp30 = this->actor.shape.rot.y - yawTarget; if (!func_80850734(play, this)) { - if (func_8082FC24(this) || func_80847ED4(this)) { + if (Player_IsZTargetingWithHostileUpdate(this) || func_80847ED4(this)) { func_80848048(play, this); } else { if ((speedTarget == 0.0f) || (ABS_ALT(sp30) > 0x6000) || @@ -16908,7 +17000,7 @@ void Player_Action_58(Player* this, PlayState* play) { if (speedTarget == 0.0f) { func_808353DC(play, this); - } else if (!func_8082FC24(this) && !func_80847ED4(this)) { + } else if (!Player_IsZTargetingWithHostileUpdate(this) && !func_80847ED4(this)) { func_8083B73C(play, this, yawTarget); } else { func_80848094(play, this, &speedTarget, &yawTarget); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c044cbefb9..089f2691c6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2193,7 +2193,7 @@ 0x80123358:("Player_InBlockingCsMode",), 0x801233E4:("Player_InCsMode",), 0x80123420:("Player_CheckHostileLockOn",), - 0x80123434:("func_80123434",), + 0x80123434:("Player_FriendlyLockOnOrParallel",), 0x80123448:("func_80123448",), 0x801234B0:("Player_IsGoronOrDeku",), 0x801234D4:("func_801234D4",), @@ -4327,8 +4327,8 @@ 0x8082F938:("Player_OverrideBlureColors",), 0x8082FA5C:("func_8082FA5C",), 0x8082FB68:("Player_UpdateHostileLockOn",), - 0x8082FBE8:("func_8082FBE8",), - 0x8082FC24:("func_8082FC24",), + 0x8082FBE8:("Player_IsZTargeting",), + 0x8082FC24:("Player_IsZTargetingWithHostileUpdate",), 0x8082FC60:("func_8082FC60",), 0x8082FC78:("Player_ItemIsInUse",), 0x8082FCC4:("Player_ItemIsItemAction",), @@ -4355,7 +4355,7 @@ 0x80831094:("func_80831094",), 0x80831124:("func_80831124",), 0x80831194:("func_80831194",), - 0x8083133C:("func_8083133C",), + 0x8083133C:("Player_SetParallel",), 0x808313A8:("func_808313A8",), 0x808313F0:("func_808313F0",), 0x80831454:("func_80831454",), @@ -4379,7 +4379,7 @@ 0x80832578:("Player_UpdateShapeYaw",), 0x80832660:("Player_ScaledStepBinangClamped",), 0x80832754:("func_80832754",), - 0x80832888:("func_80832888",), + 0x80832888:("Player_UpdateZTargeting",), 0x80832CAC:("Player_CalcSpeedAndYawFromControlStick",), 0x80832F24:("Player_DecelerateToZero",), 0x80832F78:("Player_GetMovementSpeedAndYaw",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9d2d5a7a12..3cdd004877 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1707,7 +1707,7 @@ asm/non_matchings/code/z_player_lib/func_80123140.s,func_80123140,0x80123140,0x8 asm/non_matchings/code/z_player_lib/Player_InBlockingCsMode.s,Player_InBlockingCsMode,0x80123358,0x23 asm/non_matchings/code/z_player_lib/Player_InCsMode.s,Player_InCsMode,0x801233E4,0xF asm/non_matchings/code/z_player_lib/Player_CheckHostileLockOn.s,Player_CheckHostileLockOn,0x80123420,0x5 -asm/non_matchings/code/z_player_lib/func_80123434.s,func_80123434,0x80123434,0x5 +asm/non_matchings/code/z_player_lib/Player_FriendlyLockOnOrParallel.s,Player_FriendlyLockOnOrParallel,0x80123434,0x5 asm/non_matchings/code/z_player_lib/func_80123448.s,func_80123448,0x80123448,0x1A asm/non_matchings/code/z_player_lib/Player_IsGoronOrDeku.s,Player_IsGoronOrDeku,0x801234B0,0x9 asm/non_matchings/code/z_player_lib/func_801234D4.s,func_801234D4,0x801234D4,0x2F