Skip to content

Commit e2ee9fc

Browse files
Merge pull request #283 from swekka/d_a_obj_grass_coil
d_a_obj_grass_coil OK
2 parents e4640bd + 1bd24d2 commit e2ee9fc

File tree

4 files changed

+193
-18
lines changed

4 files changed

+193
-18
lines changed

config/SOUE01/rels/d_a_obj_grass_coilNP/symbols.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ __dt__28sFState_c<15dAcOgrassCoil_c>Fv = .text:0x000001D0; // type:function size
88
__dt__31sFStateFct_c<15dAcOgrassCoil_c>Fv = .text:0x00000230; // type:function size:0x6C
99
__dt__84sStateMgr_c<15dAcOgrassCoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002A0; // type:function size:0xA0
1010
__dt__54sFStateMgr_c<15dAcOgrassCoil_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000340; // type:function size:0xA4
11-
fn_268_3F0 = .text:0x000003F0; // type:function size:0xBC
12-
fn_268_4B0 = .text:0x000004B0; // type:function size:0x140
11+
createHeap__15dAcOgrassCoil_cFv = .text:0x000003F0; // type:function size:0xBC
12+
create__15dAcOgrassCoil_cFv = .text:0x000004B0; // type:function size:0x140
1313
changeState__84sStateMgr_c<15dAcOgrassCoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x000005F0; // type:function size:0x10
14-
fn_268_600 = .text:0x00000600; // type:function size:0x8
15-
fn_268_610 = .text:0x00000610; // type:function size:0x3F4
16-
fn_268_A10 = .text:0x00000A10; // type:function size:0x34
14+
doDelete__15dAcOgrassCoil_cFv = .text:0x00000600; // type:function size:0x8
15+
actorExecute__15dAcOgrassCoil_cFv = .text:0x00000610; // type:function size:0x3F4
16+
draw__15dAcOgrassCoil_cFv = .text:0x00000A10; // type:function size:0x34
1717
initializeState_Wait__15dAcOgrassCoil_cFv = .text:0x00000A50; // type:function size:0x4
1818
executeState_Wait__15dAcOgrassCoil_cFv = .text:0x00000A60; // type:function size:0x4
1919
finalizeState_Wait__15dAcOgrassCoil_cFv = .text:0x00000A70; // type:function size:0x4
@@ -40,16 +40,16 @@ isSameName__30sFStateID_c<15dAcOgrassCoil_c>CFPCc = .text:0x00000EC0; // type:fu
4040
_ctors = .ctors:0x00000000; // type:label scope:global
4141
_dtors = .dtors:0x00000000; // type:label scope:global
4242
__destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global
43-
lbl_268_rodata_0 = .rodata:0x00000000; // type:object size:0x50 data:float
43+
lbl_268_rodata_0 = .rodata:0x00000000; // type:object size:0x50 scope:local data:float
4444
g_profile_OBJ_GRASS_COIL = .data:0x00000000; // type:object size:0x40 data:4byte
45-
lbl_268_data_40 = .data:0x00000040; // type:object size:0x10 data:string
46-
lbl_268_data_50 = .data:0x00000050; // type:object size:0x38
47-
lbl_268_data_88 = .data:0x00000088; // type:object size:0x80
48-
lbl_268_data_108 = .data:0x00000108; // type:object size:0x30
49-
lbl_268_data_138 = .data:0x00000138; // type:object size:0x30
50-
lbl_268_data_168 = .data:0x00000168; // type:object size:0x18
51-
lbl_268_data_180 = .data:0x00000180; // type:object size:0x5C
52-
lbl_268_data_1DC = .data:0x000001DC; // type:object size:0x34
45+
lbl_268_data_40 = .data:0x00000040; // type:object size:0x10 scope:local data:string
46+
lbl_268_data_50 = .data:0x00000050; // type:object size:0x38 scope:local
47+
__vt__15dAcOgrassCoil_c = .data:0x00000088; // type:object size:0x80
48+
__vt__54sFStateMgr_c<15dAcOgrassCoil_c,20sStateMethodUsr_FI_c> = .data:0x00000108; // type:object size:0x30
49+
__vt__84sStateMgr_c<15dAcOgrassCoil_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000138; // type:object size:0x30
50+
lbl_268_data_168 = .data:0x00000168; // type:object size:0x18 scope:local
51+
lbl_268_data_180 = .data:0x00000180; // type:object size:0x5C scope:local
52+
__vt__30sFStateID_c<15dAcOgrassCoil_c> = .data:0x000001DC; // type:object size:0x34
5353
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
54-
lbl_268_bss_8 = .bss:0x00000008; // type:object size:0x10
55-
lbl_268_bss_18 = .bss:0x00000018; // type:object size:0x30 data:4byte
54+
lbl_268_bss_8 = .bss:0x00000008; // type:object size:0x10 scope:local
55+
lbl_268_bss_18 = .bss:0x00000018; // type:object size:0x30 scope:local data:4byte

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,7 @@ def MatchingFor(*versions):
25212521
NonMatching, "d_a_obj_goddess_statue", "REL/d/a/obj/d_a_obj_goddess_statue.cpp"
25222522
),
25232523
Rel(NonMatching, "d_a_obj_god_mark", "REL/d/a/obj/d_a_obj_god_mark.cpp"),
2524-
Rel(NonMatching, "d_a_obj_grass_coil", "REL/d/a/obj/d_a_obj_grass_coil.cpp"),
2524+
Rel(Matching, "d_a_obj_grass_coil", "REL/d/a/obj/d_a_obj_grass_coil.cpp"),
25252525
Rel(Matching, "d_a_obj_grave", "REL/d/a/obj/d_a_obj_grave.cpp"),
25262526
Rel(NonMatching, "d_a_obj_ground_cover", "REL/d/a/obj/d_a_obj_ground_cover.cpp"),
25272527
Rel(NonMatching, "d_a_obj_guard_log", "REL/d/a/obj/d_a_obj_guard_log.cpp"),

include/d/a/obj/d_a_obj_grass_coil.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#define D_A_OBJ_GRASS_COIL_H
33

44
#include "d/a/obj/d_a_obj_base.h"
5+
#include "d/col/cc/d_cc_d.h"
6+
#include "m/m3d/m_smdl.h"
7+
#include "m/m_angle.h"
8+
#include "m/m_vec.h"
9+
#include "nw4r/g3d/res/g3d_resfile.h"
510
#include "s/s_State.hpp"
611
#include "s/s_StateMgr.hpp"
712

@@ -10,10 +15,36 @@ class dAcOgrassCoil_c : public dAcObjBase_c {
1015
dAcOgrassCoil_c() : mStateMgr(*this, sStateID::null) {}
1116
virtual ~dAcOgrassCoil_c() {}
1217

18+
virtual bool createHeap() override;
19+
virtual int create() override;
20+
virtual int doDelete() override;
21+
virtual int actorExecute() override;
22+
virtual int draw() override;
23+
1324
STATE_FUNC_DECLARE(dAcOgrassCoil_c, Wait);
1425

26+
STATE_MGR_DEFINE_UTIL_EXECUTESTATE(dAcOgrassCoil_c);
27+
1528
private:
16-
/* 0x??? */ STATE_MGR_DECLARE(dAcOgrassCoil_c);
29+
/* 0x330 */ nw4r::g3d::ResFile mResFile;
30+
/* 0x334 */ m3d::smdl_c mMdl[2]; ///< Indexed by `mCut` to differentiate between noncut/cut models
31+
/* 0x36C */ STATE_MGR_DECLARE(dAcOgrassCoil_c);
32+
/* 0x3A8 */ dCcD_Cyl mCollider;
33+
/* 0x4F8 */ mVec3_c mSpawnPos; ///< Spawn Position used for when an item is dropped
34+
/* 0x504 */ mAng3_c mEffectRot;
35+
/* 0x50A */ s16 mTargetRotX; ///< Used as target for swaying when disturbed
36+
/* 0x50C */ s16 mTargetRotY; ///< Used as target for swaying when disturbed
37+
/* 0x50E */ s16 mSwayAmt; ///< Used to assist with the swaying when disturbed. Adjusts mTargetRotX
38+
/* 0x510 */ mAng mSpawnRotY; ///< A copy of the spawned rotation so mRotation.y is free to adjust.
39+
///< The final Y-rotation is represented by `mSpawnRotY - mRotation.y`
40+
/* 0x512 */ u8 _0x512;
41+
/* 0x513 */ bool mCut;
42+
43+
static dCcD_SrcCyl sCylSrc;
44+
static const u32 sCalcAngleRatio;
45+
static const s16 sEffectRotIncrement;
46+
static const float sSqDistThreshold;
47+
static const u32 lbl_268_rodata_4C;
1748
};
1849

1950
#endif
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,153 @@
11
#include "d/a/obj/d_a_obj_grass_coil.h"
22

3+
#include "c/c_lib.h"
4+
#include "common.h"
5+
#include "d/a/d_a_player.h"
6+
#include "d/a/obj/d_a_obj_base.h"
7+
#include "d/col/c/c_cc_d.h"
8+
#include "d/col/cc/d_cc_s.h"
9+
#include "d/snd/d_snd_wzsound.h"
10+
#include "f/f_base.h"
11+
#include "m/m_angle.h"
12+
#include "m/m_vec.h"
13+
#include "nw4r/g3d/res/g3d_resmdl.h"
14+
#include "s/s_Math.h"
15+
#include "toBeSorted/attention.h"
16+
#include "toBeSorted/d_emitter.h"
17+
318
SPECIAL_ACTOR_PROFILE(OBJ_GRASS_COIL, dAcOgrassCoil_c, fProfile::OBJ_GRASS_COIL, 0x263, 0, 2);
419

520
STATE_DEFINE(dAcOgrassCoil_c, Wait);
621

22+
dCcD_SrcCyl dAcOgrassCoil_c::sCylSrc = {
23+
/* mObjInf */
24+
{/* mObjAt */ {0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0},
25+
/* mObjTg */
26+
{AT_TYPE_SWORD | AT_TYPE_BOMB | AT_TYPE_0x40 | AT_TYPE_SLINGSHOT | AT_TYPE_WHIP | AT_TYPE_ARROW |
27+
AT_TYPE_CLAWSHOT | AT_TYPE_0x800000,
28+
0x200111,
29+
{0, 0xb, 0x407},
30+
0x0,
31+
0x0},
32+
/* mObjCo */ {0x29}},
33+
/* mCylInf */
34+
{50.f, 130.f}
35+
};
36+
37+
const u32 dAcOgrassCoil_c::sCalcAngleRatio = 5;
38+
39+
bool dAcOgrassCoil_c::createHeap() {
40+
void *data = getOarcResFile("GrassCoilNormal");
41+
mResFile = nw4r::g3d::ResFile(data);
42+
nw4r::g3d::ResMdl mdl = mResFile.GetResMdl("GrassCoilNormal");
43+
TRY_CREATE(mMdl[0].create(mdl, &mAllocator, 0x120, 1, nullptr));
44+
nw4r::g3d::ResMdl mdlCut = mResFile.GetResMdl("GrassCoilNormalCut");
45+
TRY_CREATE(mMdl[1].create(mdlCut, &mAllocator, 0x120, 1, nullptr));
46+
return SUCCEEDED;
47+
}
48+
49+
int dAcOgrassCoil_c::create() {
50+
mSpawnRotY = mRotation.y;
51+
mRotation.y = 0;
52+
CREATE_ALLOCATOR(dAcOgrassCoil_c);
53+
mStts.SetRank(8);
54+
mCollider.Set(sCylSrc);
55+
mCollider.SetStts(mStts);
56+
updateMatrix();
57+
mWorldMtx.YrotM(mSpawnRotY - mRotation.y);
58+
mMdl[mCut].setLocalMtx(mWorldMtx);
59+
mStateMgr.changeState(StateID_Wait);
60+
mCullingDistance = 9000.0f;
61+
mBoundingBox.Set(mVec3_c(-100.0f, -50.0f, -100.0f), mVec3_c(100.0f, 200.0f, 100.0f));
62+
field_0x1A8 = 0.0f;
63+
return SUCCEEDED;
64+
}
65+
66+
int dAcOgrassCoil_c::doDelete() {
67+
return SUCCEEDED;
68+
}
69+
70+
const s16 dAcOgrassCoil_c::sEffectRotIncrement = 0xe39; // ~20 degrees
71+
72+
int dAcOgrassCoil_c::actorExecute() {
73+
if (checkObjectProperty(OBJ_PROP_0x1)) {
74+
if (dAcPy_c::GetLink()->mPosition.squareDistanceToXZ(mPosition) > 1000000.f) {
75+
return SUCCEEDED;
76+
}
77+
}
78+
if (!mCut) {
79+
AttentionManager::GetInstance()->addUnk3Target(*this, 1, 250.0f, -100.0f, 100.0f);
80+
}
81+
if (!mCut) {
82+
bool hitBySlingshot = false;
83+
if (mCollider.ChkTgHit()) {
84+
if (mCollider.ChkTgAtHitType(AT_TYPE_SLINGSHOT)) {
85+
hitBySlingshot = true;
86+
} else {
87+
mEffectRot.y = mSpawnRotY;
88+
for (s32 i = 0; i < 2; i++) {
89+
if (i == 1) {
90+
mEffectRot.y += mAng(sEffectRotIncrement);
91+
}
92+
dEmitterBase_c *emitter = dJEffManager_c::spawnEffect(
93+
PARTICLE_RESOURCE_ID_MAPPING_485_, mPosition, &mEffectRot, nullptr, nullptr, nullptr, 0, 0
94+
);
95+
if (emitter != nullptr) {
96+
emitter->bindShpEmitter(dJEffManager_c::GrassCoil, true);
97+
}
98+
}
99+
mCollider.ClrTgSet();
100+
mCut = true;
101+
mSwayAmt = -mAng::d2s(18.0011);
102+
startSound(SE_Gcoil_CUT);
103+
mCollider.SetR(25.0f);
104+
mCollider.SetH(70.0f);
105+
mSpawnPos = mPosition;
106+
mSpawnPos.y += 30.0f;
107+
itemDroppingAndGivingRelated(&mSpawnPos, 0);
108+
}
109+
}
110+
if (hitBySlingshot || (mSwayAmt == 0 && mCollider.ChkCoHit() && dAcPy_c::GetLink()->mSpeed > 0.0f)) {
111+
if (!mCut) {
112+
mSwayAmt = -mAng::d2s(13.0025);
113+
} else {
114+
mSwayAmt = -mAng::d2s(2);
115+
}
116+
mTargetRotY = cLib::targetAngleY(dAcPy_c::GetLink()->mPosition, mPosition) - 0x8000;
117+
}
118+
}
119+
120+
if (mSwayAmt != 0) {
121+
s32 _a = 0;
122+
123+
mSwayAmt += s16(-mTargetRotX * (0.35f + (0.01f * _a)));
124+
mSwayAmt *= 0.85f + (0.01f * _a);
125+
mTargetRotX += mSwayAmt;
126+
}
127+
if (mTargetRotX != mRotation.x) {
128+
sLib::addCalcAngle(mRotation.x.ref(), mTargetRotX, 5, mAng::d2s(7), mAng::d2s(1));
129+
}
130+
if (mTargetRotY != mRotation.y) {
131+
sLib::addCalcAngle(mRotation.y.ref(), mTargetRotY, 5, mAng::d2s(7), mAng::d2s(1));
132+
}
133+
updateMatrix();
134+
mWorldMtx.YrotM(mSpawnRotY - mRotation.y);
135+
mMdl[mCut].setLocalMtx(mWorldMtx);
136+
if (!mCut) {
137+
mCollider.SetC(mPosition);
138+
dCcS::GetInstance()->Set(&mCollider);
139+
}
140+
return SUCCEEDED;
141+
}
142+
143+
const float dAcOgrassCoil_c::sSqDistThreshold = 1000000.f;
144+
const u32 dAcOgrassCoil_c::lbl_268_rodata_4C = 2;
145+
146+
int dAcOgrassCoil_c::draw() {
147+
drawModelType1(&mMdl[mCut]);
148+
return SUCCEEDED;
149+
}
150+
7151
void dAcOgrassCoil_c::initializeState_Wait() {}
8152
void dAcOgrassCoil_c::executeState_Wait() {}
9153
void dAcOgrassCoil_c::finalizeState_Wait() {}

0 commit comments

Comments
 (0)