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
|
/**
* @file d_a_swBall.cpp
*
*/
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/actor/d_a_swBall.h"
#include "d/actor/d_a_obj_carry.h"
#include "d/d_com_inf_game.h"
#include "d/d_lib.h"
#include "d/d_s_play.h"
static fopAc_ac_c* l_target_info[8];
static int l_target_info_count;
static void* s_ball_sub(void* i_actor, void* i_data) {
if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == fpcNm_Obj_Carry_e && ((daObjCarry_c*)i_actor)->getType() == daObjCarry_c::TYPE_LV8_BALL) {
if (l_target_info_count < 8) {
l_target_info[l_target_info_count] = (fopAc_ac_c*)i_actor;
l_target_info_count++;
} else {
// "Mysterious Ball Reaction Area Switch: mysterious ball count has exceeded limit!\n"
OS_REPORT("\x1b[43;30m怪しい玉反応領域スイッチ:怪しい玉対応できる数を越えてます!\n\x1b[m");
}
}
return NULL;
}
BOOL daSwBall_c::checkArea_sub(fopAc_ac_c* i_ball) {
if (getType() == 0) {
if (i_ball->current.pos.y >= current.pos.y - 10.0f && i_ball->current.pos.y < current.pos.y + (100.0f * scale.y) && fopAcM_searchActorDistanceXZ(this, i_ball) < (100.0f * scale.x)) {
return TRUE;
}
} else if (getType() == 1) {
cXyz bound_a(-100.0f * scale.x, 0.0f, -100.0f * scale.z);
cXyz bound_b(100.0f * scale.x, 100.0f * scale.y, 100.0f * scale.z);
bound_a.y += current.pos.y - 10.0f;
bound_b.y += current.pos.y;
if (i_ball->current.pos.y >= bound_a.y && i_ball->current.pos.y < bound_b.y && dLib_checkActorInRectangle(i_ball, this, &bound_a, &bound_b)) {
return TRUE;
}
}
return FALSE;
}
BOOL daSwBall_c::checkArea() {
fopAc_ac_c* ball_actors[8];
for (int i = 0; i < 8; i++) {
if (mBallIDs[i] != fpcM_ERROR_PROCESS_ID_e) {
ball_actors[i] = fopAcM_SearchByID(mBallIDs[i]);
} else {
ball_actors[i] = NULL;
}
if (ball_actors[i] != NULL && checkArea_sub(ball_actors[i])) {
return TRUE;
}
}
return FALSE;
}
void daSwBall_c::search_ball() {
l_target_info_count = 0;
for (int i = 0; i < 8; i++) {
l_target_info[i] = NULL;
}
fpcM_Search(s_ball_sub, this);
for (int i = 0; i < l_target_info_count; i++) {
if (l_target_info[i] != NULL) {
fpc_ProcID target_id = fopAcM_GetID(l_target_info[i]);
if (target_id != fpcM_ERROR_PROCESS_ID_e) {
int ball_idx = -1;
for (int j = 0; j < 8; j++) {
if (target_id == mBallIDs[j]) {
ball_idx = j;
break;
}
}
if (ball_idx < 0) {
for (int j = 0; j < 8; j++) {
if (mBallIDs[j] == fpcM_ERROR_PROCESS_ID_e) {
mBallIDs[j] = target_id;
break;
}
}
}
}
}
}
}
int daSwBall_c::Create() {
for (int i = 0; i < 8; i++) {
mBallIDs[i] = fpcM_ERROR_PROCESS_ID_e;
}
field_0x59c = fpcM_ERROR_PROCESS_ID_e;
execute();
if (checkArea()) {
if (getArg0() == 1) {
mMode = 3;
} else {
mMode = 2;
}
fopAcM_onSwitch(this, getSwbit());
} else {
mMode = 0;
}
return 1;
}
int daSwBall_c::create() {
fopAcM_ct(this, daSwBall_c);
if (!Create()) {
return cPhs_ERROR_e;
}
return cPhs_COMPLEATE_e;
}
int daSwBall_c::execute() {
static void (daSwBall_c::*l_func[])() = {
&daSwBall_c::actionRun,
&daSwBall_c::actionStop,
};
(this->*l_func[mAction])();
return 1;
}
void daSwBall_c::actionRun() {
search_ball();
BOOL in_area = checkArea();
switch (mMode) {
case 0:
if (in_area) {
mTimer = getArg1();
if (mTimer == 0xFF) {
mTimer = 15;
}
if (getArg0() == 1) {
if (mTimer == 0) {
fopAcM_onSwitch(this, getSwbit());
mMode = 3;
}
} else if (mTimer == 0) {
fopAcM_onSwitch(this, getSwbit());
mMode = 2;
}
mMode = 1;
}
fopAcM_offSwitch(this, getSwbit());
break;
case 1:
if (!in_area) {
mMode = 0;
} else if (cLib_calcTimer<u8>(&mTimer) == 0) {
mMode = 2;
}
break;
case 2:
fopAcM_onSwitch(this, getSwbit());
if (getArg0() == 1) {
mMode = 3;
} else if (!in_area) {
mMode = 0;
}
break;
case 3:
break;
}
PutCrrPos();
}
void daSwBall_c::actionStop() {}
void daSwBall_c::PutCrrPos() {
if (checkPullLBall()) {
daPy_py_c* player = daPy_getPlayerActorClass();
s16 spA = cLib_targetAngleY(&player->current.pos, ¤t.pos) - player->shape_angle.y;
if (fopAcM_searchPlayerDistanceXZ(this) < 300.0f + KREG_F(0) && spA < 0x4000) {
fopAc_ac_c* grab_actor = fopAcM_SearchByID(player->getGrabActorID());
if (grab_actor != NULL && fopAcM_IsActor(grab_actor) && fopAcM_GetName(grab_actor) == fpcNm_Obj_Carry_e) {
daObjCarry_c* carry_obj = (daObjCarry_c*)grab_actor;
if (carry_obj->getType() == daObjCarry_c::TYPE_LV8_BALL) {
player->setForcePutPos(current.pos);
}
}
}
daObjCarry_c* carry_obj;
for (int i = 0; i < 8; i++) {
if (mBallIDs[i] != fpcM_ERROR_PROCESS_ID_e) {
carry_obj = (daObjCarry_c*)fopAcM_SearchByID(mBallIDs[i]);
} else {
carry_obj = NULL;
}
bool sp8 = false;
if (carry_obj != NULL) {
if (field_0x59c == mBallIDs[i] || field_0x59c == fpcM_ERROR_PROCESS_ID_e) {
switch (field_0x593[i]) {
case 0:
if (!fopAcM_checkCarryNow(carry_obj) && checkArea_sub(carry_obj)) {
if (current.pos.x != carry_obj->current.pos.x || current.pos.z != carry_obj->current.pos.z) {
carry_obj->startCtrl();
field_0x593[i] = 1;
}
field_0x59c = mBallIDs[i];
} else {
field_0x59c = fpcM_ERROR_PROCESS_ID_e;
}
break;
case 1:
cLib_chaseF(&carry_obj->current.pos.x, current.pos.x, 10.0f);
cLib_chaseF(&carry_obj->current.pos.z, current.pos.z, 10.0f);
if (0.0f == fopAcM_searchActorDistanceXZ(this, carry_obj)) {
carry_obj->endCtrl();
field_0x593[i] = 0;
}
field_0x59c = mBallIDs[i];
break;
}
}
mIsBallCarry[i] = fopAcM_checkCarryNow(carry_obj) != 0;
}
}
}
}
int daSwBall_c::_delete() {
return 1;
}
static int daSwBall_Execute(daSwBall_c* i_this) {
return i_this->execute();
}
static int daSwBall_Delete(daSwBall_c* i_this) {
return i_this->_delete();
}
static int daSwBall_Create(fopAc_ac_c* i_this) {
return ((daSwBall_c*)i_this)->create();
}
static actor_method_class l_daSwBall_Method = {
(process_method_func)daSwBall_Create,
(process_method_func)daSwBall_Delete,
(process_method_func)daSwBall_Execute,
};
actor_process_profile_definition g_profile_SwBall = {
/* Layer ID */ fpcLy_CURRENT_e,
/* List ID */ 7,
/* List Prio */ fpcPi_CURRENT_e,
/* Proc Name */ fpcNm_SwBall_e,
/* Proc SubMtd */ &g_fpcLf_Method.base,
/* Size */ sizeof(daSwBall_c),
/* Size Other */ 0,
/* Parameters */ 0,
/* Leaf SubMtd */ &g_fopAc_Method.base,
/* Draw Prio */ fpcDwPi_SwBall_e,
/* Actor SubMtd */ &l_daSwBall_Method,
/* Status */ fopAcStts_UNK_0x40000_e,
/* Group */ fopAc_ACTOR_e,
/* Cull Type */ fopAc_CULLBOX_CUSTOM_e,
};
|