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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
/**
* d_a_obj_majyuu_door.cpp
* Object - Forsaken Fortress - Large wooden barricade (blocks entrance, destroyed with Bombs)
*/
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_obj_majyuu_door.h"
#include "d/d_bg_s_func.h"
#include "d/d_s_play.h"
#include "res/Object/S_MSPDo.h"
static dCcD_SrcCyl l_cyl_src = {
// dCcD_SrcGObjInf
{
/* Flags */ 0,
/* SrcObjAt Type */ 0,
/* SrcObjAt Atp */ 0,
/* SrcObjAt SPrm */ 0,
/* SrcObjTg Type */ AT_TYPE_ALL & ~AT_TYPE_BOOMERANG,
/* SrcObjTg SPrm */ cCcD_TgSPrm_Set_e | cCcD_TgSPrm_IsOther_e,
/* SrcObjCo SPrm */ cCcD_CoSPrm_Set_e | cCcD_CoSPrm_IsOther_e | cCcD_CoSPrm_VsGrpAll_e,
/* SrcGObjAt Se */ 0,
/* SrcGObjAt HitMark */ dCcG_AtHitMark_None_e,
/* SrcGObjAt Spl */ dCcG_At_Spl_UNK0,
/* SrcGObjAt Mtrl */ 0,
/* SrcGObjAt SPrm */ 0,
/* SrcGObjTg Se */ dCcG_SE_UNK23,
/* SrcGObjTg HitMark */ 0,
/* SrcGObjTg Spl */ dCcG_Tg_Spl_UNK0,
/* SrcGObjTg Mtrl */ 0,
/* SrcGObjTg SPrm */ 0,
/* SrcGObjCo SPrm */ 0,
},
// cM3dGCylS
{{
/* Center */ {0.0f, 0.0f, 0.0f},
/* Radius */ 75.0f,
/* Height */ 115.0f,
}},
};
GXColor daObj_MjDoor_c::smoke_col = {0x86, 0x84, 0x6D, 0xC8};
const s32 daObj_MjDoor_c::m_heapsize = 0x820;
const char daObj_MjDoor_c::m_arc_name[] = "S_MSPDo";
inline void daObj_MjDoor_c::modeProcCall() {
typedef void (daObj_MjDoor_c::*modeProc)();
static modeProc mode_proc[] = {
&daObj_MjDoor_c::modeWait,
&daObj_MjDoor_c::modeDelete,
};
(this->*mode_proc[mMode])();
}
static daObj_MjDoorHIO_c l_HIO;
/* 000000EC-0000010C .text createHeap_CB__FP10fopAc_ac_c */
static BOOL createHeap_CB(fopAc_ac_c* i_this) {
return ((daObj_MjDoor_c*)i_this)->_createHeap();
}
/* 0000010C-00000130 .text TgHitCallback__FP10fopAc_ac_cP12dCcD_GObjInfP10fopAc_ac_cP12dCcD_GObjInf */
void TgHitCallback(fopAc_ac_c* i_actor, dCcD_GObjInf*, fopAc_ac_c* i_atActor, dCcD_GObjInf*) {
if (i_atActor != NULL && fopAcM_GetName(i_atActor) == fpcNm_BOMB_e) {
((daObj_MjDoor_c*)i_actor)->health--;
}
}
/* 00000130-00000154 .text __ct__17daObj_MjDoorHIO_cFv */
daObj_MjDoorHIO_c::daObj_MjDoorHIO_c() {
field_0x4 = 0;
}
/* 0000019C-00000240 .text set_mtx__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::set_mtx() {
mpModel->setBaseScale(scale);
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::YrotM(current.angle.y);
mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
if (mMode != MODE_DELETE) {
MTXCopy(mDoMtx_stack_c::now, mMtx);
mpBgW->Move();
}
}
/* 00000240-000003A0 .text _createHeap__14daObj_MjDoor_cFv */
BOOL daObj_MjDoor_c::_createHeap() {
J3DModelData* modelData = (J3DModelData *)dComIfG_getObjectRes(m_arc_name, dRes_INDEX_S_MSPDO_BDL_S_MSPDO_e);
JUT_ASSERT(199, modelData != 0);
mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000022);
if (mpModel == NULL) {
return FALSE;
}
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::YrotM(current.angle.y);
MTXCopy(mDoMtx_stack_c::now, mMtx);
mpBgW = new dBgW();
if (mpBgW == NULL) {
return FALSE;
}
if (mpBgW->Set((cBgD_t*)dComIfG_getObjectRes(m_arc_name, dRes_INDEX_S_MSPDO_DZB_S_MSPDO_e), cBgW::MOVE_BG_e, &mMtx) == true) {
return FALSE;
}
return TRUE;
}
/* 000003A0-000003AC .text getArg__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::getArg() {
field_0x2CC = fopAcM_GetParam(this);
}
/* 000003AC-00000478 .text CreateInit__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::CreateInit() {
mStts.Init(0xFF, 0, this);
dCcD_Cyl* cyl = mCyl;
for (int i = 0; i < 10; i++, cyl++) {
cyl->Set(l_cyl_src);
cyl->SetStts(&mStts);
cyl->SetTgHitCallback(TgHitCallback);
}
mCyl[1].SetR(95.0f);
dComIfG_Bgsp()->Regist(mpBgW, this);
set_mtx();
modeWaitInit();
max_health = 30;
health = max_health;
}
/* 00000478-000005B4 .text _create__14daObj_MjDoor_cFv */
cPhs_State daObj_MjDoor_c::_create() {
fopAcM_ct_Retail(this, daObj_MjDoor_c);
cPhs_State phase = dComIfG_resLoad(&mPhs, m_arc_name);
fopAcM_ct_Demo(this, daObj_MjDoor_c);
if (phase == cPhs_COMPLEATE_e) {
getArg();
if (field_0x2CC != 0xFF
&& dComIfGs_isSwitch(field_0x2CC, fopAcM_GetRoomNo(this))) {
return cPhs_ERROR_e;
}
if (!fopAcM_entrySolidHeap(this, createHeap_CB, m_heapsize)) {
return cPhs_ERROR_e;
}
CreateInit();
}
return phase;
}
/* 000007F0-00000884 .text _delete__14daObj_MjDoor_cFv */
bool daObj_MjDoor_c::_delete() {
dComIfG_resDelete(&mPhs, m_arc_name);
if (mpBgW != NULL && mpBgW->ChkUsed()) {
dComIfG_Bgsp()->Release(mpBgW);
}
mSmoke.end();
return TRUE;
}
/* 00000884-000009D4 .text setCollision__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::setCollision() {
f32 cyl_offset[10] = {
-500.0f, -400.0f, -300.0f, -200.0f, -100.0f,
0.0f, 100.0f, 200.0f, 300.0f, 400.0f,
};
f32 sin_angle_y = cM_ssin(current.angle.y);
f32 cos_angle_y = cM_scos(current.angle.y);
dCcD_Cyl* cyl = mCyl;
for (int i = 0; i < 10; i++, cyl++) {
cXyz center(
current.pos.x + cos_angle_y * cyl_offset[i],
current.pos.y - REG12_F(0),
current.pos.z + -sin_angle_y * cyl_offset[i]
);
cyl->SetC(center);
cyl->SetR(100.0f);
cyl->SetH(1350.0f);
dComIfG_Ccsp()->Set(cyl);
}
}
/* 000009D4-000009E0 .text modeWaitInit__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::modeWaitInit() {
mMode = MODE_WAIT;
}
/* 000009E0-00000A34 .text modeWait__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::modeWait() {
setCollision();
if (health < 0 || l_HIO.field_0x4 != 0) {
modeDeleteInit();
}
}
/* 00000A34-00000AEC .text smoke_set__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::smoke_set() {
static JGeometry::TVec3<f32> smoke_scale(1.25f, 1.25f, 1.25f);
dComIfGp_particle_setToon(dPa_name::ID_IT_ST_MJMON_SMOKE00,
&mPos, &mAngle, NULL, 0xB9, &mSmoke, fopAcM_GetRoomNo(this));
if (mSmoke.getEmitter() != NULL) {
mSmoke.getEmitter()->mGlobalPrmColor.a = 200;
}
}
/* 00000AEC-00000D64 .text modeDeleteInit__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::modeDeleteInit() {
if (field_0x2CC != 0xFF) {
dComIfGs_onSwitch(field_0x2CC, fopAcM_GetRoomNo(this));
}
mMode = MODE_DELETE;
fopAcM_seStart(this, JA_SE_OBJ_MJ_GATE_BREAK, 0);
cXyz scale(1.0f, 1.0f, 1.0f);
dComIfGp_particle_set(dPa_name::ID_IT_SN_MJMON_HAHEN_L00, ¤t.pos, ¤t.angle,
&scale, 0xFF, NULL, -1, &tevStr.mColorK0, &tevStr.mColorK0);
dComIfGp_particle_set(dPa_name::ID_IT_SN_MJMON_HAHEN_S00, ¤t.pos, ¤t.angle,
&scale, 0xFF, NULL, -1, &tevStr.mColorK0, &tevStr.mColorK0);
cXyz pos = current.pos;
pos.y = dBgS_GetWaterHeight(pos);
dComIfGp_particle_set(dPa_name::ID_IT_SN_MJMON_HAMON00, &pos, ¤t.angle,
&scale, 0xFF, NULL, -1);
dComIfGp_particle_set(dPa_name::ID_IT_SN_MJMON_SHIBUKI00, &pos, ¤t.angle,
&scale, 0xFF, NULL, -1);
mPos = current.pos;
mAngle = current.angle;
smoke_set();
mSmokeTimer = 0x32;
mDeleteTimer = 600;
dComIfG_Bgsp()->Release(mpBgW);
dCcD_Cyl* cyl = mCyl;
for (int i = 0; i < 10; i++, cyl++) {
cyl->OffCoSPrmBit(cCcD_CoSPrm_Set_e | cCcD_CoSPrm_IsOther_e |
cCcD_CoSPrm_VsGrpAll_e);
cyl->OffTgSPrmBit(cCcD_TgSPrm_Set_e | cCcD_TgSPrm_IsOther_e);
}
}
/* 00000D64-00000DF0 .text modeDelete__14daObj_MjDoor_cFv */
void daObj_MjDoor_c::modeDelete() {
if (mSmoke.getEmitter() != NULL) {
if (cLib_calcTimer(&mSmokeTimer) != 0) {
if (mSmokeTimer <= 40) {
mSmoke.getEmitter()->setGlobalAlpha(mSmokeTimer * 5);
}
} else {
mSmoke.end();
}
}
if (cLib_calcTimer(&mDeleteTimer) == 0) {
fopAcM_delete(this);
}
}
/* 00000DF0-00000EB4 .text _execute__14daObj_MjDoor_cFv */
bool daObj_MjDoor_c::_execute() {
modeProcCall();
fopAcM_posMoveF(this, NULL);
set_mtx();
return FALSE;
}
/* 00000EB4-00000F28 .text _draw__14daObj_MjDoor_cFv */
bool daObj_MjDoor_c::_draw() {
if (mMode == MODE_DELETE) {
return TRUE;
}
g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &tevStr);
g_env_light.setLightTevColorType(mpModel, &tevStr);
mDoExt_modelUpdateDL(mpModel);
return TRUE;
}
/* 00000F28-00000F48 .text daObj_MjDoorCreate__FPv */
static cPhs_State daObj_MjDoorCreate(void* i_this) {
return ((daObj_MjDoor_c*)i_this)->_create();
}
/* 00000F48-00000F6C .text daObj_MjDoorDelete__FPv */
static BOOL daObj_MjDoorDelete(void* i_this) {
return ((daObj_MjDoor_c*)i_this)->_delete();
}
/* 00000F6C-00000F90 .text daObj_MjDoorExecute__FPv */
static BOOL daObj_MjDoorExecute(void* i_this) {
return ((daObj_MjDoor_c*)i_this)->_execute();
}
/* 00000F90-00000FB4 .text daObj_MjDoorDraw__FPv */
static BOOL daObj_MjDoorDraw(void* i_this) {
return ((daObj_MjDoor_c*)i_this)->_draw();
}
/* 00000FB4-00000FBC .text daObj_MjDoorIsDelete__FPv */
static BOOL daObj_MjDoorIsDelete(void*) {
return TRUE;
}
static actor_method_class daObj_MjDoorMethodTable = {
(process_method_func)daObj_MjDoorCreate,
(process_method_func)daObj_MjDoorDelete,
(process_method_func)daObj_MjDoorExecute,
(process_method_func)daObj_MjDoorIsDelete,
(process_method_func)daObj_MjDoorDraw,
};
actor_process_profile_definition g_profile_OBJ_MJDOOR = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 0x0003,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_OBJ_MJDOOR_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(daObj_MjDoor_c),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_OBJ_MJDOOR_e,
/* Actor SubMtd */ &daObj_MjDoorMethodTable,
/* Status */ fopAcStts_UNK40000_e,
/* Group */ fopAc_ACTOR_e,
/* Cull Type */ fopAc_CULLBOX_4_e,
};
|