Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation pass for the Target system #1558

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

engineer124
Copy link
Contributor

This primarily focuses on the parts of the Targeting system handled in z_actor. All these docs are based on discussions we had in MM around this PR led by AngheloAlf: zeldaret/mm#1281

Copy link
Collaborator

@fig02 fig02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a complete review, just some high level initial thoughts

include/z64actor.h Outdated Show resolved Hide resolved
include/z64actor.h Outdated Show resolved Hide resolved
src/overlays/actors/ovl_player_actor/z_player.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@Dragorn421 Dragorn421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😏 🏹 🎯
this system sure is complicated... and there's still a chunk in player bruh

include/z64actor.h Outdated Show resolved Hide resolved
include/z64actor.h Outdated Show resolved Hide resolved
src/code/z_actor.c Outdated Show resolved Hide resolved
src/code/z_actor.c Show resolved Hide resolved
@engineer124
Copy link
Contributor Author

😏 🏹 🎯 this system sure is complicated... and there's still a chunk in player bruh

Yup 😏 here's some wip rough docs of the rest, including the player targeting code:
https://github.com/engineer124/oot/compare/zTarget...engineer124:oot:zTargetFull?expand=1

src/code/z_actor.c Outdated Show resolved Hide resolved
src/code/z_actor.c Outdated Show resolved Hide resolved
@Dragorn421 Dragorn421 added the Waiting for author There are requested changes that have not been addressed label Oct 15, 2023
void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, PlayState* play) {
TargetContextEntry* entry;
NaviColor* naviColor;
void Target_InitReticle(TargetContext* targetCtx, s32 actorCategory, PlayState* play) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also went for Target_InitReticle instead of Target_InitLockOn and did some more LockOn -> Reticle in general.

Would be nice if this name would mirror Target_SetNaviState as well?

@fig02 fig02 removed the Waiting for author There are requested changes that have not been addressed label Nov 21, 2023
Comment on lines 529 to 542
/* 0x28 */ Color_RGBAf naviOuterColor;
/* 0x38 */ Actor* naviHoverActor; // The actor that Navi hovers over
/* 0x3C */ Actor* lockOnActor;
/* 0x40 */ f32 naviMoveProgressFactor; // Controls Navi so she can smootly transition to the target actor
/* 0x44 */ f32 reticleRadius; // Control the reticle coming in from offscreen when you first target
/* 0x48 */ s16 reticleFadeAlphaControl; // Set and fade the reticle alpha. Also controls the reticle drawing with non-zero values.
/* 0x4A */ u8 naviActorCategory;
/* 0x4B */ u8 rotZTick;
/* 0x4C */ s8 lockOnIndex;
/* 0x50 */ LockOnReticle lockOnReticles[3];
/* 0x8C */ Actor* forcedTargetActor; // Never set to non-NULL
/* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY
/* 0x94 */ Actor* arrowPointedActor;
} TargetContext; // size = 0x98
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* 0x28 */ Color_RGBAf naviOuterColor;
/* 0x38 */ Actor* naviHoverActor; // The actor that Navi hovers over
/* 0x3C */ Actor* lockOnActor;
/* 0x40 */ f32 naviMoveProgressFactor; // Controls Navi so she can smootly transition to the target actor
/* 0x44 */ f32 reticleRadius; // Control the reticle coming in from offscreen when you first target
/* 0x48 */ s16 reticleFadeAlphaControl; // Set and fade the reticle alpha. Also controls the reticle drawing with non-zero values.
/* 0x4A */ u8 naviActorCategory;
/* 0x4B */ u8 rotZTick;
/* 0x4C */ s8 lockOnIndex;
/* 0x50 */ LockOnReticle lockOnReticles[3];
/* 0x8C */ Actor* forcedTargetActor; // Never set to non-NULL
/* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY
/* 0x94 */ Actor* arrowPointedActor;
} TargetContext; // size = 0x98
/* 0x28 */ Color_RGBAf naviOuterColor;
/* 0x38 */ Actor* naviHoverActor; // The actor that Navi hovers over
/* 0x3C */ Actor* lockOnActor;
/* 0x40 */ f32 naviMoveProgressFactor; // Controls Navi so she can smootly transition to the target actor
/* 0x44 */ f32 reticleRadius; // Control the reticle coming in from offscreen when you first target
/* 0x48 */ s16 reticleFadeAlphaControl; // Set and fade the reticle alpha. Also controls the reticle drawing with non-zero values.
/* 0x4A */ u8 naviHoverActorCategory; // category of the actor Navi is currently hovering over
/* 0x4B */ u8 reticleSpinCounter; // counts up when a reticle is active, used for z rotation of reticle
/* 0x4C */ s8 lockOnIndex;
/* 0x50 */ LockOnReticle lockOnReticles[3];
/* 0x8C */ Actor* forcedTargetActor; // Not used, always set to NULL
/* 0x90 */ Actor* bgmEnemy; // The nearest enemy to player with the right flags that will trigger NA_BGM_ENEMY
/* 0x94 */ Actor* arrowHoverActor; // actor a target arrow is currently hovering over
} TargetContext; // size = 0x98

Open for discussions ofc, but this is the direction id like to see some of these names move in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these seem good to me

Comment on lines 331 to 332
// Use multiple triangle sets for the movement effect when the triangles are
// getting closer to the actor from the margin of the screen
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "Use multiple reticles for the effect of the reticle quickly zooming in on an actor from off screen"

Comment on lines 386 to 387
// Draw the 4 lock-on triangles
for (triangleIndex = 0; triangleIndex < 4; triangleIndex++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Draw 4 triangles that make up the reticle", or something to that effect

Comment on lines 501 to 502
if (lockOnActor->id == ACTOR_EN_BOOM) {
// Avoid drawing the lock on triangles on the boomerang
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Don't draw reticle when locked onto the boomerang"

Comment on lines 522 to 523
} else {
targetCtx->unk_4B = (targetCtx->unk_4B + 3) | 0x80;
targetCtx->unk_44 = 120.0f;
// 0x80 is or'd to avoid getting this value be set to zero
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"0x80 is or'd to avoid a value of zero", or something. as is the sentence doesnt read right

Comment on lines 1522 to 1523
// Linear scaling, yaw being 90 degree means it will return the original distance, 0 degree will adjust to 60%
// of the distance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

degree -> degrees

Comment on lines +3135 to +3136
void Target_FindTargetableActorForCategory(PlayState* play, ActorContext* actorCtx, Player* player, u32 actorCategory) {
f32 distSq;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to make sure, when this system calls an actor "targetable", that means it is either lock-able, or hover-able?

I feel like this is going to be a common place of confusion moving forward, with most people assuming "targetable" means "lockable", cause thats how the term is commonly used. But I guess theres not much we can do about it. I dont have any ideas for a different term.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at it again, it's actually very specifically used for "hover-able".

Target_FindTargetableActorForCategory is used specifically for Target_GetTargetActor and no where else, and Target_GetTargetActor is used to get the actor that's set to targetCtx->arrowHoverActor. Afterwards, actor in that function gets overwritten with something else so it's not used for any other purpose. It's just that arrowHoverActor then gets used for other purposes later to allow an actor to be locked-on

if ((player->unk_664 != NULL) && (player->unk_84B[player->unk_846] == 2)) {
    targetCtx->arrowHoverActor = NULL;
} else {
    Target_GetTargetActor(play, &play->actorCtx, &actor, player);
    targetCtx->arrowHoverActor = actor;
}

So maybe:
Target_GetTargetActor -> Target_GetArrowHoverActor
Target_FindTargetableActorForCategory -> Target_FindArrowHoverActorForCategory

But then

Actor* sTargetableNearestActor;
Actor* sTargetablePrioritizedActor;
f32 sTargetableNearestActorDistSq;
s32 sTargetablePrioritizedPriority;

Should all change to ArrowHoverActor?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking, maybe we shouldnt be so set on this being the "arrow" actor, and more on the fact that its the next lock-able actor?
Does the arrow appear above things that are not lockable?
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

video helps get the point across better. this "current" and "next" lockable actor interaction is a pretty important concept to get across, and I dont think the current "arrow" naming helps with this. but Ive not investigated all of the code to see if the way it ends up working in practice translates to these functions well

2023-11-24.23-36-14.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants