summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Thomas <42302100+elijah-thomas774@users.noreply.github.com>2025-05-24 03:34:09 -0400
committerGitHub <noreply@github.com>2025-05-24 03:34:09 -0400
commit9efc1e0ab925eb88a00e1e3f2e7810fa63d5267b (patch)
tree6b1fd566f38ee64d8959676ad8d9aeab739a0b27
parentb8b2375891b14698cad4a3e167eee2b669f538ca (diff)
d_t_action OK (#172)
* d_t_action OK
-rw-r--r--config/SOUE01/rels/d_t_actionNP/symbols.txt24
-rw-r--r--config/SOUE01/symbols.txt2
-rw-r--r--configure.py2
-rw-r--r--include/d/a/d_a_base.h7
-rw-r--r--include/d/d_player_act.h13
-rw-r--r--include/d/t/d_t_action.h38
-rw-r--r--include/m/m_angle.h9
-rw-r--r--src/REL/d/t/d_t_action.cpp90
-rw-r--r--src/d/a/d_a_base.cpp4
9 files changed, 159 insertions, 30 deletions
diff --git a/config/SOUE01/rels/d_t_actionNP/symbols.txt b/config/SOUE01/rels/d_t_actionNP/symbols.txt
index 9fea26f1..037067fc 100644
--- a/config/SOUE01/rels/d_t_actionNP/symbols.txt
+++ b/config/SOUE01/rels/d_t_actionNP/symbols.txt
@@ -2,19 +2,19 @@ _prolog = .text:0x00000000; // type:function size:0x2C scope:global
_epilog = .text:0x00000030; // type:function size:0x2C scope:global
_unresolved = .text:0x00000060; // type:function size:0x4 scope:global
dTgAction_c_classInit__Fv = .text:0x00000070; // type:function size:0x4C
-TgActTag__init = .text:0x000000C0; // type:function size:0x64
-fn_202_130 = .text:0x00000130; // type:function size:0x8
-fn_202_140 = .text:0x00000140; // type:function size:0x58
-fn_202_1A0 = .text:0x000001A0; // type:function size:0x6C
-TgActTag__update = .text:0x00000210; // type:function size:0x27C
-fn_202_490 = .text:0x00000490; // type:function size:0x8
+create__11dTgAction_cFv = .text:0x000000C0; // type:function size:0x64
+doDelete__11dTgAction_cFv = .text:0x00000130; // type:function size:0x8
+setActiveArea__11dTgAction_cFf = .text:0x00000140; // type:function size:0x58
+resetActiveArea__11dTgAction_cFv = .text:0x000001A0; // type:function size:0x6C
+actorExecute__11dTgAction_cFv = .text:0x00000210; // type:function size:0x27C
+draw__11dTgAction_cFv = .text:0x00000490; // type:function size:0x8
__dt__11dTgAction_cFv = .text:0x000004A0; // type:function size:0x5C
_ctors = .ctors:0x00000000; // type:label scope:global
_dtors = .dtors:0x00000000; // type:label scope:global
-lbl_202_rodata_0 = .rodata:0x00000000; // type:object size:0x4 data:float
-lbl_202_rodata_4 = .rodata:0x00000004; // type:object size:0x4 align:4 data:float
-lbl_202_rodata_8 = .rodata:0x00000008; // type:object size:0x4 align:4 data:float
-lbl_202_rodata_C = .rodata:0x0000000C; // type:object size:0x4 align:4 data:float
+lbl_202_rodata_0 = .rodata:0x00000000; // type:object size:0x4 scope:local data:float
+lbl_202_rodata_4 = .rodata:0x00000004; // type:object size:0x4 scope:local align:4 data:float
+lbl_202_rodata_8 = .rodata:0x00000008; // type:object size:0x4 scope:local align:4 data:float
+lbl_202_rodata_C = .rodata:0x0000000C; // type:object size:0x4 scope:local align:4 data:float
g_profile_ACTION_TAG = .data:0x00000000; // type:object size:0x10
-lbl_202_data_10 = .data:0x00000010; // type:object size:0x4 data:4byte
-TgActTag__vtable = .data:0x00000014; // type:object size:0x74
+lbl_202_data_10 = .data:0x00000010; // type:object size:0x4 scope:local data:4byte
+__vt__11dTgAction_c = .data:0x00000014; // type:object size:0x74
diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt
index 6769ea6e..be93fef6 100644
--- a/config/SOUE01/symbols.txt
+++ b/config/SOUE01/symbols.txt
@@ -1151,7 +1151,7 @@ ActorEnemyBase__shouldUpdateMaybe = .text:0x8002F400; // type:function size:0xB4
ActorEnemyBase__postUpdate = .text:0x8002F4C0; // type:function size:0x7C
ActorEnemyBase__preDraw = .text:0x8002F540; // type:function size:0x74
fn_8002F5C0 = .text:0x8002F5C0; // type:function size:0x110
-checkBeetleActorReferences__17daPlayerActBase_cFv = .text:0x8002F6D0; // type:function size:0x8
+checkBeetleActorReferences__17daPlayerActBase_cFl = .text:0x8002F6D0; // type:function size:0x8
getBeetleActorReferencesSize__17daPlayerActBase_cFv = .text:0x8002F6E0; // type:function size:0x8
fn_8002F6F0 = .text:0x8002F6F0; // type:function size:0xC
fn_8002F700 = .text:0x8002F700; // type:function size:0x8
diff --git a/configure.py b/configure.py
index c535fcbb..f7851fef 100644
--- a/configure.py
+++ b/configure.py
@@ -2448,7 +2448,7 @@ config.libs = [
Rel(NonMatching, "d_SoftwareKeyboard", "REL/d/d_SoftwareKeyboard.cpp"),
Rel(NonMatching, "d_s_boot", "REL/d/d_s_boot.cpp"),
Rel(NonMatching, "d_title_manager", "REL/d/d_title_manager.cpp"),
- Rel(NonMatching, "d_t_action", "REL/d/t/d_t_action.cpp"),
+ Rel(Matching, "d_t_action", "REL/d/t/d_t_action.cpp"),
Rel(NonMatching, "d_t_at0", "REL/d/t/d_t_at0.cpp"),
Rel(NonMatching, "d_t_auto_message", "REL/d/t/d_t_auto_message.cpp"),
Rel(NonMatching, "d_t_barrel", "REL/d/t/d_t_barrel.cpp"),
diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h
index f0bfddc8..e293b927 100644
--- a/include/d/a/d_a_base.h
+++ b/include/d/a/d_a_base.h
@@ -15,8 +15,8 @@ struct cBgS_PolyInfo;
struct SoundSource {
virtual ~SoundSource() {}
- // TODO there's probably multiple inheritance involved and stuff
- #define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset();
+// TODO there's probably multiple inheritance involved and stuff
+#define SOUNDSOURCE_VIRTUAL(offset) virtual void vt_##offset();
SOUNDSOURCE_VIRTUAL(0x0C);
SOUNDSOURCE_VIRTUAL(0x10);
@@ -33,7 +33,7 @@ struct SoundSource {
SOUNDSOURCE_VIRTUAL(0x3C);
SOUNDSOURCE_VIRTUAL(0x40);
SOUNDSOURCE_VIRTUAL(0x44);
- virtual bool shutdown(); // 0x48
+ virtual bool shutdown(); // 0x48
SOUNDSOURCE_VIRTUAL(0x4C);
SOUNDSOURCE_VIRTUAL(0x50);
SOUNDSOURCE_VIRTUAL(0x54);
@@ -80,7 +80,6 @@ struct SoundSource {
SOUNDSOURCE_VIRTUAL(0xF8);
SOUNDSOURCE_VIRTUAL(0xFC);
-
virtual bool isReadyMaybe(); // 0x100
virtual bool load(void *data, const char *name); // 0x104
virtual void setFrame(f32 frame); // 0x108
diff --git a/include/d/d_player_act.h b/include/d/d_player_act.h
index aee87035..a490da69 100644
--- a/include/d/d_player_act.h
+++ b/include/d/d_player_act.h
@@ -131,10 +131,10 @@ public:
// unused; overridden by daPlayerModelBase_c
return nullptr;
}
- /* vt 0x11C */ virtual UNKWORD checkBeetleActorReferences() {
- return 0;
+ /* vt 0x11C */ virtual dAcObjBase_c *checkBeetleActorReferences(s32) {
+ return nullptr;
}
- /* vt 0x120 */ virtual UNKWORD getBeetleActorReferencesSize() {
+ /* vt 0x120 */ virtual s32 getBeetleActorReferencesSize() {
return 0;
}
/* vt 0x124 */ virtual UNKWORD vt_0x124() {
@@ -541,6 +541,13 @@ public:
return (someFlags_0x350 & mask) != 0;
}
+ inline void onFlags_0x358(u32 mask) {
+ someFlags_0x358 |= mask;
+ }
+ inline void offFlags_0x358(u32 mask) {
+ someFlags_0x358 &= ~mask;
+ }
+
inline void onFlags_0x360(u32 mask) {
field_0x360 |= mask;
}
diff --git a/include/d/t/d_t_action.h b/include/d/t/d_t_action.h
index 9bd97f8d..7f4e439f 100644
--- a/include/d/t/d_t_action.h
+++ b/include/d/t/d_t_action.h
@@ -1,14 +1,48 @@
#ifndef D_T_ACTION_H
#define D_T_ACTION_H
-#include "d/a/d_a_base.h"
+#include "d/flag/sceneflag_manager.h"
+#include "d/t/d_tg.h"
+#include "m/m_angle.h"
+#include "m/m_mtx.h"
-class dTgAction_c : public dAcBase_c {
+class dTgAction_c : public dTg_c {
public:
dTgAction_c() {}
virtual ~dTgAction_c() {}
+ enum Type_e {
+ FORCE_FADE_RESTART = 0,
+ SHOW_DASH_PROMPT = 1,
+ PREVENT_RESPAWN = 4,
+ WATER_RELATED = 5,
+ FORCE_AUTO_JUMP = 6,
+ PREVENT_LOFTWING_CALL = 7,
+ };
+
+ virtual int create() override;
+ virtual int doDelete() override;
+ virtual int draw() override;
+ virtual int actorExecute() override;
+
+ void setActiveArea(f32 scale);
+ void resetActiveArea();
+
+ bool checkActive1() const {
+ return SceneflagManager::sInstance->checkBoolFlag(roomid, mEnableFlag1);
+ }
+ bool checkActive2() const {
+ return (!(mEnableFlag2 < 0xFF) || SceneflagManager::sInstance->checkBoolFlag(roomid, mEnableFlag2));
+ }
+
private:
+ /* 0x0FC */ mMtx_c mActiveMtx;
+ /* 0x12C */ f32 mScaleIncrease;
+ /* 0x130 */ u8 mEnableFlag1;
+ /* 0x131 */ u8 mEnableFlag2;
+ /* 0x132 */ u8 mType;
+ /* 0x133 */ u8 _133;
+ /* 0x134 */ mAng field_0x134;
};
#endif
diff --git a/include/m/m_angle.h b/include/m/m_angle.h
index 01455a59..31135add 100644
--- a/include/m/m_angle.h
+++ b/include/m/m_angle.h
@@ -57,6 +57,10 @@ struct mAng {
return *this;
}
+ static s32 abs(const mAng b) {
+ return labs(b);
+ }
+
s32 step(s16 target, s32 steps, s16 max, s16 min);
f32 sin() const {
@@ -117,11 +121,6 @@ struct mAng {
return rad * (65536.0f / (2.f * M_PI));
}
- // Try not to use
- s32 diff(const mAng &other) {
- return mVal - other.mVal;
- }
-
s16 mVal;
private:
diff --git a/src/REL/d/t/d_t_action.cpp b/src/REL/d/t/d_t_action.cpp
index 5b459ac0..93e5dce3 100644
--- a/src/REL/d/t/d_t_action.cpp
+++ b/src/REL/d/t/d_t_action.cpp
@@ -1,3 +1,93 @@
#include "d/t/d_t_action.h"
+#include "common.h"
+#include "d/a/obj/d_a_obj_base.h"
+#include "d/a/obj/d_a_obj_bomb.h"
+#include "d/d_player.h"
+#include "f/f_base.h"
+#include "f/f_profile_name.h"
+#include "m/m_angle.h"
+#include "toBeSorted/area_math.h"
+
SPECIAL_ACTOR_PROFILE(ACTION_TAG, dTgAction_c, fProfile::ACTION_TAG, 0x20, 0, 0);
+
+int dTgAction_c::create() {
+ mEnableFlag1 = (params >> 6) & 0xFF;
+ mEnableFlag2 = (params >> 14) & 0xFF;
+ mType = (params >> 0) & 0x3F;
+ matrixCreateFromPosRotYScale(mActiveMtx, position, rotation.y, mScale, nullptr, 0.f);
+ return SUCCEEDED;
+}
+
+int dTgAction_c::doDelete() {
+ return SUCCEEDED;
+}
+
+void dTgAction_c::setActiveArea(f32 scale) {
+ if (mScaleIncrease < 0.1f) {
+ mScaleIncrease = scale;
+ matrixCreateFromPosRotYScale(mActiveMtx, position, rotation.y, mScale, nullptr, mScaleIncrease);
+ }
+}
+
+void dTgAction_c::resetActiveArea() {
+ if (mScaleIncrease > 0.f) {
+ mScaleIncrease = 0.f;
+ matrixCreateFromPosRotYScale(mActiveMtx, position, rotation.y, mScale, nullptr, 0.f);
+ field_0x134 = 0;
+ }
+}
+
+int dTgAction_c::actorExecute() {
+ dAcPy_c *player = getLinkPtr();
+ bool enabled = !checkActive1() && checkActive2();
+
+ // Check For Bomb within area
+ if (enabled && mType == WATER_RELATED) {
+ s32 numRefs = player->getBeetleActorReferencesSize();
+ for (s32 i = 0; i < numRefs; i++) {
+ dAcObjBase_c *pObj = player->checkBeetleActorReferences(i);
+ if (pObj == nullptr) {
+ break;
+ }
+ if (pObj->profile_name == fProfile::BOMB) {
+ if (checkIfVec3fInMatrix(mActiveMtx, pObj->GetPosition())) {
+ reinterpret_cast<dAcBomb_c *>(pObj)->On_0xA3C(0x20000000);
+ }
+ }
+ }
+ }
+
+ // Check For Player Within Area
+ if (enabled && checkIfVec3fInMatrix(mActiveMtx, player->GetPosition())) {
+ if (mType == FORCE_FADE_RESTART) {
+ player->onFlags_0x358(0x10000000);
+ setActiveArea(50.f);
+ } else if (mType == PREVENT_RESPAWN) {
+ player->onForceOrPreventActionFlags(0x80);
+ } else if (mType == FORCE_AUTO_JUMP) {
+ player->onForceOrPreventActionFlags(0x200000);
+ } else if (mType == PREVENT_LOFTWING_CALL) {
+ player->onForceOrPreventActionFlags(0x20000);
+ setActiveArea(50.f);
+ } else if (mType == WATER_RELATED) {
+ player->onForceOrPreventActionFlags(0x400000);
+ setActiveArea(15.f);
+ } else if (mType == SHOW_DASH_PROMPT) {
+ if (mAng::abs(player->rotation.y - rotation.y) < (0x2000 + field_0x134)) {
+ player->onForceOrPreventActionFlags(0x20000000);
+ setActiveArea(50.f);
+ field_0x134.set(0x38E);
+ } else {
+ resetActiveArea();
+ }
+ }
+ } else {
+ resetActiveArea();
+ }
+ return SUCCEEDED;
+}
+
+int dTgAction_c::draw() {
+ return SUCCEEDED;
+}
diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp
index ecf7193f..ff47e669 100644
--- a/src/d/a/d_a_base.cpp
+++ b/src/d/a/d_a_base.cpp
@@ -431,8 +431,8 @@ bool dAcBase_c::getDistanceAndAngleToActor(
angleToActorX.set(cLib::targetAngleX(position, actor->position));
if ((distSquared <= distThresh * distThresh)) {
- if ((labs(mAng(rotation.y.diff(angleToActorY))) <= yAngle) &&
- (labs(mAng(rotation.x.diff(angleToActorX))) <= xAngle)) {
+ if (mAng::abs((s32)(rotation.y - angleToActorY)) <= yAngle &&
+ mAng::abs((s32)(rotation.x - angleToActorX)) <= xAngle) {
isWithinRange = true;
}
}