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
|
/**
* @file cuccoChickAggr.c
* @ingroup Enemies
*
* @brief Cucco Chick Aggr enemy
*/
#include "enemy.h"
#include "player.h"
void sub_08022A88(Entity*);
void sub_08022AA4(Entity*);
void sub_08022B0C(Entity*);
u32 sub_08022B20(Entity*);
void sub_08022B44(Entity*);
extern void (*const CuccoChickAggr_Functions[])(Entity*);
extern void (*const gUnk_080CBB7C[])(Entity*);
void CuccoChickAggr(Entity* this) {
CuccoChickAggr_Functions[GetNextFunction(this)](this);
}
void CuccoChickAggr_OnTick(Entity* this) {
gUnk_080CBB7C[this->action](this);
}
void CuccoChickAggr_OnCollision(Entity* this) {
EnemyFunctionHandlerAfterCollision(this, CuccoChickAggr_Functions);
}
void CuccoChickAggr_OnGrabbed(Entity* this) {
}
void sub_08022960(Entity* this) {
sub_0804A720(this);
sub_08022A88(this);
}
void sub_08022970(Entity* this) {
if (--this->timer == 0) {
sub_08022AA4(this);
}
}
void sub_08022988(Entity* this) {
if (this->z.HALF.HI == 0 && sub_08022B20(this)) {
sub_08022B0C(this);
} else {
if (this->subtimer) {
if (--this->subtimer)
return;
this->frameIndex = 1;
this->zVelocity = Q_16_16(1.0);
EnqueueSFX(SFX_VO_CHEEP);
}
ProcessMovement0(this);
if (GravityUpdate(this, Q_8_8(32.0)) == 0) {
if (--this->timer == 0) {
sub_08022A88(this);
} else {
this->subtimer = 4;
this->frameIndex = 0;
}
}
}
}
void sub_080229F8(Entity* this) {
if (GravityUpdate(this, Q_8_8(40.0)) == 0) {
if (--this->timer == 0) {
this->action = 4;
this->timer = 6;
this->subtimer = 8;
this->frameIndex = 0;
this->speed = 0xc0;
sub_08022B44(this);
} else {
this->zVelocity = Q_16_16(1.0);
EnqueueSFX(SFX_VO_CHEEP);
}
}
}
void sub_08022A40(Entity* this) {
if (this->subtimer) {
if (--this->subtimer)
return;
this->frameIndex = 1;
}
ProcessMovement0(this);
if (GravityUpdate(this, Q_8_8(32.0)) == 0) {
if (--this->timer == 0) {
sub_08022A88(this);
} else {
sub_08022B44(this);
}
}
}
void sub_08022A88(Entity* this) {
this->action = 1;
this->timer = (Random() & 0xf) + 8;
this->frameIndex = 0;
}
void sub_08022AA4(Entity* this) {
u32 rand = Random();
this->action = 2;
this->timer = (rand & 3) + 1;
this->subtimer = 1;
this->speed = 0x80;
if (!sub_08049FA0(this) && (rand >> 8) & 3) {
this->direction = sub_08049EE4(this);
} else {
this->direction =
(rand >> 0x10) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
}
if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL))
this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
}
void sub_08022B0C(Entity* this) {
this->action = 3;
this->timer = 3;
this->subtimer = 8;
sub_08022B44(this);
}
u32 sub_08022B20(Entity* this) {
if (!sub_08049DF4(2))
return 0;
return EntityInRectRadius(this, &gPlayerEntity.base, 36, 36);
}
void sub_08022B44(Entity* this) {
this->zVelocity = Q_16_16(0.75);
this->direction = GetFacingDirection(this, &gPlayerEntity.base);
if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast))
this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
EnqueueSFX(SFX_VO_CHEEP);
}
// clang-format off
void (*const CuccoChickAggr_Functions[])(Entity*) = {
CuccoChickAggr_OnTick,
CuccoChickAggr_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
CuccoChickAggr_OnGrabbed,
};
void (*const gUnk_080CBB7C[])(Entity*) = {
sub_08022960,
sub_08022970,
sub_08022988,
sub_080229F8,
sub_08022A40,
};
// clang-format on
|