From abef65a6dba505cf07dbc59360af644092877a1a Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Thu, 1 Jul 2021 19:20:34 -0700 Subject: [PATCH] En_Niw (Cucco) (#191) * EnNiw: Rebase of WIP to work on collsion init almost matches EnNiw: WIP EnNiw: running low, and too many not-matches for my liking EnNiw: WIP 3 * EnNiw: update to master * EnNiw: fix late rodata * wtf is going on * EnNiw: update is a thing, glad I'm doing it last * EnNiw: likely branch mysery * EnNiw: a horrible little draw function * EnNiw: nope, feather draw still fucked * EnNiw: fixing merge issues with master * EnNiw: update is no longer non-matching * EnNiw: cleaning/docs * EnNiw: cleaning/docs 3 * EnNiw: more docs 4 * EnNiw: OKs again now that data was removed * EnNiw: Docs and cleaning 5 * EnNiw: Docs and cleaning 6 * EnNiw: Docs/cleaning and changed a function and that changed a bunch ugh * EnNiw: format and make check * EnNiw: data re-merged, and matches * EnNiw: forgot about these * EnNiw: another attempt at feather draw, still not even close * Multiple: now that we know the last paramter is a flag, change all to hex * Player: fix wrong padding * EnNiw parameter name consistency Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c REG Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Niw/z_en_niw.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnNiw: Likely suggestions first easy suggestions first, then I'll attempt the stuff I'm not sure will match Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnNiw: compiling again * EnNiw: more suggestions added * EnNiw: last of minor changes * EnNiw: shorten overly long float * EnNiw: feather counts as define * EnNiw: add c file description * EnNiw: Some Suggested Changes Co-authored-by: Anghelo Carvajal * EnNiw: more suggestions * EnNiw: More suggestions Co-authored-by: Anghelo Carvajal * EnNiw: moved OPEN_DISPS to contentional location, still not close * BgIcicle/EnSb: renamed func_800B78B8 to Actor_UpdateBgCheckInfo Co-authored-by: isghj8 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Anghelo Carvajal --- include/functions.h | 8 +- include/z64actor.h | 4 +- linker_scripts/code_script.txt | 8 +- linker_scripts/object_script.txt | 4 + src/code/z_actor.c | 18 +- src/code/z_en_item00.c | 2 +- .../actors/ovl_Bg_Icicle/z_bg_icicle.c | 2 +- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 2 +- .../ovl_En_Ending_Hero/z_en_ending_hero.c | 2 +- .../ovl_En_Ending_Hero2/z_en_ending_hero2.c | 2 +- .../ovl_En_Ending_Hero3/z_en_ending_hero3.c | 2 +- .../ovl_En_Ending_Hero4/z_en_ending_hero4.c | 2 +- .../ovl_En_Ending_Hero5/z_en_ending_hero5.c | 2 +- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 2 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 3 +- src/overlays/actors/ovl_En_In/z_en_in.c | 2 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 2 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 2 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 1036 ++++++++++++++++- src/overlays/actors/ovl_En_Niw/z_en_niw.h | 86 +- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 2 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 2 +- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.c | 2 +- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 2 +- .../actors/ovl_En_Tanron6/z_en_tanron6.c | 2 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 2 +- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 6 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 2 +- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 10 +- tables/functions.txt | 34 +- 31 files changed, 1172 insertions(+), 85 deletions(-) diff --git a/include/functions.h b/include/functions.h index 929dc9b19c..7665e37853 100644 --- a/include/functions.h +++ b/include/functions.h @@ -799,7 +799,7 @@ s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range void func_800B75A0(CollisionPoly* param_1, Vec3f* param_2, s16* param_3); // UNK_TYPE4 func_800B761C(Actor* param_1, UNK_TYPE4 param_2, u32 param_3); // UNK_TYPE4 func_800B7678(GlobalContext* globalCtx, Actor* param_2, s32 param_3, u32 param_4); -void func_800B78B8(GlobalContext* globalCtx, Actor* actor, f32 uParm3, f32 uParm4, f32 param_5, u32 param_6); +void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, u32 flags); // void func_800B7E04(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); s32 func_800B7FE0(f32* param_1, f32* param_2, f32* param_3, GraphicsContext* gfxCtx); // void func_800B8018(void); @@ -829,16 +829,16 @@ s32 func_800B8934(GlobalContext* globalCtx, Actor* actor); u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); UNK_TYPE4 func_800B8A1C(Actor* actor, GlobalContext* globalCtx, s32 iParm3, f32 fParm4, f32 param_5); // void func_800B8B84(void); -// void func_800B8BB0(void); +void func_800B8BB0(Actor* actor, GlobalContext* globalCtx); // void func_800B8BD0(void); -s32 func_800B8BFC(Actor* actor, GlobalContext* globalCtx); +s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx); // void func_800B8C20(void); void func_800B8C50(Actor* actor, GlobalContext* globalCtx); // void func_800B8C78(void); // void func_800B8C9C(void); // void func_800B8CEC(void); // void func_800B8D10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_800B8D50(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 param_3, s16 param_4, f32 param_5, u32 param_6); void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 param_3, s16 param_4, f32 param_5); // void func_800B8DD4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_800B8E1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); diff --git a/include/z64actor.h b/include/z64actor.h index d86af71092..4cfd665f56 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -273,7 +273,9 @@ typedef struct { /* 0xBEC */ Vec3f bodyPartsPos[18]; /* 0xCC4 */ MtxF mf_CC4; /* 0xD04 */ MtxF unkD04; - /* 0xD44 */ UNK_TYPE1 padD44[0x34]; + /* 0xD44 */ UNK_TYPE1 padD44[0x18]; + /* 0xD5C */ s8 invincibilityTimer; + /* 0xD5D */ UNK_TYPE1 padD5D[0x1B]; } ActorPlayer; // size = 0xD78 typedef enum { diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 05f53d2aa8..0157765aca 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -1041,9 +1041,15 @@ SECTIONS ovl_En_Niw : AT(RomLocation) { build/src/overlays/actors/ovl_En_Niw/z_en_niw.o(.text) - build/asm/overlays/ovl_En_Niw_data.o(.data) + build/src/overlays/actors/ovl_En_Niw/z_en_niw.o(.data) +#ifdef NON_EQUIVALENT + build/src/overlays/actors/ovl_En_Niw_rodata_overlay.o(.ovl) +#elseif NON_MATCHING + build/src/overlays/actors/ovl_En_Niw_rodata_overlay.o(.ovl) +#else build/src/overlays/actors/ovl_En_Niw/z_en_niw.o(.rodata) build/asm/overlays/ovl_En_Niw_rodata.o(.rodata) +#endif } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index b90ccbd9ef..b935b2b064 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -208,6 +208,10 @@ D_06007750 = 0x06007750; D_0600A390 = 0x0600A390; D_0600A490 = 0x0600A490; +/* en_niw */ +D_06002530 = 0x06002530; +D_060000E8 = 0x060000E8; + /* dm_char07 */ D_06000100 = 0x06000100; D_06000240 = 0x06000240; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index b0a92b62eb..2ceef01592 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -242,8 +242,8 @@ void Actor_TitleCardContextInit(GlobalContext* globalCtx, TitleCardContext* titl titleCardCtx->alpha = 0; } -void Actor_TitleCardCreate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx, u32 texture, s16 param_4, s16 param_5, - u8 param_6, u8 param_7) { +void Actor_TitleCardCreate(GlobalContext* globalCtx, TitleCardContext* titleCardCtx, u32 texture, s16 param_4, + s16 param_5, u8 param_6, u8 param_7) { titleCardCtx->texture = texture; titleCardCtx->unk4 = param_4; titleCardCtx->unk6 = param_5; @@ -568,7 +568,7 @@ s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range #pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B7678.asm") -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B78B8.asm") +#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//Actor_UpdateBgCheckInfo.asm") #pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B7E04.asm") @@ -624,9 +624,9 @@ s32 Actor_IsActorFacingActorAndWithinRange(Actor* actor, Actor* other, f32 range u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { if (actor->parent != NULL) { - return 1; + return true; } else { - return 0; + return false; } } @@ -638,7 +638,13 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { #pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B8BD0.asm") -#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B8BFC.asm") +s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { + if (!actor->parent) { + return true; + } else { + return false; + } +} #pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800B8C20.asm") diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index bffd14ba26..b0c0eda13b 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -461,7 +461,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.gravity != 0.0f) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); if (this->actor.floorHeight <= -32000.0f) { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c index 557f90e97b..4486335e74 100644 --- a/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c +++ b/src/overlays/actors/ovl_Bg_Icicle/z_bg_icicle.c @@ -186,7 +186,7 @@ void BgIcicle_Fall(BgIcicle* this, GlobalContext* globalCtx) { } else { Actor_SetVelocityAndMoveYRotationAndGravity(&this->dyna.actor); this->dyna.actor.world.pos.y += 40.0f; - func_800B78B8(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); this->dyna.actor.world.pos.y -= 40.0f; CollisionCheck_SetAT(globalCtx, &globalCtx->colCheckCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 8ec88c03b2..c9cd9f667e 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -90,7 +90,7 @@ void DmNb_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_FrameUpdateMatrix(&this->skelAnime); - func_800B78B8(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 0x4); } void DmNb_UnkActorDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* actor) { diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index 31928186d0..f32c5cc5a0 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -72,7 +72,7 @@ void EnEndingHero_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } static UNK_PTR D_80C1E970[] = { D_06007350, D_06009590, D_06009F90, D_0600A790, D_0600AB90 }; diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index eb1c0fe282..8b201a7aeb 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -57,7 +57,7 @@ void EnEndingHero2_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } void EnEndingHero2_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 94a1ef1cf5..73d28cd181 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -57,7 +57,7 @@ void EnEndingHero3_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } void EnEndingHero3_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 e52da18c72..38729764a2 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 @@ -57,7 +57,7 @@ void EnEndingHero4_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } void EnEndingHero4_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index de862f28b4..ec48db4412 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -64,7 +64,7 @@ void EnEndingHero5_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); } Gfx* D_80C23BF0[] = { D_060070C0, D_06006FB0, D_06006E80, D_06006D70, D_0600A390 }; diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index 413889a0ed..0d730fa0b7 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -329,7 +329,7 @@ void EnFg_Update(Actor* thisx, GlobalContext* globalCtx) { if (1) {} if (!flagSet) { this->actionFunc(this, globalCtx); - func_800B78B8(globalCtx, &this->actor, BASE_REG(16, 0), BASE_REG(16, 1), 0.0f, 5); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, BASE_REG(16, 0), BASE_REG(16, 1), 0.0f, 0x5); } } diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 1a09b807e1..93ba8a7802 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -430,7 +430,8 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) func_800BDC5C(&this->skelAnime, animations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl - } else if (D_801C1E2C[CUR_UPG_VALUE(UPG_WALLET)] < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { + } else if (D_801C1E2C[CUR_UPG_VALUE(UPG_WALLET)] < + (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); func_801518B0(globalCtx, 0x475, &this->actor); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index ff4d06f9b4..99df382977 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1479,7 +1479,7 @@ void EnIn_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk4AC &= ~0x40; } this->actionFunc(this, globalCtx); - func_800B78B8(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); func_808F3414(this, globalCtx); func_808F32A0(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 30341ef6c5..6340fd0e93 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -257,7 +257,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.radius = 40; } - func_800B78B8(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); Actor_SetScale(&this->actor, 0.01f); this->unk_1D8.unk_00 = 0; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 0472092ce0..84c81008bb 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -591,7 +591,7 @@ void EnMinifrog_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, 12.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base); this->actor.focus.rot.y = this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index e31863ba93..bdd5ba27ba 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -1,15 +1,40 @@ #include "z_en_niw.h" -#define FLAGS 0x00800010 +/* + * File: z_en_niw.c + * Overlay: ovl_En_Niw + * Description: Cucco (Chicken) (Japanese: Niwatori) + */ -#define THIS ((EnNiw*)thisx) +#define FLAGS 0x00800010 void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx); void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx); void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnNiw_SetupIdle(EnNiw* this); +void func_808919E8(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_SetupRunning(EnNiw* this); +void func_808924B0(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx); +void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx); +void func_808932B0(EnNiw* this, GlobalContext* globalCtx); // draw feather +void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx); +void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2); +s32 EnNiw_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, struct Actor* actor); +void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); + +// turned on during cucco storm, but not read by anything? +// maybe read by En_Attack_Niw +s16 D_80893460 = false; -/* const ActorInit En_Niw_InitVars = { ACTOR_EN_NIW, ACTORCAT_PROP, @@ -21,52 +46,1013 @@ const ActorInit En_Niw_InitVars = { (ActorFunc)EnNiw_Update, (ActorFunc)EnNiw_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/EnNiw_Init.asm") +static f32 D_80893484[] = { + 5000.0f, + -5000.0f, +}; +static f32 D_80893486[] = { + 5000.0f, + 3000.0f, + 4000.0f, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/EnNiw_Destroy.asm") +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 15, 25, 4, { 0, 0, 0 } }, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80891320.asm") +static Vec3f D_808934C4 = { + 90000.0f, + 90000.0f, + 90000.0f, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808916B0.asm") +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), + ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808917F8.asm") +static Vec3f D_808934DC = { + 90000.0f, + 90000.0f, + 90000.0f, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80891974.asm") +static Vec3f D_808934E8 = { + 90000.0f, + 90000.0f, + 90000.0f, +}; +static s32 pad = 0; + +void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* this = (EnNiw*)thisx; + Vec3f dTemp = D_808934C4; + + if (this->actor.params < 0) { // all neg values become zero + this->actor.params = ENNIW_TYPE_REGULAR; + } + + Math_Vec3f_Copy(&this->unk2BC, &dTemp); + + this->niwType = this->actor.params; + Actor_ProcessInitChain(&this->actor, sInitChain); + + this->actor.flags |= 0x1; // targetable ON + + ActorShape_Init(&thisx->shape, 0.0f, func_800B3FC0, 25.0f); + + SkelAnime_InitSV(globalCtx, &this->skelanime, &D_06002530, &D_060000E8, this->limbDrawTbl, + this->transitionDrawtable, ENNIW_LIMBCOUNT); + Math_Vec3f_Copy(&this->unk2A4, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk2B0, &this->actor.world.pos); + + this->unk308 = 10.0f; + Actor_SetScale(&this->actor, 0.01f); + + if (this->niwType == ENNIW_TYPE_UNK1) { + Actor_SetScale(&this->actor, (BREG(86) / 10000.0f) + 0.004f); + } + + // random health between 10-20 + this->actor.colChkInfo.health = Rand_ZeroFloat(9.99f) + 10.0f; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + + if (this->niwType == ENNIW_TYPE_REGULAR) { + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + } + + if (this->niwType == ENNIW_TYPE_UNK2) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + this->sfxTimer1 = 30; + this->unkTimer250 = 30; + this->actor.flags &= ~0x1; // targetable OFF + this->unknownState28E = 4; + this->actionFunc = EnNiw_Held; + this->actor.speedXZ = 0.0f; + this->unk2BC.z = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + } else { + EnNiw_SetupIdle(this); + } +} + +void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* this = (EnNiw*)thisx; + + if (this->niwType == ENNIW_TYPE_REGULAR) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2) { + f32 tempOne = 1.0f; + + if (this->unkTimer24C == 0) { + if (arg2 == 0) { + this->unk264[0] = 0.0f; + } else { + this->unk264[0] = (-10000.0f) * tempOne; + } + this->unk292 += 1; + this->unkTimer24C = 3; + if ((this->unk292 % 2) == 0) { + this->unk264[0] = 0.0f; + if (arg2 == 0) { + this->unkTimer24C = Rand_ZeroFloat(30.0f); + } + } + } + if (this->unkTimer24E == 0) { + this->unk296++; + this->unk296 &= 1; + switch (arg2) { + case 0: + this->unk264[2] = 0.0f; + this->unk264[1] = 0.0f; + break; + case 1: + this->unkTimer24E = 3; + this->unk264[2] = 7000.0f * tempOne; + this->unk264[1] = 7000.0f * tempOne; + if (this->unk296 == 0) { + this->unk264[2] = 0.0f; + this->unk264[1] = 0.0f; + } + break; + case 2: + this->unkTimer24E = 2; + this->unk264[2] = -10000.0f; + this->unk264[1] = -10000.0f; + this->unk264[7] = 25000.0f; + this->unk264[5] = 25000.0f; + this->unk264[8] = 6000.0f; + this->unk264[6] = 6000.0f; + if (this->unk296 == 0) { + this->unk264[7] = 8000.0f; + this->unk264[5] = 8000.0f; + } + break; + case 3: + this->unkTimer24E = 2; + this->unk264[5] = 10000.0f; + this->unk264[7] = 10000.0f; + if (this->unk296 == 0) { + this->unk264[5] = 3000.0f; + this->unk264[7] = 3000.0f; + } + break; + case 4: + this->unkTimer24C = 5; + break; + case 5: + this->unkTimer24E = 5; + this->unk264[5] = 14000.0f; + this->unk264[7] = 14000.0f; + if (this->unk296 == 0) { + this->unk264[5] = 10000.0f; + this->unk264[7] = 10000.0f; + } + break; + } + } + if (this->unk264[9] != this->limbFRot) { + Math_ApproachF(&this->limbFRot, this->unk264[9], 0.5f, 4000.0f); + } + if (this->unk264[0] != this->limbDRot) { + Math_ApproachF(&this->limbDRot, this->unk264[0], 0.5f, 4000.0f); + } + if (this->unk264[2] != this->limb7Rotz) { + Math_ApproachF(&this->limb7Rotz, this->unk264[2], 0.8f, 7000.0f); + } + if (this->unk264[7] != this->limb7Roty) { + Math_ApproachF(&this->limb7Roty, this->unk264[7], 0.8f, 7000.0f); + } + if (this->unk264[8] != this->limb7Rotx) { + Math_ApproachF(&this->limb7Rotx, this->unk264[8], 0.8f, 7000.0f); + } + if (this->unk264[1] != this->limbBRotz) { + Math_ApproachF(&this->limbBRotz, this->unk264[1], 0.8f, 7000.0f); + } + if (this->unk264[5] != this->limbBRoty) { + Math_ApproachF(&this->limbBRoty, this->unk264[5], 0.8f, 7000.0f); + } + if (this->unk264[6] != this->limbBRotx) { + Math_ApproachF(&this->limbBRotx, this->unk264[6], 0.8f, 7000.0f); + } +} + +void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { + f32 xView; + f32 yView; + f32 zView; + Vec3f newNiwPos; + Actor* attackNiw; + + if ((this->unkTimer252 == 0) && (this->unk290 < 7)) { + xView = globalCtx->view.focalPoint.x - globalCtx->view.eye.x; + yView = globalCtx->view.focalPoint.y - globalCtx->view.eye.y; + zView = globalCtx->view.focalPoint.z - globalCtx->view.eye.z; + newNiwPos.x = ((Rand_ZeroOne() - 0.5f) * xView) + globalCtx->view.eye.x; + newNiwPos.y = randPlusMinusPoint5Scaled(0.3f) + (globalCtx->view.eye.y + 50.0f + (yView * 0.5f)); + newNiwPos.z = ((Rand_ZeroOne() - 0.5f) * zView) + globalCtx->view.eye.z; + attackNiw = Actor_SpawnWithParent(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ATTACK_NIW, + newNiwPos.x, newNiwPos.y, newNiwPos.z, 0, 0, 0, 0); + + if (attackNiw) { + this->unk290++; + this->unkTimer252 = 10; + } + } +} + +void func_808917F8(EnNiw* this, GlobalContext* globalCtx, s32 arg2) { + f32 phi_f2; + f32 targetRotY; + f32* D_8089348CPtr = D_80893486; + + if (this->unkTimer250 == 0) { + this->unkTimer250 = 3; + if (this->actor.bgCheckFlags & 1) { + // hit floor + this->actor.velocity.y = 3.5f; // hop up? + } + } + if (this->unkTimer252 == 0) { + this->unk29A++; + this->unk29A &= 1; + this->unkTimer252 = 5; + } + if (this->unk29A == 0) { + phi_f2 = D_8089348CPtr[arg2]; + } else { + phi_f2 = -D_8089348CPtr[arg2]; + } + if (arg2 == 1 && (this->unkTimer254 == 0 || (this->actor.bgCheckFlags & 8))) { + this->unkTimer254 = 150; + if (this->yawTimer == 0) { + this->yawTimer = 70; + this->yawTowardsPlayer = this->actor.yawTowardsPlayer; + } + } + targetRotY = this->yawTowardsPlayer + phi_f2; + Math_SmoothStepToS(&this->actor.world.rot.y, targetRotY, 3, this->unk300, 0); + Math_ApproachF(&this->unk300, 3000.0f, 1.0f, 500.0f); + func_80891320(this, globalCtx, 5); +} + +void EnNiw_SetupIdle(EnNiw* this) { + SkelAnime_ChangeAnim(&this->skelanime, &D_060000E8, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_060000E8.common), 0, + -10.0f); + this->unknownState28E = 0; + this->actionFunc = func_808919E8; +} + +#ifdef NON_MATCHING +// non-matching: stack offset and regalloc +// EnNiw_Idle +void func_808919E8(EnNiw* this, GlobalContext* globalCtx) { + s16 s16tmp; + Vec3f newPos; + + newPos.y = randPlusMinusPoint5Scaled(100.0f); + newPos.z = randPlusMinusPoint5Scaled(100.0f); + if (this->niwType == ENNIW_TYPE_REGULAR) { + if (Actor_HasParent(&this->actor, globalCtx)) { + // picked up + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + this->sfxTimer1 = 30; + this->unkTimer250 = 30; + this->actor.flags &= ~0x1; // targetable OFF + this->unknownState28E = 4; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnNiw_Held; + return; + } else { + func_800B8BB0(&this->actor, globalCtx); + } + } else { + this->unkTimer252 = 10; + } + + s16tmp = 0; + if (this->unkTimer252 != 0) { + if (Rand_ZeroFloat(3.99f) < 1.0f) { + this->unk2EA++; + this->unk2EA &= 1; + } + Math_ApproachF(&this->unk264[9], D_80893484[this->unk2EA], 0.5f, 4000.0f); + } + + if ((this->unkTimer252 == 0) && (this->unkTimer250 == 0)) { + this->unk298++; + + if (this->unk298 > 7) { + this->unkTimer252 = Rand_ZeroFloat(30.0f); + this->unk298 = Rand_ZeroFloat(3.99f); + // (3.99..) is loaded into f12 for rand_zero, but f12 never released + // b18: jal Rand_ZeroFloat b18: jal Rand_ZeroFloat + // b1c: lwc1 $f12,%lo(D_80893554)(at) i b1c: lwc1 $f12,%lo(.rodata+0x54)(at) + // b20: lwc1 $f12,0x34(sp) r b20: lwc1 $f2,0x2c(sp) + + if (newPos.y < 0.0f) { + newPos.y -= 100.0f; + } else { + newPos.y += 100.0f; + } + if (newPos.z < 0.0f) { + newPos.z -= 100.0f; + } else { + newPos.z += 100.0f; + } + + this->unk2B0.x = this->unk2A4.x + newPos.y; + this->unk2B0.z = this->unk2A4.z + newPos.z; + + } else { + this->unkTimer250 = 4; + if (this->actor.bgCheckFlags & 1) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 3.5f; + } + } + } + + if (this->unkTimer250 != 0) { + Math_ApproachZeroF(&this->unk264[9], 0.5f, 4000.0f); + s16tmp = 1; + Math_ApproachF(&this->actor.world.pos.x, this->unk2B0.x, 1.0f, this->unk300); + Math_ApproachF(&this->actor.world.pos.z, this->unk2B0.z, 1.0f, this->unk300); + Math_ApproachF(&this->unk300, 3.0f, 1.0f, 0.3f); + + newPos.x = this->unk2B0.x - this->actor.world.pos.x; + newPos.z = this->unk2B0.z - this->actor.world.pos.z; + + if (fabsf(newPos.x) < 10.0f) { + newPos.x = 0.0; + } + if (fabsf(newPos.z) < 10.0f) { + newPos.z = 0.0; + } + + if ((newPos.x == 0.0f) && (newPos.z == 0.0f)) { + this->unkTimer250 = 0; + this->unk298 = 7; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S(newPos.x, newPos.z), 3, this->unk304, 0); + Math_ApproachF(&this->unk304, 10000.0f, 1.0f, 1000.0f); + } + func_80891320(this, globalCtx, s16tmp); +} +#else #pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808919E8.asm") +#endif -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80891D78.asm") +void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { + Vec3f vec3fcopy; + s16 rotZ; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80891F60.asm") + vec3fcopy = D_808934DC; + if (this->unkTimer250 == 0) { + this->unk29E = 2; + this->unkTimer250 = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808920A0.asm") + this->actor.shape.rot.x = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.x; + this->actor.shape.rot.y = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.y; + this->actor.shape.rot.z = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.z; + if (this->niwType == ENNIW_TYPE_REGULAR) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.shape.rot.z = 0; + rotZ = this->actor.shape.rot.z; + this->unknownState28E = 5; + this->actor.flags |= 0x1; // targetable ON + this->actionFunc = EnNiw_Thrown; + this->actor.shape.rot.y = rotZ; + this->actor.shape.rot.x = rotZ; + } + } else if (this->unk2BC.z != 0.0f) { this->actor.shape.rot.z = 0; + rotZ = this->actor.shape.rot.z; + this->actor.velocity.y = 8.0f; + this->actor.speedXZ = 4.0f; + this->actor.gravity = -2.0f; + this->unknownState28E = 5; + this->unk2EC = 0; + this->niwType = ENNIW_TYPE_REGULAR; + this->actor.shape.rot.y = rotZ; + this->actor.shape.rot.x = rotZ; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Math_Vec3f_Copy(&this->unk2BC, &vec3fcopy); + this->actor.flags |= 0x1; // targetable ON + this->actionFunc = EnNiw_Thrown; + } + func_80891320(this, globalCtx, 2); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80892248.asm") +// action function: recently thrown, and also hopping on the floor +void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { + if (this->unk2EC == 0) { + if (this->actor.bgCheckFlags & 1) { + this->unk2EC = 1; + this->unkTimer252 = 80; // hop timer + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 4.0f; + } else { + return; // wait until back on floor + } + } else { + if (this->actor.bgCheckFlags & 1) { + this->sfxTimer1 = 0; + this->actor.velocity.y = 4.0f; // vertical hop + this->unk29E = 1; + } + if (this->unkTimer252 == 0) { + this->unkTimer254 = 100; + this->unkTimer250 = 0; + this->unk2EC = 0; + EnNiw_SetupRunning(this); + return; + } + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80892274.asm") + if (Actor_HasParent(&this->actor, globalCtx)) { + // picked up again before could run off + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + this->sfxTimer1 = 30; + this->unk2EC = 0; + this->unkTimer250 = 30; + this->actor.flags &= ~0x1; // targetable OFF + this->unknownState28E = 4; + this->actionFunc = EnNiw_Held; + this->actor.speedXZ = 0.0f; + } else { + if (this->unkTimer252 > 5) { + func_800B8BB0(&this->actor, globalCtx); + } + func_80891320(this, globalCtx, 2); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808922D0.asm") +// action func: swimming and flying away after swimming +void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { + Vec3f ripplePos; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80892390.asm") + // even if hitting water, keep calling for reinforcements + // this should just be in update + if (this->isStormActive) { + EnNiw_SpawnAttackNiw(this, globalCtx); // spawn attack niw + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80892414.asm") + this->actor.speedXZ = 2.0f; + if (this->actor.bgCheckFlags & 0x20) { + // still touching water + this->actor.gravity = 0.0f; + if (this->actor.yDistToWater > 15.0f) { + this->actor.world.pos.y += 2.0f; + } + if (this->unkTimer250 == 0) { + this->unkTimer250 = 30; + Math_Vec3f_Copy(&ripplePos, &this->actor.world.pos); + ripplePos.y += this->actor.yDistToWater; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 30); + } + if (this->actor.bgCheckFlags & 8) { + this->actor.velocity.y = 10.0f; + this->actor.speedXZ = 1.0f; + } + } else { + this->actor.gravity = -2.0f; + if (this->actor.bgCheckFlags & 8) { + // has hit a wall + this->actor.velocity.y = 10.0f; // to the moon + this->actor.speedXZ = 1.0f; + this->actor.gravity = 0.0f; + } else { + this->actor.speedXZ = 4.0f; + } + + if (this->actor.bgCheckFlags & 1) { + this->actor.gravity = -2.0f; + this->unkTimer254 = 100; + this->unkTimer250 = 0; + this->actor.velocity.y = 0.0f; + if (!this->isStormActive) { + EnNiw_SetupRunning(this); + } else { + this->unknownState28E = 3; + this->actionFunc = EnNiw_CuccoStorm; + } + } + } + func_80891320(this, globalCtx, 2); +} + +void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { + s32 value; + if (1) { + value = 1; + } + + this->unkTimer252 = 10; + this->unknownState28E = this->unk29C = value; + this->actionFunc = EnNiw_Upset; +} + +void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx) { + // assumption: CuccoStorm is split into smaller parts because it used to be a cutscene in OOT + this->sfxTimer1 = 100; + if (this->unkTimer252 == 0) { + this->unkTimer252 = 60; + this->unkTimer24C = 10; + this->unk29C = 4; + this->unknownState28E = 2; + this->actionFunc = EnNiw_SetupCuccoStorm; + } + + func_80891320(this, globalCtx, this->unk29C); +} + +// the long crow with head back before they descend +void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { + f32 viewY; + + this->sfxTimer1 = 100; + if (this->unkTimer252 == 40) { + viewY = 14000.0f; + this->unk264[0] = 10000.0f; + this->unk264[7] = this->unk264[5] = viewY; + this->unk264[6] = 0.0f; + this->unk264[8] = 0.0f; + this->unk264[1] = 0.0f; + this->unk264[2] = 0.0f; + this->unkTimer24C = 10; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + } + if (this->unkTimer252 == 0) { + this->unkTimer252 = 10; + this->yawTowardsPlayer = this->actor.yawTowardsPlayer; + this->actor.flags &= ~0x1; // targetable OFF + this->unknownState28E = 3; + this->actionFunc = EnNiw_CuccoStorm; + } + func_80891320(this, globalCtx, this->unk29C); +} + +void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { + EnNiw_SpawnAttackNiw(this, globalCtx); + if (this->unkTimer252 == 1) { + this->actor.speedXZ = 3.0f; + this->unk29A = Rand_ZeroFloat(1.99f); + this->unkTimer250 = 0; + this->unkTimer24E = this->unkTimer250; + this->unkTimer24C = this->unkTimer250; + } else { + func_808917F8(this, globalCtx, 1); + } +} + +void EnNiw_SetupRunning(EnNiw* this) { + SkelAnime_ChangeAnim(&this->skelanime, &D_060000E8, 1.0f, 0.0f, SkelAnime_GetFrameCount(&D_060000E8.common), 0, + -10.0f); + this->unk29A = Rand_ZeroFloat(1.99f); + this->unknownState28E = 7; + this->actionFunc = func_808924B0; // running away + this->actor.speedXZ = 4.0f; +} + +#ifdef NON_MATCHING +// bad regalloc, center of first if block +// actionfunc: running away from link +void func_808924B0(EnNiw* this, GlobalContext* globalCtx) { + ActorPlayer* player = PLAYER; + Vec3f tempVec3f; + s16 temp298; + f32 dX; + f32 dZ; + + // it actually wants to copy to stack... not modify, then pass to veccopy + // and it does it BEFORE the if block, this is just unoptimized. + tempVec3f = D_808934E8; + if (this->unkTimer254 == 0) { + // the assignements in this block never want to align properly + // its not lineswap, as 800k permuter with only lineswap didn't find a solution + this->unk298 = 0; + + this->unk2A4.x = this->actor.world.pos.x; + this->unk2A4.y = this->actor.world.pos.y; + this->unk2A4.z = this->actor.world.pos.z; + this->unk2B0.x = this->actor.world.pos.x; + this->unk2B0.y = this->actor.world.pos.y; + this->unk2B0.z = this->actor.world.pos.z; + + this->unkTimer252 = this->unkTimer250 = this->unk298; + this->unk264[8] = 0; + this->unk264[6] = 0; + this->unk264[5] = 0; + this->unk264[7] = 0; + this->unk304 = 0; + this->unk300 = 0; + this->actor.speedXZ = 0; + Math_Vec3f_Copy(&this->unk2BC, &tempVec3f); + EnNiw_SetupIdle(&this->actor); + } else { + if (this->unk2BC.x != 90000.0f) { + dX = this->actor.world.pos.x - this->unk2BC.x; + dZ = this->actor.world.pos.z - this->unk2BC.z; + } else { + dX = this->actor.world.pos.x - player->base.world.pos.x; + dZ = this->actor.world.pos.z - player->base.world.pos.z; + } + this->yawTowardsPlayer = Math_Atan2S(dX, dZ); + func_808917F8(this, globalCtx, 0); + func_80891320(this, globalCtx, 2); + } +} +#else #pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808924B0.asm") +#endif -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808925F8.asm") +// check if on the ground after running, once on the ground, start idling +void EnNiw_LandBeforeIdle(EnNiw* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 1) { + EnNiw_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_8089262C.asm") +void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { + if ((!this->isStormActive) && (this->unkTimer260 == 0) && (this->niwType == ENNIW_TYPE_REGULAR)) { + if ((this->unknownState28E != 7) && (this->unk2BC.x != 90000.0f)) { + this->unkTimer260 = 10; + this->sfxTimer1 = 30; + this->unk29E = 1; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + this->unkTimer254 = 100; + this->unk2EC = 0; + EnNiw_SetupRunning(this); + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/EnNiw_Update.asm") + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + // health gets used as a hit counter until cucco storm + if (this->actor.colChkInfo.health > 0) { + this->actor.colChkInfo.health--; + } -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80892E70.asm") + if ((!D_80893460) && (this->actor.colChkInfo.health == 0)) { + // now you've done it + this->unkTimer254 = 100; + D_80893460 = true; + this->unk298 = 0; + this->sfxTimer1 = 10000; + this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; + this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; + this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; + this->unkTimer252 = this->unkTimer250 = this->unk298; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/EnNiw_Draw.asm") + this->unk264[8] = 0.0f; + this->unk264[6] = 0.0f; + this->unk264[5] = 0.0f; + this->unk264[7] = 0.0f; + this->isStormActive = true; + this->actionFunc = EnNiw_Trigger; + this->unk304 = 0.0f; + this->unk300 = 0.0f; + this->actor.speedXZ = 0.0f; + } else { + this->unkTimer260 = 10; + this->sfxTimer1 = 30; + this->unk29E = 1; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + this->unkTimer254 = 100; + this->unk2EC = 0; + EnNiw_SetupRunning(this); + } + } + } +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_80893008.asm") +void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* this = (EnNiw*)thisx; + s8 pad0; + s16 i; + ActorPlayer* player = PLAYER; + s16 pad1; + s16 featherCount; + Vec3f pos; + Vec3f spB8; + Vec3f spAC; + s32 pad2[9]; + s16 temp29C; + f32 featherScale; + f32 camResult; + f32 floorHeight; + f32 dist = 20.0f; + s32 pad3; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808930FC.asm") + this->unusedCounter28C++; + if (this->niwType == ENNIW_TYPE_UNK1) { + this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.parent->shape.rot.y; + } + + if (this->unknownState28E != 0) { + this->unk264[9] = 0.0f; + } + + if (this->unk29E != 0) { + featherCount = ENNIW_FEATHERCOUNT; + if (this->unk29E == 2) { + featherCount = 4; + } + for (i = 0; i < featherCount; i++) { + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.x; + pos.y = randPlusMinusPoint5Scaled(10.0f) + (this->actor.world.pos.y + this->unk308); + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; + featherScale = Rand_ZeroFloat(6.0f) + 6.0f; + + if ((this->unk29E == 2) && (this->unk308 != 0)) { + pos.y += 10.0f; + } + + if (this->unk308 == 0) { + featherScale = Rand_ZeroFloat(2.0f) + 2.0f; + } + spB8.x = randPlusMinusPoint5Scaled(3.0f); + spB8.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; + spB8.z = randPlusMinusPoint5Scaled(3.0f); + spAC.z = spAC.x = 0.0f; + spAC.y = -0.15000000596f; + + EnNiw_SpawnFeather(this, &pos, &spB8, &spAC, featherScale); + } + this->unk29E = 0; + } + + EnNiw_UpdateFeather(this, globalCtx); + + DECR(this->unkTimer24C); + DECR(this->unkTimer24E); + DECR(this->unkTimer250); + DECR(this->unkTimer252); + DECR(this->unkTimer254); + DECR(this->sfxTimer1); + DECR(this->flutterSfxTimer); + DECR(this->unusedTimer25A); + DECR(this->yawTimer); + DECR(this->unusedTimer25E); + DECR(this->unkTimer260); + + this->actor.shape.rot = this->actor.world.rot; + this->actor.shape.shadowScale = 15.0f; + this->actionFunc(this, globalCtx); + Actor_SetHeight(&this->actor, this->unk308); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); + + if ((this->actor.floorHeight <= BGCHECK_Y_MIN) || (this->actor.floorHeight >= 32000.0f)) { + // if cucco is off the map? + Vec3f camera; + camera.x = globalCtx->view.focalPoint.x - globalCtx->view.eye.x; + camera.y = globalCtx->view.focalPoint.y - globalCtx->view.eye.y; + camera.z = globalCtx->view.focalPoint.z - globalCtx->view.eye.z; + camResult = camera.y / sqrtf(SQXYZ(camera)); + + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.z = this->actor.home.pos.z; + this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (camResult * 160.0f); + + if (this->actor.world.pos.y < this->actor.home.pos.y) { + this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; + } + + this->actor.speedXZ = 0.0f; + this->actor.gravity = -2.0f; + Math_Vec3f_Copy(&this->unk2A4, &this->actor.home.pos); + Math_Vec3f_Copy(&this->unk2B0, &this->actor.home.pos); + + this->unk304 = 0.0f; + this->unk300 = 0.0f; + this->unusedFloat2FC = 0.0f; + this->unusedFloat2F8 = 0.0f; + this->unusedFloat2F4 = 0.0f; + this->limbBRotx = 0.0f; + this->limbBRoty = 0.0f; + this->limbBRotz = 0.0f; + this->limb7Rotx = 0.0f; + this->limb7Roty = 0.0f; + this->limb7Rotz = 0.0f; + this->limbDRot = 0.0f; + this->limbFRot = 0.0f; + + // clang-format off + this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->unk29A = this->unk29C = 0; + // clang-format on + + for (i = 0; i < 10; i++) { + this->unk264[i] = 0.0f; + } + + this->unknownState28E = 8; + this->isStormActive = false; + this->actionFunc = EnNiw_LandBeforeIdle; + return; // still required even with the else/else + + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.yDistToWater > 15.0f) && + (this->unknownState28E != 6)) { + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.y += this->actor.yDistToWater; + this->unkTimer250 = 30; + EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); + this->unkTimer252 = 0; + this->unknownState28E = 6; + this->actionFunc = EnNiw_Swimming; + + } else { + if (this->isStormActive && (this->actor.xyzDistToPlayerSq < (SQ(dist))) && (player->invincibilityTimer == 0)) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + } + + EnNiw_CheckRage(this, globalCtx); + if ((this->flutterSfxTimer == 0) && (this->unknownState28E == 4)) { + this->flutterSfxTimer = 7; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + + if (this->sfxTimer1 == 0) { + if (this->unknownState28E != 0) { + this->sfxTimer1 = 30; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck + } else { + this->sfxTimer1 = 300; + Audio_PlayActorSound2(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck + } + } + + if (!this->isStormActive) { + if (this->niwType == ENNIW_TYPE_REGULAR) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base); + + if (globalCtx) {} + + if ((this->unknownState28E != 4) && (this->unknownState28E != 5)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base); + } + } + } + } +} + +s32 EnNiw_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* actor) { + EnNiw* this = (EnNiw*)actor; + + if (limbIndex == 13) { + rot->y += (s16)this->limbDRot; + } + if (limbIndex == 15) { + rot->y += (s16)this->limbFRot; + } + if (limbIndex == 11) { + rot->x += (s16)this->limbBRotx; + rot->y += (s16)this->limbBRoty; + rot->z += (s16)this->limbBRotz; + } + if (limbIndex == 7) { + rot->x += (s16)this->limb7Rotx; + rot->y += (s16)this->limb7Roty; + rot->z += (s16)this->limb7Rotz; + } + return 0; +} + +void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNiw* this = (EnNiw*)thisx; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawSV(globalCtx, this->skelanime.skeleton, this->skelanime.limbDrawTbl, this->skelanime.dListCount, + EnNiw_LimbDraw, NULL, &this->actor); + func_808932B0(this, globalCtx); +} + +void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { + s16 i; + EnNiwFeather* feather = this->feathers; + + for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { + if (feather->isEnabled == false) { + feather->isEnabled = true; + feather->pos = *pos; + feather->vel = *vel; + feather->accel = *accel; + feather->timer = 0; + feather->scale = scale / 1000.0f; + feather->life = Rand_ZeroFloat(20.0f) + 40.0f; + feather->zRotStart = Rand_ZeroFloat(1000.0f); + break; + } + } +} + +void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { + EnNiwFeather* feather = this->feathers; + f32 featherVelocityGoal = 0.05f; + s16 i; + + for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { + if (feather->isEnabled) { + feather->timer++; + feather->pos.x += feather->vel.x; + feather->pos.y += feather->vel.y; + feather->pos.z += feather->vel.z; + feather->vel.x += feather->accel.x; + feather->vel.y += feather->accel.y; + feather->vel.z += feather->accel.z; + if (feather->isEnabled == true) { + feather->zRotStart++; + Math_ApproachF(&feather->vel.x, 0.0f, 1.0f, featherVelocityGoal); + Math_ApproachF(&feather->vel.z, 0.0f, 1.0f, featherVelocityGoal); + if (feather->vel.y < -0.5f) { + feather->vel.y = -0.5f; + } + + feather->zRot = Math_SinS(feather->zRotStart * 0xBB8) * M_PI * 0.2f; + + if (feather->life < feather->timer) { + feather->isEnabled = false; + } + } + } + } +} + +#ifdef NON_EQUIVALENT +// non-equiv: not even close +// feather draw function +void func_808932B0(EnNiw* this, GlobalContext* globalCtx) { + // vanilla wants to load this early (and other values) + // but it needs to be stored in a s register not v/a + // EnNiwFeather* feathers = &this->feathers; + u8 flag = 0; + + // permuter thinks this might be int which makes sense... + // but the end of the loop converts type, int reemoves it + // s16 i; + s32 i; + + if (globalCtx->state.gfxCtx) {} + if (this->feathers) {} + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->feathers); i++) { + if (this->feathers[i].isEnabled == true) { + if (flag == 0) { + gSPDisplayList(POLY_XLU_DISP++, D_060023B0); + + flag++; + } + + SysMatrix_InsertTranslation(this->feathers[i].pos.x, this->feathers[i].pos.y, this->feathers[i].pos.z, MTXMODE_NEW); + SysMatrix_NormalizeXYZ(&globalCtx->unk187FC); + Matrix_Scale(this->feathers[i].scale, this->feathers[i].scale, 1.0f, MTXMODE_APPLY); + SysMatrix_InsertZRotation_f(this->feathers[i].zRot, MTXMODE_APPLY); + SysMatrix_InsertTranslation(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, D_06002428); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Niw_0x80891060/func_808932B0.asm") +#endif diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index 8ff8546d38..4c09866743 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -5,11 +5,93 @@ struct EnNiw; +typedef void (*EnNiwActionFunc)(struct EnNiw*, GlobalContext*); + +typedef struct { + /* 0x0000 */ u8 isEnabled; + /* 0x0004 */ Vec3f pos; + /* 0x0010 */ Vec3f vel; + /* 0x001C */ Vec3f accel; + /* 0x0028 */ s16 life; + /* 0x002A */ s16 zRotStart; + /* 0x002C */ f32 scale; + /* 0x0030 */ f32 zRot; + /* 0x0034 */ u8 timer; +} EnNiwFeather; // size = 0x38 + +#define ENNIW_LIMBCOUNT 16 +#define ENNIW_FEATHERCOUNT 20 + typedef struct EnNiw { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x678]; + /* 0x144 */ SkelAnime skelanime; + /* 0x188 */ Vec3s limbDrawTbl[ENNIW_LIMBCOUNT]; + /* 0x1E8 */ Vec3s transitionDrawtable[ENNIW_LIMBCOUNT]; + /* 0x248 */ EnNiwActionFunc actionFunc; + /* 0x24C */ s16 unkTimer24C; + /* 0x24E */ s16 unkTimer24E; + /* 0x250 */ s16 unkTimer250; + /* 0x252 */ s16 unkTimer252; + /* 0x254 */ s16 unkTimer254; + /* 0x256 */ s16 sfxTimer1; + /* 0x258 */ s16 flutterSfxTimer; + /* 0x25A */ s16 unusedTimer25A; + /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer + /* 0x25E */ s16 unusedTimer25E; + /* 0x260 */ s16 unkTimer260; + /* 0x264 */ f32 unk264[10]; + /* 0x28C */ s16 unusedCounter28C; + /* 0x28E */ s16 unknownState28E; + /* 0x290 */ s16 unk290; + /* 0x292 */ s16 unk292; + /* 0x294 */ s16 pad294; + /* 0x296 */ s16 unk296; + /* 0x298 */ s16 unk298; + /* 0x29C */ s16 unk29A; + /* 0x29C */ u16 unk29C; + /* 0x29E */ s16 unk29E; + /* 0x2A0 */ s16 isStormActive; + /* 0x2A2 */ s16 niwType; + /* 0x2A4 */ Vec3f unk2A4; + /* 0x2B0 */ Vec3f unk2B0; + /* 0x2BC */ Vec3f unk2BC; + /* 0x2C8 */ f32 limb7Rotz; + /* 0x2CC */ f32 limb7Roty; + /* 0x2D0 */ f32 limb7Rotx; + /* 0x2D4 */ f32 limbBRotz; + /* 0x2D8 */ f32 limbBRoty; + /* 0x2DC */ f32 limbBRotx; + /* 0x2E0 */ f32 limbDRot; + /* 0x2E4 */ f32 limbFRot; + /* 0x2E8 */ s16 yawTowardsPlayer; + /* 0x2EA */ s16 unk2EA; + /* 0x2EC */ s16 unk2EC; + /* 0x2EE */ UNK_TYPE1 pad2EE[0x6]; + /* 0x2F4 */ f32 unusedFloat2F4; + /* 0x2F8 */ f32 unusedFloat2F8; + /* 0x2FC */ f32 unusedFloat2FC; + /* 0x300 */ f32 unk300; + /* 0x304 */ f32 unk304; + /* 0x308 */ f32 unk308; + /* 0x30C */ s32 pad30C; + /* 0x310 */ ColliderCylinder collider; + /* 0x35C */ EnNiwFeather feathers[ENNIW_FEATHERCOUNT]; } EnNiw; // size = 0x7BC -extern const ActorInit En_Niw_InitVars; +// in init, any value below zero becomes zero +// however, in vanilla, only 0xFFFF (-1) exists +#define ENNIW_TYPE_VANILLA 0xFFFF +#define ENNIW_TYPE_REGULAR 0 +#define ENNIW_TYPE_UNK1 1 +#define ENNIW_TYPE_UNK2 2 +// the attacking cuccos are not here, they are a different actor: +// ovl_En_Attack_Niw + +extern FlexSkeletonHeader D_06002530; +extern AnimationHeader D_060000E8; + +// feather display list? +extern Gfx D_060023B0[]; +extern Gfx D_06002428[]; #endif // Z_EN_NIW_H diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index ec4bb40b82..1dd66c1c32 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -128,7 +128,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveXYRotation(&this->actor); Math_Vec3f_Copy(&worldPos, &this->actor.world.pos); - func_800B78B8(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 7); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); if (this->actor.bgCheckFlags & 8) { if (func_800C9A4C(&globalCtx2->colCtx, this->actor.wallPoly, this->actor.wallBgId) & 0x30) { diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 3c918bd943..dcd2f398d8 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1314,7 +1314,7 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.gravity < -0.1f) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); arg3 = this->actionFunc == EnPametfrog_FallInAir ? 3.0f : 15.0f; - func_800B78B8(globalCtx, &this->actor, 25.0f, arg3, 3.0f, 0x1F); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 25.0f, arg3, 3.0f, 0x1F); } else if (this->freezeTimer == 0) { Actor_SetVelocityAndMoveXYRotation(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index 798fc996b3..dbcdd696f3 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -77,7 +77,7 @@ void EnPoFusen_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 40; SkelAnime_InitSV(globalCtx, &this->anime, &D_060024F0, &D_06000040, this->limbDrawTbl, this->transitionDrawTbl, 10); ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f); - func_800B78B8(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 0x4); if (EnPoFusen_CheckParent(this, globalCtx) == 0) { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index 734de98439..854f272319 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -345,7 +345,7 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetHeight(&this->actor, 20.0f); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); this->actionFunc(this, globalCtx); - func_800B78B8(globalCtx, &this->actor, 20.0f, 25.0f, 20.0f, 5); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 20.0f, 5); EnSb_UpdateDamage(this, globalCtx); if (player->stateFlags1 & 0x8000000) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index 865cc0e5fa..1af33851a0 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -55,7 +55,7 @@ void EnTanron6_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); } void EnTanron6_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index f1a07ea56e..c67894c29a 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -94,7 +94,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 70.0f, 0x05); if (this->framesUntilNextState == 0) { remainingFrames = 0; diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 8ac55018ea..7b1ee4a783 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -305,7 +305,7 @@ void EnTuboTrap_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f, 10.0f, 20.0f, 0x1F); Actor_SetHeight(&this->actor, 0.0f); if (this->actor.projectedPos.z < 811.0f) { diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 3469868ae4..8b426611ca 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -493,9 +493,9 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { u16 oldTime; this->actionFunc(this, globalCtx); - if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.unk11F22 != 0) && - (globalCtx->msgCtx.unk11F04 == 0x5E6) && (!FrameAdvance_IsEnabled(globalCtx)) && (globalCtx->unk18875 == 0) && - (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { + if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.unk11F22 != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) && + (!FrameAdvance_IsEnabled(globalCtx)) && (globalCtx->unk18875 == 0) && (ActorCutscene_GetCurrentIndex() == -1) && + (globalCtx->csCtx.state == 0)) { oldTime = gSaveContext.time; gSaveContext.time = (u16)REG(0xF) + oldTime; // cast req diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 4bec51d33c..796c94e8ea 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -155,7 +155,7 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { BcCheck3_BgActorInit(&this->dyna, 1); BgCheck_RelocateMeshHeader(&D_06003CD0, &colHeader); this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); - func_800B78B8(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x4); if (this->dyna.actor.floorPoly == 0) { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index 0d390df513..3aae774be0 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -243,7 +243,7 @@ void func_80926B40(ObjKibako* this) { void func_80926B54(ObjKibako* this, GlobalContext* globalCtx) { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); - func_800B78B8(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.draw = ObjKibako_Draw; this->actor.objBankIndex = this->bankIndex; @@ -281,7 +281,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { } else { Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); func_809262BC(this); - func_800B78B8(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); if (!(this->collider.base.ocFlags1 & 8) && (this->actor.xzDistToPlayer > 28.0f)) { this->collider.base.ocFlags1 |= 8; } @@ -320,7 +320,7 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { s32 sp2C; func_80926394(this, globalCtx); - if (func_800B8BFC(&this->actor, globalCtx)) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actor.room = globalCtx->roomContext.currRoom.num; if (fabsf(this->actor.speedXZ) < 0.1f) { ObjKibako_SetupIdle(this); @@ -331,7 +331,7 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { ObjKibako_SetupThrown(this); this->actor.flags &= ~0x4000000; } - func_800B78B8(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); } else { pos.x = this->actor.world.pos.x; pos.y = this->actor.world.pos.y + 20.0f; @@ -386,7 +386,7 @@ void ObjKibako_Thrown(ObjKibako* this, GlobalContext* globalCtx) { Math_StepToS(&D_8092738C, D_80927388, 0xA0); this->actor.shape.rot.x = (s16)(this->actor.shape.rot.x + D_80927384); this->actor.shape.rot.y = (s16)(this->actor.shape.rot.y + D_8092738C); - func_800B78B8(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base); CollisionCheck_SetAT(globalCtx, &globalCtx->colCheckCtx, &this->collider.base); diff --git a/tables/functions.txt b/tables/functions.txt index 154fee4d17..979f7efb8a 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -766,7 +766,7 @@ 0x800B75A0:("func_800B75A0",), 0x800B761C:("func_800B761C",), 0x800B7678:("func_800B7678",), - 0x800B78B8:("func_800B78B8",), + 0x800B78B8:("Actor_UpdateBgCheckInfo",), 0x800B7E04:("func_800B7E04",), 0x800B7FE0:("func_800B7FE0",), 0x800B8018:("func_800B8018",), @@ -798,7 +798,7 @@ 0x800B8B84:("func_800B8B84",), 0x800B8BB0:("func_800B8BB0",), 0x800B8BD0:("func_800B8BD0",), - 0x800B8BFC:("func_800B8BFC",), + 0x800B8BFC:("Actor_HasNoParent",), 0x800B8C20:("func_800B8C20",), 0x800B8C50:("func_800B8C50",), 0x800B8C78:("func_800B8C78",), @@ -5438,26 +5438,26 @@ 0x80891060:("EnNiw_Init",), 0x808912E8:("EnNiw_Destroy",), 0x80891320:("func_80891320",), - 0x808916B0:("func_808916B0",), + 0x808916B0:("EnNiw_SpawnAttackNiw",), 0x808917F8:("func_808917F8",), - 0x80891974:("func_80891974",), + 0x80891974:("EnNiw_SetupIdle",), 0x808919E8:("func_808919E8",), - 0x80891D78:("func_80891D78",), - 0x80891F60:("func_80891F60",), - 0x808920A0:("func_808920A0",), - 0x80892248:("func_80892248",), - 0x80892274:("func_80892274",), - 0x808922D0:("func_808922D0",), - 0x80892390:("func_80892390",), - 0x80892414:("func_80892414",), + 0x80891D78:("EnNiw_Held",), + 0x80891F60:("EnNiw_Thrown",), + 0x808920A0:("EnNiw_Swimming",), + 0x80892248:("EnNiw_Trigger",), + 0x80892274:("EnNiw_Upset",), + 0x808922D0:("EnNiw_SetupCuccoStorm",), + 0x80892390:("EnNiw_CuccoStorm",), + 0x80892414:("EnNiw_SetupRunning",), 0x808924B0:("func_808924B0",), - 0x808925F8:("func_808925F8",), - 0x8089262C:("func_8089262C",), + 0x808925F8:("EnNiw_LandBeforeIdle",), + 0x8089262C:("EnNiw_CheckRage",), 0x808927CC:("EnNiw_Update",), - 0x80892E70:("func_80892E70",), + 0x80892E70:("EnNiw_LimbDraw",), 0x80892FA0:("EnNiw_Draw",), - 0x80893008:("func_80893008",), - 0x808930FC:("func_808930FC",), + 0x80893008:("EnNiw_SpawnFeather",), + 0x808930FC:("EnNiw_UpdateFeather",), 0x808932B0:("func_808932B0",), 0x808937F0:("EnTite_Init",), 0x808939EC:("EnTite_Destroy",),