From 2e79b83bb81b1fd65a12a2b2a018de27271611a0 Mon Sep 17 00:00:00 2001 From: fig02 Date: Tue, 10 Sep 2024 22:00:41 -0400 Subject: [PATCH] More target related state flags (#2184) * name some more flags * format * cdi suggestion --- include/z64player.h | 8 ++--- src/code/z_player_lib.c | 8 ++--- .../actors/ovl_player_actor/z_player.c | 35 ++++++++++--------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/z64player.h b/include/z64player.h index c8758b0b39..de15c9b691 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -663,7 +663,7 @@ typedef struct WeaponInfo { #define PLAYER_STATE1_12 (1 << 12) #define PLAYER_STATE1_13 (1 << 13) #define PLAYER_STATE1_14 (1 << 14) -#define PLAYER_STATE1_15 (1 << 15) +#define PLAYER_STATE1_Z_TARGETING (1 << 15) // Either lock-on or parallel is active. This flag is never checked for and is practically unused. #define PLAYER_STATE1_16 (1 << 16) #define PLAYER_STATE1_PARALLEL (1 << 17) // "Parallel" mode, Z-Target without an actor lock-on #define PLAYER_STATE1_18 (1 << 18) @@ -678,7 +678,7 @@ typedef struct WeaponInfo { #define PLAYER_STATE1_27 (1 << 27) #define PLAYER_STATE1_28 (1 << 28) #define PLAYER_STATE1_29 (1 << 29) -#define PLAYER_STATE1_30 (1 << 30) +#define PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE (1 << 30) // Lock-on was released automatically, for example by leaving the lock-on leash range #define PLAYER_STATE1_31 (1 << 31) #define PLAYER_STATE2_0 (1 << 0) @@ -694,7 +694,7 @@ typedef struct WeaponInfo { #define PLAYER_STATE2_10 (1 << 10) #define PLAYER_STATE2_11 (1 << 11) #define PLAYER_STATE2_12 (1 << 12) -#define PLAYER_STATE2_13 (1 << 13) +#define PLAYER_STATE2_LOCK_ON_WITH_SWITCH (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_14 (1 << 14) #define PLAYER_STATE2_15 (1 << 15) #define PLAYER_STATE2_DO_ACTION_ENTER (1 << 16) // Sets the "Enter On A" DoAction @@ -721,7 +721,7 @@ typedef struct WeaponInfo { #define PLAYER_STATE3_4 (1 << 4) #define PLAYER_STATE3_5 (1 << 5) #define PLAYER_STATE3_RESTORE_NAYRUS_LOVE (1 << 6) // Set by ocarina effects actors when destroyed to signal Nayru's Love may be restored (see `ACTOROVL_ALLOC_ABSOLUTE`) -#define PLAYER_STATE3_7 (1 << 7) +#define PLAYER_STATE3_FLYING_WITH_HOOKSHOT (1 << 7) // Flying in the air with the hookshot as it pulls Player toward its destination typedef void (*PlayerActionFunc)(struct Player*, struct PlayState*); typedef s32 (*UpperActionFunc)(struct Player*, struct PlayState*); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index e33b9ad594..a3fa204ec4 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -492,7 +492,7 @@ void Player_SetBootData(PlayState* play, Player* this) { int Player_InBlockingCsMode(PlayState* play, Player* this) { return (this->stateFlags1 & (PLAYER_STATE1_7 | PLAYER_STATE1_29)) || (this->csAction != PLAYER_CSACTION_NONE) || (play->transitionTrigger == TRANS_TRIGGER_START) || (this->stateFlags1 & PLAYER_STATE1_0) || - (this->stateFlags3 & PLAYER_STATE3_7) || + (this->stateFlags3 & PLAYER_STATE3_FLYING_WITH_HOOKSHOT) || ((gSaveContext.magicState != MAGIC_STATE_IDLE) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0)); } @@ -603,7 +603,7 @@ void Player_UpdateBottleHeld(PlayState* play, Player* this, s32 item, s32 itemAc void func_8008EDF0(Player* this) { this->focusActor = NULL; - this->stateFlags2 &= ~PLAYER_STATE2_13; + this->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } void func_8008EE08(Player* this) { @@ -611,8 +611,8 @@ void func_8008EE08(Player* this) { (this->stateFlags1 & (PLAYER_STATE1_21 | PLAYER_STATE1_23 | PLAYER_STATE1_27)) || (!(this->stateFlags1 & (PLAYER_STATE1_18 | PLAYER_STATE1_19)) && ((this->actor.world.pos.y - this->actor.floorHeight) < 100.0f))) { - this->stateFlags1 &= ~(PLAYER_STATE1_15 | PLAYER_STATE1_16 | PLAYER_STATE1_PARALLEL | PLAYER_STATE1_18 | - PLAYER_STATE1_19 | PLAYER_STATE1_30); + this->stateFlags1 &= ~(PLAYER_STATE1_Z_TARGETING | PLAYER_STATE1_16 | PLAYER_STATE1_PARALLEL | + PLAYER_STATE1_18 | PLAYER_STATE1_19 | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE); } else if (!(this->stateFlags1 & (PLAYER_STATE1_18 | PLAYER_STATE1_19 | PLAYER_STATE1_21))) { this->stateFlags1 |= PLAYER_STATE1_19; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e5cd07cbc2..9df85e5ff1 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -2316,7 +2316,7 @@ void func_80833A20(Player* this, s32 newMeleeWeaponState) { } s32 func_80833B2C(Player* this) { - if (this->stateFlags1 & (PLAYER_STATE1_16 | PLAYER_STATE1_PARALLEL | PLAYER_STATE1_30)) { + if (this->stateFlags1 & (PLAYER_STATE1_16 | PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE)) { return 1; } else { return 0; @@ -3179,7 +3179,7 @@ s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFun this->stateFlags1 &= ~(PLAYER_STATE1_2 | PLAYER_STATE1_6 | PLAYER_STATE1_26 | PLAYER_STATE1_28 | PLAYER_STATE1_29 | PLAYER_STATE1_31); this->stateFlags2 &= ~(PLAYER_STATE2_19 | PLAYER_STATE2_27 | PLAYER_STATE2_28); - this->stateFlags3 &= ~(PLAYER_STATE3_1 | PLAYER_STATE3_3 | PLAYER_STATE3_7); + this->stateFlags3 &= ~(PLAYER_STATE3_1 | PLAYER_STATE3_3 | PLAYER_STATE3_FLYING_WITH_HOOKSHOT); this->av1.actionVar1 = 0; this->av2.actionVar2 = 0; @@ -3404,7 +3404,7 @@ int Player_CanUpdateItems(Player* this) { s32 Player_UpdateUpperBody(Player* this, PlayState* play) { if (!(this->stateFlags1 & PLAYER_STATE1_23) && (this->actor.parent != NULL) && Player_HoldsHookshot(this)) { Player_SetupAction(play, this, Player_Action_80850AEC, 1); - this->stateFlags3 |= PLAYER_STATE3_7; + this->stateFlags3 |= PLAYER_STATE3_FLYING_WITH_HOOKSHOT; Player_AnimPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start); Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_PLAYER_SETMOVE | @@ -3555,13 +3555,14 @@ void func_80836BEC(Player* this, PlayState* play) { s32 isTalking; if (!zButtonHeld) { - this->stateFlags1 &= ~PLAYER_STATE1_30; + 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_7 | PLAYER_STATE1_29)) || (this->stateFlags3 & PLAYER_STATE3_7)) { + (this->stateFlags1 & (PLAYER_STATE1_7 | PLAYER_STATE1_29)) || + (this->stateFlags3 & PLAYER_STATE3_FLYING_WITH_HOOKSHOT)) { this->unk_66C = 0; - } else if (zButtonHeld || (this->stateFlags2 & PLAYER_STATE2_13) || (this->unk_684 != NULL)) { + } else if (zButtonHeld || (this->stateFlags2 & PLAYER_STATE2_LOCK_ON_WITH_SWITCH) || (this->unk_684 != NULL)) { if (this->unk_66C <= 5) { this->unk_66C = 5; } else { @@ -3598,7 +3599,7 @@ void func_80836BEC(Player* this, PlayState* play) { // Dark Link uses Hold Targeting. usingHoldTargeting = (gSaveContext.zTargetSetting != 0) || (this->actor.category != ACTORCAT_PLAYER); - this->stateFlags1 |= PLAYER_STATE1_15; + this->stateFlags1 |= PLAYER_STATE1_Z_TARGETING; if ((nextLockOnActor != NULL) && !(nextLockOnActor->flags & ACTOR_FLAG_LOCK_ON_DISABLED)) { @@ -3613,7 +3614,7 @@ void func_80836BEC(Player* this, PlayState* play) { // Set new lock-on if (!usingHoldTargeting) { - this->stateFlags2 |= PLAYER_STATE2_13; + this->stateFlags2 |= PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } this->focusActor = nextLockOnActor; @@ -3625,9 +3626,9 @@ void func_80836BEC(Player* this, PlayState* play) { } } - this->stateFlags1 &= ~PLAYER_STATE1_30; + this->stateFlags1 &= ~PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE; } else { - if (!(this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_30))) { + if (!(this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE))) { Player_SetParallel(this); } } @@ -3637,7 +3638,7 @@ void func_80836BEC(Player* this, PlayState* play) { if ((this->actor.category == ACTORCAT_PLAYER) && (this->focusActor != this->unk_684) && Attention_ShouldReleaseLockOn(this->focusActor, this, ignoreLeash)) { func_8008EDF0(this); - this->stateFlags1 |= PLAYER_STATE1_30; + this->stateFlags1 |= PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE; } else if (this->focusActor != NULL) { this->focusActor->attentionPriority = 40; } @@ -3655,7 +3656,7 @@ void func_80836BEC(Player* this, PlayState* play) { } } else { if (this->stateFlags1 & PLAYER_STATE1_PARALLEL) { - this->stateFlags2 &= ~PLAYER_STATE2_13; + this->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } else { func_8008EE08(this); } @@ -6020,7 +6021,7 @@ void func_8083C0E8(Player* this, PlayState* play) { } void func_8083C148(Player* this, PlayState* play) { - if (!(this->stateFlags3 & PLAYER_STATE3_7)) { + if (!(this->stateFlags3 & PLAYER_STATE3_FLYING_WITH_HOOKSHOT)) { func_8083B010(this); if (this->stateFlags1 & PLAYER_STATE1_27) { func_80838F18(play, this); @@ -10764,7 +10765,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { if (this->csAction != PLAYER_CSACTION_NONE) { Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_NORMAL); } else if (!(this->stateFlags1 & PLAYER_STATE1_20)) { - if ((this->actor.parent != NULL) && (this->stateFlags3 & PLAYER_STATE3_7)) { + if ((this->actor.parent != NULL) && (this->stateFlags3 & PLAYER_STATE3_FLYING_WITH_HOOKSHOT)) { camMode = CAM_MODE_HOOKSHOT_FLY; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, this->actor.parent); } else if (Player_Action_8084377C == this->actionFunc) { @@ -10795,7 +10796,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { } else { camMode = CAM_MODE_LEDGE_HANG; } - } else if (this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_30)) { + } else if (this->stateFlags1 & (PLAYER_STATE1_PARALLEL | PLAYER_STATE1_LOCK_ON_FORCED_TO_RELEASE)) { if (func_8002DD78(this) || func_808334B4(this)) { camMode = CAM_MODE_Z_AIM; } else if (this->stateFlags1 & PLAYER_STATE1_21) { @@ -11949,7 +11950,7 @@ void Player_Action_8084B530(Player* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TALK; if (!CHECK_FLAG_ALL(this->talkActor->flags, ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE)) { - this->stateFlags2 &= ~PLAYER_STATE2_13; + this->stateFlags2 &= ~PLAYER_STATE2_LOCK_ON_WITH_SWITCH; } Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); @@ -15400,7 +15401,7 @@ s32 Player_StartFishing(PlayState* play) { s32 func_80852F38(PlayState* play, Player* this) { if (!Player_InBlockingCsMode(play, this) && (this->invincibilityTimer >= 0) && !func_8008F128(this) && - !(this->stateFlags3 & PLAYER_STATE3_7)) { + !(this->stateFlags3 & PLAYER_STATE3_FLYING_WITH_HOOKSHOT)) { func_80832564(play, this); Player_SetupAction(play, this, Player_Action_8084F308, 0); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_re_dead_attack);