mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-13 19:35:28 +00:00
Document Player's Face and z_actor FaceChange functions (#1928)
* create some enums * gonna try struct instead of array * struct works. add docs too * inline function comments * fix function comment * name faces, move enums * rename textures * outnames * remove comments * change comment slightly * fixup face comments * review * offset comments * add and use PLAYER_FACE_MAX * typo * more comment on blinkDuration * another change to the comment
This commit is contained in:
parent
07505dae37
commit
bd0941405d
10 changed files with 220 additions and 70 deletions
|
@ -3189,33 +3189,64 @@ void Enemy_StartFinishingBlow(PlayState* play, Actor* actor) {
|
|||
SfxSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE);
|
||||
}
|
||||
|
||||
s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
|
||||
if (DECR(arg0[1]) == 0) {
|
||||
arg0[1] = Rand_S16Offset(arg1, arg2);
|
||||
/**
|
||||
* Updates `FaceChange` data for a blinking pattern.
|
||||
* This system expects that the actor using the system has defined 3 faces in this exact order:
|
||||
* "eyes open", "eyes half open", "eyes closed".
|
||||
*
|
||||
* @param faceChange pointer to an actor's faceChange data
|
||||
* @param blinkIntervalBase The base number of frames between blinks
|
||||
* @param blinkIntervalRandRange The range for a random number of frames that can be added to `blinkIntervalBase`
|
||||
* @param blinkDuration The number of frames it takes for a single blink to occur
|
||||
*/
|
||||
s16 FaceChange_UpdateBlinking(FaceChange* faceChange, s16 blinkIntervalBase, s16 blinkIntervalRandRange,
|
||||
s16 blinkDuration) {
|
||||
if (DECR(faceChange->timer) == 0) {
|
||||
faceChange->timer = Rand_S16Offset(blinkIntervalBase, blinkIntervalRandRange);
|
||||
}
|
||||
|
||||
if ((arg0[1] - arg3) > 0) {
|
||||
arg0[0] = 0;
|
||||
} else if (((arg0[1] - arg3) > -2) || (arg0[1] < 2)) {
|
||||
arg0[0] = 1;
|
||||
if ((faceChange->timer - blinkDuration) > 0) {
|
||||
// `timer - duration` is positive so this is the default state: "eyes open" face
|
||||
faceChange->face = 0;
|
||||
} else if (((faceChange->timer - blinkDuration) > -2) || (faceChange->timer < 2)) {
|
||||
// This condition aims to catch both cases where the "eyes half open" face is needed.
|
||||
// Note that the comparison assumes the duration of the "eyes half open" phase is 2 frames, irrespective of the
|
||||
// value of `blinkDuration`. The duration for the "eyes closed" phase is `blinkDuration - 4`.
|
||||
// For Player's use case `blinkDuration` is 6, so the "eyes closed" phase happens to have
|
||||
// the same duration as each "eyes half open" phase.
|
||||
faceChange->face = 1;
|
||||
} else {
|
||||
arg0[0] = 2;
|
||||
// If both conditions above fail, the only possibility left is the "eyes closed" face
|
||||
faceChange->face = 2;
|
||||
}
|
||||
|
||||
return arg0[0];
|
||||
return faceChange->face;
|
||||
}
|
||||
|
||||
s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
|
||||
if (DECR(arg0[1]) == 0) {
|
||||
arg0[1] = Rand_S16Offset(arg1, arg2);
|
||||
arg0[0]++;
|
||||
/**
|
||||
* Updates `FaceChange` data for randomly selected face sets.
|
||||
* Each set contains 3 faces. After the timer runs out, the next face in the set is used.
|
||||
* After the third face in a set is used, a new face set is randomly chosen.
|
||||
*
|
||||
* @param faceChange pointer to an actor's faceChange data
|
||||
* @param changeTimerBase The base number of frames between each face change
|
||||
* @param changeTimerRandRange The range for a random number of frames that can be added to `changeTimerBase`
|
||||
* @param faceSetRange The max number of face sets that will be chosen from
|
||||
*/
|
||||
s16 FaceChange_UpdateRandomSet(FaceChange* faceChange, s16 changeTimerBase, s16 changeTimerRandRange,
|
||||
s16 faceSetRange) {
|
||||
if (DECR(faceChange->timer) == 0) {
|
||||
faceChange->timer = Rand_S16Offset(changeTimerBase, changeTimerRandRange);
|
||||
faceChange->face++;
|
||||
|
||||
if ((arg0[0] % 3) == 0) {
|
||||
arg0[0] = (s32)(Rand_ZeroOne() * arg3) * 3;
|
||||
if ((faceChange->face % 3) == 0) {
|
||||
// Randomly chose a "set number", then multiply by 3 because each set has 3 faces.
|
||||
// This will use the first face in the newly chosen set.
|
||||
faceChange->face = (s32)(Rand_ZeroOne() * faceSetRange) * 3;
|
||||
}
|
||||
}
|
||||
|
||||
return arg0[0];
|
||||
return faceChange->face;
|
||||
}
|
||||
|
||||
void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue