Skip to content

Commit 08623f9

Browse files
Merge pull request #274 from elijah-thomas774/d_t_barrel
d_t_barrel and d_t_barrel_pos
2 parents fc4700e + c0b8b12 commit 08623f9

File tree

10 files changed

+370
-127
lines changed

10 files changed

+370
-127
lines changed

config/SOUE01/rels/d_a_obj_barrelNP/symbols.txt

Lines changed: 89 additions & 89 deletions
Large diffs are not rendered by default.

config/SOUE01/rels/d_a_obj_stage_sinkNP/symbols.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ finalizeState_Wait__15dAcOstageSink_cFv = .text:0x00000AA0; // type:function siz
2525
initializeState_Move__15dAcOstageSink_cFv = .text:0x00000AB0; // type:function size:0x4
2626
executeState_Move__15dAcOstageSink_cFv = .text:0x00000AC0; // type:function size:0x23C
2727
finalizeState_Move__15dAcOstageSink_cFv = .text:0x00000D00; // type:function size:0x4
28-
fn_383_D10 = .text:0x00000D10; // type:function size:0xC
28+
GetInstance__15dAcOstageSink_cFv = .text:0x00000D10; // type:function size:0xC
2929
fn_383_D20 = .text:0x00000D20; // type:function size:0xA0
3030
fn_383_DC0 = .text:0x00000DC0; // type:function size:0x18
3131
__dt__15dAcOstageSink_cFv = .text:0x00000DE0; // type:function size:0x100

config/SOUE01/rels/d_t_barrelNP/symbols.txt

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ _unresolved = .text:0x00000060; // type:function size:0x4 scope:global
44
__register_global_object = .text:0x00000070; // type:function size:0x1C scope:global
55
__destroy_global_chain = .text:0x00000090; // type:function size:0x54 scope:global
66
dTgBarrel_c_classInit__Fv = .text:0x000000F0; // type:function size:0x100
7-
__dt__11dTgBarrel_cFv = .text:0x000001F0; // type:function size:0x58
7+
__dt__5dTg_cFv = .text:0x000001F0; // type:function size:0x58
88
__dt__24sFState_c<11dTgBarrel_c>Fv = .text:0x00000250; // type:function size:0x58
99
__dt__27sFStateFct_c<11dTgBarrel_c>Fv = .text:0x000002B0; // type:function size:0x6C
1010
__dt__80sStateMgr_c<11dTgBarrel_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000320; // type:function size:0xA0
1111
__dt__50sFStateMgr_c<11dTgBarrel_c,20sStateMethodUsr_FI_c>Fv = .text:0x000003C0; // type:function size:0xA4
12-
fn_442_470 = .text:0x00000470; // type:function size:0x14
13-
fn_442_490 = .text:0x00000490; // type:function size:0x58
14-
fn_442_4F0 = .text:0x000004F0; // type:function size:0x14
15-
fn_442_510 = .text:0x00000510; // type:function size:0x58
16-
TgBarrel__init1 = .text:0x00000570; // type:function size:0xC0
12+
__ct__24dAcRef_c<12dAcOBarrel_c>Fv = .text:0x00000470; // type:function size:0x14
13+
__dt__24dAcRef_c<12dAcOBarrel_c>Fv = .text:0x00000490; // type:function size:0x58
14+
__ct__26dAcRef_c<14dTgBarrelPos_c>Fv = .text:0x000004F0; // type:function size:0x14
15+
__dt__26dAcRef_c<14dTgBarrelPos_c>Fv = .text:0x00000510; // type:function size:0x58
16+
actorCreate__11dTgBarrel_cFv = .text:0x00000570; // type:function size:0xC0
1717
changeState__80sStateMgr_c<11dTgBarrel_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000630; // type:function size:0x10
18-
TgBarrel__init2 = .text:0x00000640; // type:function size:0x9C
19-
fn_442_6E0 = .text:0x000006E0; // type:function size:0x8
20-
TgBarrel__update = .text:0x000006F0; // type:function size:0x30
18+
actorPostCreate__11dTgBarrel_cFv = .text:0x00000640; // type:function size:0x9C
19+
doDelete__11dTgBarrel_cFv = .text:0x000006E0; // type:function size:0x8
20+
actorExecute__11dTgBarrel_cFv = .text:0x000006F0; // type:function size:0x30
2121
executeState__80sStateMgr_c<11dTgBarrel_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000720; // type:function size:0x10
22-
fn_442_730 = .text:0x00000730; // type:function size:0x8
22+
draw__11dTgBarrel_cFv = .text:0x00000730; // type:function size:0x8
2323
initializeState_Wait__11dTgBarrel_cFv = .text:0x00000740; // type:function size:0x4
2424
executeState_Wait__11dTgBarrel_cFv = .text:0x00000750; // type:function size:0x2E0
25-
fn_442_A30 = .text:0x00000A30; // type:function size:0x1C
25+
calcTimer<Uc>__4sLibFPUc_Uc = .text:0x00000A30; // type:function size:0x1C
2626
finalizeState_Wait__11dTgBarrel_cFv = .text:0x00000A50; // type:function size:0x4
2727
initializeState_Stop__11dTgBarrel_cFv = .text:0x00000A60; // type:function size:0x4
2828
executeState_Stop__11dTgBarrel_cFv = .text:0x00000A70; // type:function size:0x74
2929
finalizeState_Stop__11dTgBarrel_cFv = .text:0x00000AF0; // type:function size:0x4
30-
fn_442_B00 = .text:0x00000B00; // type:function size:0x21C
31-
fn_442_D20 = .text:0x00000D20; // type:function size:0x108
30+
checkPlayerPos__11dTgBarrel_cFRC7mVec3_c = .text:0x00000B00; // type:function size:0x21C
31+
__dt__11dTgBarrel_cFv = .text:0x00000D20; // type:function size:0x108
3232
getStateID__80sStateMgr_c<11dTgBarrel_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000E30; // type:function size:0x10
3333
build__27sFStateFct_c<11dTgBarrel_c>FRC12sStateIDIf_c = .text:0x00000E40; // type:function size:0x60
3434
dispose__27sFStateFct_c<11dTgBarrel_c>FRP10sStateIf_c = .text:0x00000EA0; // type:function size:0xC
@@ -50,15 +50,16 @@ isSameName__26sFStateID_c<11dTgBarrel_c>CFPCc = .text:0x00001220; // type:functi
5050
_ctors = .ctors:0x00000000; // type:label scope:global
5151
_dtors = .dtors:0x00000000; // type:label scope:global
5252
__destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global
53-
lbl_442_rodata_0 = .rodata:0x00000000; // type:object size:0x14 data:float
53+
lbl_442_rodata_0 = .rodata:0x00000000; // type:object size:0x14 scope:local data:float
5454
g_profile_TAG_BARREL = .data:0x00000000; // type:object size:0x10 data:4byte
55-
TgBarrel__vtable = .data:0x00000010; // type:object size:0x78
56-
lbl_442_data_88 = .data:0x00000088; // type:object size:0x30
57-
lbl_442_data_B8 = .data:0x000000B8; // type:object size:0x30
58-
lbl_442_data_E8 = .data:0x000000E8; // type:object size:0x18
59-
lbl_442_data_100 = .data:0x00000100; // type:object size:0x10C
60-
lbl_442_data_20C = .data:0x0000020C; // type:object size:0x34
55+
__vt__11dTgBarrel_c = .data:0x00000010; // type:object size:0x74
56+
lbl_442_data_88 = .data:0x00000088; // type:object size:0x30 scope:local
57+
lbl_442_data_B8 = .data:0x000000B8; // type:object size:0x30 scope:local
58+
lbl_442_data_E8 = .data:0x000000E8; // type:object size:0x18 scope:local
59+
lbl_442_data_100 = .data:0x00000100; // type:object size:0x10C scope:local
60+
lbl_442_data_20C = .data:0x0000020C; // type:object size:0x34 scope:local
6161
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
62-
lbl_442_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte
63-
TgBarrel__StateID_Wait = .bss:0x00000018; // type:object size:0x40 data:4byte
64-
TgBarrel__StateID_Stop = .bss:0x00000058; // type:object size:0x30 data:4byte
62+
@23673 = .bss:0x00000008; // type:object size:0xC scope:local data:4byte
63+
StateID_Wait__11dTgBarrel_c = .bss:0x00000018; // type:object size:0x30 data:4byte
64+
@23677 = .bss:0x00000048; // type:object size:0xC scope:local data:4byte
65+
StateID_Stop__11dTgBarrel_c = .bss:0x00000058; // type:object size:0x30 data:4byte

config/SOUE01/rels/d_t_barrel_posNP/symbols.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ _prolog = .text:0x00000000; // type:function size:0x2C scope:global
22
_epilog = .text:0x00000030; // type:function size:0x2C scope:global
33
_unresolved = .text:0x00000060; // type:function size:0x4 scope:global
44
dTgBarrelPos_c_classInit__Fv = .text:0x00000070; // type:function size:0x5C
5-
TgBarrelPos__init = .text:0x000000D0; // type:function size:0x7C
6-
fn_443_150 = .text:0x00000150; // type:function size:0x8
7-
fn_443_160 = .text:0x00000160; // type:function size:0xE0
8-
fn_443_240 = .text:0x00000240; // type:function size:0x8
5+
create__14dTgBarrelPos_cFv = .text:0x000000D0; // type:function size:0x7C
6+
doDelete__14dTgBarrelPos_cFv = .text:0x00000150; // type:function size:0x8
7+
actorExecute__14dTgBarrelPos_cFv = .text:0x00000160; // type:function size:0xE0
8+
draw__14dTgBarrelPos_cFv = .text:0x00000240; // type:function size:0x8
99
__dt__14dTgBarrelPos_cFv = .text:0x00000250; // type:function size:0x74
1010
_ctors = .ctors:0x00000000; // type:label scope:global
1111
_dtors = .dtors:0x00000000; // type:label scope:global
1212
g_profile_TAG_BARREL_POS = .data:0x00000000; // type:object size:0x10
13-
lbl_443_section4_10 = .data:0x00000010; // type:object size:0x74
13+
__vt__14dTgBarrelPos_c = .data:0x00000010; // type:object size:0x74

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2878,7 +2878,7 @@ def MatchingFor(*versions):
28782878
Rel(NonMatching, "d_t_at0", "REL/d/t/d_t_at0.cpp"),
28792879
Rel(NonMatching, "d_t_auto_message", "REL/d/t/d_t_auto_message.cpp"),
28802880
Rel(NonMatching, "d_t_barrel", "REL/d/t/d_t_barrel.cpp"),
2881-
Rel(NonMatching, "d_t_barrel_pos", "REL/d/t/d_t_barrel_pos.cpp"),
2881+
Rel(Matching, "d_t_barrel_pos", "REL/d/t/d_t_barrel_pos.cpp"),
28822882
Rel(NonMatching, "d_t_bb_quake", "REL/d/t/d_t_bb_quake.cpp"),
28832883
Rel(NonMatching, "d_t_bcal_tag", "REL/d/t/d_t_bcal_tag.cpp"),
28842884
Rel(NonMatching, "d_t_bcz", "REL/d/t/d_t_bcz.cpp"),

include/d/a/obj/d_a_obj_stage_sink.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "d/a/obj/d_a_obj_base.h"
55
#include "s/s_State.hpp"
6-
#include "s/s_StateMgr.hpp"
76

87
class dAcOstageSink_c : public dAcObjBase_c {
98
public:
@@ -13,8 +12,12 @@ class dAcOstageSink_c : public dAcObjBase_c {
1312
STATE_FUNC_DECLARE(dAcOstageSink_c, Wait);
1413
STATE_FUNC_DECLARE(dAcOstageSink_c, Move);
1514

15+
static dAcOstageSink_c *GetInstance();
16+
1617
private:
1718
/* 0x??? */ STATE_MGR_DECLARE(dAcOstageSink_c);
19+
20+
static dAcOstageSink_c *sInstance;
1821
};
1922

2023
#endif

include/d/t/d_t_barrel.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
#ifndef D_T_BARREL_H
22
#define D_T_BARREL_H
33

4+
#include "common.h"
45
#include "d/a/d_a_base.h"
6+
#include "d/t/d_tg.h"
7+
#include "m/m_vec.h"
58
#include "s/s_State.hpp"
6-
#include "s/s_StateMgr.hpp"
79

8-
class dTgBarrel_c : public dAcBase_c {
10+
class dTgBarrelPos_c;
11+
class dAcOBarrel_c;
12+
class dAcOstageSink_c;
13+
14+
class dTgBarrel_c : public dTg_c {
915
public:
1016
dTgBarrel_c() : mStateMgr(*this, sStateID::null) {}
1117
virtual ~dTgBarrel_c() {}
1218

19+
virtual int doDelete() override;
20+
virtual int draw() override;
21+
virtual int actorCreate() override;
22+
virtual int actorPostCreate() override;
23+
virtual int actorExecute() override;
24+
1325
STATE_FUNC_DECLARE(dTgBarrel_c, Wait);
1426
STATE_FUNC_DECLARE(dTgBarrel_c, Stop);
1527

28+
bool checkPlayerPos(const mVec3_c &playerPos);
29+
1630
private:
17-
/* 0x??? */ STATE_MGR_DECLARE(dTgBarrel_c);
31+
/* 0x0FC */ STATE_MGR_DECLARE(dTgBarrel_c);
32+
/* 0x138 */ dAcRef_c<dAcOstageSink_c> mStageRef;
33+
/* 0x144 */ dAcRef_c<dTgBarrelPos_c> mTgBarrelPosArr[10];
34+
/* 0x1BC */ dAcRef_c<dAcOBarrel_c> mBarrelArr[10];
35+
/* 0x234 */ mVec3_c mSpawnPosition;
36+
/* 0x240 */ u8 mStopFlag; ///< Stop Sceneflag - Note there is no checking done to see if valid
37+
/* 0x241 */ u8 mSpawnInterval; ///< Barrel Spawn Interval in Seconds
38+
/* 0x242 */ u8 mSpawnTimer; ///< Barrel Spawn Timer
39+
/* 0x243 */ u8 mBarrelPosCount; ///< Represents the index of the highest dTgBarrelPos_c in mTgBarrelPosArr
40+
/* 0x244 */ u8 mBarrelPosIndex; ///< Rolling index to spawn dAcOBarrel_c from a dTgBarrelPos_c
41+
/* 0x245 */ u8 mLinkId; ///< Link Id used to find correct dTgBarrelPos_c
42+
/* 0x246 */ bool mSpawnActive; ///< Used to reset the spawn timer after the player has already entered the area
1843
};
1944

2045
#endif

include/d/t/d_t_barrel_pos.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
#ifndef D_T_BARREL_POS_H
22
#define D_T_BARREL_POS_H
33

4-
#include "d/a/d_a_base.h"
4+
#include "d/t/d_tg.h"
5+
#include "m/m_vec.h"
56

6-
class dTgBarrelPos_c : public dAcBase_c {
7+
class dAcOstageSink_c;
8+
9+
class dTgBarrelPos_c : public dTg_c {
710
public:
811
dTgBarrelPos_c() {}
912
virtual ~dTgBarrelPos_c() {}
1013

14+
virtual int create() override;
15+
virtual int doDelete() override;
16+
virtual int draw() override;
17+
virtual int actorExecute() override;
18+
19+
u8 getLinkIndex() const {
20+
return mLinkIndex;
21+
}
22+
u8 getLinkId() const {
23+
return mLinkId;
24+
}
25+
1126
private:
27+
/* 0x0FC */ dAcRef_c<dAcOstageSink_c> mStageRef;
28+
/* 0x108 */ mVec3_c mSpawnPosition;
29+
/* 0x114 */ u8 mLinkIndex; ///< Link Index used in dTgBarrel_c array
30+
/* 0x115 */ u8 mLinkId; ///< Link Id used to find correct dTgBarrel_c
1231
};
1332

1433
#endif

src/REL/d/t/d_t_barrel.cpp

Lines changed: 153 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,164 @@
11
#include "d/t/d_t_barrel.h"
22

3+
#include "common.h"
4+
#include "d/a/d_a_base.h"
5+
#include "d/a/d_a_player.h"
6+
#include "d/a/obj/d_a_obj_barrel.h"
7+
#include "d/a/obj/d_a_obj_base.h"
8+
#include "d/a/obj/d_a_obj_stage_sink.h"
9+
#include "d/flag/sceneflag_manager.h"
10+
#include "d/t/d_t_barrel_pos.h"
11+
#include "f/f_base.h"
12+
#include "f/f_manager.h"
13+
#include "f/f_profile_name.h"
14+
#include "m/m_angle.h"
15+
#include "m/m_mtx.h"
16+
#include "m/m_vec.h"
17+
#include "s/s_Math.h"
18+
319
SPECIAL_ACTOR_PROFILE(TAG_BARREL, dTgBarrel_c, fProfile::TAG_BARREL, 0x221, 0, 0);
420

521
STATE_DEFINE(dTgBarrel_c, Wait);
622
STATE_DEFINE(dTgBarrel_c, Stop);
723

24+
// Weak function ordering issue of the ctor and dtor of the objects
25+
// for the following in the member arrays
26+
// dAcRef_c<dTgBarrelPos_c>
27+
// dAcRef_c<dAcOBarrel_c>
28+
29+
int dTgBarrel_c::actorCreate() {
30+
mStopFlag = getFromParams(0, 0xFF);
31+
mLinkId = getFromParams(16, 0xF);
32+
mSpawnInterval = getFromParams(8, 0xFF);
33+
mSpawnTimer = 1;
34+
35+
mStageRef.link(dAcOstageSink_c::GetInstance());
36+
mSpawnPosition = mPosition;
37+
38+
for (int i = 0; i < (int)ARRAY_LENGTH(mBarrelArr); ++i) {
39+
mBarrelArr[i].unlink();
40+
}
41+
42+
mStateMgr.changeState(StateID_Wait);
43+
44+
return SUCCEEDED;
45+
}
46+
47+
int dTgBarrel_c::actorPostCreate() {
48+
dTgBarrelPos_c *pTgBarrelPos = nullptr;
49+
do {
50+
pTgBarrelPos =
51+
static_cast<dTgBarrelPos_c *>(fManager_c::searchBaseByProfName(fProfile::TAG_BARREL_POS, pTgBarrelPos));
52+
53+
if (pTgBarrelPos != nullptr) {
54+
u8 index = pTgBarrelPos->getLinkIndex();
55+
if (mLinkId == pTgBarrelPos->getLinkId()) {
56+
mTgBarrelPosArr[index].link(pTgBarrelPos);
57+
if (index >= mBarrelPosCount) {
58+
mBarrelPosCount = index + 1;
59+
}
60+
}
61+
}
62+
63+
} while (pTgBarrelPos != nullptr);
64+
65+
return SUCCEEDED;
66+
}
67+
68+
int dTgBarrel_c::doDelete() {
69+
return SUCCEEDED;
70+
}
71+
72+
int dTgBarrel_c::actorExecute() {
73+
mStateMgr.executeState();
74+
return SUCCEEDED;
75+
}
76+
77+
int dTgBarrel_c::draw() {
78+
return SUCCEEDED;
79+
}
80+
881
void dTgBarrel_c::initializeState_Wait() {}
9-
void dTgBarrel_c::executeState_Wait() {}
82+
void dTgBarrel_c::executeState_Wait() {
83+
if (SceneflagManager::sInstance->checkBoolFlag(mRoomID, mStopFlag)) {
84+
mStateMgr.changeState(StateID_Stop);
85+
return;
86+
}
87+
dAcOstageSink_c *pStage = mStageRef.get();
88+
89+
mVec3_c pos = pStage->mPosition;
90+
mAng3_c rot = pStage->mRotation;
91+
92+
mVec3_c stageDist = mSpawnPosition - pos;
93+
mMtx_c m;
94+
m.transS(pos);
95+
m.ZXYrotM(rot);
96+
m.multVecSR(stageDist, mPosition);
97+
98+
mPosition += pos;
99+
100+
if (checkPlayerPos(dAcPy_c::GetLink()->mPosition)) {
101+
if (0 == sLib::calcTimer(&mSpawnTimer)) {
102+
mSpawnActive = true;
103+
104+
u8 idx = 0xFF;
105+
for (int i = 0; i < (int)ARRAY_LENGTH(mBarrelArr); ++i) {
106+
if (!mBarrelArr[i].isLinked()) {
107+
idx = i;
108+
// I think they forgor a break here
109+
}
110+
}
111+
112+
if (idx != 0xFF) {
113+
dTgBarrelPos_c *pTgBarrelPos = mTgBarrelPosArr[mBarrelPosIndex].get();
114+
if (pTgBarrelPos != nullptr) {
115+
mVec3_c spawnPos = pTgBarrelPos->mPosition;
116+
mAng3_c spawnRot(0, 0x4000, 0);
117+
dAcObjBase_c *pObj = dAcObjBase_c::create(
118+
fProfile::OBJ_BARREL, mRoomID, 0xFF00FF2, &spawnPos, &spawnRot, nullptr, 0xFFFFFFFF
119+
);
120+
mBarrelArr[idx].link(static_cast<dAcOBarrel_c *>(pObj));
121+
}
122+
if (++mBarrelPosIndex >= mBarrelPosCount) {
123+
mBarrelPosIndex = 0;
124+
}
125+
}
126+
mSpawnTimer = mSpawnInterval * 30;
127+
}
128+
} else {
129+
if (mSpawnActive) {
130+
mSpawnTimer = mSpawnInterval * 30;
131+
}
132+
}
133+
}
10134
void dTgBarrel_c::finalizeState_Wait() {}
135+
11136
void dTgBarrel_c::initializeState_Stop() {}
12-
void dTgBarrel_c::executeState_Stop() {}
137+
void dTgBarrel_c::executeState_Stop() {
138+
if (!SceneflagManager::sInstance->checkBoolFlag(mRoomID, mStopFlag)) {
139+
mStateMgr.changeState(StateID_Wait);
140+
}
141+
}
13142
void dTgBarrel_c::finalizeState_Stop() {}
143+
144+
bool dTgBarrel_c::checkPlayerPos(const mVec3_c &playerPos) {
145+
f32 scale = 0.5f;
146+
147+
mVec3_c pos = playerPos - (mPosition + (mVec3_c::Ey * mScale.y * scale));
148+
mAng rot = mStageRef.get()->mRotation.z;
149+
150+
pos.x = pos.x / mScale.x;
151+
pos.y = pos.y / mScale.y;
152+
pos.z = pos.z / mScale.z;
153+
154+
f32 halfCos = rot.cos() * scale;
155+
if (rot.cos() != 0.f) {
156+
scale = mScale.x * ((pos.x * rot.sin()) / rot.cos()) / mScale.y;
157+
}
158+
159+
return (
160+
(pos.x <= halfCos && pos.x >= -halfCos) //
161+
&& pos.y <= scale + 0.5f + 1e-6f && pos.y >= scale + -0.5f - 1e-6f //
162+
&& pos.z <= 0.5f && pos.z >= -0.5f
163+
);
164+
}

0 commit comments

Comments
 (0)