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
|
#include "d/a/d_a_insect.h"
#include "c/c_math.h"
#include "common.h"
#include "d/a/d_a_player.h"
#include "d/col/bg/d_bg_pc.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/bg/d_bg_s_acch.h"
#include "d/col/bg/d_bg_s_lin_chk.h"
#include "d/col/bg/d_bg_w_base.h"
#include "d/col/c/c_cc_d.h"
#include "d/col/c/c_m3d_g_pla.h"
#include "d/snd/d_snd_wzsound.h"
#include "m/m_angle.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "toBeSorted/attention.h"
#include "toBeSorted/d_emitter.h"
void dAcOInsect_c::kill() {
dJEffManager_c::spawnEffect(PARTICLE_RESOURCE_ID_MAPPING_394_, mPosition, nullptr, nullptr, nullptr, nullptr, 0, 0);
startSound(SE_Insect_DISAPPEAR);
deleteRequest();
}
bool dAcOInsect_c::checkForLinkScare() {
if (dAcPy_c::LINK != nullptr) {
if (dAcPy_c::LINK->getCurrentAction() == 12 /* Rolling */) { // TODO (Player Action Enum)
if (dAcPy_c::LINK->getDistanceTo(mPosition) < 50.f) {
mLinkNearby = 1;
return true;
}
} else if (dAcPy_c::LINK->mSpeed > 1.f) {
if (dAcPy_c::LINK->getDistanceTo(mPosition) < 30.f) {
mLinkNearby = 1;
return true;
}
}
}
return false;
}
void dAcOInsect_c::checkDeath(dBgS_Acch &acch) {
if (acch.ChkWaterHit() && acch.mWtr.GetGroundH() >= mPosition.y) {
kill();
}
if (acch.ChkGroundLanding() && dBgS::GetInstance()->GetSpecialCode(acch.mGnd) == POLY_ATTR_LAVA) {
kill();
}
if (mPosition.y < mPositionCopy.y - 5000.f) {
deleteRequest();
}
}
bool dAcOInsect_c::isLinkUsingBugNet() {
if (dAcPy_c::LINK != nullptr && !dAcPy_c::LINK->isUsingBugnet()) {
return false;
}
return true;
}
s32 dAcOInsect_c::getLinkSpeedLevel() {
if (dAcPy_c::LINK != nullptr) {
f32 speed = fabsf(dAcPy_c::LINK->mSpeed);
if (speed < 0.1f) {
return 0;
} else if (speed < 10.0f) {
return 1;
} else {
return 2;
}
}
return 3;
}
bool dAcOInsect_c::checkPlayerRadius(f32 rad) {
if (dAcPy_c::LINK != nullptr && isWithinPlayerRadius(rad)) {
return true;
}
return false;
}
bool dAcOInsect_c::checkPlayerElevationDiff(f32 dist) {
if (dAcPy_c::LINK != nullptr && fabsf(dAcPy_c::LINK->mPosition.y - mPosition.y) > dist) {
return false;
}
return true;
}
void dAcOInsect_c::someBaseFunction() {
dAcPy_c *link = dAcPy_c::LINK;
if (link != nullptr) {
if (checkPlayerElevationDiff(500.0f) && checkPlayerRadius(dAcOInsect_0x8C())) {
field_0x335 = field_0x334;
field_0x334 = link->isUsingBugnet1();
if (link->isUsingBugnet1()) {
field_0x330++;
return;
}
field_0x330 = 0;
return;
} else {
field_0x334 = 0;
field_0x335 = 0;
field_0x330 = 0;
}
}
}
bool dAcOInsect_c::someBaseFunction0() {
f32 rad = dAcOInsect_0x80();
if (checkPlayerElevationDiff(500.0f) && checkPlayerRadius(rad)) {
field_0x338 = 1;
return true;
}
bool b = (field_0x335 != 0 && field_0x334 == 0) || field_0x330 > 3;
if (b) {
field_0x338 = 2;
return true;
} else {
field_0x338 = 0;
return false;
}
}
void dAcOInsect_c::addAttentionTarget() {
preAttention();
static InteractionTargetDef tmpTarget = {1, 0, 0, UNK_18, 0x2, 150.0f, 0.0f, 0.0f, -300.0f, 100.0f, 50.0f, 1.0f};
if (shouldAddAttentionTarget()) {
AttentionManager *attn = AttentionManager::GetInstance();
if (attn != nullptr) {
attn->addCatchTarget(*this, 0x1, 400.0f, -200.0f, 200.0f);
tmpTarget.field_0x14 = getAttentionField();
attn->addTarget(*this, tmpTarget, 0, nullptr);
}
}
}
void dAcOInsect_c::preAttention() {
mPositionCopy2 = mPosition;
mPositionCopy2.y += 20.f;
mPositionCopy3 = mPositionCopy2;
}
f32 dAcOInsect_c::dAcOInsect_0x80() {
switch (getLinkSpeedLevel()) {
case 1: return dAcOInsect_0x84();
case 2: return dAcOInsect_0x88();
default: return dAcOInsect_0x84();
}
}
bool dAcOInsect_c::isLinkCloseAndFlag() {
dAcPy_c *link = dAcPy_c::LINK;
if (link != nullptr && link->checkFlags0x350(0x2000)) {
f32 d = dAcOInsect_0x94();
return getSquareDistanceTo(link->mPosition) < d;
}
return false;
}
bool dAcOInsect_c::checkDeath(cCcD_Obj &col) {
if (field_0x3F4 != 0) {
field_0x3F4--;
return false;
}
if (col.ChkTgHit() &&
(col.ChkTgAtHitType(AT_TYPE_SWORD) || col.ChkTgAtHitType(AT_TYPE_PHYSICS) || col.ChkTgAtHitType(AT_TYPE_BOMB) ||
col.ChkTgAtHitType(AT_TYPE_0x40) || col.ChkTgAtHitType(AT_TYPE_SLINGSHOT) ||
col.ChkTgAtHitType(AT_TYPE_ARROW) || col.ChkTgAtHitType(AT_TYPE_CLAWSHOT) ||
col.ChkTgAtHitType(AT_TYPE_0x800000) || col.ChkTgAtHitType(AT_TYPE_WHIP))) {
mLinkNearby = 0;
return true;
}
return false;
}
bool dAcOInsect_c::checkCaught(cCcD_Obj &col) {
if (col.ChkTgHit() && col.ChkTgAtHitType(AT_TYPE_BUGNET)) {
return true;
}
return false;
}
bool dAcOInsect_c::resetScale() {
mScale.set(1.0f, 1.0f, 1.0f);
return true;
}
bool dAcOInsect_c::fn_8018FAA0() {
if (field_0x3FC.get() != 0 && field_0x40D == 0) {
return true;
}
return false;
}
bool dAcOInsect_c::fn_8018FAD0() {
f32 speed = fabsf(mSpeed);
if (cM::isLessThanZero(speed)) {
fn_8018FDF0(mPlane_0x3A8.GetN());
return true;
} else {
f32 clampSpeed = speed < 5.0f ? mSpeed > 0.f ? mSpeed : -5.f : 5.f;
mVec3_c pos0 = mPosition + field_0x360;
mVec3_c pos1 = pos0 + field_0x36C * mSpeed;
int linType = fn_801900B0(pos0, pos1);
field_0x410[0] = pos0;
field_0x434[0] = pos1;
// TODO
}
}
void dAcOInsect_c::fn_8018FDF0(const mVec3_c &point) {
mMtx_c mtx;
field_0x360 = point;
mtx.setAxisRotation(field_0x360, mRotation.y.radian_c());
// TODO
f32 a_comparision = 0.99f;
}
int dAcOInsect_c::fn_801900B0(const mVec3_c &point0, const mVec3_c &point1) {
cM3dGPla pla;
if (!dBgS_ObjLinChk::LineCross(&point0, &point1, this)) {
return 1;
}
if (!dBgS_ObjLinChk::GetTriPla(&pla)) {
return 1;
}
if (mMaterial != dBgS_ObjLinChk::GetMaterial()) {
return 2;
}
mPosition = dBgS_ObjLinChk::GetInstance().GetLinEnd();
mPlane_0x3A8 = pla;
field_0x3BC = 1;
fn_8018FDF0(pla.GetN());
return 0;
}
// Looks like it decides on a direction and angle based on a target point?
bool dAcOInsect_c::fn_80190180(mAng &outAng) {
// Stack and reg problems
mVec3_c vecs[4];
vecs[0].set(1.0f, 0.0f, 1.0f);
vecs[1].set(1.0f, 0.0f, -1.0f);
vecs[2].set(-1.0f, 0.0f, -1.0f);
vecs[3].set(-1.0f, 0.0f, 1.0f);
int i3 = -1;
s16 angs[4];
angs[0] = 0x2000;
angs[1] = 0x6000;
angs[2] = 0xA000;
angs[3] = 0xE000;
if (field_0x3BF != 0) {
f32 len = fabsf(field_0x33C.y + field_0x35C * 0.5f - mPosition.y);
for (int i = 0; i < 4; i++) {
// mVec3_c tmp2 = field_0x3C0.multVec(vecs[i] * 20.0f);
f32 len2 = fabsf(field_0x33C.y + field_0x35C * 0.5f - field_0x3C0.multVec(vecs[i] * 20.0f).y);
if (len > len2) {
len = len2;
i3 = i;
}
}
} else if (field_0x3BE != 0) {
mVec3_c dir = field_0x33C - mPosition;
f32 len = dir.squareMagXZ();
for (int i = 0; i < 4; i++) {
// mVec3_c tmp2 = field_0x3C0.multVec(vecs[i] * 20.0f);
f32 len2 = (field_0x33C - field_0x3C0.multVec(vecs[i] * 20.0f)).squareMagXZ();
if (len > len2) {
len = len2;
i3 = i;
}
}
}
if (i3 >= 0) {
outAng = angs[i3];
field_0x45C = vecs[i3];
return true;
}
return false;
}
void dAcOInsect_c::fn_80190440() {
f32 a = 2250000.f; // float order
}
void dAcOInsect_c::fn_80190160() {
field_0x33C = field_0x348;
field_0x354 = field_0x358;
field_0x40C = 0;
}
|