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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
/**
* @file d_a_obj_lv6swturn.cpp
*
*/
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/d_s_play.h"
#include "d/actor/d_a_obj_lv6swturn.h"
#include "d/actor/d_a_player.h"
static char* l_arcName = "Obj_l6tsw";
#if DEBUG
daObjLv6SwTurn_HIO_c::daObjLv6SwTurn_HIO_c() {
mWaitTime = 0x2f;
mChargeTime = 0x23;
mRotationTime = 0x5a;
unkA = 0x0;
mDrawFlag = 0x0;
}
void daObjLv6SwTurn_HIO_c::genMessage(JORMContext* context) {
context->genLabel("Lv6回転スイッチ", 0);
context->genSlider("タメ時間(初回)", &mWaitTime, 0, 100);
context->genSlider("タメ時間(連続)", &mChargeTime, 0, 100);
context->genSlider("回転時間", &mRotationTime, 0, 500);
context->genCheckBox("チェック描画", &mDrawFlag, 0x1);
}
#endif
static fopAc_ac_c* PPCallBack(fopAc_ac_c* actor1, fopAc_ac_c* actor2, s16 param_2,
dBgW_Base::PushPullLabel pushPull) {
static const int pp_field = 3;
UNUSED(param_2);
dBgW_Base::PushPullLabel pushPull_3 = cLib_checkBit(pushPull, dBgW_Base::PPLABEL_3);
daObjLv6SwTurn_c* swTurnActor1 = (daObjLv6SwTurn_c*)actor1;
daObjLv6SwTurn_c* swTurnActor2 = (daObjLv6SwTurn_c*)actor2;
if (pushPull_3 != dBgW_Base::PPLABEL_NONE) {
cXyz posVec = swTurnActor2->current.pos - swTurnActor1->current.pos;
mDoMtx_stack_c::YrotS(-swTurnActor1->shape_angle.y);
mDoMtx_stack_c::multVec(&posVec, &posVec);
int ind;
if (posVec.z > 0.0f) {
ind = cLib_checkBit(pushPull_3, dBgW_Base::PPLABEL_PULL) ? 0 : 1;
} else {
ind = cLib_checkBit(pushPull_3, dBgW_Base::PPLABEL_PULL) ? 1 : 0;
}
for (int i = 0; i < 2; i++) {
if (i == ind) {
swTurnActor1->unk5AE[i]++;
} else {
swTurnActor1->unk5AE[i] = 0;
}
}
swTurnActor1->unk5AD = 1;
swTurnActor1->unk5C4 = pushPull;
}
return actor1;
}
void daObjLv6SwTurn_c::initBaseMtx() {
unk5A8->setBaseScale(scale);
setBaseMtx();
}
void daObjLv6SwTurn_c::setBaseMtx() {
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::YrotM(shape_angle.y);
unk5A8->setBaseTRMtx(mDoMtx_stack_c::get());
MTXCopy(mDoMtx_stack_c::get(), mBgMtx);
}
int daObjLv6SwTurn_c::Create() {
if (fopAcM_isSwitch(this, getSwbit())) {
unk5BC = 1;
} else if (fopAcM_isSwitch(this, getSwbit2())) {
unk5BC = -1;
} else {
unk5BC = 0;
}
fopAcM_SetMtx(this, unk5A8->getBaseTRMtx());
fopAcM_setCullSizeBox2(this, unk5A8->getModelData());
mpBgW->SetPushPullCallback(PPCallBack);
init_modeWait();
MoveBGExecute();
initBaseMtx();
return TRUE;
}
int daObjLv6SwTurn_c::CreateHeap() {
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcName, 4);
JUT_ASSERT(268, modelData != NULL);
unk5A8 = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
if (unk5A8 == NULL) {
return FALSE;
}
return TRUE;
}
#if DEBUG
static daObjLv6SwTurn_HIO_c l_HIO;
#endif
int daObjLv6SwTurn_c::create1st() {
int step = dComIfG_resLoad(&unk5A0, l_arcName);
if (step == cPhs_COMPLEATE_e) {
step = MoveBGCreate(l_arcName, 7, dBgS_MoveBGProc_TypicalRotY, 0x1800, 0);
if (step == cPhs_ERROR_e) {
return step;
}
#if DEBUG
l_HIO.entryHIO("Lv6回転スイッチ");
#endif
}
return step;
}
int daObjLv6SwTurn_c::Execute(Mtx** i_pMtx) {
unk5C0++;
mode_proc_call();
*i_pMtx = &mBgMtx;
setBaseMtx();
eyePos = current.pos;
attention_info.position = current.pos;
unk5AD = 0;
return TRUE;
}
enum daObjLv6SwTurn_c_mode{
DAOBJLV6SWTURN_C_MODE_WAIT,
DAOBJLV6SWTURN_C_MODE_ROTATE,
};
void daObjLv6SwTurn_c::mode_proc_call() {
typedef void (daObjLv6SwTurn_c::*func_type)();
static func_type l_func[] = {
&daObjLv6SwTurn_c::modeWait,
&daObjLv6SwTurn_c::modeRotate
};
(this->*l_func[mMode])();
}
void daObjLv6SwTurn_c::init_modeWait() {
unk5B2 = 0;
unk5B8 = -1;
for (int i = 0; i < 2; i++) {
unk5AE[i] = 0;
}
mMode = DAOBJLV6SWTURN_C_MODE_WAIT;
}
void daObjLv6SwTurn_c::modeWait() {
bool a = true;
int b = -1;
daPy_py_c* player = daPy_getPlayerActorClass();
if (unk5AD) {
for (int i = 0; i < 2; i++) {
u32 timer;
if (cLib_checkBit(unk5C4, cBgW::PPLABEL_4)) {
#if DEBUG
timer = l_HIO.mWaitTime;
#else
timer = 0x2f;
#endif
} else {
#if DEBUG
timer = l_HIO.mChargeTime;
#else
timer = 0x23;
#endif
}
if (unk5AE[i] == (u8)timer) {
unk5B8 = i;
}
if (unk5AE[i] != 0) {
b = i;
}
}
if ((unk5B8 == 0 && unk5BC == 1) || (unk5B8 == 1 && unk5BC == -1)) {
unk5B8 = -1;
} else {
a = 0;
}
bool c = false;
if ((unk5BC == 0 && b != -1) || (unk5BC == 1 && b == 1) || (unk5BC == -1 && b == 0)) {
c = true;
}
if (c) {
if (b == 0) {
cLib_addCalcAngleS2(&unk5B4, 500 + KREG_S(1), 60, 5);
} else {
cLib_addCalcAngleS2(&unk5B4, -500 - KREG_S(1), 60, 5);
}
if (unk5BD == 18) {
fopAcM_seStart(this, Z2SE_OBJ_L6_RL_SW_ON, 0);
OS_REPORT("Lv6回転スイッチ:Z2SE_OBJ_L6_RL_SW_ON\n");
}
unk5BD++;
unk5B2 = unk5B4 * std::fabs(cM_ssin((KREG_S(0) + 992) * unk5BD)) + 10.0f;
if (unk5B2 == unk5C8) {
unk5B2++;
}
}
if (unk5B8 != -1 && unk5CA == current.angle.y) {
((daPy_py_c*)dComIfGp_getPlayer(0))->onPushPullKeep();
init_modeRotate();
}
} else {
unk5B4 = 0;
unk5BD = 0;
cLib_addCalcAngleS(&unk5B2, 0, 4, 50, 5);
}
shape_angle.y = current.angle.y + (unk5BC * 0x4000) + unk5B2;
if (a) {
for (int i = 0; i < 2; i++) {
unk5AE[i] = 0;
}
unk5B8 = -1;
}
if (daPy_py_c::checkNowWolf()) {
cXyz c = player->current.pos - current.pos;
mDoMtx_stack_c::YrotS(-shape_angle.y);
mDoMtx_stack_c::multVec(&c, &c);
if (c.z > 0.0f) {
if (unk5BC == -1) {
mpBgW->OffPushPullOk();
} else {
mpBgW->OnPushPullOk();
}
} else {
if (unk5BC == 1) {
mpBgW->OffPushPullOk();
} else {
mpBgW->OnPushPullOk();
}
}
} else {
mpBgW->OnPushPullOk();
}
unk5C8 = unk5B2;
unk5CA = current.angle.y;
}
void daObjLv6SwTurn_c::init_modeRotate() {
unk5B4 = 0;
unk5BD = 0;
unk5B0 = 0;
unk5B6 = shape_angle.y;
mMode = DAOBJLV6SWTURN_C_MODE_ROTATE;
}
void daObjLv6SwTurn_c::modeRotate() {
unk5B0++;
#if DEBUG
unk5B2 = (f32)unk5B0 / (f32)l_HIO.mRotationTime * (f32)0x4000;
#else
unk5B2 = (f32)unk5B0 / (f32)0x5a * (f32)0x4000;
#endif
if (unk5B8 == 1) {
unk5B2 = -unk5B2;
}
shape_angle.y = unk5B6 + unk5B2;
fopAcM_seStartLevel(this, Z2SE_OBJ_L6_RL_SW_MV, 0);
#if DEBUG
if (unk5B0 == l_HIO.mRotationTime)
#else
if (unk5B0 == 0x5a)
#endif
{
if (unk5B8 == 0) {
unk5BC++;
} else {
unk5BC--;
}
if (unk5BC == 1) {
fopAcM_onSwitch(this, getSwbit());
fopAcM_offSwitch(this, getSwbit2());
} else if (unk5BC == 0) {
fopAcM_offSwitch(this, getSwbit());
fopAcM_offSwitch(this, getSwbit2());
} else if (unk5BC == -1) {
fopAcM_offSwitch(this, getSwbit());
fopAcM_onSwitch(this, getSwbit2());
}
((daPy_py_c*)dComIfGp_getPlayer(0))->offPushPullKeep();
fopAcM_seStart(this, Z2SE_OBJ_L6_RL_SW_OFF, 0);
dComIfGp_getVibration().StartShock(8, 0x1f, cXyz(0.0f, 1.0f, 0.0f));
init_modeWait();
}
}
int daObjLv6SwTurn_c::Draw() {
g_env_light.settingTevStruct(0x10, ¤t.pos, &tevStr);
g_env_light.setLightTevColorType_MAJI(unk5A8, &tevStr);
dComIfGd_setListBG();
mDoExt_modelUpdateDL(unk5A8);
dComIfGd_setList();
#if DEBUG
if (l_HIO.mDrawFlag) {
mpBgW->DebugDraw();
}
#endif
return TRUE;
}
int daObjLv6SwTurn_c::Delete() {
dComIfG_resDelete(&unk5A0, l_arcName);
#if DEBUG
l_HIO.removeHIO();
#endif
return TRUE;
}
static int daObjLv6SwTurn_create1st(daObjLv6SwTurn_c* i_this) {
fopAcM_ct(i_this, daObjLv6SwTurn_c);
return i_this->create1st();
}
static int daObjLv6SwTurn_MoveBGDelete(daObjLv6SwTurn_c* i_this) {
return i_this->MoveBGDelete();
}
static int daObjLv6SwTurn_MoveBGExecute(daObjLv6SwTurn_c* i_this) {
return i_this->MoveBGExecute();
}
static int daObjLv6SwTurn_MoveBGDraw(daObjLv6SwTurn_c* i_this) {
return i_this->MoveBGDraw();
}
static actor_method_class daObjLv6SwTurn_METHODS = {
(process_method_func)daObjLv6SwTurn_create1st,
(process_method_func)daObjLv6SwTurn_MoveBGDelete,
(process_method_func)daObjLv6SwTurn_MoveBGExecute,
NULL,
(process_method_func)daObjLv6SwTurn_MoveBGDraw,
};
actor_process_profile_definition g_profile_Obj_Lv6SwTurn = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 3,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_Obj_Lv6SwTurn_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(daObjLv6SwTurn_c),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_Obj_Lv6SwTurn_e,
/* Actor SubMtd */ &daObjLv6SwTurn_METHODS,
/* Status */ fopAcStts_UNK_0x40000_e | fopAcStts_CULL_e,
/* Group */ fopAc_ACTOR_e,
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
};
|