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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
There was a problem hiding this 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
Yup 😏 here's some wip rough docs of the rest, including the player targeting code: |
void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, PlayState* play) { | ||
TargetContextEntry* entry; | ||
NaviColor* naviColor; | ||
void Target_InitReticle(TargetContext* targetCtx, s32 actorCategory, PlayState* play) { |
There was a problem hiding this comment.
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?
include/z64actor.h
Outdated
/* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* 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
There was a problem hiding this comment.
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
src/code/z_actor.c
Outdated
// Use multiple triangle sets for the movement effect when the triangles are | ||
// getting closer to the actor from the margin of the screen |
There was a problem hiding this comment.
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"
src/code/z_actor.c
Outdated
// Draw the 4 lock-on triangles | ||
for (triangleIndex = 0; triangleIndex < 4; triangleIndex++) { |
There was a problem hiding this comment.
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
src/code/z_actor.c
Outdated
if (lockOnActor->id == ACTOR_EN_BOOM) { | ||
// Avoid drawing the lock on triangles on the boomerang |
There was a problem hiding this comment.
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"
src/code/z_actor.c
Outdated
} 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 |
There was a problem hiding this comment.
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
src/code/z_actor.c
Outdated
// Linear scaling, yaw being 90 degree means it will return the original distance, 0 degree will adjust to 60% | ||
// of the distance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
degree -> degrees
void Target_FindTargetableActorForCategory(PlayState* play, ActorContext* actorCtx, Player* player, u32 actorCategory) { | ||
f32 distSq; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
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