summaryrefslogtreecommitdiff
path: root/src/enemy
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2020-07-13 15:27:20 -0700
committertheo3 <arisstephenson2@gmail.com>2020-07-13 15:27:20 -0700
commit62ddaaa5f6fe2dc2aaa2dd002d4ce0b1d61a3cc9 (patch)
treed625ad1b183fc6aa5b56c00ce6573ef850679731 /src/enemy
parentc47f16e5e7b0abb010133b3ee1a58099d8b8915d (diff)
add subdirs
Diffstat (limited to 'src/enemy')
-rw-r--r--src/enemy/bladeTrap.c34
-rw-r--r--src/enemy/bombPeahat.c86
-rw-r--r--src/enemy/bowMoblin.c41
-rw-r--r--src/enemy/hangingSeed.c39
-rw-r--r--src/enemy/keese.c131
-rw-r--r--src/enemy/lakitu.c429
-rw-r--r--src/enemy/lakituCloud.c150
-rw-r--r--src/enemy/miniFireballGuy.c61
-rw-r--r--src/enemy/octorok.c119
-rw-r--r--src/enemy/slime.c167
-rw-r--r--src/enemy/smallPesto.c68
11 files changed, 1325 insertions, 0 deletions
diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c
new file mode 100644
index 00000000..3c37d08a
--- /dev/null
+++ b/src/enemy/bladeTrap.c
@@ -0,0 +1,34 @@
+#include "global.h"
+#include "entity.h"
+#include "room.h"
+extern void sub_080A2CC0();
+extern void sub_0806F69C();
+extern void sub_08004488();
+extern Entity* GetCurrentRoomProperty();
+
+void BladeTrap(Entity* ent) {
+ u16 uVar1;
+ Entity* pEVar2;
+ u16* puVar3;
+ if (ent->action == 0) {
+ ent->action = 1;
+ pEVar2 = GetCurrentRoomProperty((u8)(ent->entityType).form);
+ ent->attachedEntity = pEVar2;
+ sub_080A2CC0((EntityData*)ent, &ent->attachedEntity, &ent->field_0x74);
+ }
+ if ((ent->direction & 0x80) == 0) {
+ sub_0806F69C(ent);
+ }
+
+
+
+ puVar3 = &(ent->field_0x74);
+ uVar1 = *puVar3;
+ *puVar3 = uVar1 - 1;
+ if ((*puVar3) == 0) {
+ if ((u16)(ent->direction & 0x80) == 0) {
+ sub_08004488(0x74);
+ }
+ sub_080A2CC0((EntityData*)ent, &ent->attachedEntity, puVar3);
+ }
+}
diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c
new file mode 100644
index 00000000..3921737a
--- /dev/null
+++ b/src/enemy/bombPeahat.c
@@ -0,0 +1,86 @@
+#include "global.h"
+#include "entity.h"
+#include "functions.h"
+#include "link.h"
+
+extern s32 sub_080012DC(Entity*);
+extern u32 GetNextFunction(Entity*);
+extern void sub_0802AD54(Entity*);
+extern void sub_0802B048(Entity*);
+extern void sub_0806F4E8(Entity*);
+extern void sub_0806F3E4(Entity*);
+
+extern void (*const gUnk_080012C8[])(Entity*);
+extern void (*const gUnk_080CD0F0[])(Entity*);
+extern void (*const gUnk_080CD120[])(Entity*);
+extern void (*const gUnk_080CD134[])(Entity*);
+extern void (*const gUnk_080CD108[])(Entity*);
+extern void (*const gUnk_080CD140[])(Entity*);
+
+void BombPeahat(Entity* this) {
+ s32 iVar1;
+ u32 uVar2;
+
+ if (((this->entityType).form == 2) && (iVar1 = sub_080012DC(this), iVar1)) {
+ gUnk_080012C8[iVar1](this);
+ } else {
+ gUnk_080CD0F0[GetNextFunction(this)](this);
+ }
+}
+
+void sub_0802A84C(Entity* this) {
+ switch (this->entityType.form) {
+ default:
+ gUnk_080CD108[this->action](this);
+ sub_0802AD54(this);
+ return;
+ case 2:
+ gUnk_080CD120[this->action](this);
+ sub_0802B048(this);
+ return;
+ case 3:
+ gUnk_080CD134[this->action](this);
+ }
+}
+
+void sub_0802A8AC(Entity *this) {
+ *((u8 *)&this->field_0x80 + 1) = 0;
+ if (this->entityType.form < 2) {
+ InitializeAnimation(this, 0);
+ }
+}
+
+void sub_0802A8C8(Entity* this)
+{
+ gUnk_080CD140[this->previousActionFlag](this);
+}
+
+void sub_0802A8E0(Entity *this)
+{
+ this->previousActionFlag = 1;
+ this->filler[1] = 0x3c;
+}
+
+void sub_0802A8EC(Entity *this)
+{
+ sub_0806F4E8(this);
+}
+
+void sub_0802A8F4(Entity *this)
+{
+ sub_0806F3E4(this);
+}
+
+void sub_0802A8FC(Entity *this)
+{
+ if ((gLinkState.field_0x1c & 0xf) == 0) {
+ this->currentHealth = gLinkState.field_0x1c & 0xf;
+ }
+}
+
+void nullsub_143(Entity* this){}
+
+void sub_0802A91C(Entity *this)
+{
+ this->currentHealth = 0;
+}
diff --git a/src/enemy/bowMoblin.c b/src/enemy/bowMoblin.c
new file mode 100644
index 00000000..6c7620d6
--- /dev/null
+++ b/src/enemy/bowMoblin.c
@@ -0,0 +1,41 @@
+#include "global.h"
+#include "entity.h"
+
+extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*));
+extern void SetChildOffset(Entity*, u32, u32, u32);
+extern void sub_0804A9FC(Entity*, u32);
+extern void sub_0804AA30(Entity*, void (*const funcs[][])(Entity*));
+extern void sub_0803C5F0(Entity*);
+
+extern void (*const gUnk_080CFF78[])(Entity*);
+extern void (*const gUnk_080CFF90[])(Entity*);
+
+void BowMoblin(Entity *this)
+{
+ EnemyFunctionHandler(this, gUnk_080CFF78);
+ SetChildOffset(this, 0, 1, -0x18);
+}
+
+void sub_0803C180(Entity *this)
+{
+ gUnk_080CFF90[this->action](this);
+}
+
+void sub_0803C198(Entity *this)
+{
+ Entity *pEVar1;
+
+ if (this->field_0x43 != 0) {
+ sub_0804A9FC(this,0x1c);
+ }
+ sub_0804AA30(this, &gUnk_080CFF78);
+ if ((this->bitfield & 0x80) != 0) {
+ sub_0803C5F0(this);
+ pEVar1 = this->attachedEntity;
+ if (pEVar1 != NULL) {
+ pEVar1->field_0xf++;
+ }
+ }
+}
+
+void nullsub_168(Entity* this){} \ No newline at end of file
diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c
new file mode 100644
index 00000000..7f0ba1dc
--- /dev/null
+++ b/src/enemy/hangingSeed.c
@@ -0,0 +1,39 @@
+#include "global.h"
+#include "entity.h"
+
+extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*));
+extern void DeleteThisEntity();
+
+extern void (*const gUnk_080CB570[])(Entity*);
+extern void (*const gUnk_080CB588[])(Entity*);
+
+void HangingSeed(Entity *this)
+{
+ EnemyFunctionHandler(this, gUnk_080CB570);
+}
+
+void sub_080216E4(Entity *this)
+{
+ gUnk_080CB588[this->action](this);
+}
+
+void sub_080216FC(Entity *this)
+{
+ if ((this->bitfield & 0x80) != 0) {
+ CreateFx(this, 3, 0x80);
+ DeleteThisEntity();
+ }
+}
+
+void nullsub_7(Entity* this){}
+
+void sub_08021720(Entity *this)
+{
+ this->action = 1;
+ this->spriteSettings.b.draw = 1;
+ this->frameIndex = (this->entityType).form;
+ this->spriteRendering.b3 = 1;
+ this->spritePriority.b0 = 3;
+}
+
+void nullsub_08(Entity* this){} \ No newline at end of file
diff --git a/src/enemy/keese.c b/src/enemy/keese.c
new file mode 100644
index 00000000..0cbc9acd
--- /dev/null
+++ b/src/enemy/keese.c
@@ -0,0 +1,131 @@
+#include "global.h"
+#include "entity.h"
+#include "enemy.h"
+#include "link.h"
+
+extern void sub_0804AA30(Entity*, void *);
+extern u32 sub_0806F520(Entity*);
+extern void sub_0806F4E8(Entity*);
+extern u32 sub_0806F3E4(Entity*);
+extern void sub_0804A7D4(Entity*);
+extern void sub_0804A720(Entity*);
+extern u32 Random();
+extern void sub_08021EF0(Entity*);
+extern void sub_080AEFB4(Entity*);
+extern void sub_08021F24(Entity*);
+extern u32 sub_0806FCB8(Entity*, s32, s32, u32);
+
+extern void (*gUnk_080CB69C[])(Entity*);
+extern void (*gUnk_080CB6B4[])(Entity*);
+extern void (*gUnk_080CB6C4[])(Entity*);
+
+extern u8 gUnk_080CB6D0[];
+extern u16 gUnk_080CB6D6[];
+
+
+extern u8 gUnk_080CB6D0[];
+
+void Keese(Entity *this)
+{
+ gUnk_080CB69C[GetNextFunction(this)](this);
+}
+
+void sub_08021D80(Entity *this)
+{
+ gUnk_080CB6B4[this->action](this);
+}
+
+void sub_08021d98(Entity *this)
+{
+ sub_0804AA30(this, &gUnk_080CB69C);
+}
+
+void sub_08021DA8(Entity *this)
+{
+ if (sub_0806F520(this)) {
+ gUnk_080CB6C4[this->previousActionFlag](this);
+ }
+}
+
+void sub_08021DCC(Entity *this)
+{
+ this->previousActionFlag = 2;
+}
+
+void sub_08021DD4(Entity *this)
+{
+ sub_0806F4E8(this);
+}
+
+void sub_08021DDC(Entity *this)
+{
+ if (sub_0806F3E4(this)) {
+ sub_0804A7D4(this);
+ }
+}
+
+void sub_08021DF0(Entity *this)
+{
+
+ sub_0804A720(this);
+ if ((this->entityType).form != 0) {
+ this->spritePriority.b1 = 1;
+ this->height.HALF.HI = -0x10;
+ }
+ this->direction = Random() & 0x1f;
+ this->filler[0] = 1;
+ this->spritePriority.b0 = 3;
+ this->collisionLayer = 3;
+ UpdateSpriteForCollisionLayer(this);
+ sub_08021EF0(this);
+}
+
+void sub_08021E4C(Entity *this)
+{
+ if (this->field_0x78.HWORD != 0) {
+ this->field_0x78.HWORD--;
+ }
+ if (this->field_0x7a != 0) {
+ (this->field_0x7a)--;
+ }
+ GetNextFrame(this);
+ if ((this->frames.b.f3) != 0) {
+ sub_08021F24(this);
+ }
+ else {
+ sub_080AEFB4(this);
+ }
+ this->spriteOffsetY = gUnk_080CB6D0[this->frames.all];
+}
+
+void sub_08021EA4(Entity *this)
+{
+ if (--this->actionDelay == 0) {
+ sub_08021EF0(this);
+ }
+}
+
+void sub_08021EBC(Entity *this)
+{
+ s32 iVar1;
+
+ if (this->actionDelay != 0) {
+ this->actionDelay--;
+ }
+ else {
+ iVar1 = sub_0806FCB8(this, gLinkEntity.x.HALF.HI, gLinkEntity.y.HALF.HI, 0x70);
+ if (iVar1 != 0) {
+ sub_08021EF0(this);
+ }
+ }
+}
+
+void sub_08021EF0(Entity *this)
+{
+ u32 uVar1;
+
+ this->action = 1;
+ this->field_0x78.HWORD = gUnk_080CB6D6[Random() & 0xf];
+ this->field_0x7a = 0x3c;
+ InitializeAnimation(this, 0);
+}
diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c
new file mode 100644
index 00000000..9189c525
--- /dev/null
+++ b/src/enemy/lakitu.c
@@ -0,0 +1,429 @@
+#include "global.h"
+#include "entity.h"
+#include "trig.h"
+#include "random.h"
+#include "link.h"
+
+// Lakitu
+extern void EnemyFunctionHandler(Entity *, void (*const funcs[])(Entity*));
+extern void SetChildOffset(Entity *, u32, u32, u32);
+
+// sub_0803C758
+extern void sub_0803CAD0(Entity *);
+
+// sub_0803C784
+extern void sub_0803CBAC(Entity *); // Also used in sub_0803C86C
+extern Entity *CreateFx(Entity*, u32, u32);
+extern void sub_0804A9FC(Entity *, u32);
+extern void sub_0804AA30(Entity *, void (*const funcs[])(Entity *));
+
+// sub_0803C820
+extern u32 sub_0806F520(Entity *);
+
+// sub_0803C850
+extern void sub_0806F4E8(Entity *);
+
+// sub_0803C87C
+extern Entity *sub_0804A98C(Entity *, u32, u32);
+extern void sub_0804A720(Entity *);
+
+// sub_0803C8BC and sub_0803C918
+extern void sub_0803CA84(Entity *, u32);
+extern bool32 sub_0803CA4C(Entity *);
+
+// Many functions
+extern void UpdateAnimationSingleFrame(Entity *);
+extern void InitAnimationForceUpdate(Entity *, u32);
+
+// sub_0803C918
+extern u32 sub_0803CB04(Entity *);
+
+// sub_0803C97C
+extern void sub_0803CB64(Entity *);
+
+// sub_0803C9D4 and sub_0803CB04
+extern void sub_0803CB34(Entity *);
+
+// sub_0803CA0C
+extern u32 sub_08003FC4(Entity *, u32);
+extern void sub_0803CC08(Entity *this);
+
+// sub_0803CA4C
+extern u32 sub_0806FCB8(Entity *, u32, u32, u32);
+extern u32 sub_080041A0(Entity *, Entity *, u32, u32);
+
+// sub_0803CA84
+extern u32 GetFacingDirection(Entity *, Entity *);
+
+// sub_0803CAD0
+extern u8 sub_080045D4(s16, s16, u16, u16);
+extern void sub_080AEFE0(Entity *);
+
+// sub_0803CB64
+extern void PositionRelative(Entity *, Entity *, u32, u32);
+extern void sub_08004488(u32);
+
+typedef struct {
+ s8 x;
+ s8 y;
+} PACKED OffsetCoords;
+
+// sub_0803CC08
+extern void DeleteEntity(Entity *);
+
+// Variables
+extern void (*const gUnk_080D0110[])(Entity *);
+extern void (*const gUnk_080D0128[])(Entity *);
+extern void (*const gUnk_080D0148[])(Entity *);
+extern const OffsetCoords gUnk_080D0154[];
+
+void Lakitu(Entity *this) {
+ EnemyFunctionHandler(this, gUnk_080D0110);
+
+ SetChildOffset(this, 0, 1, -16);
+}
+
+void sub_0803C758(Entity *this) {
+ if (this->action != 0 && this->action != 7) {
+ sub_0803CAD0(this);
+ }
+
+ gUnk_080D0128[this->action](this);
+}
+
+void sub_0803C784(Entity *this) {
+ if ((this->bitfield & 0x7f) == 0x1d) {
+ this->field_0x20 = 0x20000;
+
+ sub_0803CBAC(this);
+ }
+ else {
+ if (this->damageType == 0x43) {
+ Entity *sound = CreateFx(this, 2, 0);
+
+ if (sound != 0) {
+ u32 angle = (this->field_0x3e ^ 0x10) << 3;
+ s32 sine;
+
+ sine = gSineTable[angle];
+ if (sine < 0) {
+ sine += 0x1f;
+ }
+
+ sound->x.HALF.HI += sine >> 5;
+
+ sine = gSineTable[angle + 0x40];
+ if (sine < 0) {
+ sine += 0x1f;
+ }
+
+ sound->y.HALF.HI -= sine >> 5;
+ }
+ }
+ }
+
+ if (this->field_0x43) {
+ sub_0804A9FC(this, 0x1c);
+ }
+
+ sub_0804AA30(this, gUnk_080D0110);
+}
+
+void sub_0803C820(Entity *this) {
+ if (sub_0806F520(this)) {
+ gUnk_080D0148[this->previousActionFlag](this);
+ }
+}
+
+void sub_0803C844(Entity *this) {
+ this->previousActionFlag = 1;
+ this->field_0x1d = 0x3c;
+}
+
+void sub_0803C850(Entity *this) {
+ Entity *cloud = this->attachedEntity;
+ if (cloud != 0) {
+ cloud->spriteOffsetX = this->spriteOffsetX;
+ }
+
+ sub_0806F4E8(this);
+}
+
+void sub_0803C86C(Entity *this) {
+ sub_0803CBAC(this);
+ this->attachedEntity = 0;
+}
+
+void sub_0803C87C(Entity *this) {
+ Entity *cloud = sub_0804A98C(this, 17, 0);
+ if (cloud == 0) {
+ return;
+ }
+
+ cloud->parent = this;
+ this->attachedEntity = cloud;
+
+ sub_0804A720(this);
+
+ this->action = 1;
+
+ this->height.HALF.HI = -2;
+
+ this->spriteOffsetY = 0xff;
+
+ this->field_0x74 = this->x.HALF.HI;
+ this->field_0x76 = this->y.HALF.HI;
+}
+
+void sub_0803C8BC(Entity *this) {
+ sub_0803CA84(this, 0);
+
+ if (sub_0803CA4C(this)) {
+ this->action = 2;
+ this->spriteSettings.b.draw = 1;
+ }
+}
+
+void sub_0803C8E4(Entity *this) {
+ UpdateAnimationSingleFrame(this);
+
+ if (this->frames.b.f3) {
+ this->action = 3;
+ this->actionDelay = 0x3c;
+
+ this->damageType = 0x42;
+
+ InitAnimationForceUpdate(this, this->animationState + 4);
+ }
+}
+
+void sub_0803C918(Entity *this) {
+ if (sub_0803CB04(this) != 0) {
+ return;
+ }
+
+ if (sub_0803CA4C(this) == 0) {
+ this->action = 4;
+
+ this->damageType = 0x43;
+ InitAnimationForceUpdate(this, this->animationState + 0xc);
+ }
+ else {
+ sub_0803CA84(this, 4);
+ }
+}
+
+void sub_0803C950(Entity *this) {
+ UpdateAnimationSingleFrame(this);
+
+ if (this->frames.b.f3 != 0) {
+ this->action = 1;
+ this->spriteSettings.b.draw = 0;
+
+ InitAnimationForceUpdate(this, this->animationState);
+ }
+}
+
+void sub_0803C97C(Entity *this) {
+ UpdateAnimationSingleFrame(this);
+
+ if (this->frames.b.f3 == 0) {
+ return;
+ }
+
+ sub_0803CB64(this);
+ this->action = 6;
+ this->damageType = 0x42;
+
+
+ if ((Random() & 1) && this->field_0x78.HALF.HI == 0) {
+ this->actionDelay = 0xf;
+ this->field_0x78.HALF.HI = 1;
+ }
+ else {
+ this->actionDelay = 0x1e;
+ this->field_0x78.HALF.HI = 0;
+
+ InitAnimationForceUpdate(this->attachedEntity, this->animationState);
+ }
+}
+
+void sub_0803C9D4(Entity *this) {
+ this->actionDelay--;
+
+ if (this->actionDelay != 0) {
+ return;
+ }
+
+ if (this->field_0x78.HALF.HI == 1) {
+ sub_0803CB34(this);
+ }
+ else {
+ this->action = 3;
+ this->actionDelay = 0xb4;
+
+ InitAnimationForceUpdate(this, this->animationState + 4);
+ }
+}
+
+void sub_0803CA0C(Entity *this) {
+ if (sub_08003FC4(this, 0x1800) == 0 && this->animIndex <= 19) {
+ InitAnimationForceUpdate(this, this->animationState + 20);
+
+ this->spritePriority.b1 = 0;
+ }
+
+ UpdateAnimationSingleFrame(this);
+ sub_0803CC08(this);
+}
+
+bool32 sub_0803CA4C(Entity *this) {
+ if (sub_0806FCB8(this, gLinkEntity.x.HALF.HI, gLinkEntity.y.HALF.HI, 0x28) == 0) {
+ if (sub_080041A0(this, &gLinkEntity, 0x70, 0x50)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void sub_0803CA84(Entity *this, u32 unkParameter) {
+ u32 altAnimState = GetFacingDirection(this, &gLinkEntity);
+
+ if (((altAnimState - 3) & 7) > 2 || ((this->animationState - (altAnimState >> 3)) & 3) > 1) {
+ u32 intermediate = (altAnimState + 4) & 0x18;
+ altAnimState = intermediate >> 3;
+
+ if (altAnimState != this->animationState) {
+ this->animationState = altAnimState;
+
+ InitAnimationForceUpdate(this, altAnimState + unkParameter);
+ InitAnimationForceUpdate(this->attachedEntity, altAnimState);
+ }
+ }
+}
+
+void sub_0803CAD0(Entity *this) {
+ if (sub_0806FCB8(this, this->field_0x74, this->field_0x76, 1) == 0) {
+ this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74, this->field_0x76);
+
+ sub_080AEFE0(this);
+ }
+}
+
+bool32 sub_0803CB04(Entity *this) {
+ bool32 returnValue;
+ u8 delay;
+
+ delay = --this->actionDelay;
+ if (delay != 0) {
+ returnValue = 0;
+ }
+ else {
+ sub_0803CB34(this);
+ this->field_0x78.HALF.HI = delay;
+
+ InitAnimationForceUpdate(this->attachedEntity, this->animationState + 4);
+ returnValue = 1;
+ }
+
+ return returnValue;
+}
+
+void sub_0803CB34(Entity *this) {
+ this->action = 5;
+ this->damageType = 0xa6;
+
+ this->field_0x78.HALF.LO = GetFacingDirection(this, &gLinkEntity);
+
+ InitAnimationForceUpdate(this, this->animationState + 8);
+}
+
+void sub_0803CB64(Entity *this) {
+ Entity *cloud;
+ const OffsetCoords *offset;
+
+ cloud = sub_0804A98C(this, 18, 0);
+
+ if (cloud == 0) {
+ return;
+ }
+
+ offset = &gUnk_080D0154[this->animationState];
+
+ cloud->direction = this->field_0x78.HALF.LO;
+
+ PositionRelative(this, cloud, offset->x << 16, offset->y << 16);
+
+ sub_08004488(0x193);
+}
+
+void sub_0803CBAC(Entity *this) {
+ Entity *cloud;
+
+ cloud = this->attachedEntity;
+ if (cloud != 0) {
+ cloud->flags |= 0x80;
+ cloud->damageType = 0x43;
+ }
+
+ this->action = 7;
+ this->spriteSettings.b.draw = 1;
+
+ this->spritePriority.b1 = 1;
+
+ this->flags2 &= 0x7b;
+
+ this->damageType = 0x42;
+
+ InitAnimationForceUpdate(this, this->animationState + 16);
+}
+
+void sub_0803CC08(Entity *this) {
+ Entity *cloud;
+ Entity *sound;
+
+ cloud = this->attachedEntity;
+ if (cloud == 0) {
+ return;
+ }
+
+ if ((u32)(cloud->height.HALF.HI - this->height.HALF.HI) > 2) {
+ return;
+ }
+
+ if (this->field_0x20 >= 0) {
+ return;
+ }
+
+ if (!sub_0806FCB8(this, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
+ return;
+ }
+
+ sound = CreateFx(this, 2, 0);
+ if (sound != 0) {
+ sound->x.HALF.HI += 6;
+ sound->y.HALF.HI += 6;
+ }
+
+ sound = CreateFx(this, 2, 0);
+ if (sound != 0) {
+ sound->x.HALF.HI -= 6;
+ sound->y.HALF.HI += 6;
+ }
+
+ sound = CreateFx(this, 2, 0);
+ if (sound != 0) {
+ sound->x.HALF.HI += 6;
+ sound->y.HALF.HI -= 6;
+ }
+
+ sound = CreateFx(this, 2, 0);
+ if (sound != 0) {
+ sound->x.HALF.HI -= 6;
+ sound->y.HALF.HI -= 6;
+ }
+
+ this->attachedEntity = 0;
+ DeleteEntity(cloud);
+} \ No newline at end of file
diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c
new file mode 100644
index 00000000..0dca3465
--- /dev/null
+++ b/src/enemy/lakituCloud.c
@@ -0,0 +1,150 @@
+#include "global.h"
+#include "entity.h"
+#include "link.h"
+
+extern u32 GetNextFunction(Entity *);
+
+extern void (* const gUnk_080D0418[])(Entity *);
+extern void (* const gUnk_080D0430[])(Entity *);
+extern void (* const gUnk_080D043C[])(Entity *);
+
+extern bool32 sub_0806F3E4(Entity *);
+extern bool32 sub_0806F520(Entity *);
+
+extern void sub_0800449C(Entity *, u32);
+extern void sub_0803CE14(Entity *);
+extern void sub_0803CE3C(Entity *);
+extern Entity *GetCurrentRoomProperty(u8);
+extern void sub_0806F4E8(Entity *);
+extern void sub_0806F69C(Entity *);
+extern void sub_08079D84(void);
+extern void sub_080A2CC0(Entity *, Entity **, u16 *);
+
+void LakituCloud(Entity *this) {
+ gUnk_080D0418[GetNextFunction(this)](this);
+}
+
+void sub_0803CCD4(Entity *this) {
+ gUnk_080D0430[this->action](this);
+}
+
+void sub_0803CCEC(Entity *this) {
+ this->field_0x42 = 0;
+ sub_0803CCD4(this);
+}
+
+void sub_0803CCFC(Entity *this) {
+ if (sub_0806F520(this) == 0) {
+ if (this->previousActionFlag == 2) {
+ sub_0803CE3C(this);
+ }
+ }
+ else {
+ gUnk_080D043C[this->previousActionFlag](this);
+ }
+}
+
+void sub_0803CD2C(Entity *this) {
+ this->previousActionFlag = 1;
+ this->field_0x1d = 0x3c;
+}
+
+void sub_0803CD38(Entity *this) {
+ sub_0806F4E8(this);
+}
+
+void sub_0803CD40(Entity *this) {
+ if (!sub_0806F3E4(this)) {
+ return;
+ }
+
+ ModHealth(-2);
+
+ sub_0800449C(&gLinkEntity, 122);
+ sub_08079D84();
+
+ sub_0803CE3C(this);
+}
+
+void sub_0803CD6C(Entity *this) {
+ Entity *lakitu;
+
+ this->action = 1;
+ this->height.HALF.HI = -2;
+
+ // Set parent to lakitu
+ lakitu = GetCurrentRoomProperty(this->entityType.form);
+ this->attachedEntity = lakitu;
+ this->parent = lakitu;
+
+ this->field_0x78.HWORD = this->x.HALF.HI;
+ this->field_0x7a = this->y.HALF.HI;
+
+ InitAnimationForceUpdate(this, 4);
+
+ sub_0803CE14(this);
+}
+
+void sub_0803CDA8(Entity *this) {
+ UpdateAnimationSingleFrame(this);
+
+ if ((this->direction & 0x80) == 0) {
+ sub_0806F69C(this);
+ }
+
+ if (--this->field_0x74 << 0x10 == 0) {
+ sub_0803CE14(this);
+ }
+}
+
+void sub_0803CDD8(Entity *this) {
+ u8 one;
+ u8 draw;
+
+ draw = this->spriteSettings.b.draw;
+ one = 1;
+ this->spriteSettings.b.draw = draw ^ one;
+
+ this->actionDelay--;
+
+ if (this->actionDelay == 0) {
+ this->action = 1;
+
+ this->flags |= 0x80;
+
+ this->spriteSettings.b.draw = one;
+ }
+}
+
+void sub_0803CE14(Entity *this) {
+ u8 direction;
+
+ sub_080A2CC0(this, &this->attachedEntity, &this->field_0x74);
+
+ direction = this->direction;
+ if (direction & 0x80) {
+ return;
+ }
+
+ direction = direction / 8 + 4;
+
+ InitAnimationForceUpdate(this, direction);
+}
+
+void sub_0803CE3C(Entity *this) {
+ CreateFx(this, 2, 0);
+
+ this->action = 2;
+ this->actionDelay = 60;
+
+ this->flags &= 0x7f;
+
+ this->field_0x3a &= 0xfb;
+
+ this->x.HALF.HI = this->field_0x78.HWORD;
+ this->y.HALF.HI = this->field_0x7a;
+
+ this->attachedEntity = this->parent;
+
+ sub_0803CE14(this);
+}
diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c
new file mode 100644
index 00000000..d7bdc540
--- /dev/null
+++ b/src/enemy/miniFireballGuy.c
@@ -0,0 +1,61 @@
+#include "global.h"
+#include "entity.h"
+
+extern void EnemyFunctionHandler(Entity*, void (*const func[])(Entity*));
+extern void sub_0804AA30(Entity*, void (*const func[][])(Entity*));
+extern void sub_0804A7D4(Entity*);
+extern void sub_0804A720(Entity*);
+extern void sub_08045678(Entity*);
+extern void sub_080AEFE0(void);
+extern u32 sub_08003FC4(Entity*, u32);
+extern void sub_08045678(Entity*);
+
+extern void (*const gUnk_080D1868[])(Entity*);
+extern void (*const gUnk_080D1880[])(Entity*);
+
+void MiniFireballGuy(Entity *this)
+{
+ EnemyFunctionHandler(this, gUnk_080D1868);
+}
+
+void sub_080455BC(Entity *this)
+{
+ gUnk_080D1880[this->action](this);
+}
+
+void sub_080455D4(Entity *this)
+{
+ sub_0804AA30(this, &gUnk_080D1868);
+}
+
+void sub_080455E4(Entity *this)
+{
+ if ((this != this->parent) && (this->parent != NULL)) {
+ this->field_0x6c = this->field_0x6c & 0x7f;
+ this->parent->attachedEntity = this->attachedEntity;
+ this->attachedEntity->parent = this->parent;
+ }
+ sub_0804A7D4(this);
+}
+
+void nullsub_23(Entity* this) {}
+
+void sub_08045618(Entity *this)
+{
+ this->action = 1;
+ this->spriteSettings.b.draw = 1;
+ this->nonPlanarMovement = 0x80;
+ this->field_0x3c = this->field_0x3c | 0x10;
+ sub_0804A720(this);
+ InitializeAnimation(this, 1);
+ sub_08045678(this);
+}
+
+void sub_08045654(Entity *this)
+{
+ sub_080AEFE0();
+ GetNextFrame(this);
+ if (sub_08003FC4(this, 0x1800) == 0) {
+ sub_08045678(this);
+ }
+} \ No newline at end of file
diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c
new file mode 100644
index 00000000..ff699ec0
--- /dev/null
+++ b/src/enemy/octorok.c
@@ -0,0 +1,119 @@
+#include "global.h"
+#include "entity.h"
+
+extern void EnemyFunctionHandler();
+extern void SetChildOffset();
+extern void sub_0804AA30();
+extern void sub_0804A9FC();
+extern void sub_0804A7D4();
+extern void CreateDeathFx();
+extern void sub_0801ECFC();
+extern u32 sub_0806F520();
+extern void sub_0806F4E8();
+extern void sub_0806F3E4();
+extern void InitializeAnimationAnimation();
+extern void sub_0804A720();
+extern u32 Random();
+extern void sub_0801ED14();
+
+extern void(*gOctorok[2]);
+extern void (*gOctorokIdle[4])(Entity*);
+extern void (*gUnk_080CA158[4])(Entity*);
+
+extern u8 gUnk_080CA170[8];
+// Main
+void Octorok(Entity* ent) {
+ EnemyFunctionHandler(ent, gOctorok);
+ SetChildOffset(ent, 0, 1, -16);
+}
+
+// Idle
+void sub_0801EAD0(Entity* ent) {
+ gOctorokIdle[ent->action](ent);
+}
+
+// Touch player
+void sub_0801EAE8(Entity* ent) {
+ if (ent->field_0x43 != 0) {
+ sub_0804A9FC(ent, 28);
+ }
+ sub_0804AA30(ent, gOctorok);
+}
+
+// Death
+void sub_0801EB0C(Entity* ent) {
+ if ((ent->entityType).form == 0) {
+ sub_0804A7D4(ent);
+ } else {
+ CreateDeathFx(ent, 241, 0);
+ }
+}
+
+void sub_0801EB2C(Entity* ent) {
+ s32 iVar1;
+
+ if ((ent->previousActionFlag < 3) && (iVar1 = sub_0806F520(ent), iVar1 == 0)) {
+ sub_0801ECFC(ent);
+ InitializeAnimation(ent, ent->animationState);
+ } else {
+ gUnk_080CA158[ent->previousActionFlag](ent);
+ }
+}
+
+void sub_0801EB68(Entity* ent) {
+ ent->previousActionFlag = 1;
+ ent->filler[1] = 60;
+}
+
+void sub_0801EB74(Entity* ent) {
+ sub_0806F4E8(ent);
+}
+
+void sub_0801EB7C(Entity* ent) {
+ sub_0806F3E4(ent);
+}
+
+void sub_0801EB84(Entity* ent) {
+ ent->flags = ent->flags & 127;
+ InitializeAnimationAnimation(ent, 2);
+}
+
+void nullsub_3() {
+}
+
+void sub_0801EB9C(Entity* ent) {
+ if ((ent->flags & 128) != 0) {
+ ent->flags = ent->flags | 128;
+ ent->field_0x3a = ent->field_0x3a & 251;
+ } else {
+ ent->currentHealth = 0;
+ }
+}
+
+// Init
+#ifdef NON_MATCHING
+void sub_0801EBC8(Entity* ent) {
+ sub_0804A720();
+ ent->animationState = (ent->entityType).form == 2 ? (ent->entityType).form : Random() & 3;
+ ent->filler[0] = 18;
+ sub_0801ECFC(ent);
+ InitializeAnimation(ent, ent->animationState);
+}
+#else
+NAKED
+void sub_0801EBC8(Entity* ent) {
+ asm(".include \"asm/octorok/sub_0801EBC8.inc\"");
+}
+#endif
+
+void sub_0801EBF4(Entity* ent) {
+ u32 uVar2;
+
+ if (--ent->actionDelay == 0) {
+ ent->action = 2;
+ uVar2 = Random();
+ ent->actionDelay = gUnk_080CA170[uVar2 & 3];
+ sub_0801ED14(ent);
+ }
+ GetNextFrame(ent);
+}
diff --git a/src/enemy/slime.c b/src/enemy/slime.c
new file mode 100644
index 00000000..42a5d952
--- /dev/null
+++ b/src/enemy/slime.c
@@ -0,0 +1,167 @@
+#include "global.h"
+#include "entity.h"
+
+typedef struct {
+ void* field_0x0;
+ void* entityCount;
+ u8 freezeTime;
+} EntityHandler;
+
+extern void EnemyFunctionHandler(Entity*, void*);
+extern void SetChildOffset(Entity*, u32, u32, u32);
+extern void sub_0804AA30(Entity*, void*);
+extern void sub_0804A9FC(Entity*, u32);
+extern void sub_0804A720(Entity*);
+extern void sub_08044FF8(Entity*);
+extern u32 Random(void);
+extern u32 sub_0806FA04(u32, u32);
+extern u32 sub_08049FA0(Entity*);
+extern u32 sub_08049EE4(Entity*);
+extern u32 sub_080AEF88(void);
+
+extern void (*gUnk_080D16BC[])(Entity*);
+extern void (*gUnk_080D16A4[])(Entity*);
+
+extern u8 gUnk_080D16D0;
+extern EntityHandler gUnk_03003DB8;
+
+void Slime(Entity* this)
+
+{
+ EnemyFunctionHandler(this, &gUnk_080D16A4);
+ SetChildOffset(this, 0, 1, -12);
+}
+
+void sub_08044F70(Entity* this) {
+ gUnk_080D16BC[this->action](this);
+}
+
+void sub_08044F88(Entity* this) {
+ if ((this->currentHealth != 0) && (this->cutsceneBeh.HALF.LO != this->currentHealth)) {
+ this->action = 4;
+ } else {
+ sub_0804AA30(this, &gUnk_080D16A4);
+ }
+
+ if (this->field_0x43 != 0) {
+ sub_0804A9FC(this, 28);
+ }
+}
+
+void nullsub_171() {
+}
+
+void sub_08044FC8(Entity* this) {
+ this->action = 1;
+ this->spriteSettings.b.draw = 1;
+ this->nonPlanarMovement = 128;
+ sub_0804A720(this);
+ InitializeAnimation(this, 0);
+ sub_08044FF8(this);
+}
+
+void sub_08044FF8(Entity* this) {
+ u32 bVar1;
+
+ this->action = 2;
+ bVar1 = Random();
+ this->actionDelay = (bVar1 & 31) + 30;
+ this->cutsceneBeh.HALF.LO = this->currentHealth;
+}
+
+void sub_08045018(Entity* this) {
+ u32 cVar1;
+ u32 param3;
+ u32 iVar3;
+ u32 randValue;
+
+ GetNextFrame(this);
+ param3 = this->actionDelay -= 1;
+ if (param3 == 0) {
+ this->action = 3;
+ this->actionDelay = 1;
+ if (0 < this->nonPlanarMovement) {
+ this->actionDelay = sub_0806FA04(4096, this->nonPlanarMovement) >> 8;
+ }
+ iVar3 = sub_08049FA0(this);
+ if ((iVar3 == 0) && (randValue = Random(), (randValue & 3) != 0)) {
+ cVar1 = sub_08049EE4(this);
+ this->direction = (cVar1 + 0xfc + (Random() & 8)) & 24;
+ return;
+ }
+ this->direction = Random() & 24;
+ }
+}
+
+void sub_08045088(Entity* this) {
+ u8 bVar1;
+
+ sub_080AEF88();
+ GetNextFrame(this);
+ bVar1 = this->actionDelay -= 1;
+ if (bVar1 == 0) {
+ this->action = 1;
+ }
+}
+
+#ifdef NON_MATCHING
+void sub_080450A8(Entity* this)
+
+{
+ u8 bVar1;
+ u32 uVar2;
+ s32 iVar3;
+ s32 iVar4;
+ Entity* pEVar5;
+ Entity** ppEVar6;
+ s32 dividend;
+ u32 uVar7;
+ Entity* local_r6_72;
+ u32 divisor;
+ u8* pcVar8;
+ Entity* local_2c[4];
+
+ ppEVar6 = local_2c;
+ bVar1 = (&gUnk_080D16D0)[(this->entityType).form];
+ divisor = (u32)bVar1;
+ if ((int)gUnk_03003DB8.entityCount < (int)(72 - divisor)) {
+ uVar7 = divisor;
+ if (bVar1 != 0) {
+ do {
+ uVar2 = CreateEnemy(87, this->entityType.form);
+ *ppEVar6 = uVar2;
+ ppEVar6 = ppEVar6 + 1;
+ uVar7 = uVar7 - 1;
+ } while (uVar7 != 0);
+ }
+ pcVar8 = "\x06";
+ iVar4 = 0;
+ if (bVar1 != 0) {
+ do {
+ local_r6_72 = local_2c[iVar4];
+ dividend = iVar4 + 1;
+ iVar3 = Div(dividend, divisor);
+ local_r6_72->attachedEntity = local_2c[iVar3];
+ iVar4 = Div(iVar4 + divisor + -1, divisor);
+ local_r6_72->parent = local_2c[iVar4];
+ (local_r6_72->entityType).parameter = 1;
+ local_r6_72->height.WORD = 0;
+ local_r6_72->hurtBlinkTime = 240;
+ sub_08045178(this, local_r6_72, *pcVar8, pcVar8[1]);
+ pcVar8 = pcVar8 + 2;
+ iVar4 = dividend;
+ } while (dividend < divisor);
+ }
+ pEVar5 = CreateFx(this, 2, 0);
+ if (pEVar5 != NULL) {
+ CopyPosition(this, pEVar5);
+ }
+ DeleteEnemy(this);
+ }
+}
+#else
+NAKED
+void sub_080450A8(Entity* this) {
+ asm(".include \"asm/non_matching/slime/sub_080450A8.inc\"");
+}
+#endif
diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c
new file mode 100644
index 00000000..c29fe80c
--- /dev/null
+++ b/src/enemy/smallPesto.c
@@ -0,0 +1,68 @@
+#include "global.h"
+#include "entity.h"
+
+extern u32 GetNextFunction(Entity*);
+extern u32 sub_0806F520(Entity*);
+extern void sub_0806F4E8(Entity*);
+extern u32 sub_0806F3E4();
+extern void sub_0804A7D4(Entity*);
+extern void sub_0804A720(Entity*);
+extern void sub_080317F8(Entity*);
+
+extern void (*gUnk_080CE530[])(Entity*);
+extern void (*gUnk_080CE548[])(Entity*);
+extern void (*gUnk_080CE554[])(Entity*);
+
+void SmallPesto(Entity *this)
+{
+ gUnk_080CE530[GetNextFunction(this)](this);
+}
+
+void sub_08031680(Entity *this)
+{
+ gUnk_080CE548[this->action](this);
+}
+
+void nullsub_152(){}
+
+void sub_0803169C(Entity *this)
+{
+ s32 iVar1;
+
+ GetNextFrame(this);
+ iVar1 = sub_0806F520(this);
+ if (iVar1 == 0) {
+ this->action = 1;
+ this->previousActionFlag = 0;
+ this->flags = this->flags | 0x80;
+ this->nonPlanarMovement = 0x40;
+ this->field_0xf = 1;
+ }
+ else {
+ gUnk_080CE554[this->previousActionFlag](this);
+ }
+}
+
+void sub_080316DC(Entity *this)
+{
+ this->previousActionFlag = 1;
+ this->filler[1] = 0x3c;
+}
+
+void sub_080316E8(Entity *this)
+{
+ sub_0806F4E8(this);
+}
+
+void sub_080316F0(Entity *this)
+{
+ if (sub_0806F3E4()) {
+ sub_0804A7D4(this);
+ }
+}
+
+void sub_08031704(Entity *this)
+{
+ sub_0804A720(this);
+ sub_080317F8(this);
+}