From 08571c4865fed64bb39c422ae0b973f977af93b4 Mon Sep 17 00:00:00 2001 From: Skelp <59535863+Skelp@users.noreply.github.com> Date: Wed, 4 Jun 2025 20:31:32 +0200 Subject: [PATCH] #181: d_a_tag_attention (#784) * #181: d_a_tag_attention matching; TODO: implement chk_inside and dComIfGp_att_Look2RequestF * #181: continue working on d_a_tag_attention, matching almost complete * #181: revert naming class member (not certain enough) * #181: preliminary changes to resolve #784 comments regarding usage of debug maps * #181: commit suggestion by @WilliamArnett, fixing regalloc error Co-authored-by: WilliamArnett <149556961+WilliamArnett@users.noreply.github.com> * #181: fix missing curly bracket * #181: resolve #784 comments with the kind help of @WilliamArnett; move `daTagAttention::Act_c::chk_inside` to header file; split `plyrToObjVec` definition to match assembly; remove temp variable, use values directly and swap operands; implement `Look2RequestF` in `include/d/d_attention.h`; remove non-matching use of temp variable `iVar1` and replace `current.pos` with uninitialized variable in `daTagAttention::Act_c::_execute` * Update include/d/actor/d_a_tag_attention.h Co-authored-by: WilliamArnett <149556961+WilliamArnett@users.noreply.github.com> * #181: update `d_a_tag_attention` to `Matching` in `configure.py`; remove Non-Matching comments * #181: change matching type to `Equivalent` for `d_a_tag_attention` * Apply suggestions from code review Co-authored-by: LagoLunatic * #181: fix PrmAbstract call --------- Co-authored-by: WilliamArnett <149556961+WilliamArnett@users.noreply.github.com> Co-authored-by: LagoLunatic --- configure.py | 2 +- include/d/actor/d_a_tag_attention.h | 71 +++++++++++++++++++++++++++-- include/d/d_attention.h | 2 +- src/d/actor/d_a_tag_attention.cpp | 51 +++++++++++++++------ 4 files changed, 105 insertions(+), 21 deletions(-) diff --git a/configure.py b/configure.py index 03a65e232..d6e554599 100755 --- a/configure.py +++ b/configure.py @@ -1441,7 +1441,7 @@ config.libs = [ ActorRel(Matching, "d_a_swc00"), ActorRel(Equivalent, "d_a_swhit0", extra_cflags=['-pragma "nosyminline on"']), # weak func order ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_swtdoor"), - ActorRel(NonMatching, "d_a_tag_attention"), + ActorRel(Equivalent, "d_a_tag_attention"), ActorRel(NonMatching, "d_a_tag_ba1"), ActorRel(Matching, "d_a_tag_event"), ActorRel(Matching, "d_a_tag_evsw", extra_cflags=['-pragma "nosyminline on"']), diff --git a/include/d/actor/d_a_tag_attention.h b/include/d/actor/d_a_tag_attention.h index 10eca4f81..739583112 100644 --- a/include/d/actor/d_a_tag_attention.h +++ b/include/d/actor/d_a_tag_attention.h @@ -1,20 +1,81 @@ #ifndef D_A_TAG_ATTENTION_H #define D_A_TAG_ATTENTION_H +#include "SSystem/SComponent/c_math.h" +#include "d/d_a_obj.h" #include "f_op/f_op_actor.h" +#include "d/d_cc_d.h" namespace daTagAttention { class Act_c : public fopAc_ac_c { public: - void chk_inside(cXyz*) const {} - void prm_get_Type() const {} - void prm_get_swSave() const {} + bool chk_inside(cXyz* pos) const { + if (!m_b0x290){ + return false; + } + + fopAc_ac_c* player = dComIfGp_getPlayer(0); + cXyz plyrToObjVec = player->current.pos-current.pos; + if (subtype == 0){ + // spherical collision check + f32 distance = plyrToObjVec.abs(); + + if (distance > scale.x * 100.0f) { + return false; + } + }else{ + // box collision check + if (current.angle.y){ + s16 yRotAngle = current.angle.y; + f32 temp = + plyrToObjVec.x * cM_ssin(yRotAngle) + + plyrToObjVec.z * cM_scos(yRotAngle); + plyrToObjVec.x = + plyrToObjVec.x * cM_scos(yRotAngle) - + plyrToObjVec.z * cM_ssin(yRotAngle); + plyrToObjVec.z = temp; + } + + if ((plyrToObjVec.x < -scale.x * 100.0f) || (plyrToObjVec.x > scale.x * 100.0f)){ + return false; + } + if ((plyrToObjVec.y < -scale.y * 100.0f) || (plyrToObjVec.y > scale.y * 100.0f)){ + return false; + } + if ((plyrToObjVec.z < -scale.z * 100.0f) || (plyrToObjVec.z > scale.z * 100.0f)){ + return false; + } + } + + *pos = current.pos; + return true; + } + + int prm_get_Type() const + { + return daObj::PrmAbstract(this, PRM_TYPE_W, PRM_TYPE_S); + } + + int prm_get_swSave() const + { + return daObj::PrmAbstract(this, PRM_SWSAVE_W, PRM_SWSAVE_S); + } cPhs_State _create(); bool _execute(); - + + enum Prm_e { + PRM_TYPE_W = 0x02, + PRM_TYPE_S = 0x08, + PRM_SWSAVE_W = 0x08, + PRM_SWSAVE_S = 0x00, + }; + public: - /* Place member variables here */ + /* 0x290 */ bool m_b0x290; + /* padding */ s8 mPad[8]; + /* 0x2B8 */ dCcD_Stts mStts; + /* 0x2D8 */ dCcD_Sph mSph; }; }; diff --git a/include/d/d_attention.h b/include/d/d_attention.h index fb912b43a..3835f62b0 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -260,7 +260,7 @@ public: void LookRequest(fopAc_ac_c* reqActor, f32 horizontalDist, f32 upDist, f32 downDist, s16 angle, int param_5) { mLook[0].request(reqActor, horizontalDist, upDist, downDist, angle, param_5); } - void Look2RequestF(fopAc_ac_c*, s16, int) {} + void Look2RequestF(fopAc_ac_c* param_1, s16 param_2, int param_3) {mLook[1].requestF(param_1,param_2,param_3);} public: /* 0x000 */ daPy_lk_c* mpPlayer; diff --git a/src/d/actor/d_a_tag_attention.cpp b/src/d/actor/d_a_tag_attention.cpp index 83b5ab1f0..22fb38672 100644 --- a/src/d/actor/d_a_tag_attention.cpp +++ b/src/d/actor/d_a_tag_attention.cpp @@ -6,7 +6,8 @@ #include "d/actor/d_a_tag_attention.h" #include "d/d_procname.h" #include "d/d_priority.h" -#include "d/d_cc_d.h" +#include "f_op/f_op_actor_mng.h" +#include "d/d_com_inf_game.h" static dCcD_SrcSph sph_check_src = { // dCcD_SrcGObjInf @@ -37,42 +38,64 @@ static dCcD_SrcSph sph_check_src = { }, }; - /* 00000078-00000188 .text _create__Q214daTagAttention5Act_cFv */ cPhs_State daTagAttention::Act_c::_create() { - /* Nonmatching */ + fopAcM_SetupActor(this, Act_c); + mStts.Init(0xFF, 0xFF, this); + mSph.Set(sph_check_src); + mSph.SetStts(&mStts); + return cPhs_COMPLEATE_e; } /* 00000340-00000480 .text _execute__Q214daTagAttention5Act_cFv */ bool daTagAttention::Act_c::_execute() { - /* Nonmatching */ + mSph.SetC(current.pos); + mSph.SetR(scale.x * 100.0f); + dComIfG_Ccsp()->Set(&mSph); + m_b0x290 = true; + if (prm_get_Type() == 1){ + if (fopAcM_isSwitch(this, prm_get_swSave()) == FALSE){ + m_b0x290 = false; + } + }else if (prm_get_Type() == 2){ + if (fopAcM_isSwitch(this, prm_get_swSave()) != FALSE){ + m_b0x290 = false; + } + } + + cXyz unused; + if (chk_inside(&unused)){ + dComIfGp_att_Look2RequestF(this, 0x6000, 1); + } + + return true; } namespace daTagAttention { namespace { /* 00000480-000004A0 .text Mthd_Create__Q214daTagAttention31@unnamed@d_a_tag_attention_cpp@FPv */ -cPhs_State Mthd_Create(void*) { - /* Nonmatching */ +cPhs_State Mthd_Create(void* i_this) { + return static_cast(i_this)->_create(); } /* 000004A0-000004A8 .text Mthd_Delete__Q214daTagAttention31@unnamed@d_a_tag_attention_cpp@FPv */ -BOOL Mthd_Delete(void*) { - /* Nonmatching */ +bool Mthd_Delete(void* i_this) { + return TRUE; } /* 000004A8-000004C8 .text Mthd_Execute__Q214daTagAttention31@unnamed@d_a_tag_attention_cpp@FPv */ -BOOL Mthd_Execute(void*) { - /* Nonmatching */ +bool Mthd_Execute(void* i_this) { + return static_cast(i_this)->_execute(); } /* 000004C8-000004D0 .text Mthd_Draw__Q214daTagAttention31@unnamed@d_a_tag_attention_cpp@FPv */ -BOOL Mthd_Draw(void*) { - /* Nonmatching */ +BOOL Mthd_Draw(void* i_this) { + return TRUE; } /* 000004D0-000004D8 .text Mthd_IsDelete__Q214daTagAttention31@unnamed@d_a_tag_attention_cpp@FPv */ -BOOL Mthd_IsDelete(void*) { - /* Nonmatching */ +BOOL Mthd_IsDelete(void* i_this) { + return TRUE; } static actor_method_class Mthd_Table = {