From 634470f6ee884e9829602833b382fa7539e32d37 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 27 Dec 2023 22:48:44 -0800 Subject: [PATCH] d_a_tag_etc match --- configure.py | 2 +- include/d/actor/d_a_npc_md.h | 6 +- include/d/actor/d_a_tag_etc.h | 12 +- src/d/actor/d_a_tag_etc.cpp | 199 ++++++++++++++++++++++++---------- 4 files changed, 155 insertions(+), 64 deletions(-) diff --git a/configure.py b/configure.py index 2f85b251f..d91d3fc8b 100644 --- a/configure.py +++ b/configure.py @@ -1605,7 +1605,7 @@ config.libs = [ ActorRel(Matching, "d_a_switem", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_swpropeller"), ActorRel(Matching, "d_a_swtact"), - ActorRel(NonMatching, "d_a_tag_etc"), + ActorRel(Matching, "d_a_tag_etc"), ActorRel(NonMatching, "d_a_tag_island"), ActorRel(NonMatching, "d_a_tag_kf1"), ActorRel(Matching, "d_a_tag_ret", extra_cflags=['-pragma "nosyminline on"']), diff --git a/include/d/actor/d_a_npc_md.h b/include/d/actor/d_a_npc_md.h index 80b73b642..9709903b3 100644 --- a/include/d/actor/d_a_npc_md.h +++ b/include/d/actor/d_a_npc_md.h @@ -273,7 +273,7 @@ public: void calcFlyingTimer() {} void checkBitEffectStatus(u8) {} void checkStatus(u32) {} - void checkStatusCamTagIn() {} + u8 checkStatusCamTagIn() { return cLib_checkBit(m30F0, 0x20UL); } void checkStatusFly() {} void clearJntAng() {} void clearStatus() {} @@ -285,12 +285,12 @@ public: void isLightBodyHit() {} void isMirror() {} void isShipRide() {} - void offBitCamTagIn() {} + void offBitCamTagIn() { cLib_offBit(m30F0, 0x20UL); } void offFlying() {} void offMirror() {} void offPlayerRoom() {} void offShipRide() {} - void onBitCamTagIn() {} + void onBitCamTagIn() { cLib_onBit(m30F0, 0x20UL); } void onFlying() {} void onMirror() {} void onPlayerRoom() {} diff --git a/include/d/actor/d_a_tag_etc.h b/include/d/actor/d_a_tag_etc.h index a3c29bd3f..3f436fa59 100644 --- a/include/d/actor/d_a_tag_etc.h +++ b/include/d/actor/d_a_tag_etc.h @@ -5,12 +5,14 @@ class daTag_Etc_c : public fopAc_ac_c { public: + typedef BOOL (ActionFunc)(daTag_Etc_c*); + inline BOOL draw(); inline BOOL execute(); - void setActio(unsigned char) {} + void setActio(u8 action) { mAction = action; } u8 getEventNo(); - u32 getType2(); + u8 getType2(); BOOL rangeCheck(fopAc_ac_c*); BOOL otherCheck(fopAc_ac_c*); void demoProc(); @@ -18,12 +20,12 @@ public: s32 create(); public: - /* 0x290 */ u8 field_0x290; + /* 0x290 */ u8 mAction; /* 0x291*/ u8 field_0x291; /* 0x292*/ u8 field_0x292; /* 0x293*/ u8 field_0x293; - /* 0x294 */ s32 processId; - /* 0x298 */ s16 eventIndex; + /* 0x294 */ s32 mProcID; + /* 0x298 */ s16 mEventIdx; /* 0x29A */ short field_0x29A; }; diff --git a/src/d/actor/d_a_tag_etc.cpp b/src/d/actor/d_a_tag_etc.cpp index 84fcae712..44a9dd990 100644 --- a/src/d/actor/d_a_tag_etc.cpp +++ b/src/d/actor/d_a_tag_etc.cpp @@ -6,8 +6,16 @@ #include "d/actor/d_a_tag_etc.h" #include "d/actor/d_a_npc_md.h" #include "d/d_com_inf_game.h" +#include "d/d_procname.h" #include "dolphin/types.h" +enum Action { + ACT_WAIT, + ACT_SEARCH, + ACT_HUNT, + ACT_READY, + ACT_EVENT, +}; /* 00000078-00000084 .text getEventNo__11daTag_Etc_cFv */ u8 daTag_Etc_c::getEventNo() { @@ -15,28 +23,24 @@ u8 daTag_Etc_c::getEventNo() { } /* 00000084-00000090 .text getType2__11daTag_Etc_cFv */ -u32 daTag_Etc_c::getType2() { +u8 daTag_Etc_c::getType2() { return fopAcM_GetParam(this) >> 8 & 0xF; } /* Not Matching */ /* 00000090-000001B4 .text rangeCheck__11daTag_Etc_cFP10fopAc_ac_c */ BOOL daTag_Etc_c::rangeCheck(fopAc_ac_c* pActor) { - BOOL result; float distanceMagnitude; cXyz delta; delta = pActor->current.pos - current.pos; - if (delta.y >= 0.0f) { - if ((mScale.x * 100.0f) <= delta.absXZ() || (mScale.x * 100.0f) < delta.y) { - result = FALSE; - } else { - result = TRUE; - } - } else { - result = FALSE; - } - return result; + if (delta.y < 0.0f) + return FALSE; + + if (delta.absXZ() < (mScale.x * 100.0f) && delta.y <= (mScale.y * 100.0f)) + return TRUE; + + return FALSE; } /* 000001B4-00000214 .text otherCheck__11daTag_Etc_cFP10fopAc_ac_c */ @@ -65,7 +69,7 @@ void daTag_Etc_c::demoProc() { daNpc_Md_c* pMedli; int staffIdx; u8 cVar3; - pMedli = (daNpc_Md_c*)fopAcM_SearchByID(processId); + pMedli = (daNpc_Md_c*)fopAcM_SearchByID(mProcID); staffIdx = dComIfGp_evmng_getMyStaffId("TAG_ETC_D", NULL, 0); if (staffIdx != -1) { @@ -94,7 +98,7 @@ void daTag_Etc_c::demoInitProc() { cVar1 = getType2(); switch (cVar1) { case 0: - pActor = fopAcM_SearchByID(processId); + pActor = fopAcM_SearchByID(mProcID); dComIfGp_event_setItemPartner(pActor); field_0x29A = 0xf; break; @@ -108,22 +112,21 @@ s32 daTag_Etc_c::create() { float fVar1; u8 stageEVNTListIndex; u16 uVar2; - u8 cVar3; fopAcM_SetupActor(this, daTag_Etc_c); stageEVNTListIndex = getEventNo(); - eventIndex = dComIfGp_evmng_getEventIdx(NULL, stageEVNTListIndex); - if (eventIndex == -1) { - field_0x290 = 0; + mEventIdx = dComIfGp_evmng_getEventIdx(NULL, stageEVNTListIndex); + if (mEventIdx == -1) { + setActio(ACT_WAIT); } else { - cVar3 = getType2(); - switch (cVar3) { + switch (getType2()) { case 0: - field_0x290 = 1; + setActio(ACT_SEARCH); break; default: - field_0x290 = 0; + setActio(ACT_WAIT); + break; } } shape_angle.z = 0; @@ -137,52 +140,138 @@ s32 daTag_Etc_c::create() { } /* 00000458-00000460 .text daTag_Etc_action_wait__FP11daTag_Etc_c */ -u8 daTag_Etc_action_wait(daTag_Etc_c*) { - return 1; -} - -/* 00000460-000004E8 .text daTag_Etc_action_search__FP11daTag_Etc_c */ -void daTag_Etc_action_search(daTag_Etc_c* pEtcTag) { - /* Nonmatching */ -} - -/* 000004E8-00000560 .text daTag_Etc_action_event__FP11daTag_Etc_c */ -void daTag_Etc_action_event(daTag_Etc_c*) { - /* Nonmatching */ -} - -/* 00000560-0000063C .text daTag_Etc_action_ready__FP11daTag_Etc_c */ -void daTag_Etc_action_ready(daTag_Etc_c*) { - /* Nonmatching */ -} - -/* 0000063C-000006EC .text daTag_Etc_action_hunt__FP11daTag_Etc_c */ -void daTag_Etc_action_hunt(daTag_Etc_c*) { - /* Nonmatching */ -} - -/* 000006EC-000006F4 .text daTag_Etc_Draw__FP11daTag_Etc_c */ -static BOOL daTag_Etc_Draw(daTag_Etc_c*) { +static BOOL daTag_Etc_action_wait(daTag_Etc_c* i_this) { return TRUE; } +/* 00000460-000004E8 .text daTag_Etc_action_search__FP11daTag_Etc_c */ +static BOOL daTag_Etc_action_search(daTag_Etc_c* i_this) { + fopAc_ac_c* actor = NULL; + switch (i_this->getType2()) { + case 0: + actor = fopAcM_searchFromName("Md1", 0, 0); + break; + } + + if (actor != NULL) { + i_this->mProcID = fopAcM_GetID(actor); + i_this->setActio(ACT_HUNT); + } + + return TRUE; +} + +/* 000004E8-00000560 .text daTag_Etc_action_event__FP11daTag_Etc_c */ +static BOOL daTag_Etc_action_event(daTag_Etc_c* i_this) { + if (dComIfGp_evmng_endCheck(i_this->mEventIdx)) { + i_this->mProcID = fpcM_ERROR_PROCESS_ID_e; + i_this->setActio(ACT_SEARCH); + dComIfGp_event_reset(); + } else { + i_this->demoProc(); + } + + return TRUE; +} + +/* 00000560-0000063C .text daTag_Etc_action_ready__FP11daTag_Etc_c */ +static BOOL daTag_Etc_action_ready(daTag_Etc_c* i_this) { + fopAc_ac_c* actor = fopAcM_SearchByID(i_this->mProcID); + if (i_this->mEvtInfo.checkCommandDemoAccrpt()) { + i_this->demoInitProc(); + i_this->setActio(ACT_EVENT); + daTag_Etc_action_event(i_this); + } else if (actor == NULL || !i_this->rangeCheck(actor) || !i_this->otherCheck(actor)) { + i_this->mProcID = fpcM_ERROR_PROCESS_ID_e; + i_this->setActio(ACT_SEARCH); + } else { + fopAcM_orderOtherEventId(i_this, i_this->mEventIdx); + } + + return TRUE; +} + +/* 0000063C-000006EC .text daTag_Etc_action_hunt__FP11daTag_Etc_c */ +static BOOL daTag_Etc_action_hunt(daTag_Etc_c* i_this) { + daNpc_Md_c* actor = (daNpc_Md_c*)fopAcM_SearchByID(i_this->mProcID); + if (actor == NULL) { + i_this->mProcID = fpcM_ERROR_PROCESS_ID_e; + i_this->setActio(ACT_SEARCH); + return TRUE; + } + + if (i_this->rangeCheck(actor) && i_this->otherCheck(actor)) { + actor->onBitCamTagIn(); + } else { + actor->offBitCamTagIn(); + } + + return TRUE; +} + +BOOL daTag_Etc_c::draw() { + return TRUE; +} + +BOOL daTag_Etc_c::execute() { + static ActionFunc* l_action[] = { + daTag_Etc_action_wait, + daTag_Etc_action_search, + daTag_Etc_action_hunt, + daTag_Etc_action_ready, + daTag_Etc_action_event, + }; + l_action[mAction](this); + return TRUE; +} + +/* 000006EC-000006F4 .text daTag_Etc_Draw__FP11daTag_Etc_c */ +static BOOL daTag_Etc_Draw(daTag_Etc_c* i_this) { + return i_this->draw(); +} + /* 000006F4-00000730 .text daTag_Etc_Execute__FP11daTag_Etc_c */ -static BOOL daTag_Etc_Execute(daTag_Etc_c*) { - /* Nonmatching */ +static BOOL daTag_Etc_Execute(daTag_Etc_c* i_this) { + return i_this->execute(); } /* 00000730-00000738 .text daTag_Etc_IsDelete__FP11daTag_Etc_c */ -static BOOL daTag_Etc_IsDelete(daTag_Etc_c*) { +static BOOL daTag_Etc_IsDelete(daTag_Etc_c* i_this) { return TRUE; } /* 00000738-00000768 .text daTag_Etc_Delete__FP11daTag_Etc_c */ -static BOOL daTag_Etc_Delete(daTag_Etc_c* i_actor) { - i_actor->~daTag_Etc_c(); +static BOOL daTag_Etc_Delete(daTag_Etc_c* i_this) { + i_this->~daTag_Etc_c(); return TRUE; } /* 00000768-00000788 .text daTag_Etc_Create__FP10fopAc_ac_c */ -static s32 daTag_Etc_Create(fopAc_ac_c* i_actor) { - return reinterpret_cast(i_actor)->create(); +static s32 daTag_Etc_Create(fopAc_ac_c* i_this) { + return reinterpret_cast(i_this)->create(); } + +static actor_method_class l_daTag_Etc_Method = { + (process_method_func)daTag_Etc_Create, + (process_method_func)daTag_Etc_Delete, + (process_method_func)daTag_Etc_Execute, + (process_method_func)daTag_Etc_IsDelete, + (process_method_func)daTag_Etc_Draw, +}; + +actor_process_profile_definition g_profile_TAG_ETC = { + /* LayerID */ fpcLy_CURRENT_e, + /* ListID */ 7, + /* ListPrio */ fpcPi_CURRENT_e, + /* ProcName */ PROC_TAG_ETC, + /* Proc SubMtd */ &g_fpcLf_Method.mBase, + /* Size */ sizeof(daTag_Etc_c), + /* SizeOther */ 0, + /* Parameters */ 0, + /* Leaf SubMtd */ &g_fopAc_Method.base, + /* Priority */ 0x0122, + /* Actor SubMtd */ &l_daTag_Etc_Method, + /* Status */ fopAcStts_UNK40000_e | fopAcStts_UNK4000_e, + /* Group */ fopAc_ACTOR_e, + /* CullType */ fopAc_CULLBOX_6_e, +};