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
|
/**
* @file bobomb.c
* @ingroup Enemies
*
* @brief Bobomb enemy
*/
#include "asm.h"
#include "collision.h"
#include "enemy.h"
#include "functions.h"
#include "object.h"
#include "sound.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} BobombEntity;
void sub_0802CB68(BobombEntity* this);
void sub_0802CBC4(BobombEntity* this);
void sub_0802CC18(BobombEntity* this);
extern void (*const Bobomb_Functions[])(BobombEntity*);
extern void (*const gUnk_080CD5EC[])(BobombEntity*);
extern void (*const gUnk_080CD600[])(BobombEntity*);
extern void (*const gUnk_080CD618[])(BobombEntity*);
void Bobomb(BobombEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Bobomb_Functions);
}
void Bobomb_OnTick(BobombEntity* this) {
gUnk_080CD5EC[super->action](this);
}
void Bobomb_OnCollision(BobombEntity* this) {
if (super->contactFlags & 0x80) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
if (this->unk_82) {
super->knockbackDuration = 0;
gPlayerEntity.base.knockbackDuration = 4;
}
return;
case 0xe:
case 0x14:
case 0x15:
case 0x16:
super->action = 3;
super->knockbackDuration = 0;
sub_0802CBC4(this);
return;
}
this->unk_82++;
this->unk_80 = 28;
switch (this->unk_82) {
case 1:
sub_0802CB68(this);
EnqueueSFX(SFX_14D);
break;
case 2:
super->action = 3;
super->hitType = 0x6e;
super->subtimer = 1;
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_81 = 1;
InitializeAnimation(super, super->direction >> 4 | IdleWest);
break;
}
}
EnemyFunctionHandlerAfterCollision(super, Bobomb_Functions);
}
void Bobomb_OnGrabbed(BobombEntity* this) {
if (super->subAction < 3 && !sub_0806F520(super)) {
super->subAction = 0;
super->subtimer = 1;
super->z.HALF.HI = 0;
if (this->unk_82 != 2) {
super->speed = this->unk_82 ? 0x200 : 0x80;
}
super->zVelocity = Q_16_16(1.5);
this->unk_83 = 0;
this->unk_81 = 0;
} else {
super->z.HALF.HI = -1;
gUnk_080CD600[super->subAction](this);
if (super->timer != 0) {
GetNextFrame(super);
}
}
}
void sub_0802C820(BobombEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_0802C82C(BobombEntity* this) {
sub_0806F4E8(super);
}
void sub_0802C834(BobombEntity* this) {
sub_0806F3E4(super);
}
void sub_0802C83C(BobombEntity* this) {
if (this->unk_82) {
if (--super->timer == 0) {
super->action = 3;
switch (gPlayerEntity.base.animationState & 6) {
case 2:
super->x.HALF.HI -= 6;
break;
case 6:
super->x.HALF.HI += 6;
break;
}
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
COLLISION_OFF(super);
super->hitType = 0x6e;
}
} else {
this->unk_82 = 2;
super->timer = 120;
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
COLLISION_OFF(super);
super->hitType = 0x6e;
}
}
void nullsub_149(BobombEntity* this) {
/* ... */
}
void sub_0802C8B8(BobombEntity* this) {
super->action = 3;
sub_0802CBC4(this);
}
void Bobomb_OnDeath(BobombEntity* this) {
GenericDeath(super);
super->spriteSettings.draw = 0;
}
void sub_0802C8D8(BobombEntity* this) {
super->action = 1;
super->timer = 60;
super->subtimer = 0;
super->direction = (Random() & 0x18) | DIR_DIAGONAL;
super->carryFlags = 0;
super->gustJarFlags = 0x12;
this->unk_82 = 0;
this->unk_83 = 0;
this->unk_80 = 0;
this->unk_81 = 0;
InitializeAnimation(super, super->direction >> 4);
}
void sub_0802C91C(BobombEntity* this) {
GetNextFrame(super);
ProcessMovement0(super);
if (this->unk_82) {
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, (super->direction >> 4) | IdleEast);
}
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
if ((super->timer & 0xf) == 8) {
CreateDustSmall(super);
}
sub_0802CC18(this);
}
} else {
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, super->direction >> 4);
}
if (--super->timer == 0) {
super->timer = 60;
super->direction = (super->direction + 8) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(super, super->direction >> 4);
}
}
}
void sub_0802C9B8(BobombEntity* this) {
gUnk_080CD618[super->subAction](this);
}
void sub_0802C9D0(BobombEntity* this) {
super->subAction = 1;
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
this->unk_83 = 1;
sub_0802CC18(this);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
GetNextFrame(super);
}
void sub_0802CA10(BobombEntity* this) {
if (gPlayerState.heldObject != 5) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(super);
}
} else {
this->unk_83 = 2;
super->direction = (((gPlayerEntity.base.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest);
sub_0802CC18(this);
GetNextFrame(super);
}
}
void sub_0802CA6C(BobombEntity* this) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(super);
}
}
void sub_0802CA94(BobombEntity* this) {
super->action = 3;
COLLISION_OFF(super);
super->subtimer = 1;
super->spritePriority.b1 = 1;
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_83 = 0;
this->unk_81 = 0;
super->direction = ((gPlayerEntity.base.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
}
void sub_0802CAF8(BobombEntity* this) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
if (this->unk_81 && sub_080044EC(super, 0x2800) == 1) {
EnqueueSFX(SFX_PLACE_OBJ);
}
sub_0802CC18(this);
RegisterCarryEntity(super);
if (super->subtimer && super->z.HALF.HI == 0) {
super->subtimer = 0;
COLLISION_ON(super);
super->hitType = 0x6e;
}
GetNextFrame(super);
}
}
void nullsub_150(BobombEntity* this) {
/* ... */
}
void sub_0802CB68(BobombEntity* this) {
super->action = 1;
super->subAction = 0;
super->direction = Random() & 0x18;
super->direction |= IdleSouth;
COLLISION_ON(super);
if (this->unk_82) {
super->timer = 200;
super->speed = 0x200;
InitializeAnimation(super, (super->direction >> 4) | 2);
} else {
super->timer = 60;
super->speed = 0x80;
InitializeAnimation(super, super->direction >> 4);
}
}
void sub_0802CBC4(BobombEntity* this) {
Entity* entity;
super->action = 4;
super->spriteSettings.draw = 0;
COLLISION_OFF(super);
super->health = 0;
if (this->unk_83) {
PlayerDropHeldObject();
}
FreeCarryEntity(super);
entity = CreateObjectWithParent(super, SMOKE_PARTICLE, 0, 0);
if (entity != NULL) {
entity->collisionLayer = super->collisionLayer;
}
}
void sub_0802CC18(BobombEntity* this) {
if (--this->unk_80 == 0) {
this->unk_80 = 28;
EnqueueSFX(SFX_14D);
}
}
// clang-format off
void (*const Bobomb_Functions[])(BobombEntity*) = {
Bobomb_OnTick,
Bobomb_OnCollision,
(void (*)(BobombEntity*))GenericKnockback,
Bobomb_OnDeath,
(void (*)(BobombEntity*))GenericConfused,
Bobomb_OnGrabbed,
};
void (*const gUnk_080CD5EC[])(BobombEntity*) = {
sub_0802C8D8,
sub_0802C91C,
sub_0802C9B8,
sub_0802CAF8,
nullsub_150,
};
void (*const gUnk_080CD600[])(BobombEntity*) = {
sub_0802C820,
sub_0802C82C,
sub_0802C834,
sub_0802C83C,
nullsub_149,
sub_0802C8B8,
};
void (*const gUnk_080CD618[])(BobombEntity*) = {
sub_0802C9D0,
sub_0802CA10,
sub_0802CA6C,
sub_0802CA94,
};
// clang-format on
|