1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-28 15:56:51 +00:00

Document Mido functions, fields, and animations (#2289)

* Document `func_80AAA250`

new name: `EnMd_ReverseAnimation`

* rename `enum EnMdAnimation` > `enum EnMdAnimIndex`

* Document `struct EnMd` fields (and functions)

the list:

* `func_80AAAC78` -> `EnMd_TrackMessageState`
* `func_80AAAA24` -> `EnMd_UpdateAnimState_WithTalking`

* `func_80AAA92C` -> `EnMd_SetAnimState`
* `func_80AAA93C` -> `EnMd_UpdateAnimState`
* `func_80AAA274` -> `EnMd_UpdateAnimState1`
* `func_80AAA308` -> `EnMd_UpdateAnimState2`
* `func_80AAA39C` -> `EnMd_UpdateAnimState3`
* `func_80AAA474` -> `EnMd_UpdateAnimState4`
* `func_80AAA508` -> `EnMd_UpdateAnimState5`
* `func_80AAA5A4` -> `EnMd_UpdateAnimState6`
* `func_80AAA638` -> `EnMd_UpdateAnimState7`
* `func_80AAA6D4` -> `EnMd_UpdateAnimState8`
* `func_80AAA768` -> `EnMd_UpdateAnimState9`
* `func_80AAA7FC` -> `EnMd_UpdateAnimState10`
* `func_80AAA890` -> `EnMd_UpdateAnimState11`

* Document `func_80AAB158`

new name: `EnMd_UpdateTalking`

* Document `func_80034DD4` @ `z_actor.c`

new name: `Actor_SmoothStep_Attention`

* Document `func_80AAB5A4`

new name: `EnMd_SmoothStep_Attention`

* Document Mido's action functions

the list:
* `func_80AAB874` -> `EnMd_Idle`
* `func_80AAB8F8` -> `EnMd_Watch`
* `func_80AAB948` -> `EnMd_BlockPath`
* `func_80AABC10` -> `EnMd_ListenToOcarina`
* `func_80AABD0C` -> `EnMd_Walk`

* rename flag `temp2` -> `canUpdateTalking`

* (re)document Mido's animations

via blender and fast64

* marginally improve comments

* marginally improve comments

* actually, yes, let's name action functions as such

* Document eye textures as an enum

to clarify for `EnMd_UpdateEyes`

* rename `eyeIdx` -> `eyeTexIndex`

Mido has two eyes and different textures for them

* Undocument eye textures as an enum

i was wrong: `_Draw` function might not follow the eyes texture order
it is its own thing, like `enum EnMdBlinking` or nothing at all, yeah

* ugh, and fix a typo with blinking

rushing is no good

* drop the `Action` suffix

https://github.com/zeldaret/oot/pull/2289#discussion_r1837272286

* rename animation states as sequences

https://github.com/zeldaret/oot/pull/2289#discussion_r1837274923

* `func_80034DD4` -> `Actor_FadeInOut`

https://github.com/zeldaret/oot/pull/2289#discussion_r1837267267

* rename animation states as sequences

a continuation of b11a9e9942

* `func_80034DD4` -> `Actor_UpdateAlphaByDistance`

https://github.com/zeldaret/oot/pull/2289#discussion_r1838398475

* clarify a comment

* Document `actor.params` bits allocation

* apply review suggestions

* apply review suggestions

* apply review suggestions

* apply review suggestions

* apply review suggestions
This commit is contained in:
Leonid Kapitonov 2024-12-09 14:06:05 +01:00 committed by GitHub
parent e9b165b6e5
commit 9305a71458
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 275 additions and 253 deletions

View file

@ -71,17 +71,17 @@
<Texture Name="gMidoTex_58F0" OutName="tex_58F0" Format="ci8" Width="8" Height="8" Offset="0x58F0" TlutOffset="0x4C48"/> <Texture Name="gMidoTex_58F0" OutName="tex_58F0" Format="ci8" Width="8" Height="8" Offset="0x58F0" TlutOffset="0x4C48"/>
<!-- Mido Animations --> <!-- Mido Animations -->
<Animation Name="gMidoHandsOnHipsIdleAnim" Offset="0x02C8"/> <Animation Name="gMidoIdleAnim" Offset="0x02C8"/>
<Animation Name="gMidoSlamAnim" Offset="0x8510"/> <Animation Name="gMidoCuriousToAnnoyedAnim" Offset="0x8510"/>
<Animation Name="gMidoAngryHeadTurnAnim" Offset="0x8738"/> <Animation Name="gMidoIdleToAnnoyedAnim" Offset="0x8738"/>
<Animation Name="gMidoAnnoyedPointedHeadIdle1Anim" Offset="0x8E84"/> <Animation Name="gMidoCuriousAnim" Offset="0x8E84"/>
<Animation Name="gMidoHandsOnHipsTransitionAnim" Offset="0x8FC0"/> <Animation Name="gMidoIdleToSurpriseAnim" Offset="0x8FC0"/>
<Animation Name="gMidoRaiseHand1Anim" Offset="0x917C"/> <Animation Name="gMidoIdleToHaltAnim" Offset="0x917C"/>
<Animation Name="gMidoAnim_92B0" Offset="0x92B0"/> <Animation Name="gMidoIdleToWalkAnim" Offset="0x92B0"/>
<Animation Name="gMidoRaiseHand2Anim" Offset="0x95BC"/> <Animation Name="gMidoAnnoyedToHaltAnim" Offset="0x95BC"/>
<Animation Name="gMidoAnnoyedPointedHeadIdle2Anim" Offset="0x97F0"/> <Animation Name="gMidoAnnoyedAnim" Offset="0x97F0"/>
<Animation Name="gMidoPutHandDownAnim" Offset="0x9B1C"/> <Animation Name="gMidoHaltToCuriousAnim" Offset="0x9B1C"/>
<Animation Name="gMidoHaltAnim" Offset="0x9E68"/> <Animation Name="gMidoHaltAnim" Offset="0x9E68"/>
<Animation Name="gMidoWalkingAnim" Offset="0xA138"/> <Animation Name="gMidoWalkAnim" Offset="0xA138"/>
</File> </File>
</Root> </Root>

View file

@ -936,7 +936,7 @@ void func_80034BA0(struct PlayState* play, SkelAnime* skelAnime, OverrideLimbDra
PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); PostLimbDraw postLimbDraw, Actor* actor, s16 alpha);
void func_80034CC4(struct PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, void func_80034CC4(struct PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw,
PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); PostLimbDraw postLimbDraw, Actor* actor, s16 alpha);
s16 func_80034DD4(Actor* actor, struct PlayState* play, s16 arg2, f32 arg3); s16 Actor_UpdateAlphaByDistance(Actor* actor, struct PlayState* play, s16 alpha, f32 radius);
void Actor_UpdateFidgetTables(struct PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen); void Actor_UpdateFidgetTables(struct PlayState* play, s16* fidgetTableY, s16* fidgetTableZ, s32 tableLen);
void Actor_Noop(Actor* actor, struct PlayState* play); void Actor_Noop(Actor* actor, struct PlayState* play);

View file

@ -4407,25 +4407,25 @@ void func_80034CC4(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overr
CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8904); CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8904);
} }
s16 func_80034DD4(Actor* actor, PlayState* play, s16 arg2, f32 arg3) { s16 Actor_UpdateAlphaByDistance(Actor* actor, PlayState* play, s16 alpha, f32 radius) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
f32 var; f32 distance;
if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) { if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) {
var = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f; distance = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f;
} else { } else {
var = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); distance = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos);
} }
if (arg3 < var) { if (radius < distance) {
actor->flags &= ~ACTOR_FLAG_ATTENTION_ENABLED; actor->flags &= ~ACTOR_FLAG_ATTENTION_ENABLED;
Math_SmoothStepToS(&arg2, 0, 6, 0x14, 1); Math_SmoothStepToS(&alpha, 0, 6, 0x14, 1);
} else { } else {
actor->flags |= ACTOR_FLAG_ATTENTION_ENABLED; actor->flags |= ACTOR_FLAG_ATTENTION_ENABLED;
Math_SmoothStepToS(&arg2, 0xFF, 6, 0x14, 1); Math_SmoothStepToS(&alpha, 0xFF, 6, 0x14, 1);
} }
return arg2; return alpha;
} }
void Animation_ChangeByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, s32 index) { void Animation_ChangeByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, s32 index) {

View file

@ -15,11 +15,11 @@ void EnMd_Destroy(Actor* thisx, PlayState* play);
void EnMd_Update(Actor* thisx, PlayState* play); void EnMd_Update(Actor* thisx, PlayState* play);
void EnMd_Draw(Actor* thisx, PlayState* play); void EnMd_Draw(Actor* thisx, PlayState* play);
void func_80AAB874(EnMd* this, PlayState* play); void EnMd_Idle(EnMd* this, PlayState* play);
void func_80AAB8F8(EnMd* this, PlayState* play); void EnMd_Watch(EnMd* this, PlayState* play);
void func_80AAB948(EnMd* this, PlayState* play); void EnMd_BlockPath(EnMd* this, PlayState* play);
void func_80AABC10(EnMd* this, PlayState* play); void EnMd_ListenToOcarina(EnMd* this, PlayState* play);
void func_80AABD0C(EnMd* this, PlayState* play); void EnMd_Walk(EnMd* this, PlayState* play);
ActorProfile En_Md_Profile = { ActorProfile En_Md_Profile = {
/**/ ACTOR_EN_MD, /**/ ACTOR_EN_MD,
@ -55,41 +55,56 @@ static ColliderCylinderInit sCylinderInit = {
static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE };
typedef enum EnMdAnimation { typedef enum EnMdAnimSequence {
/* 0 */ ENMD_ANIM_0, /* 0x0 */ ENMD_ANIM_SEQ_NONE,
/* 1 */ ENMD_ANIM_1, /* 0x1 */ ENMD_ANIM_SEQ_IDLE_TO_HALT, // hands on hips -> halt gesture
/* 2 */ ENMD_ANIM_2, /* 0x2 */ ENMD_ANIM_SEQ_HALT_TO_CURIOUS, // halt gesture -> tilted head
/* 3 */ ENMD_ANIM_3, /* 0x3 */ ENMD_ANIM_SEQ_WALK_AWAY, // stop halt gesture -> start walking -> walking
/* 4 */ ENMD_ANIM_4, /* 0x4 */ ENMD_ANIM_SEQ_TWITCH_IDLE_UNUSED, // start walking -> hands on hips; never set
/* 5 */ ENMD_ANIM_5, /* 0x5 */ ENMD_ANIM_SEQ_HALT_TO_IDLE, // halt gesture -> hands on hips
/* 6 */ ENMD_ANIM_6, /* 0x6 */ ENMD_ANIM_SEQ_SURPRISE_TO_ANNOYED, // slightly raise arms from hips -> look away
/* 7 */ ENMD_ANIM_7, /* 0x7 */ ENMD_ANIM_SEQ_SURPRISE_TO_IDLE, // lower slightly raised arms to hips -> hands on hips
/* 8 */ ENMD_ANIM_8, /* 0x8 */ ENMD_ANIM_SEQ_CURIOUS_TO_ANNOYED, // tilted head and *slam* -> looking away
/* 9 */ ENMD_ANIM_9, /* 0x9 */ ENMD_ANIM_SEQ_ANNOYED_TO_HALT, // looking away -> halt gesture
/* 10 */ ENMD_ANIM_10, /* 0xA */ ENMD_ANIM_SEQ_IDLE_TO_ANNOYED, // hands on hips -> looking away
/* 11 */ ENMD_ANIM_11, /* 0xB */ ENMD_ANIM_SEQ_STOP_WALKING // stop walking -> hands on hips
/* 12 */ ENMD_ANIM_12, } EnMdAnimSequence;
/* 13 */ ENMD_ANIM_13
} EnMdAnimation; typedef enum EnMdAnimIndex {
/* 0 */ ENMD_ANIM_INDEX_IDLE_DEFAULT, // hands on hips; default idle
/* 1 */ ENMD_ANIM_INDEX_IDLE_UNUSED, // hands on hips; never set
/* 2 */ ENMD_ANIM_INDEX_IDLE_TO_HALT, // hands on hips -> halt gesture
/* 3 */ ENMD_ANIM_INDEX_HALT, // halt gesture
/* 4 */ ENMD_ANIM_INDEX_HALT_TO_CURIOUS, // halt gesture -> tilted head
/* 5 */ ENMD_ANIM_INDEX_CURIOUS, // tilted head
/* 6 */ ENMD_ANIM_INDEX_ANNOYED, // looking away
/* 7 */ ENMD_ANIM_INDEX_IDLE_TO_WALK, // hands on hips -> walking
/* 8 */ ENMD_ANIM_INDEX_WALK, // walking
/* 9 */ ENMD_ANIM_INDEX_IDLE_TO_SURPISE, // hands on hips -> slightly raised arms
/* 10 */ ENMD_ANIM_INDEX_IDLE, // hands on hips
/* 11 */ ENMD_ANIM_INDEX_CURIOUS_TO_ANNOYED, // tilted head -> looking away
/* 12 */ ENMD_ANIM_INDEX_ANNOYED_TO_HALT, // looking away -> halt gesture
/* 13 */ ENMD_ANIM_INDEX_IDLE_TO_ANNOYED // hands on hips -> looking away
} EnMdAnimIndex;
static AnimationInfo sAnimationInfo[] = { static AnimationInfo sAnimationInfo[] = {
{ &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, { &gMidoIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f },
{ &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, { &gMidoIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f },
{ &gMidoRaiseHand1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, { &gMidoIdleToHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, { &gMidoHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoPutHandDownAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, { &gMidoHaltToCuriousAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoAnnoyedPointedHeadIdle1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, { &gMidoCuriousAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoAnnoyedPointedHeadIdle2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, { &gMidoAnnoyedAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoAnim_92B0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, { &gMidoIdleToWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoWalkingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, { &gMidoWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoHandsOnHipsTransitionAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, { &gMidoIdleToSurpriseAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f }, { &gMidoIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f },
{ &gMidoSlamAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, { &gMidoCuriousToAnnoyedAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoRaiseHand2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f }, { &gMidoAnnoyedToHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoAngryHeadTurnAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f }, { &gMidoIdleToAnnoyedAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
}; };
void func_80AAA250(EnMd* this) { void EnMd_ReverseAnimation(EnMd* this) {
f32 startFrame; f32 startFrame;
startFrame = this->skelAnime.startFrame; startFrame = this->skelAnime.startFrame;
@ -99,289 +114,290 @@ void func_80AAA250(EnMd* this) {
this->skelAnime.playSpeed = -1.0f; this->skelAnime.playSpeed = -1.0f;
} }
void func_80AAA274(EnMd* this) { void EnMd_UpdateAnimSequence_IdleToHalt(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_2); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_HALT);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_3); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_HALT);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA308(EnMd* this) { void EnMd_UpdateAnimSequence_HaltToCurious(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_4); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_HALT_TO_CURIOUS);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_5); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_CURIOUS);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA39C(EnMd* this) { void EnMd_UpdateAnimSequence_WalkAway(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_2); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_HALT);
func_80AAA250(this); EnMd_ReverseAnimation(this);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_7); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_WALK);
this->unk_20A++; this->animSequenceEntry++;
} else { } else {
break; break;
} }
FALLTHROUGH; FALLTHROUGH;
case 2: case 2:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_8); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_WALK);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA474(EnMd* this) { void EnMd_UpdateAnimSequence_TwitchIdle_Unused(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_7); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_WALK);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA508(EnMd* this) { void EnMd_UpdateAnimSequence_HaltToIdle(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_2); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_HALT);
func_80AAA250(this); EnMd_ReverseAnimation(this);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA5A4(EnMd* this) { void EnMd_UpdateAnimSequence_SurpriseToAnnoyed(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_9); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_SURPISE);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_6); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_ANNOYED);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA638(EnMd* this) { void EnMd_UpdateAnimSequence_SurpriseToIdle(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_9); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_SURPISE);
func_80AAA250(this); EnMd_ReverseAnimation(this);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA6D4(EnMd* this) { void EnMd_UpdateAnimSequence_CuriousToAnnoyed(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_11); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_CURIOUS_TO_ANNOYED);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_6); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_ANNOYED);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA768(EnMd* this) { void EnMd_UpdateAnimSequence_AnnoyedToHalt(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_12); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_ANNOYED_TO_HALT);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_3); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_HALT);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA7FC(EnMd* this) { void EnMd_UpdateAnimSequence_IdleToAnnoyed(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_13); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_ANNOYED);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_6); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_ANNOYED);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA890(EnMd* this) { void EnMd_UpdateAnimSequence_StopWalking(EnMd* this) {
switch (this->unk_20A) { switch (this->animSequenceEntry) {
case 0: case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_7); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_TO_WALK);
func_80AAA250(this); EnMd_ReverseAnimation(this);
this->unk_20A++; this->animSequenceEntry++;
FALLTHROUGH; FALLTHROUGH;
case 1: case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE);
this->unk_20A++; this->animSequenceEntry++;
} }
break; break;
} }
} }
void func_80AAA92C(EnMd* this, u8 arg1) { void EnMd_SetAnimSequence(EnMd* this, u8 state) {
this->unk_20B = arg1; this->animSequence = state;
this->unk_20A = 0; this->animSequenceEntry = 0;
} }
void func_80AAA93C(EnMd* this) { void EnMd_UpdateAnimSequence(EnMd* this) {
switch (this->unk_20B) { switch (this->animSequence) {
case 1: case ENMD_ANIM_SEQ_IDLE_TO_HALT:
func_80AAA274(this); EnMd_UpdateAnimSequence_IdleToHalt(this);
break; break;
case 2: case ENMD_ANIM_SEQ_HALT_TO_CURIOUS:
func_80AAA308(this); EnMd_UpdateAnimSequence_HaltToCurious(this);
break; break;
case 3: case ENMD_ANIM_SEQ_WALK_AWAY:
func_80AAA39C(this); EnMd_UpdateAnimSequence_WalkAway(this);
break; break;
case 4: case ENMD_ANIM_SEQ_TWITCH_IDLE_UNUSED:
func_80AAA474(this); // unreachable
EnMd_UpdateAnimSequence_TwitchIdle_Unused(this);
break; break;
case 5: case ENMD_ANIM_SEQ_HALT_TO_IDLE:
func_80AAA508(this); EnMd_UpdateAnimSequence_HaltToIdle(this);
break; break;
case 6: case ENMD_ANIM_SEQ_SURPRISE_TO_ANNOYED:
func_80AAA5A4(this); EnMd_UpdateAnimSequence_SurpriseToAnnoyed(this);
break; break;
case 7: case ENMD_ANIM_SEQ_SURPRISE_TO_IDLE:
func_80AAA638(this); EnMd_UpdateAnimSequence_SurpriseToIdle(this);
break; break;
case 8: case ENMD_ANIM_SEQ_CURIOUS_TO_ANNOYED:
func_80AAA6D4(this); EnMd_UpdateAnimSequence_CuriousToAnnoyed(this);
break; break;
case 9: case ENMD_ANIM_SEQ_ANNOYED_TO_HALT:
func_80AAA768(this); EnMd_UpdateAnimSequence_AnnoyedToHalt(this);
break; break;
case 10: case ENMD_ANIM_SEQ_IDLE_TO_ANNOYED:
func_80AAA7FC(this); EnMd_UpdateAnimSequence_IdleToAnnoyed(this);
break; break;
case 11: case ENMD_ANIM_SEQ_STOP_WALKING:
func_80AAA890(this); EnMd_UpdateAnimSequence_StopWalking(this);
} }
} }
void func_80AAAA24(EnMd* this) { void EnMd_UpdateAnimSequence_WithTalking(EnMd* this) {
if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) { if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) {
switch (this->actor.textId) { switch (this->actor.textId) {
case 0x102F: case 0x102F:
if ((this->unk_208 == 0) && (this->unk_20B != 1)) { if ((this->messageEntry == 0) && (this->animSequence != ENMD_ANIM_SEQ_IDLE_TO_HALT)) {
func_80AAA92C(this, 1); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_IDLE_TO_HALT);
} }
if ((this->unk_208 == 2) && (this->unk_20B != 2)) { if ((this->messageEntry == 2) && (this->animSequence != ENMD_ANIM_SEQ_HALT_TO_CURIOUS)) {
func_80AAA92C(this, 2); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_HALT_TO_CURIOUS);
} }
if ((this->unk_208 == 5) && (this->unk_20B != 8)) { if ((this->messageEntry == 5) && (this->animSequence != ENMD_ANIM_SEQ_CURIOUS_TO_ANNOYED)) {
func_80AAA92C(this, 8); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_CURIOUS_TO_ANNOYED);
} }
if ((this->unk_208 == 11) && (this->unk_20B != 9)) { if ((this->messageEntry == 11) && (this->animSequence != ENMD_ANIM_SEQ_ANNOYED_TO_HALT)) {
func_80AAA92C(this, 9); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_ANNOYED_TO_HALT);
} }
break; break;
case 0x1033: case 0x1033:
if ((this->unk_208 == 0) && (this->unk_20B != 1)) { if ((this->messageEntry == 0) && (this->animSequence != ENMD_ANIM_SEQ_IDLE_TO_HALT)) {
func_80AAA92C(this, 1); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_IDLE_TO_HALT);
} }
if ((this->unk_208 == 1) && (this->unk_20B != 2)) { if ((this->messageEntry == 1) && (this->animSequence != ENMD_ANIM_SEQ_HALT_TO_CURIOUS)) {
func_80AAA92C(this, 2); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_HALT_TO_CURIOUS);
} }
if ((this->unk_208 == 5) && (this->unk_20B != 10)) { if ((this->messageEntry == 5) && (this->animSequence != ENMD_ANIM_SEQ_IDLE_TO_ANNOYED)) {
func_80AAA92C(this, 10); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_IDLE_TO_ANNOYED);
} }
if ((this->unk_208 == 7) && (this->unk_20B != 9)) { if ((this->messageEntry == 7) && (this->animSequence != ENMD_ANIM_SEQ_ANNOYED_TO_HALT)) {
func_80AAA92C(this, 9); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_ANNOYED_TO_HALT);
} }
break; break;
case 0x1030: case 0x1030:
case 0x1034: case 0x1034:
case 0x1045: case 0x1045:
if ((this->unk_208 == 0) && (this->unk_20B != 1)) { if ((this->messageEntry == 0) && (this->animSequence != ENMD_ANIM_SEQ_IDLE_TO_HALT)) {
func_80AAA92C(this, 1); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_IDLE_TO_HALT);
} }
break; break;
case 0x1046: case 0x1046:
if ((this->unk_208 == 0) && (this->unk_20B != 6)) { if ((this->messageEntry == 0) && (this->animSequence != ENMD_ANIM_SEQ_SURPRISE_TO_ANNOYED)) {
func_80AAA92C(this, 6); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_SURPRISE_TO_ANNOYED);
} }
break; break;
} }
} else if (this->skelAnime.animation != &gMidoHandsOnHipsIdleAnim) { } else if (this->skelAnime.animation != &gMidoIdleAnim) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE);
func_80AAA92C(this, 0); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_NONE);
} }
func_80AAA93C(this); EnMd_UpdateAnimSequence(this);
} }
s16 func_80AAAC78(EnMd* this, PlayState* play) { s16 EnMd_TrackMessageState(EnMd* this, PlayState* play) {
s16 dialogState = Message_GetState(&play->msgCtx); s16 messageState = Message_GetState(&play->msgCtx);
if ((this->unk_209 == TEXT_STATE_AWAITING_NEXT) || (this->unk_209 == TEXT_STATE_EVENT) || if ((this->messageState == TEXT_STATE_AWAITING_NEXT) || (this->messageState == TEXT_STATE_EVENT) ||
(this->unk_209 == TEXT_STATE_CLOSING) || (this->unk_209 == TEXT_STATE_DONE_HAS_NEXT)) { (this->messageState == TEXT_STATE_CLOSING) || (this->messageState == TEXT_STATE_DONE_HAS_NEXT)) {
if (this->unk_209 != dialogState) { if (this->messageState != messageState) {
this->unk_208++; this->messageEntry++;
} }
} }
this->unk_209 = dialogState; this->messageState = messageState;
return dialogState; return messageState;
} }
u16 EnMd_GetTextIdKokiriForest(PlayState* play, EnMd* this) { u16 EnMd_GetTextIdKokiriForest(PlayState* play, EnMd* this) {
@ -391,8 +407,8 @@ u16 EnMd_GetTextIdKokiriForest(PlayState* play, EnMd* this) {
return textId; return textId;
} }
this->unk_208 = 0; this->messageEntry = 0;
this->unk_209 = TEXT_STATE_NONE; this->messageState = TEXT_STATE_NONE;
if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) { if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) {
return 0x1045; return 0x1045;
@ -415,8 +431,8 @@ u16 EnMd_GetTextIdKokiriForest(PlayState* play, EnMd* this) {
} }
u16 EnMd_GetTextIdMidosHouse(PlayState* play, EnMd* this) { u16 EnMd_GetTextIdMidosHouse(PlayState* play, EnMd* this) {
this->unk_208 = 0; this->messageEntry = 0;
this->unk_209 = TEXT_STATE_NONE; this->messageState = TEXT_STATE_NONE;
if (GET_EVENTCHKINF(EVENTCHKINF_40)) { if (GET_EVENTCHKINF(EVENTCHKINF_40)) {
return 0x1028; return 0x1028;
@ -426,8 +442,8 @@ u16 EnMd_GetTextIdMidosHouse(PlayState* play, EnMd* this) {
} }
u16 EnMd_GetTextIdLostWoods(PlayState* play, EnMd* this) { u16 EnMd_GetTextIdLostWoods(PlayState* play, EnMd* this) {
this->unk_208 = 0; this->messageEntry = 0;
this->unk_209 = TEXT_STATE_NONE; this->messageState = TEXT_STATE_NONE;
if (GET_EVENTCHKINF(EVENTCHKINF_48)) { if (GET_EVENTCHKINF(EVENTCHKINF_48)) {
if (GET_INFTABLE(INFTABLE_19)) { if (GET_INFTABLE(INFTABLE_19)) {
@ -464,7 +480,7 @@ u16 EnMd_GetTextId(PlayState* play, Actor* thisx) {
s16 EnMd_UpdateTalkState(PlayState* play, Actor* thisx) { s16 EnMd_UpdateTalkState(PlayState* play, Actor* thisx) {
EnMd* this = (EnMd*)thisx; EnMd* this = (EnMd*)thisx;
switch (func_80AAAC78(this, play)) { switch (EnMd_TrackMessageState(this, play)) {
case TEXT_STATE_NONE: case TEXT_STATE_NONE:
case TEXT_STATE_DONE_HAS_NEXT: case TEXT_STATE_DONE_HAS_NEXT:
case TEXT_STATE_DONE_FADING: case TEXT_STATE_DONE_FADING:
@ -528,19 +544,19 @@ u8 EnMd_ShouldSpawn(EnMd* this, PlayState* play) {
void EnMd_UpdateEyes(EnMd* this) { void EnMd_UpdateEyes(EnMd* this) {
if (DECR(this->blinkTimer) == 0) { if (DECR(this->blinkTimer) == 0) {
this->eyeIdx++; this->eyeTexIndex++;
if (this->eyeIdx > 2) { if (this->eyeTexIndex > 2) {
this->blinkTimer = Rand_S16Offset(30, 30); this->blinkTimer = Rand_S16Offset(30, 30);
this->eyeIdx = 0; this->eyeTexIndex = 0;
} }
} }
} }
void func_80AAB158(EnMd* this, PlayState* play) { void EnMd_UpdateTalking(EnMd* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
s16 absYawDiff; s16 absYawDiff;
s16 trackingMode; s16 trackingMode;
s16 temp2; s16 canUpdateTalking;
s16 yawDiff; s16 yawDiff;
if (this->actor.xzDistToPlayer < 170.0f) { if (this->actor.xzDistToPlayer < 170.0f) {
@ -549,23 +565,23 @@ void func_80AAB158(EnMd* this, PlayState* play) {
trackingMode = trackingMode =
absYawDiff <= Npc_GetTrackingPresetMaxPlayerYaw(2) ? NPC_TRACKING_HEAD_AND_TORSO : NPC_TRACKING_NONE; absYawDiff <= Npc_GetTrackingPresetMaxPlayerYaw(2) ? NPC_TRACKING_HEAD_AND_TORSO : NPC_TRACKING_NONE;
temp2 = 1; canUpdateTalking = true;
} else { } else {
trackingMode = NPC_TRACKING_NONE; trackingMode = NPC_TRACKING_NONE;
temp2 = 0; canUpdateTalking = false;
} }
if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) { if (this->interactInfo.talkState != NPC_TALK_STATE_IDLE) {
trackingMode = NPC_TRACKING_FULL_BODY; trackingMode = NPC_TRACKING_FULL_BODY;
} }
if (this->actionFunc == func_80AABD0C) { if (this->actionFunc == EnMd_Walk) {
trackingMode = NPC_TRACKING_NONE; trackingMode = NPC_TRACKING_NONE;
temp2 = 0; canUpdateTalking = false;
} }
if (this->actionFunc == func_80AAB8F8) { if (this->actionFunc == EnMd_Watch) {
trackingMode = NPC_TRACKING_FULL_BODY; trackingMode = NPC_TRACKING_FULL_BODY;
temp2 = 1; canUpdateTalking = true;
} }
if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) { if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) {
@ -578,8 +594,8 @@ void func_80AAB158(EnMd* this, PlayState* play) {
} }
Npc_TrackPoint(&this->actor, &this->interactInfo, 2, trackingMode); Npc_TrackPoint(&this->actor, &this->interactInfo, 2, trackingMode);
if (this->actionFunc != func_80AABC10) { if (this->actionFunc != EnMd_ListenToOcarina) {
if (temp2) { if (canUpdateTalking) {
Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->collider.dim.radius + 30.0f, Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->collider.dim.radius + 30.0f,
EnMd_GetTextId, EnMd_UpdateTalkState); EnMd_GetTextId, EnMd_UpdateTalkState);
} }
@ -592,11 +608,11 @@ u8 EnMd_FollowPath(EnMd* this, PlayState* play) {
f32 pathDiffX; f32 pathDiffX;
f32 pathDiffZ; f32 pathDiffZ;
if (PARAMS_GET_NOSHIFT(this->actor.params, 8, 8) == 0xFF00) { if (ENMD_GET_PATH_INDEX_NOSHIFT(this) == (ENMD_PATH_NONE << 8)) {
return 0; return 0;
} }
path = &play->pathList[PARAMS_GET_S(this->actor.params, 8, 8)]; path = &play->pathList[ENMD_GET_PATH_INDEX(this)];
pointPos = SEGMENTED_TO_VIRTUAL(path->points); pointPos = SEGMENTED_TO_VIRTUAL(path->points);
pointPos += this->waypoint; pointPos += this->waypoint;
@ -619,11 +635,11 @@ u8 EnMd_SetMovedPos(EnMd* this, PlayState* play) {
Path* path; Path* path;
Vec3s* lastPointPos; Vec3s* lastPointPos;
if (PARAMS_GET_NOSHIFT(this->actor.params, 8, 8) == 0xFF00) { if (ENMD_GET_PATH_INDEX_NOSHIFT(this) == (ENMD_PATH_NONE << 8)) {
return 0; return 0;
} }
path = &play->pathList[PARAMS_GET_S(this->actor.params, 8, 8)]; path = &play->pathList[ENMD_GET_PATH_INDEX(this)];
lastPointPos = SEGMENTED_TO_VIRTUAL(path->points); lastPointPos = SEGMENTED_TO_VIRTUAL(path->points);
lastPointPos += path->count - 1; lastPointPos += path->count - 1;
@ -634,15 +650,15 @@ u8 EnMd_SetMovedPos(EnMd* this, PlayState* play) {
return 1; return 1;
} }
void func_80AAB5A4(EnMd* this, PlayState* play) { void EnMd_UpdateAlphaByDistance(EnMd* this, PlayState* play) {
f32 temp; f32 radius;
if (play->sceneId != SCENE_MIDOS_HOUSE) { if (play->sceneId != SCENE_MIDOS_HOUSE) {
temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) && radius = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !GET_EVENTCHKINF(EVENTCHKINF_1C) &&
(play->sceneId == SCENE_KOKIRI_FOREST)) (play->sceneId == SCENE_KOKIRI_FOREST))
? 100.0f ? 100.0f
: 400.0f; : 400.0f;
this->alpha = func_80034DD4(&this->actor, play, this->alpha, temp); this->alpha = Actor_UpdateAlphaByDistance(&this->actor, play, this->alpha, radius);
this->actor.shape.shadowAlpha = this->alpha; this->actor.shape.shadowAlpha = this->alpha;
} else { } else {
this->alpha = 255; this->alpha = 255;
@ -665,7 +681,7 @@ void EnMd_Init(Actor* thisx, PlayState* play) {
return; return;
} }
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_0); Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_INDEX_IDLE_DEFAULT);
Actor_SetScale(&this->actor, 0.01f); Actor_SetScale(&this->actor, 0.01f);
this->actor.attentionRangeType = ATTENTION_RANGE_6; this->actor.attentionRangeType = ATTENTION_RANGE_6;
this->alpha = 255; this->alpha = 255;
@ -677,7 +693,7 @@ void EnMd_Init(Actor* thisx, PlayState* play) {
CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) || CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) ||
((play->sceneId == SCENE_LOST_WOODS) && !GET_EVENTCHKINF(EVENTCHKINF_0A))) { ((play->sceneId == SCENE_LOST_WOODS) && !GET_EVENTCHKINF(EVENTCHKINF_0A))) {
this->actor.home.pos = this->actor.world.pos; this->actor.home.pos = this->actor.world.pos;
this->actionFunc = func_80AAB948; this->actionFunc = EnMd_BlockPath;
return; return;
} }
@ -685,7 +701,7 @@ void EnMd_Init(Actor* thisx, PlayState* play) {
EnMd_SetMovedPos(this, play); EnMd_SetMovedPos(this, play);
} }
this->actionFunc = func_80AAB874; this->actionFunc = EnMd_Idle;
} }
void EnMd_Destroy(Actor* thisx, PlayState* play) { void EnMd_Destroy(Actor* thisx, PlayState* play) {
@ -693,30 +709,31 @@ void EnMd_Destroy(Actor* thisx, PlayState* play) {
Collider_DestroyCylinder(play, &this->collider); Collider_DestroyCylinder(play, &this->collider);
} }
void func_80AAB874(EnMd* this, PlayState* play) { void EnMd_Idle(EnMd* this, PlayState* play) {
if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { if (this->skelAnime.animation == &gMidoIdleAnim) {
Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX);
} else if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && (this->unk_20B != 7)) { } else if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) &&
func_80AAA92C(this, 7); (this->animSequence != ENMD_ANIM_SEQ_SURPRISE_TO_IDLE)) {
EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_SURPRISE_TO_IDLE);
} }
func_80AAAA24(this); EnMd_UpdateAnimSequence_WithTalking(this);
} }
void func_80AAB8F8(EnMd* this, PlayState* play) { void EnMd_Watch(EnMd* this, PlayState* play) {
if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { if (this->skelAnime.animation == &gMidoIdleAnim) {
Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX);
} }
func_80AAA93C(this); EnMd_UpdateAnimSequence(this);
} }
void func_80AAB948(EnMd* this, PlayState* play) { void EnMd_BlockPath(EnMd* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
f32 temp; f32 temp;
Actor* actorToBlock = &GET_PLAYER(play)->actor; Actor* actorToBlock = &GET_PLAYER(play)->actor;
s16 yaw; s16 yaw;
func_80AAAA24(this); EnMd_UpdateAnimSequence_WithTalking(this);
if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) { if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) {
this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer;
@ -747,16 +764,16 @@ void func_80AAB948(EnMd* this, PlayState* play) {
SET_EVENTCHKINF(EVENTCHKINF_0A); SET_EVENTCHKINF(EVENTCHKINF_0A);
} }
func_80AAA92C(this, 3); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_WALK_AWAY);
func_80AAA93C(this); EnMd_UpdateAnimSequence(this);
this->waypoint = 1; this->waypoint = 1;
this->interactInfo.talkState = NPC_TALK_STATE_IDLE; this->interactInfo.talkState = NPC_TALK_STATE_IDLE;
this->actionFunc = func_80AABD0C; this->actionFunc = EnMd_Walk;
this->actor.speed = 1.5f; this->actor.speed = 1.5f;
return; return;
} }
if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) { if (this->skelAnime.animation == &gMidoIdleAnim) {
Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX);
} }
@ -765,7 +782,7 @@ void func_80AAB948(EnMd* this, PlayState* play) {
player->stateFlags2 |= PLAYER_STATE2_25; player->stateFlags2 |= PLAYER_STATE2_25;
player->unk_6A8 = &this->actor; player->unk_6A8 = &this->actor;
Message_StartOcarina(play, OCARINA_ACTION_CHECK_SARIA); Message_StartOcarina(play, OCARINA_ACTION_CHECK_SARIA);
this->actionFunc = func_80AABC10; this->actionFunc = EnMd_ListenToOcarina;
return; return;
} }
@ -775,11 +792,11 @@ void func_80AAB948(EnMd* this, PlayState* play) {
} }
} }
void func_80AABC10(EnMd* this, PlayState* play) { void EnMd_ListenToOcarina(EnMd* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
if (play->msgCtx.ocarinaMode >= OCARINA_MODE_04) { if (play->msgCtx.ocarinaMode >= OCARINA_MODE_04) {
this->actionFunc = func_80AAB948; this->actionFunc = EnMd_BlockPath;
play->msgCtx.ocarinaMode = OCARINA_MODE_04; play->msgCtx.ocarinaMode = OCARINA_MODE_04;
} else if (play->msgCtx.ocarinaMode == OCARINA_MODE_03) { } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_03) {
Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
@ -787,16 +804,16 @@ void func_80AABC10(EnMd* this, PlayState* play) {
this->actor.textId = 0x1067; this->actor.textId = 0x1067;
Actor_OfferTalk(&this->actor, play, this->collider.dim.radius + 30.0f); Actor_OfferTalk(&this->actor, play, this->collider.dim.radius + 30.0f);
this->actionFunc = func_80AAB948; this->actionFunc = EnMd_BlockPath;
play->msgCtx.ocarinaMode = OCARINA_MODE_04; play->msgCtx.ocarinaMode = OCARINA_MODE_04;
} else { } else {
player->stateFlags2 |= PLAYER_STATE2_23; player->stateFlags2 |= PLAYER_STATE2_23;
} }
} }
void func_80AABD0C(EnMd* this, PlayState* play) { void EnMd_Walk(EnMd* this, PlayState* play) {
Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX); Actor_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENMD_LIMB_MAX);
func_80AAA93C(this); EnMd_UpdateAnimSequence(this);
if (!(EnMd_FollowPath(this, play)) || (this->waypoint != 0)) { if (!(EnMd_FollowPath(this, play)) || (this->waypoint != 0)) {
this->actor.shape.rot = this->actor.world.rot; this->actor.shape.rot = this->actor.world.rot;
@ -811,12 +828,12 @@ void func_80AABD0C(EnMd* this, PlayState* play) {
return; return;
} }
func_80AAA92C(this, 11); EnMd_SetAnimSequence(this, ENMD_ANIM_SEQ_STOP_WALKING);
this->skelAnime.playSpeed = 0.0f; this->skelAnime.playSpeed = 0.0f;
this->actor.speed = 0.0f; this->actor.speed = 0.0f;
this->actor.home.pos = this->actor.world.pos; this->actor.home.pos = this->actor.world.pos;
this->actionFunc = func_80AAB8F8; this->actionFunc = EnMd_Watch;
} }
void EnMd_Update(Actor* thisx, PlayState* play) { void EnMd_Update(Actor* thisx, PlayState* play) {
@ -827,9 +844,9 @@ void EnMd_Update(Actor* thisx, PlayState* play) {
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
SkelAnime_Update(&this->skelAnime); SkelAnime_Update(&this->skelAnime);
EnMd_UpdateEyes(this); EnMd_UpdateEyes(this);
func_80AAB5A4(this, play); EnMd_UpdateAlphaByDistance(this, play);
Actor_MoveXZGravity(&this->actor); Actor_MoveXZGravity(&this->actor);
func_80AAB158(this, play); EnMd_UpdateTalking(this, play);
Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2);
this->actionFunc(this, play); this->actionFunc(this, play);
} }
@ -880,10 +897,10 @@ void EnMd_Draw(Actor* thisx, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx, "../z_en_md.c", 1280); OPEN_DISPS(play->state.gfxCtx, "../z_en_md.c", 1280);
if (this->alpha == 255) { if (this->alpha == 255) {
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIdx])); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex]));
func_80034BA0(play, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha); func_80034BA0(play, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha);
} else if (this->alpha != 0) { } else if (this->alpha != 0) {
gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIdx])); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex]));
func_80034CC4(play, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha); func_80034CC4(play, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha);
} }

View file

@ -29,18 +29,23 @@ typedef enum EnMdLimb {
typedef void (*EnMdActionFunc)(struct EnMd*, PlayState*); typedef void (*EnMdActionFunc)(struct EnMd*, PlayState*);
#define ENMD_GET_PATH_INDEX(this) PARAMS_GET_S(this->actor.params, 8, 8)
#define ENMD_GET_PATH_INDEX_NOSHIFT(this) PARAMS_GET_NOSHIFT(this->actor.params, 8, 8)
#define ENMD_PATH_NONE 0xFF
typedef struct EnMd { typedef struct EnMd {
/* 0x0000 */ Actor actor; /* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime; /* 0x014C */ SkelAnime skelAnime;
/* 0x0190 */ EnMdActionFunc actionFunc; /* 0x0190 */ EnMdActionFunc actionFunc;
/* 0x0194 */ ColliderCylinder collider; /* 0x0194 */ ColliderCylinder collider;
/* 0x01E0 */ NpcInteractInfo interactInfo; /* 0x01E0 */ NpcInteractInfo interactInfo;
/* 0x0208 */ u8 unk_208; /* 0x0208 */ u8 messageEntry; // tracks message state changes, like with `BOX_BREAK` or `TEXTID`
/* 0x0209 */ u8 unk_209; /* 0x0209 */ u8 messageState; // last known result of `Message_GetState`
/* 0x020A */ u8 unk_20A; /* 0x020A */ u8 animSequenceEntry; // each one changes animation info and waits
/* 0x020B */ u8 unk_20B; /* 0x020B */ u8 animSequence;
/* 0x020C */ s16 blinkTimer; /* 0x020C */ s16 blinkTimer;
/* 0x020E */ s16 eyeIdx; /* 0x020E */ s16 eyeTexIndex;
/* 0x0210 */ s16 alpha; /* 0x0210 */ s16 alpha;
/* 0x0212 */ s16 waypoint; /* 0x0212 */ s16 waypoint;
/* 0x0214 */ s16 fidgetTableY[ENMD_LIMB_MAX]; /* 0x0214 */ s16 fidgetTableY[ENMD_LIMB_MAX];

View file

@ -738,7 +738,7 @@ void EnSa_Update(Actor* thisx, PlayState* play) {
} }
if (this->actionFunc != func_80AF68E4) { if (this->actionFunc != func_80AF68E4) {
this->alpha = func_80034DD4(&this->actor, play, this->alpha, 400.0f); this->alpha = Actor_UpdateAlphaByDistance(&this->actor, play, this->alpha, 400.0f);
} else { } else {
this->alpha = 255; this->alpha = 255;
} }