summaryrefslogtreecommitdiff
path: root/src/npc/cat.c
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2023-07-05 21:34:08 +0200
committeroctorock <79596758+octorock@users.noreply.github.com>2023-08-01 11:36:11 +0200
commit488196754ea5225513dc900d23c53f2b157de409 (patch)
treec69039d9643265381dddb27cca929cbea6dfb936 /src/npc/cat.c
parent0d6b9052bacc3bbe079df0bcf25ac633ed4df073 (diff)
Create new entity structs for NPCs
Diffstat (limited to 'src/npc/cat.c')
-rw-r--r--src/npc/cat.c330
1 files changed, 170 insertions, 160 deletions
diff --git a/src/npc/cat.c b/src/npc/cat.c
index 2212a039..14927657 100644
--- a/src/npc/cat.c
+++ b/src/npc/cat.c
@@ -4,6 +4,7 @@
*
* @brief Cat NPC
*/
+#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
@@ -11,30 +12,44 @@
#include "npc.h"
#include "save.h"
+typedef struct {
+ /*0x00*/ Entity base;
+ /*0x68*/ u8 fusionOffer;
+ /*0x69*/ u8 unk_69;
+ /*0x6a*/ u8 unused[2];
+ /*0x6c*/ u16 unk_6c;
+ /*0x6e*/ u16 unk_6e;
+ /*0x70*/ u8 unk_70;
+ /*0x71*/ u8 unk_71;
+ /*0x72*/ u16 unk_72;
+ /*0x74*/ u8 unk_74;
+ /*0x75*/ u8 unk_75;
+} CatEntity;
+
static const Hitbox gUnk_08110EF0 = { 0, -1, { 5, 3, 3, 5 }, 5, 4 };
-void sub_08067C44(Entity*);
-void sub_08067B08(Entity*);
-u32 sub_08067D20(Entity*);
-void sub_08067AAC(Entity*);
-void sub_08067B34(Entity*);
-void sub_08067B80(Entity*, u32);
-void sub_08067B70(Entity*);
-void sub_08067C24(Entity*);
+void sub_08067C44(CatEntity*);
+void sub_08067B08(CatEntity*);
+bool32 sub_08067D20(CatEntity*);
+void sub_08067AAC(CatEntity*);
+void sub_08067B34(CatEntity*);
+void sub_08067B80(CatEntity*, u32);
+void sub_08067B70(CatEntity*);
+void sub_08067C24(CatEntity*);
void sub_08067BD4(Entity*);
-u32 sub_08067D74(Entity*);
+bool32 sub_08067D74(Entity*);
void sub_08067C18(Entity*);
-void sub_08067DCC(Entity*, u32);
+void sub_08067DCC(CatEntity*, u32);
void sub_08067DDC(Entity*);
-void sub_080677EC(Entity*);
-void sub_080678AC(Entity*);
-void sub_08067904(Entity*);
-void sub_0806797C(Entity*);
-void sub_0806799C(Entity*);
-void sub_080679C4(Entity*);
-void sub_08067A0C(Entity*);
-void sub_08067A78(Entity*);
-void sub_08067A98(Entity*);
+void sub_080677EC(CatEntity*);
+void sub_080678AC(CatEntity*);
+void sub_08067904(CatEntity*);
+void sub_0806797C(CatEntity*);
+void sub_0806799C(CatEntity*);
+void sub_080679C4(CatEntity*);
+void sub_08067A0C(CatEntity*);
+void sub_08067A78(CatEntity*);
+void sub_08067A98(CatEntity*);
extern Hitbox* gUnk_08111154[8];
@@ -105,159 +120,154 @@ void sub_08067790(Entity* this) {
}
// Main
-void Cat(Entity* ent) {
- static void (*const actionFuncs[9])(Entity*) = {
+void Cat(CatEntity* this) {
+ static void (*const actionFuncs[9])(CatEntity*) = {
sub_080677EC, sub_080678AC, sub_08067904, sub_0806797C, sub_0806799C,
sub_080679C4, sub_08067A0C, sub_08067A78, sub_08067A98,
};
- actionFuncs[ent->action](ent);
- sub_08067C44(ent);
- if (((ent->flags & ENT_COLLIDE) == 0) && (ent->type != 5)) {
- sub_0806ED78(ent);
+ actionFuncs[super->action](this);
+ sub_08067C44(this);
+ if (((super->flags & ENT_COLLIDE) == 0) && (super->type != 5)) {
+ sub_0806ED78(super);
}
}
-void sub_080677EC(Entity* this) {
+void sub_080677EC(CatEntity* this) {
u32 uVar2;
- this->spriteSettings.draw = 1;
- this->direction = 8;
- this->speed = 0x80;
- this->collisionFlags = 7;
- this->hurtType = 0x48;
- this->hitType = -0x58;
- this->flags2 = 1;
- this->field_0x68.HALF.HI = 0xff;
- if (this->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
- this->spriteSettings.flipX = 1;
+ super->spriteSettings.draw = 1;
+ super->direction = 8;
+ super->speed = 0x80;
+ super->collisionFlags = 7;
+ super->hurtType = 0x48;
+ super->hitType = -0x58;
+ super->flags2 = 1;
+ this->unk_69 = 0xff;
+ if (super->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
+ super->spriteSettings.flipX = 1;
} else {
- this->spriteSettings.flipX = 0;
+ super->spriteSettings.flipX = 0;
}
- this->field_0x68.HALF.LO = GetFusionToOffer(this);
- this->hitbox = (Hitbox*)&gUnk_08110EF0;
- uVar2 = sub_0805ACC0(this);
+ this->fusionOffer = GetFusionToOffer(super);
+ super->hitbox = (Hitbox*)&gUnk_08110EF0;
+ uVar2 = sub_0805ACC0(super);
if (uVar2 == 0) {
- uVar2 = this->x.HALF.HI;
+ uVar2 = super->x.HALF.HI;
} else {
uVar2 >>= 0x10;
}
- this->field_0x6c.HWORD = uVar2;
- this->field_0x6e.HWORD = this->timer + uVar2;
- this->timer = 0;
- this->field_0x74.HALF.HI = 0;
- this->field_0x74.HALF.LO = (Random() & 0x7f) + 0x1e;
- this->field_0x68.HALF.HI = 0xff;
+ this->unk_6c = uVar2;
+ this->unk_6e = super->timer + uVar2;
+ super->timer = 0;
+ this->unk_75 = 0;
+ this->unk_74 = (Random() & 0x7f) + 0x1e;
+ this->unk_69 = 0xff;
sub_08067B08(this);
}
-void sub_080678AC(Entity* this) {
- u32 iVar1;
- u16* psVar2;
-
- iVar1 = sub_08067D20(this);
- if (iVar1 != 0) {
+void sub_080678AC(CatEntity* this) {
+ if (sub_08067D20(this)) {
sub_08067B80(this, 5);
} else {
- psVar2 = (u16*)&this->field_0x70.HALF.HI;
- if (*psVar2 != 0) {
- *psVar2 = *psVar2 - 1;
+ if (this->unk_72 != 0) {
+ this->unk_72--;
}
- if ((this->frame == 1) && (*psVar2 == 0)) {
+ if ((super->frame == 1) && (this->unk_72 == 0)) {
sub_08067AAC(this);
} else {
- UpdateAnimationSingleFrame(this);
- if ((this->frame & ANIM_DONE) != 0) {
+ UpdateAnimationSingleFrame(super);
+ if ((super->frame & ANIM_DONE) != 0) {
sub_08067B34(this);
}
}
}
}
-void sub_08067904(Entity* this) {
+void sub_08067904(CatEntity* this) {
if (sub_08067D20(this) != 0) {
sub_08067B80(this, 8);
return;
}
- this->field_0x70.HALF.HI--;
- if (this->field_0x70.HALF.HI == 0) {
+ this->unk_72--;
+ if (this->unk_72 == 0) {
sub_08067B70(this);
return;
}
- if (this->direction == 8) {
- if (this->x.HALF.HI > this->field_0x6e.HWORD) {
- this->direction = 0x18;
- this->spriteSettings.flipX = 0;
+ if (super->direction == 8) {
+ if (super->x.HALF.HI > this->unk_6e) {
+ super->direction = 0x18;
+ super->spriteSettings.flipX = 0;
}
} else {
- if (this->x.HALF.HI < this->field_0x6c.HWORD) {
- this->direction = 8;
- this->spriteSettings.flipX = 1;
+ if (super->x.HALF.HI < this->unk_6c) {
+ super->direction = 8;
+ super->spriteSettings.flipX = 1;
}
}
- LinearMoveUpdate(this);
- UpdateAnimationSingleFrame(this);
+ LinearMoveUpdate(super);
+ UpdateAnimationSingleFrame(super);
}
-void sub_0806797C(Entity* this) {
- UpdateAnimationSingleFrame(this);
- if (this->frame & ANIM_DONE) {
+void sub_0806797C(CatEntity* this) {
+ UpdateAnimationSingleFrame(super);
+ if (super->frame & ANIM_DONE) {
sub_08067B08(this);
}
}
-void sub_0806799C(Entity* this) {
- UpdateAnimationSingleFrame(this);
+void sub_0806799C(CatEntity* this) {
+ UpdateAnimationSingleFrame(super);
if ((gMessage.doTextBox & 0x7f) == 0) {
sub_08067B08(this);
- SetDefaultPriority(this, PRIO_PLAYER);
+ SetDefaultPriority(super, PRIO_PLAYER);
}
}
-void sub_080679C4(Entity* this) {
- if (this->field_0x74.HALF.LO == 0 || --this->field_0x74.HALF.LO == 0 || sub_08067D20(this) == 0) {
+void sub_080679C4(CatEntity* this) {
+ if (this->unk_74 == 0 || --this->unk_74 == 0 || sub_08067D20(this) == 0) {
sub_08067C24(this);
} else {
- UpdateAnimationSingleFrame(this);
- sub_08067BD4(this);
- if (sub_08067D74(this) != 0) {
- sub_08067C18(this);
+ UpdateAnimationSingleFrame(super);
+ sub_08067BD4(super);
+ if (sub_08067D74(super) != 0) {
+ sub_08067C18(super);
}
}
}
-void sub_08067A0C(Entity* this) {
+void sub_08067A0C(CatEntity* this) {
u8 tmp;
- UpdateAnimationSingleFrame(this);
- if (this->frame & ANIM_DONE) {
- if (sub_08067D20(this) != 0) {
+ UpdateAnimationSingleFrame(super);
+ if (super->frame & ANIM_DONE) {
+ if (sub_08067D20(this)) {
sub_08067B80(this, 5);
- this->timer += 20;
+ super->timer += 20;
} else {
sub_08067C24(this);
}
} else {
- tmp = (this->frame & 7);
+ tmp = (super->frame & 7);
if (tmp != 0) {
- COLLISION_ON(this);
- this->hitbox = gUnk_08111154[tmp - 1 + ((this->spriteSettings.flipX << 2))];
+ COLLISION_ON(super);
+ super->hitbox = gUnk_08111154[tmp - 1 + ((super->spriteSettings.flipX << 2))];
} else {
- sub_08067DDC(this);
+ sub_08067DDC(super);
}
}
}
-void sub_08067A78(Entity* this) {
- UpdateAnimationSingleFrame(this);
- if (this->frame & ANIM_DONE) {
+void sub_08067A78(CatEntity* this) {
+ UpdateAnimationSingleFrame(super);
+ if (super->frame & ANIM_DONE) {
sub_08067AAC(this);
}
}
-void sub_08067A98(Entity* this) {
- if (UpdateFuseInteraction(this) != 0) {
+void sub_08067A98(CatEntity* this) {
+ if (UpdateFuseInteraction(super) != 0) {
sub_08067B08(this);
}
}
@@ -279,43 +289,43 @@ static const u16 gUnk_08111104[] = {
static const u8 gUnk_0811110C[] = { 0x3c, 0x96, 0x14 };
static const u8 gUnk_0811110F[] = { 0, -4, 8, 8, 0 };
-void sub_08067AAC(Entity* this) {
- this->action = 2;
- this->field_0x70.HALF.HI = gUnk_081110FC[(Random() & 3)];
+void sub_08067AAC(CatEntity* this) {
+ super->action = 2;
+ this->unk_72 = gUnk_081110FC[(Random() & 3)];
- this->spriteSettings.flipX = this->direction >> 4 ^ 1;
+ super->spriteSettings.flipX = super->direction >> 4 ^ 1;
sub_08067DCC(this, 3);
- SetInteractableObjectCollision(this, 0, gUnk_0811110C[2], gUnk_0811110F);
+ SetInteractableObjectCollision(super, 0, gUnk_0811110C[2], gUnk_0811110F);
}
-void sub_08067B08(Entity* this) {
- this->action = 1;
- this->field_0x70.HALF.HI = gUnk_08111104[Random() & 3];
+void sub_08067B08(CatEntity* this) {
+ super->action = 1;
+ this->unk_72 = gUnk_08111104[Random() & 3];
sub_08067B34(this);
}
-void sub_08067B34(Entity* this) {
+void sub_08067B34(CatEntity* this) {
sub_08067DCC(this, 0);
- this->frameDuration = (Random() & 0x30) + 0xb4;
- SetInteractableObjectCollision(this, 0, gUnk_0811110C[this->spriteSettings.flipX], gUnk_0811110F);
+ super->frameDuration = (Random() & 0x30) + 0xb4;
+ SetInteractableObjectCollision(super, 0, gUnk_0811110C[super->spriteSettings.flipX], gUnk_0811110F);
}
-void sub_08067B70(Entity* this) {
- this->action = 3;
+void sub_08067B70(CatEntity* this) {
+ super->action = 3;
sub_08067DCC(this, 4);
}
-void sub_08067B80(Entity* this, u32 param) {
- this->action = 5;
- this->timer = 20;
- this->field_0x74.HALF.LO = (Random() & 0x7f) + 0x1e;
- InitAnimationForceUpdate(this, param);
- sub_08067DDC(this);
- if (this->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
- this->spriteSettings.flipX = 1;
+void sub_08067B80(CatEntity* this, u32 animIndex) {
+ super->action = 5;
+ super->timer = 20;
+ this->unk_74 = (Random() & 0x7f) + 0x1e;
+ InitAnimationForceUpdate(super, animIndex);
+ sub_08067DDC(super);
+ if (super->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
+ super->spriteSettings.flipX = 1;
} else {
- this->spriteSettings.flipX = 0;
+ super->spriteSettings.flipX = 0;
}
}
@@ -336,14 +346,14 @@ void sub_08067C18(Entity* this) {
InitAnimationForceUpdate(this, 6);
}
-void sub_08067C24(Entity* this) {
- this->action = 7;
- this->field_0x74.HALF.HI = 0x14;
- sub_08067DDC(this);
- InitAnimationForceUpdate(this, 7);
+void sub_08067C24(CatEntity* this) {
+ super->action = 7;
+ this->unk_75 = 0x14;
+ sub_08067DDC(super);
+ InitAnimationForceUpdate(super, 7);
}
-void sub_08067C44(Entity* this) {
+void sub_08067C44(CatEntity* this) {
s32 iVar4;
u32 uVar5;
@@ -353,78 +363,78 @@ void sub_08067C44(Entity* this) {
uVar5 = FALSE;
}
- if (uVar5 != this->field_0x68.HALF.HI) {
+ if (uVar5 != this->unk_69) {
if (uVar5 == 0) {
- AddInteractableWhenBigObject(this);
+ AddInteractableWhenBigObject(super);
} else {
- AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO);
+ AddInteractableAsMinishFuser(super, this->fusionOffer);
}
}
- this->field_0x68.HALF.HI = uVar5;
+ this->unk_69 = uVar5;
- if (this->interactType == 0) {
+ if (super->interactType == 0) {
return;
}
- iVar4 = sub_0806FCA0(this, &gPlayerEntity);
- switch (this->animIndex) {
+ iVar4 = sub_0806FCA0(super, &gPlayerEntity);
+ switch (super->animIndex) {
case 0:
default:
if (iVar4 == 2) {
- InitAnimationForceUpdate(this, 2);
+ InitAnimationForceUpdate(super, 2);
} else {
- InitAnimationForceUpdate(this, 1);
+ InitAnimationForceUpdate(super, 1);
}
break;
case 3:
if (iVar4 == 1) {
- this->spriteSettings.flipX = 1;
+ super->spriteSettings.flipX = 1;
} else {
- if (this->spriteSettings.flipX == 3) { // TODO 3 ???
- this->spriteSettings.flipX = 0;
+ if (super->spriteSettings.flipX == 3) { // TODO 3 ???
+ super->spriteSettings.flipX = 0;
}
}
if (iVar4 != 2) {
- InitAnimationForceUpdate(this, 1);
+ InitAnimationForceUpdate(super, 1);
} else {
- InitAnimationForceUpdate(this, 2);
+ InitAnimationForceUpdate(super, 2);
}
break;
}
- if (this->interactType == 2) {
- this->action = 8;
- sub_0806F118(this);
+ if (super->interactType == 2) {
+ super->action = 8;
+ InitializeNPCFusion(super);
} else {
- this->action = 4;
- sub_08067790(this);
- SetDefaultPriority(this, PRIO_MESSAGE);
+ super->action = 4;
+ sub_08067790(super);
+ SetDefaultPriority(super, PRIO_MESSAGE);
}
- this->interactType = 0;
+ super->interactType = 0;
SoundReq(SFX_VO_CAT);
}
-u32 sub_08067D20(Entity* this) {
+bool32 sub_08067D20(CatEntity* this) {
s32 tmp;
Entity* entity;
int iVar4;
- if (this->field_0x74.HALF.HI != 0) {
- this->field_0x74.HALF.HI--;
+ if (this->unk_75 != 0) {
+ this->unk_75--;
} else {
entity = sub_08049DF4(2);
if (entity != NULL) {
- iVar4 = this->spriteSettings.flipX ? 0x10 : 0x28;
- if (((u32)(entity->x.HALF.HI - (this->x.HALF.HI - iVar4)) < 0x31) &&
- ((((u32)entity->y.HALF.HI) - (this->y.HALF.HI - 4)) < 0x39)) {
- return 1;
+ iVar4 = super->spriteSettings.flipX ? 0x10 : 0x28;
+ if (((u32)(entity->x.HALF.HI - (super->x.HALF.HI - iVar4)) < 0x31) &&
+ ((((u32)entity->y.HALF.HI) - (super->y.HALF.HI - 4)) < 0x39)) {
+ return TRUE;
}
}
}
- return 0;
+ return FALSE;
}
-u32 sub_08067D74(Entity* this) {
+bool32 sub_08067D74(Entity* this) {
Entity* entity;
int iVar2;
@@ -438,16 +448,16 @@ u32 sub_08067D74(Entity* this) {
if ((((u32)(entity->x.HALF.HI - (this->x.HALF.HI - iVar2)) < 0x1f) &&
((u32)(entity->y.HALF.HI - this->y.HALF.HI) < 0x17)) &&
(this->timer == 0)) {
- return 1;
+ return TRUE;
}
}
}
- return 0;
+ return FALSE;
}
-void sub_08067DCC(Entity* this, u32 param) {
- this->field_0x70.BYTES.byte1 = param;
- InitAnimationForceUpdate(this, param);
+void sub_08067DCC(CatEntity* this, u32 animIndex) {
+ this->unk_71 = animIndex;
+ InitAnimationForceUpdate(super, animIndex);
}
void sub_08067DDC(Entity* this) {