From 18e714e09847e441551705b424d0ec8488fa1834 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 13 Feb 2022 17:28:19 -0800 Subject: [PATCH] Document object_cow (#650) * Document object_cow * Respond to reviews * Reorder flags --- assets/xml/objects/object_cow.xml | 87 +++++++++++-------- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 37 ++++---- src/overlays/actors/ovl_En_Cow/z_en_cow.h | 12 +-- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 8 +- 4 files changed, 77 insertions(+), 67 deletions(-) diff --git a/assets/xml/objects/object_cow.xml b/assets/xml/objects/object_cow.xml index 390c54b368..535d5dd85b 100644 --- a/assets/xml/objects/object_cow.xml +++ b/assets/xml/objects/object_cow.xml @@ -1,38 +1,57 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index c41c055ee7..fd42fd3f35 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -5,9 +5,8 @@ */ #include "z_en_cow.h" -#include "objects/object_cow/object_cow.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnCow*)thisx) @@ -107,9 +106,9 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { switch (EN_COW_TYPE(thisx)) { case EN_COW_TYPE_DEFAULT: case EN_COW_TYPE_ABDUCTED: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gCowBodyChewAnim); + Animation_PlayLoop(&this->skelAnime, &gCowChewAnim); Collider_InitAndSetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); Collider_InitAndSetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); @@ -136,7 +135,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { break; case EN_COW_TYPE_TAIL: SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, - COW_LIMB_MAX); + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); this->actor.update = EnCow_UpdateTail; @@ -145,7 +144,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { EnCow_SetTailPos(this); - this->actor.flags &= ~EN_COW_FLAG_IS_TAIL; + this->actor.flags &= ~ACTOR_FLAG_1; this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; break; } @@ -171,13 +170,13 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { this->animationTimer--; } else { this->animationTimer = Rand_ZeroFloat(500.0f) + 40.0f; - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_ONCE, 1.0f); } if (this->actor.xzDistToPlayer < 150.0f) { if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { this->animationTimer = 0; } } @@ -202,7 +201,7 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; } @@ -210,7 +209,7 @@ void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnCow_Idle; } } @@ -226,7 +225,7 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); @@ -255,7 +254,7 @@ void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { this->actionFunc = EnCow_TalkEnd; } } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; //! @bug textId is reset to this no matter the intial value } @@ -273,7 +272,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { D_801BDAA4 = 0; this->actionFunc = EnCow_Talk; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; // Text to give milk after playing Epona's Song. @@ -297,7 +296,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actionFunc = EnCow_Talk; } @@ -344,12 +343,12 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); - Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCowBodyMoveHeadAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowMooAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowMooAnim), + ANIMMODE_ONCE, 1.0f); } else { - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowBodyChewAnim), + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_LOOP, 1.0f); } } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index fd865cecbe..bb9319ad97 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -2,10 +2,10 @@ #define Z_EN_COW_H #include "global.h" +#include "objects/object_cow/object_cow.h" #define EN_COW_TYPE(thisx) ((thisx)->params & 0xF) -#define EN_COW_FLAG_IS_TAIL (1 << 0) // This is never set but it is cleared for tail types #define EN_COW_FLAG_PLAYER_HAS_APPROACHED (1 << 1) #define EN_COW_FLAG_WONT_GIVE_MILK (1 << 2) @@ -19,16 +19,6 @@ struct EnCow; typedef void (*EnCowActionFunc)(struct EnCow*, GlobalContext*); -typedef enum { - /* 0 */ COW_LIMB_NONE, - /* 1 */ COW_LIMB_ROOT, - /* 2 */ COW_LIMB_HEAD, - /* 3 */ COW_LIMB_JAW, - /* 4 */ COW_LIMB_NOSE, - /* 5 */ COW_LIMB_NOSE_RING, - /* 6 */ COW_LIMB_MAX, -} ObjectCowLimbs; - typedef struct EnCow { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder colliders[2]; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 6b50e10e8b..0df7e2a277 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2364,8 +2364,9 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, 6); - Animation_PlayLoop(&this->skelAnime, &gCowBodyMoveHeadAnim); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gCowMooAnim); } } @@ -2407,7 +2408,8 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, 6); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailSwishAnim); } }