diff --git a/assets/xml/objects/object_sdn.xml b/assets/xml/objects/object_sdn.xml index 9cc607047c..691a272eef 100644 --- a/assets/xml/objects/object_sdn.xml +++ b/assets/xml/objects/object_sdn.xml @@ -1,66 +1,66 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index de8b9a9500..56f6db7da7 100644 --- a/spec +++ b/spec @@ -4956,8 +4956,7 @@ beginseg name "ovl_En_Demo_heishi" compress include "build/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.data.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Demo_heishi/ovl_En_Demo_heishi_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index b7e1609906..d38727322d 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -5,6 +5,7 @@ */ #include "z_en_demo_heishi.h" +#include "objects/object_sdn/object_sdn.h" #define FLAGS 0x00000009 @@ -15,10 +16,22 @@ void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE975C(EnDemoheishi* this, GlobalContext* globalCtx); -void func_80BE980C(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex); +void EnDemoheishi_SetupIdle(EnDemoheishi* this); +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_SetupTalk(EnDemoheishi* this); +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx); +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx); + +typedef enum { + /* 0 */ DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ DEMOHEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ DEMOHEISHI_ANIMATION_WAVE, + /* 3 */ DEMOHEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ DEMOHEISHI_ANIMATION_STAND_UP +} EnDemoheishiAnimationIndex; -#if 0 const ActorInit En_Demo_heishi_InitVars = { ACTOR_EN_DEMO_HEISHI, ACTORCAT_NPC, @@ -31,37 +44,152 @@ const ActorInit En_Demo_heishi_InitVars = { (ActorFunc)EnDemoheishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9A50 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +static u16 sTextIds[] = { 0x1473 }; // Shiro initial intro text -extern ColliderCylinderInit D_80BE9A50; +void EnDemoheishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -extern UNK_TYPE D_06003BFC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, 17); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + EnDemoheishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Init.s") +void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE95EC.s") +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9678.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE970C.s") +void EnDemoheishi_SetHeadRotation(EnDemoheishi* this) { + s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE975C.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 0x4E20)) { + this->headRotXTarget = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->headRotXTarget > 0x2710) { + this->headRotXTarget = 0x2710; + } else if (this->headRotXTarget < -0x2710) { + this->headRotXTarget = -0x2710; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE97F0.s") +void EnDemoheishi_SetupIdle(EnDemoheishi* this) { + EnDemoheishi_ChangeAnimation(this, DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP); + this->textIdIndex = 0; + this->actor.textId = sTextIds[this->textIdIndex]; + this->isTalking = false; + this->actionFunc = EnDemoheishi_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE980C.s") +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx) { + s32 absYawDiff; + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Update.s") + this->actor.flags &= ~ACTOR_FLAG_8000000; + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9974.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnDemoheishi_SetupTalk(this); + } else if (absYawDiff <= 0x4BB8) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Draw.s") +void EnDemoheishi_SetupTalk(EnDemoheishi* this) { + this->isTalking = true; + this->actionFunc = EnDemoheishi_Talk; +} + +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + EnDemoheishi_SetupIdle(this); + } +} + +void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDemoheishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_SetScale(&this->actor, 0.01f); + EnDemoheishi_SetHeadRotation(this); + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} + +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDemoheishi* this = THIS; + + if (limbIndex == DEMOHEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDemoheishi_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h index 8dcdc899d7..e6a2f9a914 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h @@ -7,12 +7,46 @@ struct EnDemoheishi; typedef void (*EnDemoheishiActionFunc)(struct EnDemoheishi*, GlobalContext*); +typedef enum { + /* 0 */ DEMOHEISHI_LIMB_NONE, + /* 1 */ DEMOHEISHI_LIMB_ROOT, + /* 2 */ DEMOHEISHI_LIMB_PELVIS, + /* 3 */ DEMOHEISHI_LIMB_LEFT_THIGH, + /* 4 */ DEMOHEISHI_LIMB_LEFT_SHIN, + /* 5 */ DEMOHEISHI_LIMB_LEFT_FOOT, + /* 6 */ DEMOHEISHI_LIMB_RIGHT_THIGH, + /* 7 */ DEMOHEISHI_LIMB_RIGHT_SHIN, + /* 8 */ DEMOHEISHI_LIMB_RIGHT_FOOT, + /* 9 */ DEMOHEISHI_LIMB_TORSO, + /* 10 */ DEMOHEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ DEMOHEISHI_LIMB_LEFT_FOREARM, + /* 12 */ DEMOHEISHI_LIMB_LEFT_HAND, + /* 13 */ DEMOHEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ DEMOHEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ DEMOHEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ DEMOHEISHI_LIMB_HEAD, + /* 17 */ DEMOHEISHI_LIMB_MAX +} EnDemoheishiLimbs; + typedef struct EnDemoheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnDemoheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x68]; -} EnDemoheishi; // size = 0x2C0 + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEMOHEISHI_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[DEMOHEISHI_LIMB_MAX]; + /* 0x254 */ EnDemoheishiActionFunc actionFunc; + /* 0x258 */ s16 headRotY; + /* 0x25A */ s16 headRotX; + /* 0x25C */ s16 headRotZ; + /* 0x25E */ s16 headRotYTarget; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 headRotZTarget; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s16 timer; + /* 0x26C */ f32 frameCount; + /* 0x270 */ s16 isTalking; + /* 0x272 */ s16 textIdIndex; + /* 0x274 */ ColliderCylinder colliderCylinder; +} EnDemoheishi; //size = 0x2C0 extern const ActorInit En_Demo_heishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 59e1fd836c..82070a2faf 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -38,7 +38,7 @@ void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sdn_Skel_00D640, &object_sdn_Anim_002A84, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierCheerWithSpear, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index 1b296098fa..b2c5924948 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -38,13 +38,13 @@ const ActorInit En_Ending_Hero6_InitVars = { static FlexSkeletonHeader* sSkeletons[] = { &object_dt_Skel_00B0CC, &object_bai_Skel_007908, &object_toryo_Skel_007150, - &object_sdn_Skel_00D640, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, + &gSoldierSkeleton, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, }; static AnimationHeader* sAnimations[] = { &object_dt_Anim_000BE0, &object_bai_Anim_0011C0, &object_toryo_Anim_000E50, - &object_sdn_Anim_002A84, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, + &gSoldierCheerWithSpear, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, }; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 96bb6a06cf..87e56de8ae 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16170,14 +16170,14 @@ 0x80BE93D8:("EnHeishi_Draw",), 0x80BE9510:("EnDemoheishi_Init",), 0x80BE95C0:("EnDemoheishi_Destroy",), - 0x80BE95EC:("func_80BE95EC",), - 0x80BE9678:("func_80BE9678",), - 0x80BE970C:("func_80BE970C",), - 0x80BE975C:("func_80BE975C",), - 0x80BE97F0:("func_80BE97F0",), - 0x80BE980C:("func_80BE980C",), + 0x80BE95EC:("EnDemoheishi_ChangeAnimation",), + 0x80BE9678:("EnDemoheishi_SetHeadRotation",), + 0x80BE970C:("EnDemoheishi_SetupIdle",), + 0x80BE975C:("EnDemoheishi_Idle",), + 0x80BE97F0:("EnDemoheishi_SetupTalk",), + 0x80BE980C:("EnDemoheishi_Talk",), 0x80BE9864:("EnDemoheishi_Update",), - 0x80BE9974:("func_80BE9974",), + 0x80BE9974:("EnDemoheishi_OverrideLimbDraw",), 0x80BE99CC:("EnDemoheishi_Draw",), 0x80BE9B20:("EnDt_Init",), 0x80BE9C48:("EnDt_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index ec70cbd0fe..b303f85530 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16195,10 +16195,10 @@ 0x80BE947C:("D_80BE947C","UNK_TYPE1","",0x1), 0x80BE9490:("D_80BE9490","UNK_TYPE1","",0x1), 0x80BE9A30:("En_Demo_heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9A50:("D_80BE9A50","UNK_TYPE1","",0x1), - 0x80BE9A7C:("D_80BE9A7C","UNK_TYPE1","",0x1), - 0x80BE9A80:("D_80BE9A80","UNK_TYPE1","",0x1), - 0x80BE9A94:("D_80BE9A94","UNK_TYPE1","",0x1), + 0x80BE9A50:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE9A7C:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE9A80:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9A94:("sAnimModes","UNK_TYPE1","",0x1), 0x80BEB1B0:("En_Dt_InitVars","UNK_TYPE1","",0x1), 0x80BEB1D0:("D_80BEB1D0","UNK_TYPE1","",0x1), 0x80BEB208:("D_80BEB208","UNK_TYPE1","",0x1),