1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#include "toBeSorted/d_enemy_sword_mdl.h"
#include "common.h"
#include "d/col/cc/d_cc_s.h"
#include "d/d_sc_game.h"
#include "m/m3d/m_shadow.h"
#include "m/m_vec.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
dCcD_SrcCps sCcSrc = {
{
{AT_TYPE_DAMAGE, 0x8D, {1, 0, 0}, 1, 0, 0, 0, 0, 0},
{0, 0, {0, 0, 0x407}, 0, 0},
{0},
},
{30.0f},
};
// Yeah these two functions do the same thing. Could've made one call the other...
bool dEnemySwordMdl_c::create(
mAllocator_c *alloc, void *pData, const char *mdlName, u32 bufferOption, const mVec3_c &v1, const mVec3_c &v2,
cCcD_Stts &stts, EGG::ResTIMG *pImg, int nView, u32 *pSize
) {
nw4r::g3d::ResMdl mdl = nw4r::g3d::ResFile(pData).GetResMdl(mdlName);
if (!mMdl.create(mdl, alloc, bufferOption, nView, pSize)) {
return false;
}
if (!mProc.create(100, alloc, pImg, 0.015f)) {
mMdl.remove();
return false;
}
field_0x074.set(v1.x, v1.y, v1.z);
field_0x080.set(v2.x, v2.y, v2.z);
for (int i = 0; i < 3; i++) {
mCcList.addCc(mCcs[i], sCcSrc);
}
mCcList.SetStts(stts);
mCcList.ClrAt();
return true;
}
bool dEnemySwordMdl_c::create(
mAllocator_c *alloc, nw4r::g3d::ResFile resFile, const char *mdlName, u32 bufferOption, const mVec3_c &v1,
const mVec3_c &v2, cCcD_Stts &stts, EGG::ResTIMG *pImg, int nView, u32 *pSize
) {
nw4r::g3d::ResMdl mdl = resFile.GetResMdl(mdlName);
if (!mMdl.create(mdl, alloc, bufferOption, nView, pSize)) {
return false;
}
if (!mProc.create(100, alloc, pImg, 0.015f)) {
mMdl.remove();
return false;
}
field_0x074.set(v1.x, v1.y, v1.z);
field_0x080.set(v2.x, v2.y, v2.z);
for (int i = 0; i < 3; i++) {
mCcList.addCc(mCcs[i], sCcSrc);
}
mCcList.SetStts(stts);
mCcList.ClrAt();
return true;
}
void dEnemySwordMdl_c::enableAttack() {
mCcs[0].OnAtSet();
mIsActive = true;
mFirstFramePassed = false;
}
// TODO - ...
void dEnemySwordMdl_c::calc(const mMtx_c &mtx, const mVec3_c &v1, bool mass) {
mMdl.setLocalMtx(mtx);
mMdl.calc(false);
MTXMultVec(mtx, field_0x074, field_0x08C);
MTXMultVec(mtx, field_0x080, field_0x098);
if (mIsActive) {
mVec3_c v = field_0x098 - field_0x08C;
v.normalize();
mVec3_c hi = field_0x098 + v * field_0x0A8;
mCcs[1].Set(mCcs[0].mEnd, hi);
mCcs[2].Set(mCcs[0].mStart, hi);
mCcs[0].Set(field_0x08C - v * field_0x0A4, hi);
mCcs[0].SetAtVec(v1);
mCcs[1].SetAtVec(v1);
mCcs[2].SetAtVec(v1);
if (mFirstFramePassed && !mCcs[1].ChkAtSet()) {
mCcs[1].OnAtSet();
mCcs[2].OnAtSet();
} else {
mFirstFramePassed = true;
}
mCcList.registerColliders();
if (mass) {
dCcS::GetInstance()->GetMassMng().SetObj(&mCcs[0], 2);
}
} else {
mFirstFramePassed = false;
if (mCcs[0].ChkAtSet()) {
mCcList.ClrAt();
}
}
mProc.calc(field_0x098, field_0x08C);
}
bool dEnemySwordMdl_c::entry(dAcObjBase_c *obj, dShadowCircle_c *shadow, mQuat_c *quat) {
if (dScGame_c::currentSpawnInfo.getTrial() == SpawnInfo::TRIAL) {
obj->fn_8002ECD0(&mMdl, 7);
} else {
obj->drawModelType1(&mMdl);
}
mProc.entry();
if (shadow != nullptr && quat != nullptr) {
m3d::mShadow_c::GetInstance()->addMdlToCircle(shadow, mMdl, *quat);
}
return true;
}
|