summaryrefslogtreecommitdiff
path: root/src/enemy/keese.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/enemy/keese.c')
-rw-r--r--src/enemy/keese.c94
1 files changed, 45 insertions, 49 deletions
diff --git a/src/enemy/keese.c b/src/enemy/keese.c
index 14f5c520..d73475f3 100644
--- a/src/enemy/keese.c
+++ b/src/enemy/keese.c
@@ -10,31 +10,36 @@ extern void sub_0806F4E8(Entity*);
extern u32 sub_0806F3E4(Entity*);
extern void sub_0804A7D4(Entity*);
extern void sub_0804A720(Entity*);
-extern void sub_08021EF0(Entity*);
+extern void Keese_StartFly(Entity*);
extern void sub_080AEFB4(Entity*);
extern void sub_08021F24(Entity*);
extern u32 sub_0806FCB8(Entity*, s32, s32, u32);
extern u32 sub_08049FA0(Entity*);
extern u32 sub_08049EE4(Entity*);
-extern void (*const gUnk_080CB69C[])(Entity*);
-extern void (*const gUnk_080CB6B4[])(Entity*);
+extern void (*const gKeeseFunctions[])(Entity*);
+extern void (*const gKeeseActions[])(Entity*);
extern void (*const gUnk_080CB6C4[])(Entity*);
-extern const s8 gUnk_080CB6D0[];
-extern const u16 gUnk_080CB6D6[];
-extern const u8 gUnk_080CB6F6[];
+extern const s8 gKeeseSpriteOffsets[];
+extern const u16 gKeeseFlyDurations[];
+extern const u8 gKeeseRestDurations[];
+
+enum {
+ KeeseAnimation_Fly,
+ KeeseAnimation_Rest,
+};
void Keese(Entity* this) {
- gUnk_080CB69C[GetNextFunction(this)](this);
+ gKeeseFunctions[GetNextFunction(this)](this);
}
-void sub_08021D80(Entity* this) {
- gUnk_080CB6B4[this->action](this);
+void Keese_OnTick(Entity* this) {
+ gKeeseActions[this->action](this);
}
void sub_08021d98(Entity* this) {
- sub_0804AA30(this, gUnk_080CB69C);
+ sub_0804AA30(this, gKeeseFunctions);
}
void sub_08021DA8(Entity* this) {
@@ -57,10 +62,9 @@ void sub_08021DDC(Entity* this) {
}
}
-void sub_08021DF0(Entity* this) {
-
+void Keese_Initialize(Entity* this) {
sub_0804A720(this);
- if ((this->entityType).form != 0) {
+ if (this->entityType.form != 0) {
this->spritePriority.b1 = 1;
this->height.HALF.HI = -0x10;
}
@@ -69,15 +73,15 @@ void sub_08021DF0(Entity* this) {
this->spritePriority.b0 = 3;
this->collisionLayer = 3;
UpdateSpriteForCollisionLayer(this);
- sub_08021EF0(this);
+ Keese_StartFly(this);
}
-void sub_08021E4C(Entity* this) {
+void Keese_Fly(Entity* this) {
if (this->field_0x78.HWORD != 0) {
this->field_0x78.HWORD--;
}
if (this->field_0x7a.HWORD != 0) {
- (this->field_0x7a.HWORD)--;
+ this->field_0x7a.HWORD--;
}
GetNextFrame(this);
if ((this->frames.b.f3) != 0) {
@@ -85,62 +89,54 @@ void sub_08021E4C(Entity* this) {
} else {
sub_080AEFB4(this);
}
- this->spriteOffsetY = gUnk_080CB6D0[this->frames.all];
+ this->spriteOffsetY = gKeeseSpriteOffsets[this->frames.all];
}
-void sub_08021EA4(Entity* this) {
+void Keese_Rest(Entity* this) {
if (--this->actionDelay == 0) {
- sub_08021EF0(this);
+ Keese_StartFly(this);
}
}
-void sub_08021EBC(Entity* this) {
- s32 iVar1;
-
+void Keese_Sleep(Entity* this) {
if (this->actionDelay != 0) {
this->actionDelay--;
} else {
- iVar1 = sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70);
- if (iVar1 != 0) {
- sub_08021EF0(this);
- }
+ if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))
+ Keese_StartFly(this);
}
}
-void sub_08021EF0(Entity* this) {
- u32 uVar1;
-
+void Keese_StartFly(Entity* this) {
this->action = 1;
- this->field_0x78.HWORD = gUnk_080CB6D6[Random() & 0xf];
- this->field_0x7a.HWORD = 0x3c;
- InitializeAnimation(this, 0);
+ this->field_0x78.HWORD = gKeeseFlyDurations[Random() & 0xf];
+ this->field_0x7a.HWORD = 60;
+ InitializeAnimation(this, KeeseAnimation_Fly);
}
void sub_08021F24(Entity* this) {
- u32 bVar1;
-
if (this->field_0x78.HWORD == 0) {
this->action = 2;
- this->actionDelay = gUnk_080CB6F6[Random() & 0xf];
- InitializeAnimation(this, 1);
+ this->actionDelay = gKeeseRestDurations[Random() & 0xf];
+ InitializeAnimation(this, KeeseAnimation_Rest);
} else if (!this->field_0x7a.HWORD &&
!(sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))) {
this->action = 3;
- this->actionDelay = 0x1e;
- InitializeAnimation(this, 1);
+ this->actionDelay = 30;
+ InitializeAnimation(this, KeeseAnimation_Rest);
} else {
if (sub_08049FA0(this) != 0) {
this->direction = Random() & 0x1f;
} else {
this->direction = sub_08049EE4(this);
}
- InitializeAnimation(this, 0);
+ InitializeAnimation(this, KeeseAnimation_Fly);
}
}
// clang-format off
-void (*const gUnk_080CB69C[])(Entity*) = {
- sub_08021D80,
+void (*const gKeeseFunctions[])(Entity*) = {
+ Keese_OnTick,
sub_08021d98,
sub_08001328,
sub_0804A7D4,
@@ -148,11 +144,11 @@ void (*const gUnk_080CB69C[])(Entity*) = {
sub_08021DA8,
};
-void (*const gUnk_080CB6B4[])(Entity*) = {
- sub_08021DF0,
- sub_08021E4C,
- sub_08021EA4,
- sub_08021EBC,
+void (*const gKeeseActions[])(Entity*) = {
+ Keese_Initialize,
+ Keese_Fly,
+ Keese_Rest,
+ Keese_Sleep,
};
void (*const gUnk_080CB6C4[])(Entity*) = {
@@ -161,16 +157,16 @@ void (*const gUnk_080CB6C4[])(Entity*) = {
sub_08021DDC,
};
-const s8 gUnk_080CB6D0[] = {
+const s8 gKeeseSpriteOffsets[] = {
1, -2, -5, -2, 1, 0,
};
-const u16 gUnk_080CB6D6[] = {
+const u16 gKeeseFlyDurations[] = {
180, 180, 300, 300, 300, 300, 300, 300,
480, 480, 480, 480, 480, 480, 720, 720,
};
-const u8 gUnk_080CB6F6[] = {
+const u8 gKeeseRestDurations[] = {
30, 30, 45, 45, 45, 45, 45, 45,
60, 60, 60, 60, 60, 60, 75, 75,
};