-
Notifications
You must be signed in to change notification settings - Fork 577
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
Document Sequence Modes and Related Functions #1046
Conversation
include/z64.h
Outdated
@@ -217,7 +217,7 @@ typedef struct { | |||
/* 0x4D */ char unk_4D[0x03]; | |||
/* 0x50 */ TargetContextEntry arr_50[3]; | |||
/* 0x8C */ Actor* unk_8C; | |||
/* 0x90 */ Actor* unk_90; | |||
/* 0x90 */ Actor* nearestEnemyBgm; |
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.
Calling an actor pointer nearestEnemyBgm
doesn't feel right to me, is it intended?
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.
It's the name I came up with yeah, but open to brainstorming a better one. Since it's a pointer to an actor, I guess it should probably end in enemy
. Actor* nearestBgmEnemy
?
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.
Having both "nearest" and "bgm" in the name doesn't make much sense to me. I think it could make more sense as simply the nearest enemy actor (used for bgm but possibly other things as well). Same for sNearestEnemyBgmDistSq
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.
From my understanding, this does not track all/generic enemies as you specifically need both the ACTOR_FLAG_0
(targetable) and ACTOR_FLAG_2
(0x4 is documented as the enemy bgm flag) to count as an enemy that plays the enemy bgm as you approach. Not all enemies have the ACTOR_FLAG_2
flag, so this is not pointing to a generic enemy, but rather a subset relating to bgm enemies.
That being said, there might be more to this as well. I just checked out @Dragorn421 ACTOR_FLAG
PR to see if anything else is going on with ACTOR_FLAG_2
that hasn't been reported yet. It does seem to do slightly more. In actor, the only other function it serves is to be required play the enemy target sfx instead of the "human" lock on sfx.
In player, it's also related to state flags stateFlags1 & 0x10
, stateFlags1 & 0x10000
, and stateFlags2 & 0x2000
. So that's interesting to me.
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 is from the speedrunning communities notes so take with a grain of salt, but 0x10 is targeting an enemy, 0x10000 is targeting anything(?) and flags2 & 0x2000 is targeting something with switch targeting enabled specifically
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.
It makes sense in the most part, tho I'm not sure if we should trust the existing documentation on the enemy bgm flag part, but yeah if it's specifically for enemies with a bgm, then nearestBgmEnemy
is probably fine
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.
That's fair to be cautious of the existing docs, but my current knowledge is entirely from the repo now. Setting the "nearestBgmEnemy", the target sfx, and the three stateFlags "possibly" related to targeting (haven't fully confirmed that myself, just the relation to the stateflags) seems to be the full usage of ACTOR_FLAG_2
, assuming no instances were missed.
Other alternatives could be something like closestBgmEnemy
or possibly just bgmEnemy
if those sound nicer to you
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.
Does the audio system care about whether it's the nearest enemy? If not then bgmEnemy
could be good enough yeah
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.
I think a good compromise could be bgmEnemy
with a brief comment explaining that its always going to be the closest one to you.
The audio system doesnt seem to care, but it is a variable in the actor context so the implementation of it in the actor system is a little bit relevant in that regard imo
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.
The single parameter that the audio system cares about is "distance" to the nearest bgm enemy i.e.:
Audio_SetNearestEnemyBgmVolume(sqrtf(globalCtx->actorCtx.targetCtx.nearestEnemyBgm->xyzDistToPlayerSq));
This distance is used in setting both the volume of the "BGM_ENEMY" played on the sub-bgm player, but is also relevant to how the channels are split between the main-bgm player (for example, the dungeon music when no enemies are around) and the sub-bgm player.
I suppose it'd be fine just leaving it as bgmEnemy
with the extra comment. There are a few places to remove the Nearest
part, I'll try to add comments where necessary
* Document Audio_SetSequenceMode * Cleanup surrounding docs * format * Clean-up * fix capital `I` in `playeridx` * Dist -> DistSq * `SetCamModeAndSeqMode` -> `UpdateCamAndSeqModes` * Get rid of extra padding * PR Feedback
This PR introduced the following enum for sequence modes:
Sequence modes 0 & 2 are heavily used by hyrule field sequence logic, as slightly altered bgms will play depending on if LInk moving, standing still, or even near an enemy.
Sequence mode 1 is related to the enemy bgm played that gets louder as you approach generic enemies. Many functions and struct names related to this enemy bgm are named as well.
Sequence mode 3 is primarily used to skip mode of the
Audio_SetSequenceMode
code and functionality, and is related to turning off generic enemy music instantly (for example, when the upgraded mini-boss bgm starts playing).This adds a small amount of docs to Audio, Player, and Actor as they all play small parts in managing these different sequence modes