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
|
/**
* @file rockChuchu.c
* @ingroup Enemies
*
* @brief Rock Chuchu enemy
*/
#include "enemy.h"
#include "sound.h"
#include "effects.h"
#include "player.h"
#include "asm.h"
extern void (*const RockChuchu_Functions[])(Entity*);
extern void (*const gUnk_080CB960[])(Entity*);
void RockChuchu(Entity* this) {
EnemyFunctionHandler(this, RockChuchu_Functions);
}
void RockChuchu_OnTick(Entity* this) {
gUnk_080CB960[this->action](this);
}
void RockChuchu_OnCollision(Entity* this) {
Entity* entity;
if (this->health) {
switch (this->contactFlags & 0x7f) {
case 4:
case 5:
case 6:
case 8:
case 9:
case 10:
case 0xb:
case 0xc:
case 0xd:
case 0x10:
case 0x11:
case 0x12:
case 0x18:
case 0x19:
case 0x1a:
if ((gPlayerState.skills & SKILL_ROCK_BREAKER) == 0)
break;
case 0x16:
case 0x1c:
CreateFx(this, FX_ROCK, 0);
entity = CreateEnemy(CHUCHU, 1);
if (entity != NULL) {
entity->type2 = 1;
#ifndef EU
entity->iframes = -8;
#endif
EnemyCopyParams(this, entity);
this->action = 2;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
this->direction = this->knockbackDirection;
this->child = entity;
}
}
} else {
if (this->hitType != 0x94)
InitializeAnimation(this, 2);
}
EnemyFunctionHandlerAfterCollision(this, RockChuchu_Functions);
}
void RockChuchu_OnGrabbed(Entity* this) {
}
void sub_08022368(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->timer = Random();
this->direction = sub_08049F84(this, 1);
InitializeAnimation(this, 0);
}
void sub_08022390(Entity* this) {
if (sub_08049FDC(this, 1)) {
if ((this->timer++ & 0xf) == 0) {
this->direction = sub_08049F84(this, 1);
this->subtimer = Random() & 4;
}
if (this->subtimer == 0) {
ProcessMovement0(this);
} else {
this->subtimer = this->subtimer - 1;
}
} else {
this->timer = Random();
}
GetNextFrame(this);
}
void sub_080223E4(Entity* this) {
Entity* entity;
entity = this->child;
if (entity != NULL) {
entity->contactFlags = (CONTACT_NOW | 0x14);
entity->iframes = 0x10;
#ifndef EU
entity->knockbackDuration = 0xc;
entity->knockbackDirection = this->direction;
#endif
}
DeleteEntity(this);
}
// clang-format off
void (*const RockChuchu_Functions[])(Entity*) = {
RockChuchu_OnTick,
RockChuchu_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
RockChuchu_OnGrabbed,
};
void (*const gUnk_080CB960[])(Entity*) = {
sub_08022368,
sub_08022390,
sub_080223E4,
};
// clang-format on
|