Create new entity structs for enemies

This commit is contained in:
octorock 2023-12-30 18:12:05 +01:00
parent 242336c385
commit 33473d1d5b
45 changed files with 6013 additions and 5652 deletions

View File

@ -0,0 +1,20 @@
#ifndef VAATIWRATH_H
#define VAATIWRATH_H
#include "enemy.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[5];
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unused2[10];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unused3[1];
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unused4[4];
/*0x84*/ u8 unk_84;
} VaatiWrathEntity;
#endif // VAATIWRATH_H

View File

@ -62,8 +62,12 @@ void AcroBandit_Type1Action8(AcroBanditEntity* this);
void AcroBandit_Type1Action9(AcroBanditEntity* this);
static void (*const AcroBandit_Functions[])(AcroBanditEntity*) = {
AcroBandit_OnTick, AcroBandit_OnCollision, AcroBandit_OnKnockback,
(void (*)(AcroBanditEntity*))GenericDeath, (void (*)(AcroBanditEntity*))GenericConfused, AcroBandit_OnGrabbed,
AcroBandit_OnTick,
AcroBandit_OnCollision,
AcroBandit_OnKnockback,
(void (*)(AcroBanditEntity*))GenericDeath,
(void (*)(AcroBanditEntity*))GenericConfused,
AcroBandit_OnGrabbed,
};
void AcroBandit(AcroBanditEntity* this) {
@ -260,35 +264,35 @@ void AcroBandit_Type0Action5(AcroBanditEntity* this) {
u32 tmp = Random();
tmp &= 3;
a = (AcroBanditEntity*) CreateEnemy(ACRO_BANDIT, 1);
a = (AcroBanditEntity*)CreateEnemy(ACRO_BANDIT, 1);
a->base.type2 = 0;
a->base.parent = NULL;
a->unk_74.HALF.LO = tmp;
sub_08031E48(this, a);
a->base.child = CreateEnemy(ACRO_BANDIT, 1);
b = (AcroBanditEntity*) a->base.child;
b = (AcroBanditEntity*)a->base.child;
b->base.type2 = 1;
b->base.parent = &a->base;
b->unk_74.HALF.LO = tmp;
sub_08031E48(this, b);
b->base.child = CreateEnemy(ACRO_BANDIT, 1);
a = (AcroBanditEntity*) b->base.child;
a = (AcroBanditEntity*)b->base.child;
a->base.type2 = 2;
a->base.parent = &b->base;
a->unk_74.HALF.LO = tmp;
sub_08031E48(this, a);
a->base.child = CreateEnemy(ACRO_BANDIT, 1);
b = (AcroBanditEntity*) a->base.child;
b = (AcroBanditEntity*)a->base.child;
b->base.type2 = 3;
b->base.parent = &a->base;
b->unk_74.HALF.LO = tmp;
sub_08031E48(this, b);
b->base.child = CreateEnemy(ACRO_BANDIT, 1);
a = (AcroBanditEntity*) b->base.child;
a = (AcroBanditEntity*)b->base.child;
a->base.type2 = 4;
a->base.parent = &b->base;
a->base.child = NULL;

View File

@ -113,7 +113,7 @@ void sub_080218CC(BeetleEntity* this) {
super->subAction = 1;
super->spriteSettings.draw = 1;
super->direction = ((sub_08049F84(super, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) &
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
super->speed = 0x100;
super->zVelocity = Q_16_16(1.125);
}

View File

@ -242,7 +242,7 @@ void sub_0802AAC0(BombPeahatEntity* this) {
#ifdef EU
void sub_0802AB40(BombPeahatEntity* this) {
sub_0802AC40(super);
sub_0802AC40(this);
if (--super->timer == 0) {
if (this->unk_7a <= 4) {
super->action = 5;
@ -254,7 +254,7 @@ void sub_0802AB40(BombPeahatEntity* this) {
this->unk_80 ^= 1;
}
} else if (--super->subtimer == 0) {
sub_0802ACDC(super, 4);
sub_0802ACDC(this, 4);
}
}
#else
@ -432,7 +432,7 @@ void sub_0802AE68(BombPeahatEntity* this) {
this->unk_80 = 1;
}
if (entity->field_0x80.HALF.HI) {
if (((BombPeahatEntity*)entity)->unk_81) {
CopyPosition(entity, super);
super->z.HALF.HI += 8;
super->spriteSettings.draw = 0;
@ -440,7 +440,7 @@ void sub_0802AE68(BombPeahatEntity* this) {
super->action = 3;
this->unk_80 = 1;
super->spriteSettings.draw = 1;
if (sub_0802B234(super)) {
if (sub_0802B234(this)) {
super->spritePriority.b1 = 3;
} else {
super->spritePriority.b1 = 0;
@ -635,13 +635,13 @@ void sub_0802B1BC(BombPeahatEntity* this) {
super->spriteSettings.draw = 1;
}
if (entity->field_0x80.HALF.HI) {
if (((BombPeahatEntity*)entity)->unk_81) {
CopyPosition(entity, super);
super->z.HALF.HI += 8;
} else {
super->action = 2;
super->spriteSettings.draw = 1;
if (sub_0802B234(super)) {
if (sub_0802B234(this)) {
super->spritePriority.b1 = 3;
} else {
super->spritePriority.b1 = 0;

View File

@ -59,7 +59,6 @@ extern void (*const BusinessScrub_Functions[])(BusinessScrubEntity*);
extern void (*const BusinessScrub_Actions[])(BusinessScrubEntity*);
extern const u8 gUnk_080CCA04[];
void BusinessScrub(BusinessScrubEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)BusinessScrub_Functions);
}

View File

@ -8,7 +8,6 @@
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];

View File

@ -28,7 +28,12 @@ void FireballGuy_Action1(FireballGuyEntity*);
void FireballGuy_Action2(FireballGuyEntity*);
static void (*const FireballGuy_Functions[])(FireballGuyEntity*) = {
FireballGuy_OnTick, FireballGuy_OnCollision, (void (*)(FireballGuyEntity*))GenericKnockback, (void (*)(FireballGuyEntity*))GenericDeath, (void (*)(FireballGuyEntity*))GenericConfused, FireballGuy_OnGrabbed,
FireballGuy_OnTick,
FireballGuy_OnCollision,
(void (*)(FireballGuyEntity*))GenericKnockback,
(void (*)(FireballGuyEntity*))GenericDeath,
(void (*)(FireballGuyEntity*))GenericConfused,
FireballGuy_OnGrabbed,
};
void FireballGuy(FireballGuyEntity* this) {

View File

@ -30,7 +30,12 @@ void Keaton_Action4(KeatonEntity*);
void Keaton_Action5(KeatonEntity*);
static void (*const Keaton_Functions[])(KeatonEntity*) = {
Keaton_OnTick, Keaton_OnCollision, (void (*)(KeatonEntity*))GenericKnockback, (void (*)(KeatonEntity*))GenericDeath, (void (*)(KeatonEntity*))GenericConfused, Keaton_OnGrabbed,
Keaton_OnTick,
Keaton_OnCollision,
(void (*)(KeatonEntity*))GenericKnockback,
(void (*)(KeatonEntity*))GenericDeath,
(void (*)(KeatonEntity*))GenericConfused,
Keaton_OnGrabbed,
};
bool32 sub_080325E8(KeatonEntity* this);
@ -163,7 +168,8 @@ void Keaton_Action5(KeatonEntity* this) {
}
u32 sub_080325E8(KeatonEntity* this) {
if ((sub_08049FA0(super) && sub_08049FDC(super, 1)) && (EntityInRectRadius(super, gUnk_020000B0, 0x68, 0x40) != 0)) {
if ((sub_08049FA0(super) && sub_08049FDC(super, 1)) &&
(EntityInRectRadius(super, gUnk_020000B0, 0x68, 0x40) != 0)) {
if (((GetFacingDirection(super, gUnk_020000B0) - (DirectionRound(super->frame)) + 2) & 0x1F) < 5) {
super->action = 3;
super->timer = 12;

View File

@ -277,8 +277,7 @@ void sub_0803CA84(LakituEntity* this, u32 unkParameter) {
void sub_0803CAD0(LakituEntity* this) {
if (!EntityWithinDistance(super, this->unk_74, this->unk_76, 1)) {
super->direction =
CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_74, this->unk_76);
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_74, this->unk_76);
ProcessMovement2(super);
}
@ -403,7 +402,12 @@ void sub_0803CC08(LakituEntity* this) {
}
void (*const Lakitu_Functions[])(LakituEntity*) = {
Lakitu_OnTick, Lakitu_OnCollision, (void (*)(LakituEntity*))GenericKnockback, (void (*)(LakituEntity*))GenericDeath, (void (*)(LakituEntity*))GenericConfused, Lakitu_OnGrabbed,
Lakitu_OnTick,
Lakitu_OnCollision,
(void (*)(LakituEntity*))GenericKnockback,
(void (*)(LakituEntity*))GenericDeath,
(void (*)(LakituEntity*))GenericConfused,
Lakitu_OnGrabbed,
};
void (*const LakituActionFuncs[])(LakituEntity*) = {

View File

@ -159,10 +159,12 @@ void sub_0803CE3C(LakituCloudEntity* this) {
}
void (*const LakituCloud_Functions[])(LakituCloudEntity*) = {
LakituCloud_OnTick, LakituCloud_OnTick, LakituCloud_OnKnockback,
(void (*)(LakituCloudEntity*))
GenericDeath, (void (*)(LakituCloudEntity*))
GenericConfused, LakituCloud_OnGrabbed,
LakituCloud_OnTick,
LakituCloud_OnTick,
LakituCloud_OnKnockback,
(void (*)(LakituCloudEntity*))GenericDeath,
(void (*)(LakituCloudEntity*))GenericConfused,
LakituCloud_OnGrabbed,
};
void (*const gUnk_080D0430[])(LakituCloudEntity*) = {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,11 @@ void sub_08034EE4(MazaalMacroEntity* this);
void sub_08034F58(MazaalMacroEntity* this);
void (*const MazaalMacro_Functions[])(MazaalMacroEntity*) = {
MazaalMacro_OnTick, MazaalMacro_OnCollision, (void (*)(MazaalMacroEntity*))GenericKnockback, MazaalMacro_OnDeath, (void (*)(MazaalMacroEntity*))GenericConfused,
MazaalMacro_OnTick,
MazaalMacro_OnCollision,
(void (*)(MazaalMacroEntity*))GenericKnockback,
MazaalMacro_OnDeath,
(void (*)(MazaalMacroEntity*))GenericConfused,
};
void (*const gUnk_080CEEA4[])(MazaalMacroEntity*) = {
sub_08034CC4,

View File

@ -23,8 +23,12 @@ void sub_08045618(MiniFireballGuyEntity* this);
void sub_08045654(MiniFireballGuyEntity* this);
static void (*const MiniFireballGuy_Functions[])(MiniFireballGuyEntity*) = {
MiniFireballGuy_OnTick, MiniFireballGuy_OnCollision, (void (*)(MiniFireballGuyEntity*))GenericKnockback, MiniFireballGuy_OnDeath,
(void (*)(MiniFireballGuyEntity*))GenericConfused, MiniFireballGuy_OnGrabbed,
MiniFireballGuy_OnTick,
MiniFireballGuy_OnCollision,
(void (*)(MiniFireballGuyEntity*))GenericKnockback,
MiniFireballGuy_OnDeath,
(void (*)(MiniFireballGuyEntity*))GenericConfused,
MiniFireballGuy_OnGrabbed,
};
void MiniFireballGuy(MiniFireballGuyEntity* this) {

View File

@ -27,7 +27,12 @@ void sub_080452FC(MiniSlimeEntity* this);
extern void ReplaceMonitoredEntity(Entity*, Entity*);
static void (*const MiniSlime_Functions[])(MiniSlimeEntity*) = {
MiniSlime_OnTick, MiniSlime_OnCollision, (void (*)(MiniSlimeEntity*))GenericKnockback, MiniSlime_OnDeath, (void (*)(MiniSlimeEntity*))GenericConfused, MiniSlime_OnGrabbed,
MiniSlime_OnTick,
MiniSlime_OnCollision,
(void (*)(MiniSlimeEntity*))GenericKnockback,
MiniSlime_OnDeath,
(void (*)(MiniSlimeEntity*))GenericConfused,
MiniSlime_OnGrabbed,
};
void MiniSlime(MiniSlimeEntity* this) {

View File

@ -4,240 +4,271 @@
*
* @brief Moldorm enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
void sub_08022EAC(Entity*);
void sub_08022F14(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
union {
/*0x7c*/ Entity* entity;
struct {
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f;
} split;
} unk_7c;
union {
/*0x80*/ Entity* entity;
struct {
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} split;
} unk_80;
/*0x84*/ u32 unk_84;
} MoldormEntity;
extern void (*const gUnk_080CBB90[])(Entity*);
extern void (*const Moldorm_Functions[])(Entity*);
extern void (*const gUnk_080CBBB4[])(Entity*);
extern void (*const gUnk_080CBBBC[])(Entity*);
void sub_08022EAC(MoldormEntity*);
void sub_08022F14(MoldormEntity*);
extern void (*const gUnk_080CBB90[])(MoldormEntity*);
extern void (*const Moldorm_Functions[])(MoldormEntity*);
extern void (*const gUnk_080CBBB4[])(MoldormEntity*);
extern void (*const gUnk_080CBBBC[])(MoldormEntity*);
extern const s8 gUnk_080CBBC4[];
void Moldorm(Entity* this) {
gUnk_080CBB90[this->type](this);
void Moldorm(MoldormEntity* this) {
gUnk_080CBB90[super->type](this);
}
void sub_08022BA0(Entity* this) {
this->field_0x78.HALF.HI++;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
EnemyFunctionHandler(this, Moldorm_Functions);
void sub_08022BA0(MoldormEntity* this) {
this->unk_79++;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
EnemyFunctionHandler(super, (EntityActionArray)Moldorm_Functions);
sub_08022EAC(this);
}
void Moldorm_OnTick(Entity* this) {
gUnk_080CBBB4[this->action](this);
void Moldorm_OnTick(MoldormEntity* this) {
gUnk_080CBBB4[super->action](this);
}
void Moldorm_OnCollision(Entity* this) {
if (this->field_0x7a.HALF.LO != this->health)
this->field_0x7a.HALF.HI = 30;
void Moldorm_OnCollision(MoldormEntity* this) {
if (this->unk_7a != super->health)
this->unk_7b = 30;
this->field_0x7a.HALF.LO = this->health;
this->timer = 1;
this->direction = this->knockbackDirection;
this->unk_7a = super->health;
super->timer = 1;
super->direction = super->knockbackDirection;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
this->child->iframes = this->iframes;
(*(Entity**)&this->field_0x7c)->iframes = this->iframes;
(*(Entity**)&this->field_0x80)->iframes = this->iframes;
EnemyFunctionHandlerAfterCollision(this, Moldorm_Functions);
super->child->iframes = super->iframes;
this->unk_7c.entity->iframes = super->iframes;
this->unk_80.entity->iframes = super->iframes;
EnemyFunctionHandlerAfterCollision(super, Moldorm_Functions);
}
void sub_08022C58(Entity* this) {
void sub_08022C58(MoldormEntity* this) {
Entity *tail0, *tail1, *tail2;
COLLISION_OFF(this);
COLLISION_OFF(super);
if (gEntCount >= 0x45)
return;
tail0 = CreateEnemy(MOLDORM, 1);
this->child = tail0;
super->child = tail0;
tail0->spritePriority.b0 = 5;
tail0->parent = this;
CopyPosition(this, tail0);
tail0->parent = super;
CopyPosition(super, tail0);
tail1 = CreateEnemy(MOLDORM, 2);
tail0->child = tail1;
tail1->spritePriority.b0 = 5;
tail1->parent = this;
CopyPosition(this, tail1);
tail1->parent = super;
CopyPosition(super, tail1);
tail2 = CreateEnemy(MOLDORM, 3);
tail1->child = tail2;
tail2->spritePriority.b0 = 5;
tail2->parent = this;
CopyPosition(this, tail2);
tail2->parent = super;
CopyPosition(super, tail2);
sub_0804A720(this);
this->action = 1;
this->timer = 1;
this->subtimer = 1;
COLLISION_ON(this);
this->parent = this;
this->child = tail0;
*(Entity**)&this->field_0x7c = tail1;
*(Entity**)&this->field_0x80 = tail2;
sub_0804A720(super);
super->action = 1;
super->timer = 1;
super->subtimer = 1;
COLLISION_ON(super);
super->parent = super;
super->child = tail0;
this->unk_7c.entity = tail1;
this->unk_80.entity = tail2;
this->direction = Random() & 0x1f;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
this->field_0x7a.HALF.LO = this->health;
super->direction = Random() & 0x1f;
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
this->unk_7a = super->health;
}
void sub_08022D40(Entity* this) {
if (this->field_0x7a.HALF.HI) {
if (this->field_0x7a.HALF.HI-- & 1) {
this->animationState = (this->animationState + 1) & 7;
this->frameIndex = this->animationState;
void sub_08022D40(MoldormEntity* this) {
if (this->unk_7b) {
if (this->unk_7b-- & 1) {
super->animationState = (super->animationState + 1) & 7;
super->frameIndex = super->animationState;
}
} else {
sub_08022F14(this);
ProcessMovement0(this);
ProcessMovement0(super);
if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
}
}
}
void sub_08022D90(Entity* this) {
if (this->parent->next != NULL) {
void sub_08022D90(MoldormEntity* this) {
if (super->parent->next != NULL) {
Entity* parent;
gUnk_080CBBBC[this->action](this);
parent = this->parent;
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
this->spriteRendering.b3 = parent->spriteRendering.b3;
this->collisionLayer = parent->collisionLayer;
gUnk_080CBBBC[super->action](this);
parent = super->parent;
super->spriteOrientation.flipY = parent->spriteOrientation.flipY;
super->spriteRendering.b3 = parent->spriteRendering.b3;
super->collisionLayer = parent->collisionLayer;
} else {
DeleteEntity(this);
DeleteEntity(super);
}
}
void sub_08022DE8(Entity* this) {
this->action = 1;
this->field_0x7c.BYTES.byte0 = 0x88;
this->field_0x7c.BYTES.byte1 = 0x88;
this->field_0x7c.BYTES.byte2 = 0x88;
this->field_0x7c.BYTES.byte3 = 0x88;
this->field_0x80.HALF.LO = 0x88;
this->field_0x80.HALF.HI = 0x88;
this->field_0x82.HALF.LO = 0x88;
this->field_0x82.HALF.HI = 0x88;
this->animationState = this->parent->animationState;
*(u32*)&this->cutsceneBeh = this->animationState * 0x11111111;
void sub_08022DE8(MoldormEntity* this) {
super->action = 1;
this->unk_7c.split.unk_7c = 0x88;
this->unk_7c.split.unk_7d = 0x88;
this->unk_7c.split.unk_7e = 0x88;
this->unk_7c.split.unk_7f = 0x88;
this->unk_80.split.unk_80 = 0x88;
this->unk_80.split.unk_81 = 0x88;
this->unk_80.split.unk_82 = 0x88;
this->unk_80.split.unk_83 = 0x88;
super->animationState = super->parent->animationState;
this->unk_84 = super->animationState * 0x11111111;
if (this->type != 3) {
this->frameIndex = this->type + 7;
if (super->type != 3) {
super->frameIndex = super->type + 7;
} else {
this->frameIndex = this->animationState + 10;
super->frameIndex = super->animationState + 10;
}
}
void sub_08022E40(Entity* this) {
void sub_08022E40(MoldormEntity* this) {
u32 bVar1;
u32 animationState;
u32 tmp;
u32 tmp2;
u8* ptr;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
tmp2 = (this->parent->field_0x78.HALF.HI + 1) & 7;
ptr = (u8*)&this->field_0x7c + tmp2;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
tmp2 = (((MoldormEntity*)super->parent)->unk_79 + 1) & 7;
ptr = (u8*)&this->unk_7c.split.unk_7c + tmp2;
bVar1 = *ptr;
tmp = (bVar1 & 0xf) - 8;
bVar1 >>= 4;
this->x.HALF.HI = ((short)((tmp * 0x100)) >> 8) + this->x.HALF.HI;
super->x.HALF.HI = ((short)((tmp * 0x100)) >> 8) + super->x.HALF.HI;
bVar1 -= 8;
this->y.HALF.HI = bVar1 + this->y.HALF.HI;
animationState = (u8)(*(u32*)&this->cutsceneBeh >> (((this->parent->field_0x78.HALF.HI + 1) & 7) << 2)) & 7;
this->animationState = animationState;
if (this->type == 3) {
this->frameIndex = animationState + 10;
super->y.HALF.HI = bVar1 + super->y.HALF.HI;
animationState = (u8)(this->unk_84 >> (((((MoldormEntity*)super->parent)->unk_79 + 1) & 7) << 2)) & 7;
super->animationState = animationState;
if (super->type == 3) {
super->frameIndex = animationState + 10;
} else {
sub_08022EAC(this);
}
}
void sub_08022EAC(Entity* this) {
void sub_08022EAC(MoldormEntity* this) {
int iVar1;
u32 tmp;
u32 tmp2;
if (this->child != NULL) {
tmp2 = ((this->parent->field_0x78.HALF.HI) & 7);
((u8*)&this->child->field_0x7c)[tmp2] = ((this->x.HALF_U.HI - this->field_0x74.HALF.LO + 8) & 0xf) +
((u32)((this->y.HALF_U.HI - this->field_0x76.HALF.LO + 8) & 0xf) << 4);
iVar1 = ((this->parent->field_0x78.HALF.HI) & 7) << 2;
tmp = (this->animationState & 7) << iVar1;
tmp |= ~(0xf << iVar1) & (*(u32*)&this->child->cutsceneBeh);
*(u32*)&this->child->cutsceneBeh = tmp;
if (super->child != NULL) {
tmp2 = ((((MoldormEntity*)super->parent)->unk_79) & 7);
((u8*)&((MoldormEntity*)super->child)->unk_7c.split.unk_7c)[tmp2] =
((super->x.HALF_U.HI - this->unk_74 + 8) & 0xf) +
((u32)((super->y.HALF_U.HI - this->unk_76 + 8) & 0xf) << 4);
iVar1 = ((((MoldormEntity*)super->parent)->unk_79) & 7) << 2;
tmp = (super->animationState & 7) << iVar1;
tmp |= ~(0xf << iVar1) & (((MoldormEntity*)super->child)->unk_84);
((MoldormEntity*)super->child)->unk_84 = tmp;
}
}
void sub_08022F14(Entity* this) {
if (sub_08049FA0(this) == 0) {
u32 bVar6 = (sub_08049EE4(this) - this->direction) & 0x1f;
void sub_08022F14(MoldormEntity* this) {
if (sub_08049FA0(super) == 0) {
u32 bVar6 = (sub_08049EE4(super) - super->direction) & 0x1f;
if (8 < ((bVar6 + 4) & 0x1f)) {
this->subtimer = 8;
super->subtimer = 8;
if (bVar6 < 0x10) {
this->field_0x78.HALF.LO = 1;
this->unk_78 = 1;
} else {
this->field_0x78.HALF.LO = -1;
this->unk_78 = -1;
}
}
}
if (--this->timer == 0) {
this->timer = 4;
if (--super->timer == 0) {
super->timer = 4;
if (--this->subtimer == 0) {
this->subtimer = 8;
this->field_0x78.HALF.LO = gUnk_080CBBC4[Random() & 1];
if (--super->subtimer == 0) {
super->subtimer = 8;
this->unk_78 = gUnk_080CBBC4[Random() & 1];
}
this->direction += this->field_0x78.HALF.LO;
this->direction &= DirectionNorthWest | 0x3;
super->direction += this->unk_78;
super->direction &= DirectionNorthWest | 0x3;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
}
}
// clang-format off
void (*const gUnk_080CBB90[])(Entity*) = {
void (*const gUnk_080CBB90[])(MoldormEntity*) = {
sub_08022BA0,
sub_08022D90,
sub_08022D90,
sub_08022D90,
};
void (*const Moldorm_Functions[])(Entity*) = {
void (*const Moldorm_Functions[])(MoldormEntity*) = {
Moldorm_OnTick,
Moldorm_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(MoldormEntity*))GenericKnockback,
(void (*)(MoldormEntity*))GenericDeath,
(void (*)(MoldormEntity*))GenericConfused,
};
void (*const gUnk_080CBBB4[])(Entity*) = {
void (*const gUnk_080CBBB4[])(MoldormEntity*) = {
sub_08022C58,
sub_08022D40,
};
void (*const gUnk_080CBBBC[])(Entity*) = {
void (*const gUnk_080CBBBC[])(MoldormEntity*) = {
sub_08022DE8,
sub_08022E40,
};

View File

@ -4,86 +4,115 @@
*
* @brief Moldworm enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ Entity* unk_74;
union {
/*0x78*/ u16 HWORD;
struct {
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
} PACKED split;
} PACKED unk_78;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unk_85;
/*0x86*/ u8 unk_86;
/*0x87*/ u8 unk_87;
} MoldwormEntity;
extern void SoundReqClipped(Entity*, u32);
extern bool32 sub_08023A38(u32);
extern void sub_08023990(Entity*, u32, u32);
extern void sub_08023A88(Entity*, u32);
void sub_080235BC(Entity*);
void sub_08023644(Entity*);
void sub_08023730(Entity*);
void sub_080237D8(Entity*);
void sub_0802390C(Entity*);
void sub_080239F0(Entity*);
bool32 sub_08023B38(Entity*);
void sub_08023990(MoldwormEntity*, u32, u32);
void sub_08023A88(MoldwormEntity*, u32);
void sub_080235BC(MoldwormEntity*);
void sub_08023644(MoldwormEntity*);
void sub_08023730(MoldwormEntity*);
void sub_080237D8(MoldwormEntity*);
void sub_0802390C(MoldwormEntity*);
void sub_080239F0(MoldwormEntity*);
bool32 sub_08023B38(MoldwormEntity*);
void sub_08023A68(MoldwormEntity*);
void sub_08023AB0(MoldwormEntity*);
extern void (*const Moldworm_Functions[])(Entity*);
extern void (*const gUnk_080CBC50[])(Entity*);
extern void (*const Moldworm_Functions[])(MoldwormEntity*);
extern void (*const gUnk_080CBC50[])(MoldwormEntity*);
extern const s8 gUnk_080CBC70[];
extern const s8 gUnk_080CBC90[];
extern void (*const gUnk_080CBC98[])(Entity*);
extern void (*const gUnk_080CBCA8[])(Entity*);
extern void (*const gUnk_080CBC98[])(MoldwormEntity*);
extern void (*const gUnk_080CBCA8[])(MoldwormEntity*);
extern const s8 gUnk_080CBCB8[];
void Moldworm(Entity* this) {
u16 prevX = this->x.HALF.HI;
u16 prevY = this->y.HALF.HI;
void Moldworm(MoldwormEntity* this) {
u16 prevX = super->x.HALF.HI;
u16 prevY = super->y.HALF.HI;
if (this->type == 0) {
if (this->action != 0) {
if (super->type == 0) {
if (super->action != 0) {
sub_0802390C(this);
}
this->field_0x7c.BYTES.byte1 = this->field_0x7c.BYTES.byte0;
EnemyFunctionHandler(this, Moldworm_Functions);
this->unk_7d = this->unk_7c;
EnemyFunctionHandler(super, (EntityActionArray)Moldworm_Functions);
} else {
if (this->parent->next != NULL) {
if (this->type != 8) {
if (super->parent->next != NULL) {
if (super->type != 8) {
sub_080235BC(this);
} else {
sub_08023730(this);
}
} else {
DeleteEntity(this);
DeleteEntity(super);
return;
}
}
if (this->parent->field_0x7c.BYTES.byte0 != this->parent->field_0x7c.BYTES.byte1 && this->child) {
u32 temp = (this->parent->field_0x7c.BYTES.byte0 - 1) & 0xf;
u8* ptr = (u8*)&this->child->field_0x78 + temp;
*ptr = (((this->x.HALF.HI - prevX + 8) & 0xf) << 4) | ((this->y.HALF.HI - prevY + 8U) & 0xf);
if (((MoldwormEntity*)super->parent)->unk_7c != ((MoldwormEntity*)super->parent)->unk_7d && super->child) {
u32 temp = (((MoldwormEntity*)super->parent)->unk_7c - 1) & 0xf;
u8* ptr = (u8*)&((MoldwormEntity*)super->child)->unk_78.split.unk_78 + temp;
*ptr = (((super->x.HALF.HI - prevX + 8) & 0xf) << 4) | ((super->y.HALF.HI - prevY + 8U) & 0xf);
}
}
void Moldworm_OnTick(Entity* this) {
gUnk_080CBC50[this->action](this);
void Moldworm_OnTick(MoldwormEntity* this) {
gUnk_080CBC50[super->action](this);
}
void Moldworm_OnCollision(Entity* this) {
if (this->subAction == 0xff) {
this->action = 7;
this->timer = 1;
this->subAction = 0;
this->hitType = 0x85;
this->iframes = -8;
this->field_0x7c.BYTES.byte3 = 0;
this->field_0x7a.HALF.HI = 0;
if (this->contactFlags == 0x80 || this->contactFlags == 0x9e) {
this->type2 = 0;
this->field_0x80.HALF.LO = 0x14;
void Moldworm_OnCollision(MoldwormEntity* this) {
if (super->subAction == 0xff) {
super->action = 7;
super->timer = 1;
super->subAction = 0;
super->hitType = 0x85;
super->iframes = -8;
this->unk_7f = 0;
this->unk_7b = 0;
if (super->contactFlags == 0x80 || super->contactFlags == 0x9e) {
super->type2 = 0;
this->unk_80 = 0x14;
} else {
this->type2 = 1;
this->field_0x80.HALF.LO = 8;
super->type2 = 1;
this->unk_80 = 8;
}
}
if (this->health == 0 && this->field_0x7c.BYTES.byte3 == 0 && this->action == 7) {
CopyPosition(this, &gPlayerEntity);
if (super->health == 0 && this->unk_7f == 0 && super->action == 7) {
CopyPosition(super, &gPlayerEntity);
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.spriteSettings.draw = 1;
gPlayerEntity.zVelocity = Q_16_16(1.5);
@ -93,64 +122,64 @@ void Moldworm_OnCollision(Entity* this) {
gPlayerState.flags &= ~PL_MOLDWORM_CAPTURED;
}
EnemyFunctionHandlerAfterCollision(this, Moldworm_Functions);
EnemyFunctionHandlerAfterCollision(super, Moldworm_Functions);
}
void Moldworm_OnKnockback(Entity* this) {
this->field_0x7c.BYTES.byte0++;
GenericKnockback(this);
void Moldworm_OnKnockback(MoldwormEntity* this) {
this->unk_7c++;
GenericKnockback(super);
}
void Moldworm_OnGrabbed(Entity* this) {
void Moldworm_OnGrabbed(MoldwormEntity* this) {
}
void sub_080231BC(Entity* this) {
void sub_080231BC(MoldwormEntity* this) {
if (gEntCount < 0x40) {
Entity* ent;
ent = this->child = CreateEnemy(MOLDWORM, 1);
ent->parent = this;
ent = super->child = CreateEnemy(MOLDWORM, 1);
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 2);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 3);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 4);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 5);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 6);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 7);
ent->parent = this;
ent->parent = super;
ent->child = CreateEnemy(MOLDWORM, 8);
*(Entity**)&ent->child->field_0x74 = ent;
((MoldwormEntity*)ent->child)->unk_74 = ent;
ent = ent->child;
ent->parent = this;
ent->parent = super;
ent->child = NULL;
sub_0804A720(this);
this->action = 6;
this->timer = 30;
this->parent = this;
this->field_0x78.HWORD = 0x1e;
this->palette.b.b0 = 5;
this->direction = Random() & 0x1f;
this->animationState = Direction8ToAnimationState(Direction8RoundUp(this->direction));
InitializeAnimation(this, this->animationState);
sub_0804A720(super);
super->action = 6;
super->timer = 30;
super->parent = super;
this->unk_78.HWORD = 0x1e;
super->palette.b.b0 = 5;
super->direction = Random() & 0x1f;
super->animationState = Direction8ToAnimationState(Direction8RoundUp(super->direction));
InitializeAnimation(super, super->animationState);
}
}
void nullsub_136(Entity* this) {
void nullsub_136(MoldwormEntity* this) {
}
void sub_08023288(Entity* this) {
if (sub_08049FDC(this, 1) && (this->timer++ & 0xf) == 0) {
void sub_08023288(MoldwormEntity* this) {
if (sub_08049FDC(super, 1) && (super->timer++ & 0xf) == 0) {
u32 idx = Random() & 0x1e;
u32 i;
@ -167,246 +196,243 @@ void sub_08023288(Entity* this) {
}
}
void sub_08023330(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 4;
this->timer = 25;
COLLISION_ON(this);
this->field_0x78.HWORD = 600;
this->direction = Random() & 0x1c;
this->animationState = this->direction >> 2;
this->field_0x7a.HALF.HI = 0;
this->field_0x7c.BYTES.byte3 = 0;
sub_08023A88(this, this->animationState);
CopyPosition(this, this->child);
CreateFx(this, FX_ROCK, 0);
void sub_08023330(MoldwormEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 4;
super->timer = 25;
COLLISION_ON(super);
this->unk_78.HWORD = 600;
super->direction = Random() & 0x1c;
super->animationState = super->direction >> 2;
this->unk_7b = 0;
this->unk_7f = 0;
sub_08023A88(this, super->animationState);
CopyPosition(super, super->child);
CreateFx(super, FX_ROCK, 0);
}
}
void sub_08023A68(Entity*);
void sub_08023AB0(Entity*);
void sub_08023398(MoldwormEntity* this) {
this->unk_7c++;
void sub_08023398(Entity* this) {
this->field_0x7c.BYTES.byte0++;
if (this->field_0x7c.BYTES.byte3 && !sub_08049FDC(this, 1)) {
this->field_0x78.HWORD = 1;
if (this->unk_7f && !sub_08049FDC(super, 1)) {
this->unk_78.HWORD = 1;
}
if (--this->field_0x78.HWORD == 0) {
if (sub_08023A38(GetTileTypeByEntity(this))) {
this->action = 5;
this->field_0x7c.BYTES.byte3 = 0;
COLLISION_OFF(this);
this->hitType = 0x85;
this->child->timer = 1;
if (--this->unk_78.HWORD == 0) {
if (sub_08023A38(GetTileTypeByEntity(super))) {
super->action = 5;
this->unk_7f = 0;
COLLISION_OFF(super);
super->hitType = 0x85;
super->child->timer = 1;
sub_08023A68(this);
CreateFx(this, FX_ROCK, 0);
CreateFx(super, FX_ROCK, 0);
return;
}
this->field_0x78.HWORD = 0x28;
this->unk_78.HWORD = 0x28;
}
if (this->field_0x7c.BYTES.byte3) {
if (this->unk_7f) {
sub_08023AB0(this);
}
if (--this->timer < 3) {
if (this->timer == 0)
this->timer = 25;
if (--super->timer < 3) {
if (super->timer == 0)
super->timer = 25;
} else {
int prevX = this->x.WORD;
int prevY = this->y.WORD;
ProcessMovement0(this);
if (this->x.WORD == prevX && this->y.WORD == prevY) {
this->field_0x7c.BYTES.byte0--;
int prevX = super->x.WORD;
int prevY = super->y.WORD;
ProcessMovement0(super);
if (super->x.WORD == prevX && super->y.WORD == prevY) {
this->unk_7c--;
}
if ((gRoomTransition.frameCount & 7) == 0) {
u32 uVar4;
sub_08004596(this, sub_08049F84(this, 1));
uVar4 = Direction8ToAnimationState(Direction8RoundUp(this->direction));
if (uVar4 != this->animationState) {
this->animationState = uVar4;
InitializeAnimation(this, uVar4 + this->field_0x7a.HALF.HI);
sub_08004596(super, sub_08049F84(super, 1));
uVar4 = Direction8ToAnimationState(Direction8RoundUp(super->direction));
if (uVar4 != super->animationState) {
super->animationState = uVar4;
InitializeAnimation(super, uVar4 + this->unk_7b);
}
}
}
}
void sub_080234A4(Entity* this) {
this->field_0x7c.BYTES.byte0++;
GetNextFrame(this);
if (this->field_0x7c.BYTES.byte3) {
this->action = 6;
this->spriteSettings.draw = 0;
this->field_0x78.HWORD = 300;
void sub_080234A4(MoldwormEntity* this) {
this->unk_7c++;
GetNextFrame(super);
if (this->unk_7f) {
super->action = 6;
super->spriteSettings.draw = 0;
this->unk_78.HWORD = 300;
}
}
void sub_080234D8(Entity* this) {
if (--this->field_0x78.HWORD == 0) {
this->action = 2;
this->palette.b.b0 = 5;
this->direction = Random() & 0x1f;
this->animationState = Direction8ToAnimationState(Direction8RoundUp(this->direction));
sub_08023A88(this, this->animationState);
void sub_080234D8(MoldwormEntity* this) {
if (--this->unk_78.HWORD == 0) {
super->action = 2;
super->palette.b.b0 = 5;
super->direction = Random() & 0x1f;
super->animationState = Direction8ToAnimationState(Direction8RoundUp(super->direction));
sub_08023A88(this, super->animationState);
}
}
void sub_0802351C(Entity* this) {
if ((this->timer != 0) && ((this->type2 == 1) || (gPlayerEntity.frameIndex == 0xff))) {
this->timer = 0;
this->child->action = 3;
this->child->subtimer = this->field_0x80.HALF.LO;
InitializeAnimation(this->child, this->child->animationState + 1);
InitializeAnimation(this, this->animationState);
void sub_0802351C(MoldwormEntity* this) {
if ((super->timer != 0) && ((super->type2 == 1) || (gPlayerEntity.frameIndex == 0xff))) {
super->timer = 0;
super->child->action = 3;
super->child->subtimer = this->unk_80;
InitializeAnimation(super->child, super->child->animationState + 1);
InitializeAnimation(super, super->animationState);
}
if (this->field_0x7c.BYTES.byte3 == 0) {
if (this->type2 == 0) {
gPlayerEntity.animationState = this->animationState & 7;
if (this->unk_7f == 0) {
if (super->type2 == 0) {
gPlayerEntity.animationState = super->animationState & 7;
gPlayerState.flags |= PL_MOLDWORM_CAPTURED;
PositionRelative(this, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[this->animationState & 7]));
gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7];
PositionRelative(super, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[super->animationState & 7]));
gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[super->animationState & 7];
}
} else {
this->action = 4;
super->action = 4;
}
}
void sub_080235BC(Entity* this) {
gUnk_080CBC98[this->action](this);
void sub_080235BC(MoldwormEntity* this) {
gUnk_080CBC98[super->action](this);
}
void sub_080235D4(Entity* this) {
void sub_080235D4(MoldwormEntity* this) {
Entity* parent;
this->action = 1;
parent = this->parent;
this->x.HALF.HI = parent->x.HALF.HI;
this->y.HALF.HI = parent->y.HALF.HI;
super->action = 1;
parent = super->parent;
super->x.HALF.HI = parent->x.HALF.HI;
super->y.HALF.HI = parent->y.HALF.HI;
sub_080239F0(this);
if (this->type == 1) {
this->animationState = 0x10;
if (super->type == 1) {
super->animationState = 0x10;
} else {
this->animationState = 0x12;
super->animationState = 0x12;
}
InitializeAnimation(this, this->animationState);
InitializeAnimation(super, super->animationState);
}
void sub_08023604(Entity* this) {
if (((u8*)&this->field_0x78)[this->parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) {
this->action = 2;
this->timer = 0;
COLLISION_ON(this);
this->spriteSettings.draw = 1;
void sub_08023604(MoldwormEntity* this) {
if (((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)super->parent)->unk_7c & 0xf] != 0x88) {
super->action = 2;
super->timer = 0;
COLLISION_ON(super);
super->spriteSettings.draw = 1;
sub_08023644(this);
}
}
void sub_08023644(Entity* this) {
Entity* parent = this->parent;
void sub_08023644(MoldwormEntity* this) {
Entity* parent = super->parent;
if (parent->animIndex == 0x17 && this->timer != 0 && this->x.HALF.HI == parent->x.HALF.HI &&
this->y.HALF.HI == parent->y.HALF.HI) {
this->action = 1;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
this->child->timer = 1;
if (parent->animIndex == 0x17 && super->timer != 0 && super->x.HALF.HI == parent->x.HALF.HI &&
super->y.HALF.HI == parent->y.HALF.HI) {
super->action = 1;
COLLISION_OFF(super);
super->spriteSettings.draw = 0;
super->child->timer = 1;
sub_080239F0(this);
}
if (parent->field_0x7c.BYTES.byte0 != parent->field_0x7c.BYTES.byte1) {
u8* tmp = &((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf];
this->x.HALF.HI += (*tmp >> 4) - 8;
this->y.HALF.HI += (*tmp & 0xf) - 8;
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
this->spriteRendering.b3 = parent->spriteRendering.b3;
this->collisionLayer = parent->collisionLayer;
if (((MoldwormEntity*)parent)->unk_7c != ((MoldwormEntity*)parent)->unk_7d) {
u8* tmp = &((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)parent)->unk_7c & 0xf];
super->x.HALF.HI += (*tmp >> 4) - 8;
super->y.HALF.HI += (*tmp & 0xf) - 8;
super->spriteOrientation.flipY = parent->spriteOrientation.flipY;
super->spriteRendering.b3 = parent->spriteRendering.b3;
super->collisionLayer = parent->collisionLayer;
}
}
void sub_080236F8(Entity* parent) {
if (--parent->subtimer == 0) {
parent->action = 2;
parent->child->action = 3;
parent->child->subtimer = parent->parent->field_0x80.HALF.LO;
InitializeAnimation(parent->child, parent->child->animationState + 1);
InitializeAnimation(parent, parent->animationState);
void sub_080236F8(MoldwormEntity* this) {
if (--super->subtimer == 0) {
super->action = 2;
super->child->action = 3;
super->child->subtimer = ((MoldwormEntity*)super->parent)->unk_80;
InitializeAnimation(super->child, super->child->animationState + 1);
InitializeAnimation(super, super->animationState);
}
}
void sub_08023730(Entity* this) {
gUnk_080CBCA8[this->action](this);
void sub_08023730(MoldwormEntity* this) {
gUnk_080CBCA8[super->action](this);
}
void sub_08023748(Entity* this) {
void sub_08023748(MoldwormEntity* this) {
Entity* parent;
this->action = 1;
this->animationState = 20;
parent = this->parent;
this->x.HALF.HI = parent->x.HALF.HI;
this->y.HALF.HI = parent->y.HALF.HI;
super->action = 1;
super->animationState = 20;
parent = super->parent;
super->x.HALF.HI = parent->x.HALF.HI;
super->y.HALF.HI = parent->y.HALF.HI;
sub_080239F0(this);
sub_08023A68(this);
}
void sub_0802376C(Entity* this) {
Entity* parent = this->parent;
void sub_0802376C(MoldwormEntity* this) {
Entity* parent = super->parent;
if (parent->spriteSettings.draw == 1 && parent->animIndex < 0x10) {
this->spriteSettings.draw = 1;
GetNextFrame(this);
super->spriteSettings.draw = 1;
GetNextFrame(super);
}
if (((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) {
this->action = 2;
this->timer = 0;
COLLISION_ON(this);
this->parent->field_0x7c.BYTES.byte3 = 1;
if (((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)parent)->unk_7c & 0xf] != 0x88) {
super->action = 2;
super->timer = 0;
COLLISION_ON(super);
((MoldwormEntity*)super->parent)->unk_7f = 1;
sub_08023A88(this, 20);
sub_080237D8(this);
}
}
void sub_080237D8(Entity* this) {
Entity* parent = this->parent;
void sub_080237D8(MoldwormEntity* this) {
Entity* parent = super->parent;
if ((parent->animIndex == 0x17) && (this->timer != 0) && (this->x.HALF.HI == parent->x.HALF.HI) &&
(this->y.HALF.HI == parent->y.HALF.HI)) {
this->action = 1;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
parent->field_0x7c.BYTES.byte3 = 1;
if ((parent->animIndex == 0x17) && (super->timer != 0) && (super->x.HALF.HI == parent->x.HALF.HI) &&
(super->y.HALF.HI == parent->y.HALF.HI)) {
super->action = 1;
COLLISION_OFF(super);
super->spriteSettings.draw = 0;
((MoldwormEntity*)parent)->unk_7f = 1;
sub_080239F0(this);
sub_08023A68(this);
}
if (parent->field_0x7c.BYTES.byte0 != parent->field_0x7c.BYTES.byte1) {
u8* tmp = &((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf];
this->x.HALF.HI += (*tmp >> 4) - 8;
this->y.HALF.HI += (*tmp & 0xf) - 8;
if (((MoldwormEntity*)parent)->unk_7c != ((MoldwormEntity*)parent)->unk_7d) {
u8* tmp = &((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)parent)->unk_7c & 0xf];
super->x.HALF.HI += (*tmp >> 4) - 8;
super->y.HALF.HI += (*tmp & 0xf) - 8;
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
this->spriteRendering.b3 = parent->spriteRendering.b3;
this->collisionLayer = parent->collisionLayer;
super->spriteOrientation.flipY = parent->spriteOrientation.flipY;
super->spriteRendering.b3 = parent->spriteRendering.b3;
super->collisionLayer = parent->collisionLayer;
}
}
void sub_08023894(Entity* this) {
if (--this->subtimer == 0) {
this->action = 2;
this->parent->field_0x7c.BYTES.byte3 = 1;
InitializeAnimation(this, this->animationState);
if (this->parent->type2 == 0) {
void sub_08023894(MoldwormEntity* this) {
if (--super->subtimer == 0) {
super->action = 2;
((MoldwormEntity*)super->parent)->unk_7f = 1;
InitializeAnimation(super, super->animationState);
if (super->parent->type2 == 0) {
gPlayerState.flags |= PL_MOLDWORM_RELEASED;
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(*(Entity**)&this->field_0x74, this));
gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(this->unk_74, super));
gPlayerEntity.animationState = gPlayerEntity.direction >> 2;
gPlayerEntity.iframes = 12;
ModHealth(-0x10);
@ -415,14 +441,14 @@ void sub_08023894(Entity* this) {
}
}
void sub_0802390C(Entity* this) {
if (this->contactFlags & 0x80) {
Entity* ent = this->child;
void sub_0802390C(MoldwormEntity* this) {
if (super->contactFlags & 0x80) {
Entity* ent = super->child;
do {
ent->iframes = this->iframes;
ent->iframes = super->iframes;
} while (ent = ent->child, ent != NULL);
} else {
Entity* ent = this->child;
Entity* ent = super->child;
do {
if (ent->contactFlags & 0x80) {
u8 bVar2 = 0xff - ent->health;
@ -430,13 +456,13 @@ void sub_0802390C(Entity* this) {
u32 tmp;
ent->health = 0xff;
tmp = (u8)ent->iframes;
if (this->health >= bVar2) {
this->health -= bVar2;
if (super->health >= bVar2) {
super->health -= bVar2;
} else {
this->health = 0;
super->health = 0;
}
ent = this;
ent = super;
do {
ent->iframes = tmp;
} while (ent = ent->child, ent != NULL);
@ -447,44 +473,44 @@ void sub_0802390C(Entity* this) {
}
}
void sub_08023990(Entity* this, u32 param_2, u32 param_3) {
void sub_08023990(MoldwormEntity* this, u32 param_2, u32 param_3) {
Entity* ent;
this->action = 3;
this->spriteSettings.draw = 1;
this->palette.b.b0 = 0x5;
this->palette.b.b4 = 0x5;
this->spritePriority.b0 = 7;
this->x.HALF.HI = param_2;
this->y.HALF.HI = param_3;
this->collisionLayer = gPlayerEntity.collisionLayer;
UpdateSpriteForCollisionLayer(this);
InitializeAnimation(this, 0x16);
super->action = 3;
super->spriteSettings.draw = 1;
super->palette.b.b0 = 0x5;
super->palette.b.b4 = 0x5;
super->spritePriority.b0 = 7;
super->x.HALF.HI = param_2;
super->y.HALF.HI = param_3;
super->collisionLayer = gPlayerEntity.collisionLayer;
UpdateSpriteForCollisionLayer(super);
InitializeAnimation(super, 0x16);
ent = this->child;
ent = super->child;
do {
sub_080239F0(ent);
CopyPosition(this, ent);
sub_080239F0((MoldwormEntity*)ent);
CopyPosition(super, ent);
} while (ent = ent->child, ent != NULL);
}
void sub_080239F0(Entity* this) {
*(u8*)&this->field_0x78 = 0x88;
*(u8*)((int)&this->field_0x78 + 1) = 0x88;
*(u8*)&this->field_0x7a = 0x88;
*(u8*)((int)&this->field_0x7a + 1) = 0x88;
*(u8*)&this->field_0x7c = 0x88;
*(u8*)((int)&this->field_0x7c + 1) = 0x88;
*(u8*)((int)&this->field_0x7c + 2) = 0x88;
*(u8*)((int)&this->field_0x7c + 3) = 0x88;
*(u8*)&this->field_0x80 = 0x88;
*(u8*)((int)&this->field_0x80 + 1) = 0x88;
*(u8*)&this->field_0x82 = 0x88;
*(u8*)((int)&this->field_0x82 + 1) = 0x88;
*(u8*)&this->cutsceneBeh = 0x88;
*(u8*)((int)&this->cutsceneBeh + 1) = 0x88;
*(u8*)&this->field_0x86 = 0x88;
*(u8*)((int)&this->field_0x86 + 1) = 0x88;
void sub_080239F0(MoldwormEntity* this) {
this->unk_78.split.unk_78 = 0x88;
this->unk_78.split.unk_79 = 0x88;
this->unk_7a = 0x88;
this->unk_7b = 0x88;
this->unk_7c = 0x88;
this->unk_7d = 0x88;
this->unk_7e = 0x88;
this->unk_7f = 0x88;
this->unk_80 = 0x88;
this->unk_81 = 0x88;
this->unk_82 = 0x88;
this->unk_83 = 0x88;
this->unk_84 = 0x88;
this->unk_85 = 0x88;
this->unk_86 = 0x88;
this->unk_87 = 0x88;
}
bool32 sub_08023A38(u32 tileType) {
@ -500,39 +526,39 @@ bool32 sub_08023A38(u32 tileType) {
}
}
void sub_08023A68(Entity* this) {
ChangeObjPalette(this, 5);
this->spritePriority.b0 = 7;
InitializeAnimation(this, 0x17);
void sub_08023A68(MoldwormEntity* this) {
ChangeObjPalette(super, 5);
super->spritePriority.b0 = 7;
InitializeAnimation(super, 0x17);
}
void sub_08023A88(Entity* this, u32 unk) {
ChangeObjPalette(this, 0x22);
this->spritePriority.b0 = 4;
InitializeAnimation(this, unk);
void sub_08023A88(MoldwormEntity* this, u32 unk) {
ChangeObjPalette(super, 0x22);
super->spritePriority.b0 = 4;
InitializeAnimation(super, unk);
}
void sub_08023AB0(Entity* this) {
if (this->field_0x7a.HALF.HI == 8) {
if (this->field_0x7c.BYTES.byte2) {
this->field_0x7c.BYTES.byte2--;
} else if (!sub_08023B38(this) || (this->field_0x78.HWORD <= 0x1D)) {
this->hitType = 0x85;
this->field_0x7a.HALF.HI = 0;
this->field_0x7c.BYTES.byte2 = 30;
InitializeAnimation(this, this->animationState);
void sub_08023AB0(MoldwormEntity* this) {
if (this->unk_7b == 8) {
if (this->unk_7e) {
this->unk_7e--;
} else if (!sub_08023B38(this) || (this->unk_78.HWORD <= 0x1d)) {
super->hitType = 0x85;
this->unk_7b = 0;
this->unk_7e = 30;
InitializeAnimation(super, super->animationState);
}
} else if (this->field_0x7c.BYTES.byte2) {
this->field_0x7c.BYTES.byte2--;
} else if (this->field_0x78.HWORD >= 90 && sub_08023B38(this)) {
this->hitType = 0x87;
this->field_0x7a.HALF.HI = 8;
this->field_0x7c.BYTES.byte2 = 10;
InitializeAnimation(this, this->animationState + 8);
} else if (this->unk_7e) {
this->unk_7e--;
} else if (this->unk_78.HWORD >= 90 && sub_08023B38(this)) {
super->hitType = 0x87;
this->unk_7b = 8;
this->unk_7e = 10;
InitializeAnimation(super, super->animationState + 8);
}
}
bool32 sub_08023B38(Entity* this) {
bool32 sub_08023B38(MoldwormEntity* this) {
Entity* entity;
bool32 result;
s32 iVar2;
@ -544,8 +570,8 @@ bool32 sub_08023B38(Entity* this) {
if (entity == NULL) {
return FALSE;
} else {
tmp1 = (this->x.HALF.HI + (gUnk_080CBCB8[this->animationState * 2 + 0]));
tmp2 = (this->y.HALF.HI + (gUnk_080CBCB8[this->animationState * 2 + 1]));
tmp1 = (super->x.HALF.HI + (gUnk_080CBCB8[super->animationState * 2 + 0]));
tmp2 = (super->y.HALF.HI + (gUnk_080CBCB8[super->animationState * 2 + 1]));
result = FALSE;
if ((entity->x.HALF.HI - tmp1 + 0x14U < 0x29) && (entity->y.HALF.HI - tmp2 + 0x14U < 0x29)) {
result = TRUE;
@ -555,16 +581,16 @@ bool32 sub_08023B38(Entity* this) {
}
// clang-format off
void (*const Moldworm_Functions[])(Entity*) = {
void (*const Moldworm_Functions[])(MoldwormEntity*) = {
Moldworm_OnTick,
Moldworm_OnCollision,
Moldworm_OnKnockback,
GenericDeath,
GenericConfused,
(void (*)(MoldwormEntity*))GenericDeath,
(void (*)(MoldwormEntity*))GenericConfused,
Moldworm_OnGrabbed,
};
void (*const gUnk_080CBC50[])(Entity*) = {
void (*const gUnk_080CBC50[])(MoldwormEntity*) = {
sub_080231BC,
nullsub_136,
sub_08023288,
@ -587,17 +613,17 @@ const s8 gUnk_080CBC70[] = {
};
const s8 gUnk_080CBC90[] = {
0xff, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
0xff, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
};
void (*const gUnk_080CBC98[])(Entity*) = {
void (*const gUnk_080CBC98[])(MoldwormEntity*) = {
sub_080235D4,
sub_08023604,
sub_08023644,
sub_080236F8,
};
void (*const gUnk_080CBCA8[])(Entity*) = {
void (*const gUnk_080CBCA8[])(MoldwormEntity*) = {
sub_08023748,
sub_0802376C,
sub_080237D8,

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
*
* @brief Puffstool enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "object.h"
@ -15,11 +15,7 @@ typedef struct {
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u8 unk_7c;
// // Overlap of 1
// /*0x7c*/ u16 unk_7c;
// Overlap of 1
/*0x7d*/ u8 unk_7d;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
@ -31,24 +27,24 @@ typedef struct {
extern u8 gUnk_080B3E80[];
bool32 sub_080258C4(Entity*);
void sub_08025B18(Entity*);
void sub_08025C2C(Entity*);
void sub_08025BD4(Entity*);
void sub_080256B4(Entity*);
bool32 sub_08025C44(Entity*);
u32 sub_08025C60(Entity*);
bool32 sub_0802571C(Entity*);
void sub_08025A54(Entity*);
void sub_08025AE8(Entity*);
bool32 sub_0802594C(Entity*, u32);
bool32 sub_080257EC(Entity*, u32, u32);
bool32 sub_080258C4(PuffstoolEntity*);
void sub_08025B18(PuffstoolEntity*);
void sub_08025C2C(PuffstoolEntity*);
void sub_08025BD4(PuffstoolEntity*);
void sub_080256B4(PuffstoolEntity*);
bool32 sub_08025C44(PuffstoolEntity*);
u32 sub_08025C60(PuffstoolEntity*);
bool32 sub_0802571C(PuffstoolEntity*);
void sub_08025A54(PuffstoolEntity*);
void sub_08025AE8(PuffstoolEntity*);
bool32 sub_0802594C(PuffstoolEntity*, u32);
bool32 sub_080257EC(PuffstoolEntity*, u32, u32);
bool32 sub_08025AB8(u32, u32);
extern void (*const Puffstool_Functions[])(Entity*);
extern void (*const gUnk_080CBFB4[])(Entity*);
extern void (*const Puffstool_Functions[])(PuffstoolEntity*);
extern void (*const gUnk_080CBFB4[])(PuffstoolEntity*);
extern const u8 gUnk_080CBFE8[];
extern void (*const gUnk_080CBFEC[])(Entity*);
extern void (*const gUnk_080CBFEC[])(PuffstoolEntity*);
extern const u8 gUnk_080CBFF8[];
extern const u16 gUnk_080CC000[];
extern const s8 gUnk_080CC020[];
@ -59,277 +55,276 @@ extern const s8 gUnk_080CC0A8[];
extern const s8 gUnk_080CC0BA[];
extern const s8 gUnk_080CC0C2[];
void Puffstool(Entity* this) {
EnemyFunctionHandler(this, Puffstool_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Puffstool(PuffstoolEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Puffstool_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void Puffstool_OnTick(Entity* this) {
gUnk_080CBFB4[this->action](this);
void Puffstool_OnTick(PuffstoolEntity* this) {
gUnk_080CBFB4[super->action](this);
}
void Puffstool_OnCollide(Entity* this) {
void Puffstool_OnCollide(PuffstoolEntity* this) {
u8 tmp;
switch (this->contactFlags & 0x7f) {
switch (super->contactFlags & 0x7f) {
case 0 ... 3:
/* ... */
break;
case 0x1b:
sub_0804AA1C(this);
sub_0804AA1C(super);
tmp = gUnk_080CBFE8[(*(Entity**)&this->contactedEntity)->type];
if (tmp < this->field_0x82.HALF.LO) {
this->field_0x82.HALF.LO -= gUnk_080CBFE8[(*(Entity**)&this->contactedEntity)->type];
tmp = gUnk_080CBFE8[(*(Entity**)&super->contactedEntity)->type];
if (tmp < this->unk_82) {
this->unk_82 -= gUnk_080CBFE8[(*(Entity**)&super->contactedEntity)->type];
} else {
this->cutsceneBeh.HWORD = 0x294;
this->hitType = 0x83;
this->field_0x82.HALF.LO = 0;
ChangeObjPalette(this, 0x7c);
this->unk_84 = 0x294;
super->hitType = 0x83;
this->unk_82 = 0;
ChangeObjPalette(super, 0x7c);
}
this->action = 7;
this->timer = 60;
if (0 < this->zVelocity) {
this->zVelocity = 0;
super->action = 7;
super->timer = 60;
if (0 < super->zVelocity) {
super->zVelocity = 0;
}
this->iframes = -0xc;
this->knockbackDuration = 0;
if (this->field_0x80.HALF.LO == 0) {
this->animationState = (*(Entity**)&this->contactedEntity)->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
this->frameDuration = 6;
this->field_0x80.HALF.LO = 1;
super->iframes = -0xc;
super->knockbackDuration = 0;
if (this->unk_80 == 0) {
super->animationState = (*(Entity**)&super->contactedEntity)->direction >> 3;
InitializeAnimation(super, super->animationState + 4);
super->frameDuration = 6;
this->unk_80 = 1;
}
break;
default:
if (this->hitType == 0x82 && this->iframes < 0) {
if (super->hitType == 0x82 && super->iframes < 0) {
Entity* entity = CreateObject(DIRT_PARTICLE, 2, 0);
if (entity != NULL) {
entity->spritePriority.b0 = 3;
CopyPosition(this, entity);
CopyPosition(super, entity);
}
EnqueueSFX(SFX_186);
}
break;
}
EnemyFunctionHandlerAfterCollision(this, Puffstool_Functions);
EnemyFunctionHandlerAfterCollision(super, Puffstool_Functions);
}
void Puffstool_OnDeath(Entity* this) {
if ((this->gustJarState & 2) && this->timer == 1 && this->field_0x82.HALF.LO) {
void Puffstool_OnDeath(PuffstoolEntity* this) {
if ((super->gustJarState & 2) && super->timer == 1 && this->unk_82) {
sub_08025B18(this);
}
GenericDeath(this);
GenericDeath(super);
}
void Puffstool_OnGrabbed(Entity* this) {
GravityUpdate(this, Q_8_8(32.0));
if (sub_0806F520(this)) {
gUnk_080CBFEC[this->subAction](this);
void Puffstool_OnGrabbed(PuffstoolEntity* this) {
GravityUpdate(super, Q_8_8(32.0));
if (sub_0806F520(super)) {
gUnk_080CBFEC[super->subAction](this);
} else {
sub_08025C2C(this);
}
}
void sub_08025180(Entity* this) {
this->subAction = 1;
this->timer = Random();
this->animationState = (((*(Entity**)&this->contactedEntity)->direction ^ 0x10) >> 3);
InitializeAnimation(this, this->animationState + 4);
sub_0804AA1C(this);
void sub_08025180(PuffstoolEntity* this) {
super->subAction = 1;
super->timer = Random();
super->animationState = (((*(Entity**)&super->contactedEntity)->direction ^ 0x10) >> 3);
InitializeAnimation(super, super->animationState + 4);
sub_0804AA1C(super);
}
void sub_080251AC(Entity* this) {
if (this->field_0x82.HALF.LO >= 4) {
this->field_0x82.HALF.LO -= 3;
if ((--this->timer & 3) == 0) {
void sub_080251AC(PuffstoolEntity* this) {
if (this->unk_82 >= 4) {
this->unk_82 -= 3;
if ((--super->timer & 3) == 0) {
sub_08025BD4(this);
}
} else {
this->cutsceneBeh.HWORD = 0x294;
this->hitType = 0x83;
this->field_0x82.HALF.LO = 0;
ChangeObjPalette(this, 0x7c);
this->unk_84 = 0x294;
super->hitType = 0x83;
this->unk_82 = 0;
ChangeObjPalette(super, 0x7c);
}
GetNextFrame(this);
GetNextFrame(super);
}
void sub_080251FC(Entity* this) {
sub_0804A720(this);
this->field_0x82.HALF.LO = 240;
this->direction = Random() & 0x1c;
this->field_0x80.HALF.LO = 0;
void sub_080251FC(PuffstoolEntity* this) {
sub_0804A720(super);
this->unk_82 = 240;
super->direction = Random() & 0x1c;
this->unk_80 = 0;
sub_080256B4(this);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
void sub_08025230(Entity* this) {
if (this->field_0x80.HALF.HI)
this->field_0x80.HALF.HI--;
void sub_08025230(PuffstoolEntity* this) {
if (this->unk_81)
this->unk_81--;
sub_08025C44(this);
GetNextFrame(this);
if (--this->timer == 0) {
this->timer = (Random() & 3) + 4;
this->direction = sub_08025C60(this);
GetNextFrame(super);
if (--super->timer == 0) {
super->timer = (Random() & 3) + 4;
super->direction = sub_08025C60(this);
}
if (this->collisions != COL_NONE) {
if (--this->subtimer == 0) {
sub_0800417E(this, this->collisions);
if (super->collisions != COL_NONE) {
if (--super->subtimer == 0) {
sub_0800417E(super, super->collisions);
}
} else {
this->subtimer = 30;
super->subtimer = 30;
}
if (this->field_0x78.HWORD == 0) {
if (this->unk_78 == 0) {
if (sub_0802571C(this)) {
this->action = 2;
this->timer = 240;
this->field_0x86.HWORD = COORD_TO_TILE(this);
super->action = 2;
super->timer = 240;
this->unk_86 = COORD_TO_TILE(super);
}
} else {
this->field_0x78.HWORD--;
this->unk_78--;
}
}
void sub_080252E0(Entity* this) {
void sub_080252E0(PuffstoolEntity* this) {
u32 tile;
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, (u16)this->field_0x7c.HALF.LO,
(u16)this->field_0x7c.HALF.HI);
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_7c, this->unk_7e);
sub_08025C44(this);
GetNextFrame(this);
GetNextFrame(super);
tile = COORD_TO_TILE(this);
if (tile == this->field_0x86.HWORD) {
if (--this->timer == 0) {
tile = COORD_TO_TILE(super);
if (tile == this->unk_86) {
if (--super->timer == 0) {
sub_080256B4(this);
}
} else {
this->field_0x86.HWORD = tile;
this->timer = 240;
this->unk_86 = tile;
super->timer = 240;
}
if (this->x.HALF.HI == (u16)this->field_0x7c.HALF.LO && this->y.HALF.HI == (u16)this->field_0x7c.HALF.HI) {
this->action = 3;
this->timer = 30;
this->subtimer = 0;
this->zVelocity = Q_16_16(1.5);
InitializeAnimation(this, 1);
if (super->x.HALF.HI == this->unk_7c && super->y.HALF.HI == this->unk_7e) {
super->action = 3;
super->timer = 30;
super->subtimer = 0;
super->zVelocity = Q_16_16(1.5);
InitializeAnimation(super, 1);
}
}
void sub_0802538C(Entity* this) {
if (this->timer) {
this->timer--;
void sub_0802538C(PuffstoolEntity* this) {
if (super->timer) {
super->timer--;
} else {
if (this->frame == 0) {
GetNextFrame(this);
if (super->frame == 0) {
GetNextFrame(super);
} else {
GravityUpdate(this, Q_8_8(32.0));
if (this->zVelocity < Q_16_16(0.125)) {
this->action = 4;
InitializeAnimation(this, 2);
GravityUpdate(super, Q_8_8(32.0));
if (super->zVelocity < Q_16_16(0.125)) {
super->action = 4;
InitializeAnimation(super, 2);
}
}
}
}
void sub_080253D4(Entity* this) {
GetNextFrame(this);
if (!GravityUpdate(this, Q_8_8(32.0))) {
if (this->subtimer == 0) {
this->action = 5;
InitializeAnimation(this, 3);
void sub_080253D4(PuffstoolEntity* this) {
GetNextFrame(super);
if (!GravityUpdate(super, Q_8_8(32.0))) {
if (super->subtimer == 0) {
super->action = 5;
InitializeAnimation(super, 3);
} else {
this->action = 6;
this->timer = 30;
InitializeAnimation(this, 3);
super->action = 6;
super->timer = 30;
InitializeAnimation(super, 3);
sub_08025A54(this);
sub_08025AE8(this);
}
}
}
void sub_0802541C(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 3;
this->subtimer = 1;
this->zVelocity = Q_16_16(2.0);
InitializeAnimation(this, 1);
void sub_0802541C(PuffstoolEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 3;
super->subtimer = 1;
super->zVelocity = Q_16_16(2.0);
InitializeAnimation(super, 1);
}
}
void sub_0802544C(Entity* this) {
if (this->frame == 0) {
GetNextFrame(this);
void sub_0802544C(PuffstoolEntity* this) {
if (super->frame == 0) {
GetNextFrame(super);
} else {
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_080256B4(this);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
}
}
void sub_0802547C(Entity* this) {
GravityUpdate(this, Q_8_8(32.0));
GetNextFrame(this);
if ((this->timer & 7) == 0) {
void sub_0802547C(PuffstoolEntity* this) {
GravityUpdate(super, Q_8_8(32.0));
GetNextFrame(super);
if ((super->timer & 7) == 0) {
sub_08025BD4(this);
}
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_08025C2C(this);
}
}
void sub_080254B4(Entity* this) {
GravityUpdate(this, Q_8_8(32.0));
if (this->frame & ANIM_DONE) {
if (this->z.HALF.HI == 0) {
if (this->cutsceneBeh.HWORD == 0) {
this->hitType = 0x82;
this->field_0x82.HALF.LO = -0x10;
void sub_080254B4(PuffstoolEntity* this) {
GravityUpdate(super, Q_8_8(32.0));
if (super->frame & ANIM_DONE) {
if (super->z.HALF.HI == 0) {
if (this->unk_84 == 0) {
super->hitType = 0x82;
this->unk_82 = -0x10;
sub_080256B4(this);
} else {
this->action = 0xc;
Create0x68FX(this, FX_STARS);
super->action = 0xc;
Create0x68FX(super, FX_STARS);
}
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
} else {
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_08025514(Entity* this) {
GetNextFrame(this);
if (sub_0802594C(this, this->timer++)) {
this->action = 2;
this->timer = 240;
this->field_0x80.HALF.HI = 120;
} else if (3 < this->timer) {
this->action = 10;
this->timer = 32;
void sub_08025514(PuffstoolEntity* this) {
GetNextFrame(super);
if (sub_0802594C(this, super->timer++)) {
super->action = 2;
super->timer = 240;
this->unk_81 = 120;
} else if (3 < super->timer) {
super->action = 10;
super->timer = 32;
}
}
void sub_08025554(Entity* this) {
void sub_08025554(PuffstoolEntity* this) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
sub_080256B4(this);
} else {
if ((this->timer & 3) == 0) {
this->direction = GetFacingDirection(entity, this);
if ((super->timer & 3) == 0) {
super->direction = GetFacingDirection(entity, super);
}
sub_08025C44(this);
GetNextFrame(this);
if (this->timer != 0) {
this->timer--;
GetNextFrame(super);
if (super->timer != 0) {
super->timer--;
} else {
if (!sub_080258C4(this)) {
sub_080256B4(this);
@ -338,19 +333,19 @@ void sub_08025554(Entity* this) {
}
}
void sub_080255AC(Entity* this) {
void sub_080255AC(PuffstoolEntity* this) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
sub_080256B4(this);
} else {
if (this->field_0x80.HALF.HI != 0) {
this->field_0x80.HALF.HI--;
if (this->unk_81 != 0) {
this->unk_81--;
}
if (--this->timer == 0) {
if (--super->timer == 0) {
s32 tmp;
this->timer = (Random() & 3) + 4;
super->timer = (Random() & 3) + 4;
tmp = Random() & 0xf;
if (tmp < 8) {
@ -358,57 +353,57 @@ void sub_080255AC(Entity* this) {
}
tmp -= 7;
this->direction = (GetFacingDirection(entity, this) + tmp) & (0x3 | DirectionNorthWest);
super->direction = (GetFacingDirection(entity, super) + tmp) & (0x3 | DirectionNorthWest);
}
if (this->field_0x78.HWORD == 0) {
if (this->unk_78 == 0) {
if (sub_080258C4(this) == 0) {
sub_080256B4(this);
}
} else {
this->field_0x78.HWORD--;
this->unk_78--;
}
sub_08025C44(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_0802563C(Entity* this) {
GetNextFrame(this);
void sub_0802563C(PuffstoolEntity* this) {
GetNextFrame(super);
if (--this->cutsceneBeh.HWORD == 0) {
ChangeObjPalette(this, 0x28);
this->hitType = 0x82;
this->field_0x82.HALF.LO = 240;
if (--this->unk_84 == 0) {
ChangeObjPalette(super, 0x28);
super->hitType = 0x82;
this->unk_82 = 240;
sub_080256B4(this);
sub_0804AA1C(this);
} else if (this->cutsceneBeh.HWORD < 120) {
u32 tmp3 = gUnk_080CBFF8[this->cutsceneBeh.HWORD >> 4];
if ((this->cutsceneBeh.HWORD & tmp3) == 0) {
if (this->cutsceneBeh.HWORD & (tmp3 + 1)) {
ChangeObjPalette(this, 124);
sub_0804AA1C(super);
} else if (this->unk_84 < 120) {
u32 tmp3 = gUnk_080CBFF8[this->unk_84 >> 4];
if ((this->unk_84 & tmp3) == 0) {
if (this->unk_84 & (tmp3 + 1)) {
ChangeObjPalette(super, 124);
} else {
ChangeObjPalette(this, 40);
ChangeObjPalette(super, 40);
}
}
}
}
void sub_080256B4(Entity* this) {
this->action = 1;
this->timer = (Random() & 3) + 4;
this->subtimer = 30;
this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & DirectionNorthWest;
this->field_0x78.HWORD = gUnk_080CC000[Random() & 0xf];
this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1;
this->field_0x7a.HALF.HI = 0;
void sub_080256B4(PuffstoolEntity* this) {
super->action = 1;
super->timer = (Random() & 3) + 4;
super->subtimer = 30;
super->direction = (super->direction + 7 + ((s32)Random() % 7) * 4) & DirectionNorthWest;
this->unk_78 = gUnk_080CC000[Random() & 0xf];
this->unk_7a = ((s32)Random() % 0x18) << 1;
this->unk_7b = 0;
}
bool32 sub_0802571C(Entity* this) {
bool32 sub_0802571C(PuffstoolEntity* this) {
RoomControls* ctrl = &gRoomControls;
u16 xDiff = (this->x.HALF.HI - ctrl->origin_x + 8) & -0x10;
u16 yDiff = (this->y.HALF.HI - ctrl->origin_y + 8) & -0x10;
u16 unk = this->field_0x7a.HALF.LO;
u16 xDiff = (super->x.HALF.HI - ctrl->origin_x + 8) & -0x10;
u16 yDiff = (super->y.HALF.HI - ctrl->origin_y + 8) & -0x10;
u16 unk = this->unk_7a;
u16 i;
for (i = 0; i < 4; i++) {
@ -416,8 +411,8 @@ bool32 sub_0802571C(Entity* this) {
u16 sVar4 = yDiff + gUnk_080CC020[unk + 1];
if (sub_080257EC(this, sVar3, sVar4)) {
this->field_0x7c.HALF.LO = sVar3 + ctrl->origin_x;
this->field_0x7c.HALF.HI = sVar4 + ctrl->origin_y;
this->unk_7c = sVar3 + ctrl->origin_x;
this->unk_7e = sVar4 + ctrl->origin_y;
return TRUE;
}
@ -427,28 +422,28 @@ bool32 sub_0802571C(Entity* this) {
}
}
this->field_0x7a.HALF.LO = unk;
this->field_0x7a.HALF.HI++;
this->unk_7a = unk;
this->unk_7b++;
return FALSE;
}
bool32 sub_080257EC(Entity* this, u32 x, u32 y) {
u16 tileType = sub_080B1A48(x - 0x00, y - 0x00, this->collisionLayer);
bool32 sub_080257EC(PuffstoolEntity* this, u32 x, u32 y) {
u16 tileType = sub_080B1A48(x - 0x00, y - 0x00, super->collisionLayer);
if (tileType != 0x312 && gUnk_080B37A0[tileType] != 0x16 && gUnk_080B3E80[tileType] == 0) {
return TRUE;
}
tileType = sub_080B1A48(x - 0x10, y - 0x00, this->collisionLayer);
tileType = sub_080B1A48(x - 0x10, y - 0x00, super->collisionLayer);
if (tileType != 0x312 && gUnk_080B37A0[tileType] != 0x16 && gUnk_080B3E80[tileType] == 0) {
return TRUE;
}
tileType = sub_080B1A48(x - 0x00, y - 0x10, this->collisionLayer);
tileType = sub_080B1A48(x - 0x00, y - 0x10, super->collisionLayer);
if (tileType != 0x312 && gUnk_080B37A0[tileType] != 0x16 && gUnk_080B3E80[tileType] == 0) {
return TRUE;
}
tileType = sub_080B1A48(x - 0x10, y - 0x10, this->collisionLayer);
tileType = sub_080B1A48(x - 0x10, y - 0x10, super->collisionLayer);
if (tileType != 0x312 && gUnk_080B37A0[tileType] != 0x16 && gUnk_080B3E80[tileType] == 0) {
return TRUE;
}
@ -456,26 +451,26 @@ bool32 sub_080257EC(Entity* this, u32 x, u32 y) {
return FALSE;
}
bool32 sub_080258C4(Entity* this) {
bool32 sub_080258C4(PuffstoolEntity* this) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
return FALSE;
} else {
s32 iVar4;
s32 iVar1;
iVar4 = entity->x.HALF.HI - this->x.HALF.HI;
iVar4 = entity->x.HALF.HI - super->x.HALF.HI;
iVar4 = iVar4 * iVar4;
iVar1 = entity->y.HALF.HI - this->y.HALF.HI;
iVar1 = entity->y.HALF.HI - super->y.HALF.HI;
iVar1 = iVar1 * iVar1;
iVar4 = iVar4 + iVar1;
if (this->cutsceneBeh.HWORD == 0 && this->field_0x80.HALF.HI == 0 && 0x400 >= iVar4) {
this->action = 9;
this->timer = 0;
if (this->unk_84 == 0 && this->unk_81 == 0 && 0x400 >= iVar4) {
super->action = 9;
super->timer = 0;
return TRUE;
} else if (0x900 >= iVar4) {
this->action = 11;
this->timer = 1;
this->field_0x78.HWORD = gUnk_080CC050[Random() & 0xf];
super->action = 11;
super->timer = 1;
this->unk_78 = gUnk_080CC050[Random() & 0xf];
return TRUE;
} else {
return FALSE;
@ -484,15 +479,15 @@ bool32 sub_080258C4(Entity* this) {
}
// regalloc
bool32 sub_0802594C(Entity* this, u32 param_2) {
bool32 sub_0802594C(PuffstoolEntity* this, u32 param_2) {
s16 xDiff;
s16 yDiff;
s16 iVar9;
u32 uVar1;
const s8* unk = gUnk_080CC090[param_2];
uVar1 = this->collisionLayer;
xDiff = (this->x.HALF.HI - gRoomControls.origin_x + 8) & -0x10;
yDiff = (this->y.HALF.HI - gRoomControls.origin_y + 8) & -0x10;
uVar1 = super->collisionLayer;
xDiff = (super->x.HALF.HI - gRoomControls.origin_x + 8) & -0x10;
yDiff = (super->y.HALF.HI - gRoomControls.origin_y + 8) & -0x10;
do {
u8 bVar7;
u8 bVar4;
@ -506,8 +501,8 @@ bool32 sub_0802594C(Entity* this, u32 param_2) {
bVar6 = sub_080B1B18(iVar9 - 0x00, iVar11 - 0x10, uVar1);
bVar7 = sub_080B1B18(iVar9 - 0x10, iVar11 - 0x10, uVar1);
if ((bVar4 | bVar5 | bVar6 | bVar7) == 0) {
this->field_0x7c.HALF.LO = gRoomControls.origin_x + iVar9;
this->field_0x7c.HALF.HI = gRoomControls.origin_y + iVar11;
this->unk_7c = gRoomControls.origin_x + iVar9;
this->unk_7e = gRoomControls.origin_y + iVar11;
return TRUE;
}
unk += 2;
@ -516,10 +511,10 @@ bool32 sub_0802594C(Entity* this, u32 param_2) {
return 0;
}
void sub_08025A54(Entity* this) {
u32 layer = this->collisionLayer;
s16 x = this->x.HALF.HI - gRoomControls.origin_x;
s16 y = this->y.HALF.HI - gRoomControls.origin_y;
void sub_08025A54(PuffstoolEntity* this) {
u32 layer = super->collisionLayer;
s16 x = super->x.HALF.HI - gRoomControls.origin_x;
s16 y = super->y.HALF.HI - gRoomControls.origin_y;
const s8* offset = gUnk_080CC0A0;
u32 i = 0;
@ -541,26 +536,26 @@ bool32 sub_08025AB8(u32 tile, u32 layer) {
return FALSE;
}
void sub_08025AE8(Entity* this) {
void sub_08025AE8(PuffstoolEntity* this) {
Entity* entity;
entity = CreateFx(this, FX_BROWN_SMOKE, 0);
entity = CreateFx(super, FX_BROWN_SMOKE, 0);
if (entity != NULL) {
entity->y.WORD--;
}
entity = CreateFx(this, FX_BROWN_SMOKE_LARGE, 0);
entity = CreateFx(super, FX_BROWN_SMOKE_LARGE, 0);
if (entity != NULL) {
entity->y.WORD++;
}
}
void sub_08025B18(Entity* this) {
void sub_08025B18(PuffstoolEntity* this) {
Entity* entity;
s32 x = this->x.HALF.HI - gRoomControls.origin_x;
s32 y = this->y.HALF.HI - gRoomControls.origin_y;
u32 layer = this->collisionLayer;
s32 x = super->x.HALF.HI - gRoomControls.origin_x;
s32 y = super->y.HALF.HI - gRoomControls.origin_y;
u32 layer = super->collisionLayer;
const s8* offset = gUnk_080CC0A8;
u32 i = 0;
@ -570,7 +565,7 @@ void sub_08025B18(Entity* this) {
entity = CreateObject(DIRT_PARTICLE, 2, 0);
if (entity != NULL) {
PositionRelative(this, entity, Q_16_16(offset[0]), Q_16_16(offset[1]));
PositionRelative(super, entity, Q_16_16(offset[0]), Q_16_16(offset[1]));
entity->x.HALF.HI &= -0x10;
entity->x.HALF.HI += 8;
entity->y.HALF.HI &= -0x10;
@ -580,50 +575,50 @@ void sub_08025B18(Entity* this) {
}
}
void sub_08025BD4(Entity* this) {
if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) {
void sub_08025BD4(PuffstoolEntity* this) {
if (this->unk_82 && (super->frame & 1) == 0) {
Entity* entity = CreateObject(DIRT_PARTICLE, 0, 0);
if (entity != NULL) {
PositionRelative(this, entity, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 0]),
Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 1]));
PositionRelative(super, entity, Q_16_16(gUnk_080CC0BA[super->animationState * 2 + 0]),
Q_16_16(gUnk_080CC0BA[super->animationState * 2 + 1]));
entity->z.HALF.HI = -10;
}
}
}
void sub_08025C2C(Entity* this) {
this->action = 8;
this->field_0x80.HALF.LO = 0;
InitializeAnimation(this, 8);
void sub_08025C2C(PuffstoolEntity* this) {
super->action = 8;
this->unk_80 = 0;
InitializeAnimation(super, 8);
}
bool32 sub_08025C44(Entity* this) {
if ((this->frame & 1) == 0) {
return ProcessMovement0(this);
bool32 sub_08025C44(PuffstoolEntity* this) {
if ((super->frame & 1) == 0) {
return ProcessMovement0(super);
} else {
return FALSE;
}
}
u32 sub_08025C60(Entity* this) {
if (!sub_08049FA0(this) && (Random() & 1)) {
return sub_08049EE4(this);
u32 sub_08025C60(PuffstoolEntity* this) {
if (!sub_08049FA0(super) && (Random() & 1)) {
return sub_08049EE4(super);
}
return (gUnk_080CC0C2[Random() & 7] + this->direction) & 0x1f;
return (gUnk_080CC0C2[Random() & 7] + super->direction) & 0x1f;
}
// clang-format off
void (*const Puffstool_Functions[])(Entity*) = {
void (*const Puffstool_Functions[])(PuffstoolEntity*) = {
Puffstool_OnTick,
Puffstool_OnCollide,
GenericKnockback,
(void (*)(PuffstoolEntity*))GenericKnockback,
Puffstool_OnDeath,
GenericConfused,
(void (*)(PuffstoolEntity*))GenericConfused,
Puffstool_OnGrabbed,
};
void (*const gUnk_080CBFB4[])(Entity*) = {
void (*const gUnk_080CBFB4[])(PuffstoolEntity*) = {
sub_080251FC,
sub_08025230,
sub_080252E0,
@ -643,7 +638,7 @@ const u8 gUnk_080CBFE8[] = {
40, 120, 240, 0x0
};
void (*const gUnk_080CBFEC[])(Entity*) = {
void (*const gUnk_080CBFEC[])(PuffstoolEntity*) = {
sub_08025180,
sub_080251AC,
sub_080251AC,

View File

@ -28,7 +28,12 @@ void sub_08031418(RopeEntity* this);
void sub_08031420(RopeEntity* this);
static void (*const Rope_Functions[6])(RopeEntity*) = {
Rope_OnTick, Rope_OnCollision, (void (*)(RopeEntity*))GenericKnockback, (void (*)(RopeEntity*))GenericDeath, (void (*)(RopeEntity*))GenericConfused, Rope_OnGrabbed,
Rope_OnTick,
Rope_OnCollision,
(void (*)(RopeEntity*))GenericKnockback,
(void (*)(RopeEntity*))GenericDeath,
(void (*)(RopeEntity*))GenericConfused,
Rope_OnGrabbed,
};
extern Entity* gUnk_020000B0;

View File

@ -28,7 +28,12 @@ void sub_080382EC(RopeGoldenEntity* this);
void sub_08038304(RopeGoldenEntity* this);
static void (*const RopeGolden_Functions[6])(RopeGoldenEntity*) = {
RopeGolden_OnTick, RopeGolden_OnCollision, (void (*)(RopeGoldenEntity*))GenericKnockback, RopeGolden_OnDeath, (void (*)(RopeGoldenEntity*))GenericConfused, RopeGolden_OnTick,
RopeGolden_OnTick,
RopeGolden_OnCollision,
(void (*)(RopeGoldenEntity*))GenericKnockback,
RopeGolden_OnDeath,
(void (*)(RopeGoldenEntity*))GenericConfused,
RopeGolden_OnTick,
};
void sub_080383AC(RopeGoldenEntity* this);

View File

@ -31,7 +31,12 @@ void sub_080450A8(SlimeEntity* this);
void sub_08045178(SlimeEntity* this, Entity*, int, int);
static void (*const Slime_Functions[])(SlimeEntity*) = {
Slime_OnTick, Slime_OnCollision, (void (*)(SlimeEntity*))GenericKnockback, (void (*)(SlimeEntity*))GenericDeath, (void (*)(SlimeEntity*))GenericConfused, Slime_OnGrabbed,
Slime_OnTick,
Slime_OnCollision,
(void (*)(SlimeEntity*))GenericKnockback,
(void (*)(SlimeEntity*))GenericDeath,
(void (*)(SlimeEntity*))GenericConfused,
Slime_OnGrabbed,
};
void Slime(SlimeEntity* this) {

View File

@ -26,7 +26,12 @@ void sub_080316E8(SmallPestoEntity* this);
void sub_080316F0(SmallPestoEntity* this);
static void (*const SmallPesto_Functions[])(SmallPestoEntity*) = {
SmallPesto_OnTick, SmallPesto_OnCollision, (void (*)(SmallPestoEntity*))GenericKnockback, (void (*)(SmallPestoEntity*))GenericDeath, (void (*)(SmallPestoEntity*))GenericConfused, SmallPesto_OnGrabbed,
SmallPesto_OnTick,
SmallPesto_OnCollision,
(void (*)(SmallPestoEntity*))GenericKnockback,
(void (*)(SmallPestoEntity*))GenericDeath,
(void (*)(SmallPestoEntity*))GenericConfused,
SmallPesto_OnGrabbed,
};
void sub_080317B4(SmallPestoEntity* this);

View File

@ -4,24 +4,36 @@
*
* @brief Spear Moblin enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
void sub_08028604(Entity*);
void sub_08028754(Entity*);
void sub_08028784(Entity*);
void sub_080287E0(Entity*);
void sub_08028728(Entity*);
bool32 sub_080286CC(Entity*);
bool32 sub_080288A4(Entity*);
void sub_08028858(Entity*);
void sub_080288C0(Entity*);
bool32 sub_08028828(u32, u32);
void sub_080287B4(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[18];
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u8 unused2[4];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} SpearMoblinEntity;
extern void (*const SpearMoblin_Functions[])(Entity*);
extern void (*const gUnk_080CC7A8[])(Entity*);
void sub_08028604(SpearMoblinEntity*);
void sub_08028754(SpearMoblinEntity*);
void sub_08028784(SpearMoblinEntity*);
void sub_080287E0(SpearMoblinEntity*);
void sub_08028728(SpearMoblinEntity*);
bool32 sub_080286CC(SpearMoblinEntity*);
bool32 sub_080288A4(SpearMoblinEntity*);
void sub_08028858(SpearMoblinEntity*);
void sub_080288C0(SpearMoblinEntity*);
bool32 sub_08028828(u32, u32);
void sub_080287B4(SpearMoblinEntity*);
extern void (*const SpearMoblin_Functions[])(SpearMoblinEntity*);
extern void (*const gUnk_080CC7A8[])(SpearMoblinEntity*);
extern const u8 gUnk_080CC7BC[];
extern const s8 gUnk_080CC7C0[];
extern const s8 gUnk_080CC7D0[];
@ -29,266 +41,266 @@ extern const u16 gUnk_080CC7D8[];
extern const Hitbox* const gUnk_080CC944[];
void SpearMoblin(Entity* this) {
EnemyFunctionHandler(this, SpearMoblin_Functions);
SetChildOffset(this, 0, 1, -0x20);
if (this->child && this->child->next) {
CopyPosition(this, this->child);
void SpearMoblin(SpearMoblinEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)SpearMoblin_Functions);
SetChildOffset(super, 0, 1, -0x20);
if (super->child && super->child->next) {
CopyPosition(super, super->child);
}
}
void SpearMoblin_OnTick(Entity* this) {
gUnk_080CC7A8[this->action](this);
void SpearMoblin_OnTick(SpearMoblinEntity* this) {
gUnk_080CC7A8[super->action](this);
}
void SpearMoblin_OnCollision(Entity* this) {
if (this->confusedTime != 0)
Create0x68FX(this, FX_STARS);
void SpearMoblin_OnCollision(SpearMoblinEntity* this) {
if (super->confusedTime != 0)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, SpearMoblin_Functions);
if (this->contactFlags & 0x80) {
if (this->action != 4) {
EnemyFunctionHandlerAfterCollision(super, SpearMoblin_Functions);
if (super->contactFlags & 0x80) {
if (super->action != 4) {
sub_08028754(this);
} else {
if ((this->contactFlags & 0x3f) == 0) {
this->field_0x7a.HALF.LO++;
this->field_0x80.HALF.HI = 0x16;
if ((super->contactFlags & 0x3f) == 0) {
this->unk_7a++;
this->unk_81 = 0x16;
sub_08028784(this);
}
}
}
this->child->iframes = this->iframes;
if (this->health == 0) {
this->speed = 0;
this->field_0x82.HALF.LO = 0;
super->child->iframes = super->iframes;
if (super->health == 0) {
super->speed = 0;
this->unk_82 = 0;
sub_080287E0(this);
DeleteEntity(this->child);
this->child = NULL;
DeleteEntity(super->child);
super->child = NULL;
}
}
void SpearMoblin_OnGrabbed(Entity* this) {
void SpearMoblin_OnGrabbed(SpearMoblinEntity* this) {
/* ... */
}
void sub_08028314(Entity* this) {
void sub_08028314(SpearMoblinEntity* this) {
Entity* pEVar2;
sub_0804A720(this);
this->action = 1;
this->animationState = 0;
this->field_0x7a.HALF.HI = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
this->field_0x7a.HALF.LO = 0;
this->field_0x82.HALF.LO = 1;
sub_0804A720(super);
super->action = 1;
super->animationState = 0;
this->unk_7b = 0;
this->unk_80 = 0;
this->unk_83 = 0;
this->unk_81 = 0;
this->unk_7a = 0;
this->unk_82 = 1;
if (this->timer) {
this->animationState = this->type2 << 1;
this->timer = 30;
this->speed = 0x80;
this->direction = this->animationState << 2;
if (super->timer) {
super->animationState = super->type2 << 1;
super->timer = 30;
super->speed = 0x80;
super->direction = super->animationState << 2;
sub_080287E0(this);
} else {
this->animationState = 0x10;
super->animationState = 0x10;
sub_08028604(this);
}
pEVar2 = CreateProjectile(MOBLIN_SPEAR);
if (pEVar2 != NULL) {
pEVar2->parent = this;
this->child = pEVar2;
pEVar2->parent = super;
super->child = pEVar2;
}
}
void sub_08028378(Entity* this) {
if (this->field_0x80.HALF.HI != 0) {
this->field_0x80.HALF.HI--;
void sub_08028378(SpearMoblinEntity* this) {
if (this->unk_81 != 0) {
this->unk_81--;
}
if (--this->timer == 0) {
if (++this->field_0x80.HALF.LO >= 0x10) {
if (--super->timer == 0) {
if (++this->unk_80 >= 0x10) {
sub_08028728(this);
} else {
sub_08028604(this);
}
} else {
if (sub_080286CC(this)) {
this->field_0x7a.HALF.HI |= 1;
this->unk_7b |= 1;
}
if (sub_080288A4(this)) {
sub_0800417E(this, this->collisions);
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->field_0x82.HALF.HI++;
sub_0800417E(super, super->collisions);
super->animationState = DirectionRoundUp(super->direction) >> 2;
this->unk_83++;
sub_080287E0(this);
}
}
if (this->subtimer >= 0xc) {
if (this->field_0x7a.HALF.HI != 0) {
if (super->subtimer >= 0xc) {
if (this->unk_7b != 0) {
sub_08028754(this);
}
} else {
this->subtimer++;
super->subtimer++;
}
sub_08028858(this);
}
void sub_08028420(Entity* this) {
if (--this->timer == 0) {
this->action = 3;
this->field_0x82.HALF.LO = 0;
this->field_0x80.HALF.LO = 0;
this->animationState = 0x10;
void sub_08028420(SpearMoblinEntity* this) {
if (--super->timer == 0) {
super->action = 3;
this->unk_82 = 0;
this->unk_80 = 0;
super->animationState = 0x10;
sub_08028604(this);
} else {
if (sub_080286CC(this)) {
this->field_0x7a.HALF.HI |= 1;
this->unk_7b |= 1;
}
}
if (this->subtimer >= 0xc) {
if (this->field_0x7a.HALF.HI != 0) {
if (super->subtimer >= 0xc) {
if (this->unk_7b != 0) {
sub_08028754(this);
}
} else {
this->subtimer++;
super->subtimer++;
}
sub_08028858(this);
}
void sub_08028488(Entity* this) {
if (--this->timer == 0) {
switch (this->field_0x82.HALF.LO) {
void sub_08028488(SpearMoblinEntity* this) {
if (--super->timer == 0) {
switch (this->unk_82) {
case 3:
this->action = 4;
this->speed = 0x180;
this->direction = sub_08049F84(this, 1);
super->action = 4;
super->speed = 0x180;
super->direction = sub_08049F84(super, 1);
EnqueueSFX(SFX_EM_MOBLIN_SPEAR);
break;
case 2:
this->action = 2;
this->speed = 0;
this->timer = (Random() & 7) * 3 + 64;
super->action = 2;
super->speed = 0;
super->timer = (Random() & 7) * 3 + 64;
break;
case 4:
this->direction = (this->direction + 0x10) & DirectionWest;
super->direction = (super->direction + 0x10) & DirectionWest;
/* fallthrough */
case 1:
default:
this->action = 1;
this->field_0x82.HALF.LO = 1;
this->speed = 0x80;
this->timer = (Random() & 7) * 3 + 0x22;
super->action = 1;
this->unk_82 = 1;
super->speed = 0x80;
super->timer = (Random() & 7) * 3 + 0x22;
break;
}
this->subtimer = 0;
this->animationState = DirectionRoundUp(this->direction) >> 2;
super->subtimer = 0;
super->animationState = DirectionRoundUp(super->direction) >> 2;
sub_080287E0(this);
}
sub_08028858(this);
}
void sub_08028528(Entity* this) {
void sub_08028528(SpearMoblinEntity* this) {
Entity* entity = sub_08049DF4(1);
const Hitbox* box;
if (entity == NULL) {
this->subtimer = 0;
super->subtimer = 0;
sub_08028728(this);
} else {
sub_080288C0(this);
box = gUnk_080CC944[this->animationState >> 1];
this->hitbox->offset_x = box->offset_x;
this->hitbox->offset_y = box->offset_y;
this->hitbox->width = box->width;
this->hitbox->height = box->height;
box = gUnk_080CC944[super->animationState >> 1];
super->hitbox->offset_x = box->offset_x;
super->hitbox->offset_y = box->offset_y;
super->hitbox->width = box->width;
super->hitbox->height = box->height;
if (this->field_0x7a.HALF.LO != 0) {
this->field_0x7a.HALF.LO = 0;
this->field_0x80.HALF.HI = 0x16;
if (this->unk_7a != 0) {
this->unk_7a = 0;
this->unk_81 = 0x16;
sub_08028784(this);
} else {
if (++this->timer == 0x20) {
if (++super->timer == 0x20) {
u32 direction;
this->timer = 0;
direction = GetFacingDirection(this, entity);
if (sub_08028828(this->direction, direction)) {
this->direction = direction;
super->timer = 0;
direction = GetFacingDirection(super, entity);
if (sub_08028828(super->direction, direction)) {
super->direction = direction;
}
}
if ((this->timer & 7) == 0) {
if ((super->timer & 7) == 0) {
EnqueueSFX(SFX_F0);
CreateFx(this, FX_DEATH, 0x40);
CreateFx(super, FX_DEATH, 0x40);
}
if (++this->field_0x7a.HALF.HI == 0x80) {
this->field_0x7a.HALF.LO++;
if (++this->unk_7b == 0x80) {
this->unk_7a++;
}
}
if (0x20 < this->field_0x7a.HALF.HI) {
ProcessMovement0(this);
if (0x20 < this->unk_7b) {
ProcessMovement0(super);
}
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_08028604(Entity* this) {
void sub_08028604(SpearMoblinEntity* this) {
u32 iVar3;
this->subtimer = 0;
if (this->field_0x82.HALF.LO == 1) {
this->timer = gUnk_080CC7BC[Random() & 3];
this->speed = 0x80;
if (sub_08049FA0(this) != 0) {
super->subtimer = 0;
if (this->unk_82 == 1) {
super->timer = gUnk_080CC7BC[Random() & 3];
super->speed = 0x80;
if (sub_08049FA0(super) != 0) {
u32 rand = Random();
u32 tmp;
tmp = gUnk_080CC7D0[rand & 7] + 0x18;
this->direction = DirectionRound(tmp + this->direction);
iVar3 = Direction8ToAnimationState(this->direction);
super->direction = DirectionRound(tmp + super->direction);
iVar3 = Direction8ToAnimationState(super->direction);
} else {
iVar3 = sub_08049EE4(this);
if (this->field_0x82.HALF.HI == 0) {
iVar3 = sub_08049EE4(super);
if (this->unk_83 == 0) {
u32 rand = Random();
iVar3 += gUnk_080CC7C0[rand & 0xf];
} else {
u32 rand = Random();
iVar3 += gUnk_080CC7C0[rand & 7];
this->timer = this->timer + 0x10;
this->field_0x82.HALF.HI--;
super->timer = super->timer + 0x10;
this->unk_83--;
}
this->direction = (iVar3 + 4U) & DirectionWest;
iVar3 = Direction8ToAnimationState(this->direction);
super->direction = (iVar3 + 4U) & DirectionWest;
iVar3 = Direction8ToAnimationState(super->direction);
}
} else {
this->timer = 12;
this->speed = 0;
iVar3 = Direction8ToAnimationState(this->direction);
super->timer = 12;
super->speed = 0;
iVar3 = Direction8ToAnimationState(super->direction);
}
if (iVar3 != this->animationState) {
this->animationState = iVar3;
if (iVar3 != super->animationState) {
super->animationState = iVar3;
sub_080287E0(this);
}
}
bool32 sub_080286CC(Entity* this) {
if (this->field_0x80.HALF.HI == 0) {
bool32 sub_080286CC(SpearMoblinEntity* this) {
if (this->unk_81 == 0) {
Entity* entity = sub_08049DF4(1);
if (entity != NULL) {
if (this->field_0x82.HALF.LO == 2 && sub_0806FC80(this, entity, 0x30))
if (this->unk_82 == 2 && sub_0806FC80(super, entity, 0x30))
return TRUE;
if (sub_0806FC80(this, entity, 0x40) &&
DirectionRoundUp(GetFacingDirection(this, entity)) >> 2 == this->animationState)
if (sub_0806FC80(super, entity, 0x40) &&
DirectionRoundUp(GetFacingDirection(super, entity)) >> 2 == super->animationState)
return TRUE;
}
}
@ -296,45 +308,45 @@ bool32 sub_080286CC(Entity* this) {
return FALSE;
}
void sub_08028728(Entity* this) {
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->direction = this->animationState << 2;
this->field_0x82.HALF.HI >>= 1;
void sub_08028728(SpearMoblinEntity* this) {
super->animationState = DirectionRoundUp(super->direction) >> 2;
super->direction = super->animationState << 2;
this->unk_83 >>= 1;
sub_080287B4(this);
this->field_0x82.HALF.LO = 2;
this->unk_82 = 2;
}
void sub_08028754(Entity* this) {
this->direction = sub_08049F84(this, 1);
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->field_0x82.HALF.HI = 0;
void sub_08028754(SpearMoblinEntity* this) {
super->direction = sub_08049F84(super, 1);
super->animationState = DirectionRoundUp(super->direction) >> 2;
this->unk_83 = 0;
sub_080287B4(this);
this->field_0x82.HALF.LO = 3;
this->unk_82 = 3;
}
void sub_08028784(Entity* this) {
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->direction = this->animationState << 2;
this->field_0x82.HALF.HI = 0;
void sub_08028784(SpearMoblinEntity* this) {
super->animationState = DirectionRoundUp(super->direction) >> 2;
super->direction = super->animationState << 2;
this->unk_83 = 0;
sub_080287B4(this);
this->timer <<= 1;
this->field_0x82.HALF.LO = 4;
super->timer <<= 1;
this->unk_82 = 4;
}
void sub_080287B4(Entity* this) {
this->action = 3;
this->timer = 32;
this->subtimer = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x7a.HALF.HI = 0;
this->speed = 0;
this->field_0x82.HALF.LO = 0;
void sub_080287B4(SpearMoblinEntity* this) {
super->action = 3;
super->timer = 32;
super->subtimer = 0;
this->unk_80 = 0;
this->unk_7b = 0;
super->speed = 0;
this->unk_82 = 0;
sub_080287E0(this);
}
void sub_080287E0(Entity* this) {
u32 sprite = this->animationState >> 1;
switch (this->field_0x82.HALF.LO) {
void sub_080287E0(SpearMoblinEntity* this) {
u32 sprite = super->animationState >> 1;
switch (this->unk_82) {
case 0:
/* ... */
break;
@ -349,7 +361,7 @@ void sub_080287E0(Entity* this) {
sprite += 0xc;
break;
}
InitializeAnimation(this, sprite);
InitializeAnimation(super, sprite);
}
bool32 sub_08028828(u32 arg0, u32 arg1) {
@ -363,50 +375,50 @@ bool32 sub_08028828(u32 arg0, u32 arg1) {
return FALSE;
}
void sub_08028858(Entity* this) {
void sub_08028858(SpearMoblinEntity* this) {
const Hitbox* box;
sub_080288C0(this);
box = gUnk_080CC944[this->animationState >> 1];
this->hitbox->offset_x = box->offset_x;
this->hitbox->offset_y = box->offset_y;
this->hitbox->width = box->width;
this->hitbox->height = box->height;
box = gUnk_080CC944[super->animationState >> 1];
super->hitbox->offset_x = box->offset_x;
super->hitbox->offset_y = box->offset_y;
super->hitbox->width = box->width;
super->hitbox->height = box->height;
if (this->field_0x82.HALF.LO == 0) {
this->speed = 0;
if (this->unk_82 == 0) {
super->speed = 0;
}
ProcessMovement0(this);
GetNextFrame(this);
ProcessMovement0(super);
GetNextFrame(super);
}
bool32 sub_080288A4(Entity* this) {
return (this->collisions & gUnk_080CC7D8[this->animationState >> 1]) != 0;
bool32 sub_080288A4(SpearMoblinEntity* this) {
return (super->collisions & gUnk_080CC7D8[super->animationState >> 1]) != 0;
}
void sub_080288C0(Entity* this) {
Entity* entity = this->child;
void sub_080288C0(SpearMoblinEntity* this) {
Entity* entity = super->child;
if ((entity != NULL) && (entity->contactFlags & 0x80)) {
this->knockbackDirection = entity->knockbackDirection;
this->iframes = -entity->iframes;
this->knockbackSpeed = entity->knockbackSpeed;
this->knockbackDuration = entity->knockbackDuration;
super->knockbackDirection = entity->knockbackDirection;
super->iframes = -entity->iframes;
super->knockbackSpeed = entity->knockbackSpeed;
super->knockbackDuration = entity->knockbackDuration;
entity->knockbackDuration = 0;
}
}
// clang-format off
void (*const SpearMoblin_Functions[])(Entity*) = {
void (*const SpearMoblin_Functions[])(SpearMoblinEntity*) = {
SpearMoblin_OnTick,
SpearMoblin_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(SpearMoblinEntity*))GenericKnockback,
(void (*)(SpearMoblinEntity*))GenericDeath,
(void (*)(SpearMoblinEntity*))GenericConfused,
SpearMoblin_OnGrabbed,
};
void (*const gUnk_080CC7A8[])(Entity*) = {
void (*const gUnk_080CC7A8[])(SpearMoblinEntity*) = {
sub_08028314,
sub_08028378,
sub_08028420,

View File

@ -4,41 +4,48 @@
*
* @brief Spiny Chuchu enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "hitbox.h"
u32 sub_080228CC(Entity*);
u32 sub_080228F0(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
} SpinyChuchuEntity;
extern void (*const SpinyChuchu_Functions[])(Entity*);
extern void (*const gUnk_080CBA40[])(Entity*);
u32 sub_080228CC(SpinyChuchuEntity*);
u32 sub_080228F0(SpinyChuchuEntity*);
extern void (*const SpinyChuchu_Functions[])(SpinyChuchuEntity*);
extern void (*const gUnk_080CBA40[])(SpinyChuchuEntity*);
extern const u8 gUnk_080CBA60[];
extern Entity* gUnk_020000B0;
void SpinyChuchu(Entity* this) {
EnemyFunctionHandler(this, SpinyChuchu_Functions);
SetChildOffset(this, 0, 1, -0x10);
void SpinyChuchu(SpinyChuchuEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)SpinyChuchu_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void SpinyChuchu_OnTick(Entity* this) {
gUnk_080CBA40[this->action](this);
void SpinyChuchu_OnTick(SpinyChuchuEntity* this) {
gUnk_080CBA40[super->action](this);
}
void SpinyChuchu_OnCollision(Entity* this) {
if (this->health) {
if (this->hitType == 0x65) {
switch (this->contactFlags & 0x7f) {
void SpinyChuchu_OnCollision(SpinyChuchuEntity* this) {
if (super->health) {
if (super->hitType == 0x65) {
switch (super->contactFlags & 0x7f) {
case 2:
case 3:
this->action = 2;
this->subtimer = 60;
this->hitType = 0x5c;
this->hitbox = (Hitbox*)&gHitbox_23;
InitializeAnimation(this, 0);
super->action = 2;
super->subtimer = 60;
super->hitType = 0x5c;
super->hitbox = (Hitbox*)&gHitbox_23;
InitializeAnimation(super, 0);
break;
case 8:
case 9:
@ -49,225 +56,225 @@ void SpinyChuchu_OnCollision(Entity* this) {
case 0x18:
case 0x19:
case 0x1a:
Create0x68FX(this, FX_STARS);
this->action = 5;
this->hitType = 0x5c;
InitializeAnimation(this, 1);
Create0x68FX(super, FX_STARS);
super->action = 5;
super->hitType = 0x5c;
InitializeAnimation(super, 1);
}
} else if (this->contactFlags == 0x94) {
Create0x68FX(this, FX_STARS);
this->action = 5;
InitializeAnimation(this, 1);
} else if (super->contactFlags == 0x94) {
Create0x68FX(super, FX_STARS);
super->action = 5;
InitializeAnimation(super, 1);
}
if (this->field_0x80.HALF.LO != this->health) {
this->action = 5;
this->hitType = 0x5c;
InitializeAnimation(this, 1);
if (this->unk_80 != super->health) {
super->action = 5;
super->hitType = 0x5c;
InitializeAnimation(super, 1);
} else {
if (this->action == 3) {
this->action = 4;
InitializeAnimation(this, 3);
if (super->action == 3) {
super->action = 4;
InitializeAnimation(super, 3);
EnqueueSFX(SFX_194);
}
}
} else {
InitializeAnimation(this, 1);
InitializeAnimation(super, 1);
}
this->field_0x80.HALF.LO = this->health;
EnemyFunctionHandlerAfterCollision(this, SpinyChuchu_Functions);
this->unk_80 = super->health;
EnemyFunctionHandlerAfterCollision(super, SpinyChuchu_Functions);
}
void SpinyChuchu_OnKnockback(Entity* this) {
if (this->animIndex == 1)
GetNextFrame(this);
sub_08001318(this);
void SpinyChuchu_OnKnockback(SpinyChuchuEntity* this) {
if (super->animIndex == 1)
GetNextFrame(super);
sub_08001318(super);
}
void SpinyChuchu_OnDeath(Entity* this) {
GravityUpdate(this, Q_8_8(24.0));
if (this->frame & 1) {
GenericDeath(this);
void SpinyChuchu_OnDeath(SpinyChuchuEntity* this) {
GravityUpdate(super, Q_8_8(24.0));
if (super->frame & 1) {
GenericDeath(super);
} else {
GetNextFrame(this);
GetNextFrame(super);
}
}
void SpinyChuchu_OnGrabbed(Entity* this) {
void SpinyChuchu_OnGrabbed(SpinyChuchuEntity* this) {
}
void sub_080225EC(Entity* this) {
sub_0804A720(this);
this->field_0x80.HALF.LO = this->health;
this->field_0x80.HALF.HI = 0x5a;
if (this->timer == 0) {
this->action = 2;
InitializeAnimation(this, 0);
void sub_080225EC(SpinyChuchuEntity* this) {
sub_0804A720(super);
this->unk_80 = super->health;
this->unk_81 = 0x5a;
if (super->timer == 0) {
super->action = 2;
InitializeAnimation(super, 0);
} else {
this->action = 1;
this->subtimer = 60;
this->spriteSettings.draw = 3;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
this->z.HALF.HI = -0x80;
InitializeAnimation(this, 6);
super->action = 1;
super->subtimer = 60;
super->spriteSettings.draw = 3;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
super->z.HALF.HI = -0x80;
InitializeAnimation(super, 6);
}
}
void sub_08022654(Entity* this) {
switch (this->subAction) {
void sub_08022654(SpinyChuchuEntity* this) {
switch (super->subAction) {
case 0:
if (--this->subtimer)
if (--super->subtimer)
return;
this->subAction = 1;
super->subAction = 1;
SoundReq(SFX_12D);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
/* fallthrough */
case 1:
if (GravityUpdate(this, Q_8_8(24.0)))
if (GravityUpdate(super, Q_8_8(24.0)))
return;
this->subAction = 2;
this->spriteSettings.draw = 1;
InitializeAnimation(this, 5);
super->subAction = 2;
super->spriteSettings.draw = 1;
InitializeAnimation(super, 5);
EnqueueSFX(SFX_PLY_LAND);
UpdateSpriteForCollisionLayer(this);
UpdateSpriteForCollisionLayer(super);
/* fallthrough */
case 2:
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 3;
this->hitType = 0x65;
InitializeAnimation(this, 2);
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 3;
super->hitType = 0x65;
InitializeAnimation(super, 2);
}
break;
}
}
void sub_080226EC(Entity* this) {
if (sub_08049FDC(this, 1)) {
void sub_080226EC(SpinyChuchuEntity* this) {
if (sub_08049FDC(super, 1)) {
if (sub_080228CC(this)) {
this->action = 3;
this->hitType = 0x65;
InitializeAnimation(this, 2);
super->action = 3;
super->hitType = 0x65;
InitializeAnimation(super, 2);
return;
}
if (sub_080228F0(this)) {
this->action = 6;
this->zVelocity = Q_16_16(1.125);
this->speed = 0x140;
this->direction = GetFacingDirection(this, gUnk_020000B0);
this->hitType = 0x5a;
InitializeAnimation(this, 4);
super->action = 6;
super->zVelocity = Q_16_16(1.125);
super->speed = 0x140;
super->direction = GetFacingDirection(super, gUnk_020000B0);
super->hitType = 0x5a;
InitializeAnimation(super, 4);
return;
}
if ((this->timer++ & 7) == 0) {
this->direction = sub_08049F84(this, 1);
if ((super->timer++ & 7) == 0) {
super->direction = sub_08049F84(super, 1);
}
ProcessMovement0(this);
ProcessMovement0(super);
}
GetNextFrame(this);
GetNextFrame(super);
}
void sub_08022780(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 4;
InitializeAnimation(this, 3);
void sub_08022780(SpinyChuchuEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 4;
InitializeAnimation(super, 3);
EnqueueSFX(SFX_194);
}
}
void sub_080227AC(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
this->hitbox = (Hitbox*)&gHitbox_32;
void sub_080227AC(SpinyChuchuEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
super->hitbox = (Hitbox*)&gHitbox_32;
} else {
this->hitbox = (Hitbox*)&gHitbox_23;
super->hitbox = (Hitbox*)&gHitbox_23;
}
if (this->frame & 2) {
this->frame &= ~2;
this->hitType = 0x5c;
if (super->frame & 2) {
super->frame &= ~2;
super->hitType = 0x5c;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->subtimer = gUnk_080CBA60[Random() & 3];
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->subtimer = gUnk_080CBA60[Random() & 3];
InitializeAnimation(super, 0);
}
}
void sub_0802281C(Entity* this) {
GravityUpdate(this, Q_8_8(24.0));
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 2;
this->speed = 0x20;
InitializeAnimation(this, 0);
sub_0804AA1C(this);
void sub_0802281C(SpinyChuchuEntity* this) {
GravityUpdate(super, Q_8_8(24.0));
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->speed = 0x20;
InitializeAnimation(super, 0);
sub_0804AA1C(super);
}
}
void sub_08022854(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
ProcessMovement2(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 7;
this->hitType = 0x5c;
InitializeAnimation(this, 5);
void sub_08022854(SpinyChuchuEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
ProcessMovement2(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
super->action = 7;
super->hitType = 0x5c;
InitializeAnimation(super, 5);
EnqueueSFX(SFX_PLY_LAND);
}
}
}
void sub_0802289C(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 2;
this->speed = 0x20;
this->field_0x80.HALF.HI = 0x78;
InitializeAnimation(this, 0);
void sub_0802289C(SpinyChuchuEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->speed = 0x20;
this->unk_81 = 0x78;
InitializeAnimation(super, 0);
}
}
u32 sub_080228CC(Entity* this) {
if (this->subtimer == 0) {
if (PlayerInRange(this, 1, 0x28))
u32 sub_080228CC(SpinyChuchuEntity* this) {
if (super->subtimer == 0) {
if (PlayerInRange(super, 1, 0x28))
return 1;
} else {
this->subtimer--;
super->subtimer--;
}
return 0;
}
u32 sub_080228F0(Entity* this) {
if (this->field_0x80.HALF.HI == 0) {
if (PlayerInRange(this, 1, 0x40))
u32 sub_080228F0(SpinyChuchuEntity* this) {
if (this->unk_81 == 0) {
if (PlayerInRange(super, 1, 0x40))
return 1;
} else {
this->field_0x80.HALF.HI--;
this->unk_81--;
}
return 0;
}
// clang-format off
void (*const SpinyChuchu_Functions[])(Entity*) = {
void (*const SpinyChuchu_Functions[])(SpinyChuchuEntity*) = {
SpinyChuchu_OnTick,
SpinyChuchu_OnCollision,
SpinyChuchu_OnKnockback,
SpinyChuchu_OnDeath,
GenericConfused,
(void (*)(SpinyChuchuEntity*))GenericConfused,
SpinyChuchu_OnGrabbed,
};
void (*const gUnk_080CBA40[])(Entity*) = {
void (*const gUnk_080CBA40[])(SpinyChuchuEntity*) = {
sub_080225EC,
sub_08022654,
sub_080226EC,

View File

@ -4,38 +4,52 @@
*
* @brief Tektite enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
static void sub_0802F45C(Entity* this);
static void Tektite_OnTick(Entity*);
static void Tektite_OnCollision(Entity*);
static void Tektite_OnConfused(Entity*);
static void Tektite_OnGrabbed(Entity*);
static void sub_0802F210(Entity*);
static void sub_0802F284(Entity*);
static void sub_0802F300(Entity*);
static void sub_0802F3F4(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[20];
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unused2[3];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} TektiteEntity;
static void (*const Tektite_Functions[])(Entity*) = {
Tektite_OnTick, Tektite_OnCollision, GenericKnockback, GenericDeath, Tektite_OnConfused, Tektite_OnGrabbed,
static void sub_0802F45C(TektiteEntity* this);
static void Tektite_OnTick(TektiteEntity*);
static void Tektite_OnCollision(TektiteEntity*);
static void Tektite_OnConfused(TektiteEntity*);
static void Tektite_OnGrabbed(TektiteEntity*);
static void sub_0802F210(TektiteEntity*);
static void sub_0802F284(TektiteEntity*);
static void sub_0802F300(TektiteEntity*);
static void sub_0802F3F4(TektiteEntity*);
static void (*const Tektite_Functions[])(TektiteEntity*) = {
Tektite_OnTick,
Tektite_OnCollision,
(void (*)(TektiteEntity*))GenericKnockback,
(void (*)(TektiteEntity*))GenericDeath,
Tektite_OnConfused,
Tektite_OnGrabbed,
};
void Tektite(Entity* this) {
EnemyFunctionHandler(this, Tektite_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Tektite(TektiteEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Tektite_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void Tektite_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void Tektite_OnTick(TektiteEntity* this) {
static void (*const actionFuncs[])(TektiteEntity*) = {
sub_0802F210,
sub_0802F284,
sub_0802F300,
sub_0802F3F4,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
static const u8 gUnk_080CDEF8[] = {
@ -45,175 +59,167 @@ static const u8 gUnk_080CDEF8[] = {
0x48,
};
void Tektite_OnCollision(Entity* this) {
u32 bVar1;
u32 uVar2;
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
void Tektite_OnCollision(TektiteEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Tektite_Functions);
if ((this->contactFlags & 0x80) != 0) {
switch (this->contactFlags & 0x3f) {
EnemyFunctionHandlerAfterCollision(super, Tektite_Functions);
if ((super->contactFlags & 0x80) != 0) {
switch (super->contactFlags & 0x3f) {
case 0x14:
this->action = 1;
this->subAction = 0;
if (this->type != 0) {
this->timer = 192;
super->action = 1;
super->subAction = 0;
if (super->type != 0) {
super->timer = 192;
} else {
this->timer = gUnk_080CDEF8[Random() & 3];
super->timer = gUnk_080CDEF8[Random() & 3];
}
this->subtimer = 0;
*(u8*)&this->field_0x7c = 0;
if (this->z.HALF.HI != 0) {
this->zVelocity >>= 2;
super->subtimer = 0;
this->unk_7c = 0;
if (super->z.HALF.HI != 0) {
super->zVelocity >>= 2;
} else {
this->zVelocity = 0;
super->zVelocity = 0;
}
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
break;
case 0xe:
case 0x15:
this->health = 0;
super->health = 0;
break;
}
}
}
void Tektite_OnGrabbed(Entity* this) {
void Tektite_OnGrabbed(TektiteEntity* this) {
}
void Tektite_OnConfused(Entity* this) {
GenericConfused(this);
if (this->z.HALF.HI != 0) {
GravityUpdate(this, this->field_0x80.HWORD);
void Tektite_OnConfused(TektiteEntity* this) {
GenericConfused(super);
if (super->z.HALF.HI != 0) {
GravityUpdate(super, this->unk_80);
}
}
void sub_0802F210(Entity* this) {
u32 temp;
u32 temp2;
void sub_0802F210(TektiteEntity* this) {
sub_0804A720(super);
super->action = 1;
super->subAction = 0;
super->timer = gUnk_080CDEF8[Random() & 3];
super->timer += (Random() & 0x1f);
super->subtimer = 0;
this->unk_7c = 0;
sub_0804A720(this);
this->action = 1;
this->subAction = 0;
this->timer = gUnk_080CDEF8[Random() & 3];
this->timer += (Random() & 0x1f);
this->subtimer = 0;
*(u8*)&this->field_0x7c = 0;
this->unk_80 = super->type == 0 ? Q_8_8(24.0) : Q_8_8(40.0);
this->unk_82 = super->type == 0 ? (Q_16_16(2.5) >> 4) : (Q_16_16(3.0) >> 4);
this->field_0x80.HWORD = this->type == 0 ? Q_8_8(24.0) : Q_8_8(40.0);
this->field_0x82.HWORD = this->type == 0 ? (Q_16_16(2.5) >> 4) : (Q_16_16(3.0) >> 4);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
void sub_0802F284(Entity* this) {
if (this->timer > 0x60) {
UpdateAnimationVariableFrames(this, 2);
void sub_0802F284(TektiteEntity* this) {
if (super->timer > 0x60) {
UpdateAnimationVariableFrames(super, 2);
} else {
GetNextFrame(this);
GetNextFrame(super);
}
if (this->timer != 0) {
this->timer--;
} else if (this->subtimer != 0) {
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = 16;
this->subtimer = this->type;
this->zVelocity = this->field_0x82.HWORD << 4;
if (super->timer != 0) {
super->timer--;
} else if (super->subtimer != 0) {
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = 16;
super->subtimer = super->type;
super->zVelocity = this->unk_82 << 4;
sub_0802F45C(this);
InitializeAnimation(this, 2);
InitializeAnimation(super, 2);
}
} else if (this->frame & ANIM_DONE) {
this->subtimer = 64;
InitializeAnimation(this, 1);
} else if (super->frame & ANIM_DONE) {
super->subtimer = 64;
InitializeAnimation(super, 1);
}
}
void sub_0802F300(Entity* this) {
void sub_0802F300(TektiteEntity* this) {
s32 temp;
u32 rand;
GetNextFrame(this);
ProcessMovement0(this);
temp = this->z.HALF.HI;
GetNextFrame(super);
ProcessMovement0(super);
temp = super->z.HALF.HI;
rand = Random() & 0xf;
if (sub_080044EC(this, this->field_0x80.HWORD) == 1) {
this->action = 3;
this->subAction = 0;
if (this->type != 0) {
if (sub_080044EC(super, this->unk_80) == 1) {
super->action = 3;
super->subAction = 0;
if (super->type != 0) {
rand = 0;
}
if (rand == 0) {
this->timer = 192;
super->timer = 192;
} else {
this->timer = gUnk_080CDEF8[rand & 3] + rand;
super->timer = gUnk_080CDEF8[rand & 3] + rand;
}
this->subtimer = 0;
InitializeAnimation(this, 3);
super->subtimer = 0;
InitializeAnimation(super, 3);
return;
} else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
} else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) {
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
} else if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
} else if ((GetTileUnderEntity(super) & 0xf0) == 0x50) {
super->direction = (super->direction + 0x10) & (0x3 | DirectionNorthWest);
}
if (--this->timer == 0) {
this->timer = 16;
if (this->subtimer != 0) {
this->subtimer--;
if (--super->timer == 0) {
super->timer = 16;
if (super->subtimer != 0) {
super->subtimer--;
sub_0802F45C(this);
}
}
if ((this->subAction == 0) && (temp < this->z.HALF.HI)) {
InitializeAnimation(this, 4);
this->subAction = 1;
if ((super->subAction == 0) && (temp < super->z.HALF.HI)) {
InitializeAnimation(super, 4);
super->subAction = 1;
}
if (temp < -0xc) {
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
} else {
this->spriteRendering.b3 = 2;
this->spriteOrientation.flipY = 2;
super->spriteRendering.b3 = 2;
super->spriteOrientation.flipY = 2;
}
}
void sub_0802F3F4(Entity* this) {
void sub_0802F3F4(TektiteEntity* this) {
GetNextFrame(super);
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
if ((*(u8*)&this->field_0x7c.HALF.LO < 2) && ((this->type % 2) != 0)) {
this->action = 2;
this->timer = 16;
this->subtimer = this->type;
this->zVelocity = this->field_0x82.HWORD << 4;
(*(u8*)&this->field_0x7c.HALF.LO)++;
if (super->frame & ANIM_DONE) {
if ((this->unk_7c < 2) && ((super->type % 2) != 0)) {
super->action = 2;
super->timer = 16;
super->subtimer = super->type;
super->zVelocity = this->unk_82 << 4;
this->unk_7c++;
sub_0802F45C(this);
InitializeAnimation(this, 2);
InitializeAnimation(super, 2);
} else {
this->action = 1;
*(u8*)&this->field_0x7c.HALF.LO = 0;
InitializeAnimation(this, 0);
super->action = 1;
this->unk_7c = 0;
InitializeAnimation(super, 0);
}
}
}
static void sub_0802F45C(Entity* this) {
static void sub_0802F45C(TektiteEntity* this) {
u32 temp;
if (sub_08049FA0(this) == 0) {
this->direction = sub_08049EE4(this);
} else if (sub_08049FDC(this, 1) != 0) {
this->direction = sub_08049F84(this, 1);
if (sub_08049FA0(super) == 0) {
super->direction = sub_08049EE4(super);
} else if (sub_08049FDC(super, 1) != 0) {
super->direction = sub_08049F84(super, 1);
} else {
temp = (Random() & 0xf) + 0x18;
this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest);
super->direction = (temp + super->direction) & (0x3 | DirectionNorthWest);
}
}

View File

@ -4,187 +4,190 @@
*
* @brief Golden Tektite enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "item.h"
#include "functions.h"
#include "item.h"
void sub_08038168(Entity*);
void TektiteGolden_OnTick(Entity*);
void TektiteGolden_OnCollision(Entity*);
void TektiteGolden_OnDeath(Entity*);
void TektiteGolden_OnConfused(Entity*);
void TektiteGolden_OnTick(Entity*);
void sub_08037FA0(Entity*);
void sub_08037Fe0(Entity*);
void sub_08038048(Entity*);
void sub_08038110(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
} TektiteGoldenEntity;
static void (*const TektiteGolden_Functions[])(Entity*) = {
TektiteGolden_OnTick, TektiteGolden_OnCollision, GenericKnockback,
void sub_08038168(TektiteGoldenEntity*);
void TektiteGolden_OnTick(TektiteGoldenEntity*);
void TektiteGolden_OnCollision(TektiteGoldenEntity*);
void TektiteGolden_OnDeath(TektiteGoldenEntity*);
void TektiteGolden_OnConfused(TektiteGoldenEntity*);
void TektiteGolden_OnTick(TektiteGoldenEntity*);
void sub_08037FA0(TektiteGoldenEntity*);
void sub_08037Fe0(TektiteGoldenEntity*);
void sub_08038048(TektiteGoldenEntity*);
void sub_08038110(TektiteGoldenEntity*);
static void (*const TektiteGolden_Functions[])(TektiteGoldenEntity*) = {
TektiteGolden_OnTick, TektiteGolden_OnCollision, (void (*)(TektiteGoldenEntity*))GenericKnockback,
TektiteGolden_OnDeath, TektiteGolden_OnConfused, TektiteGolden_OnTick,
};
void TektiteGolden(Entity* this) {
EnemyFunctionHandler(this, TektiteGolden_Functions);
SetChildOffset(this, 0, 1, -0x10);
void TektiteGolden(TektiteGoldenEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)TektiteGolden_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void TektiteGolden_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void TektiteGolden_OnTick(TektiteGoldenEntity* this) {
static void (*const actionFuncs[])(TektiteGoldenEntity*) = {
sub_08037FA0,
sub_08037Fe0,
sub_08038048,
sub_08038110,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void TektiteGolden_OnCollision(Entity* this) {
u32 uVar1;
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
void TektiteGolden_OnCollision(TektiteGoldenEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, TektiteGolden_Functions);
if (this->contactFlags == 0x94) {
this->action = 1;
this->subAction = 0;
this->timer = 20;
this->subtimer = 0;
this->field_0x80.HALF.LO = 0;
if (this->z.HALF.HI != 0) {
this->zVelocity >>= 2;
EnemyFunctionHandlerAfterCollision(super, TektiteGolden_Functions);
if (super->contactFlags == 0x94) {
super->action = 1;
super->subAction = 0;
super->timer = 20;
super->subtimer = 0;
this->unk_80 = 0;
if (super->z.HALF.HI != 0) {
super->zVelocity >>= 2;
} else {
this->zVelocity = 0;
super->zVelocity = 0;
}
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
}
void TektiteGolden_OnDeath(Entity* this) {
void TektiteGolden_OnDeath(TektiteGoldenEntity* this) {
u32 uVar1;
if ((this->gustJarState & 2) == 0) {
SetGlobalFlag(this->type2);
if ((super->gustJarState & 2) == 0) {
SetGlobalFlag(super->type2);
}
if (this->type != 0) {
if (super->type != 0) {
uVar1 = ITEM_RUPEE200;
} else {
uVar1 = ITEM_RUPEE100;
}
CreateDeathFx(this, 0xff, uVar1);
CreateDeathFx(super, 0xff, uVar1);
}
void TektiteGolden_OnConfused(Entity* this) {
GenericConfused(this);
if (this->z.HALF.HI != 0) {
GravityUpdate(this, Q_8_8(48.0));
void TektiteGolden_OnConfused(TektiteGoldenEntity* this) {
GenericConfused(super);
if (super->z.HALF.HI != 0) {
GravityUpdate(super, Q_8_8(48.0));
}
}
void sub_08037FA0(Entity* this) {
if (CheckGlobalFlag(this->type2)) {
void sub_08037FA0(TektiteGoldenEntity* this) {
if (CheckGlobalFlag(super->type2)) {
DeleteThisEntity();
}
sub_0804A720(this);
this->action = 1;
this->subAction = 0;
this->timer = (Random() & 0x1f) + 32;
this->subtimer = 0;
this->field_0x80.HALF.LO = 0;
InitializeAnimation(this, 0);
sub_0804A720(super);
super->action = 1;
super->subAction = 0;
super->timer = (Random() & 0x1f) + 32;
super->subtimer = 0;
this->unk_80 = 0;
InitializeAnimation(super, 0);
}
void sub_08037Fe0(Entity* this) {
UpdateAnimationVariableFrames(this, 2);
if (this->timer != 0) {
this->timer--;
} else if (this->subtimer != 0) {
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = 6;
this->subtimer = 0;
this->zVelocity = Q_16_16(3.5);
void sub_08037Fe0(TektiteGoldenEntity* this) {
UpdateAnimationVariableFrames(super, 2);
if (super->timer != 0) {
super->timer--;
} else if (super->subtimer != 0) {
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = 6;
super->subtimer = 0;
super->zVelocity = Q_16_16(3.5);
sub_08038168(this);
InitializeAnimation(this, 2);
InitializeAnimation(super, 2);
}
} else if (this->frame & ANIM_DONE) {
this->subtimer = 64;
InitializeAnimation(this, 1);
} else if (super->frame & ANIM_DONE) {
super->subtimer = 64;
InitializeAnimation(super, 1);
}
}
void sub_08038048(Entity* this) {
void sub_08038048(TektiteGoldenEntity* this) {
s32 temp;
u32 rand;
UpdateAnimationVariableFrames(this, 2);
ProcessMovement0(this);
temp = this->z.HALF.HI;
UpdateAnimationVariableFrames(super, 2);
ProcessMovement0(super);
temp = super->z.HALF.HI;
rand = Random() & 0xf;
if (sub_080044EC(this, 0x3000) == 1) {
this->action = 3;
this->subAction = 0;
this->timer = 20;
InitializeAnimation(this, 3);
if (sub_080044EC(super, 0x3000) == 1) {
super->action = 3;
super->subAction = 0;
super->timer = 20;
InitializeAnimation(super, 3);
return;
} else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
} else if ((GetTileUnderEntity(this) & 0xf0) == 0x50) {
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
} else if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
} else if ((GetTileUnderEntity(super) & 0xf0) == 0x50) {
super->direction = (super->direction + 0x10) & (0x3 | DirectionNorthWest);
}
if (--this->timer == 0) {
this->timer = rand + 16;
if (--super->timer == 0) {
super->timer = rand + 16;
sub_08038168(this);
}
if ((this->subAction == 0) && (temp < this->z.HALF.HI)) {
InitializeAnimation(this, 4);
this->subAction = 1;
if ((super->subAction == 0) && (temp < super->z.HALF.HI)) {
InitializeAnimation(super, 4);
super->subAction = 1;
}
if (temp < -0xc) {
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
} else {
this->spriteRendering.b3 = 2;
this->spriteOrientation.flipY = 2;
super->spriteRendering.b3 = 2;
super->spriteOrientation.flipY = 2;
}
}
void sub_08038110(Entity* this) {
UpdateAnimationVariableFrames(this, 2);
if (this->frame & ANIM_DONE) {
if (this->field_0x80.HALF.LO < 5) {
this->action = 2;
this->timer = 8;
this->zVelocity = Q_16_16(3.5);
void sub_08038110(TektiteGoldenEntity* this) {
UpdateAnimationVariableFrames(super, 2);
if (super->frame & ANIM_DONE) {
if (this->unk_80 < 5) {
super->action = 2;
super->timer = 8;
super->zVelocity = Q_16_16(3.5);
sub_08038168(this);
InitializeAnimation(this, 2);
InitializeAnimation(super, 2);
} else {
this->action = 1;
this->field_0x80.HALF.LO = 0;
this->timer = 192;
InitializeAnimation(this, 0);
super->action = 1;
this->unk_80 = 0;
super->timer = 192;
InitializeAnimation(super, 0);
}
}
}
void sub_08038168(Entity* this) {
void sub_08038168(TektiteGoldenEntity* this) {
u32 temp;
if (sub_08049FA0(this) == 0) {
this->direction = sub_08049EE4(this);
} else if (sub_08049FDC(this, 1) != 0) {
this->direction = sub_08049F84(this, 1);
if (sub_08049FA0(super) == 0) {
super->direction = sub_08049EE4(super);
} else if (sub_08049FDC(super, 1) != 0) {
super->direction = sub_08049F84(super, 1);
} else {
temp = (Random() & 0xf) + 0x18;
this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest);
super->direction = (temp + super->direction) & (0x3 | DirectionNorthWest);
}
}

View File

@ -4,12 +4,17 @@
*
* @brief Tree Item enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "item.h"
#include "object.h"
static bool32 ShouldSpawnTreeItem(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68;
} TreeItemEntity;
static bool32 ShouldSpawnTreeItem(TreeItemEntity*);
extern void sub_08049CF4(Entity*);
@ -32,17 +37,17 @@ const u8 gTreeItemDrops[] = { 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x
#define FAIRY_INDEX 8
void TreeItem(Entity* this) {
void TreeItem(TreeItemEntity* this) {
Entity* itemEntity;
if (this->action == 0) {
this->action++;
this->field_0x68.HALF.LO = GetRandomByWeight(gTreeItemDropTables[this->type]);
if (this->field_0x68.HALF.LO > FAIRY_INDEX) {
if (super->action == 0) {
super->action++;
this->unk_68 = GetRandomByWeight(gTreeItemDropTables[super->type]);
if (this->unk_68 > FAIRY_INDEX) {
DeleteThisEntity();
}
if (this->field_0x68.HALF.LO < FAIRY_INDEX && GetInventoryValue(ITEM_KINSTONE_BAG) == 0) {
this->field_0x68.HALF.LO = FAIRY_INDEX;
if (this->unk_68 < FAIRY_INDEX && GetInventoryValue(ITEM_KINSTONE_BAG) == 0) {
this->unk_68 = FAIRY_INDEX;
}
}
@ -50,18 +55,18 @@ void TreeItem(Entity* this) {
return;
}
switch (this->field_0x68.HALF.LO) {
switch (this->unk_68) {
case FAIRY_INDEX:
itemEntity = CreateObject(FAIRY, 0x60, 0);
if (itemEntity) {
itemEntity->timer = 0;
CopyPosition(this, itemEntity);
CopyPosition(super, itemEntity);
}
break;
case 0 ...(FAIRY_INDEX - 1):
itemEntity = CreateObject(GRAVEYARD_KEY, 0x7, gTreeItemDrops[this->field_0x68.HALF.LO]);
itemEntity = CreateObject(GRAVEYARD_KEY, 0x7, gTreeItemDrops[this->unk_68]);
if (itemEntity) {
CopyPosition(this, itemEntity);
CopyPosition(super, itemEntity);
itemEntity->y.HALF.HI += 16;
itemEntity->z.HALF.HI = -32;
}
@ -70,20 +75,20 @@ void TreeItem(Entity* this) {
break;
}
sub_08049CF4(this);
sub_08049CF4(super);
DeleteThisEntity();
}
static bool32 ShouldSpawnTreeItem(Entity* this) {
int diff;
int expectedStateX, expectedStateY;
int playerState;
static bool32 ShouldSpawnTreeItem(TreeItemEntity* this) {
s32 diff;
s32 expectedStateX, expectedStateY;
s32 playerState;
if (gPlayerEntity.action != PLAYER_BOUNCE) {
return FALSE;
}
diff = gPlayerEntity.x.HALF.HI - this->x.HALF.HI;
diff = gPlayerEntity.x.HALF.HI - super->x.HALF.HI;
expectedStateX = 6;
if (diff & 0x8000) {
expectedStateX = 2;
@ -94,7 +99,7 @@ static bool32 ShouldSpawnTreeItem(Entity* this) {
return FALSE;
}
diff = gPlayerEntity.y.HALF.HI - this->y.HALF.HI;
diff = gPlayerEntity.y.HALF.HI - super->y.HALF.HI;
expectedStateY = 0;
if (diff & 0x8000) {
expectedStateY = 4;

File diff suppressed because it is too large Load Diff

View File

@ -4,416 +4,431 @@
*
* @brief Vaati Ball enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "object.h"
#include "player.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u8 unk_74;
/*0x75*/ u8 unused2[2];
/*0x77*/ u8 unk_77;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unused3[2];
/*0x7c*/ u32 unk_7c;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unused4[2];
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unused5[1];
/*0x86*/ u8 unk_86;
} VaatiBallEntity;
typedef struct {
s8 h, v;
} PACKED PosOffset;
void sub_0804468C(Entity*);
void sub_080447E0(Entity*);
void sub_08044868(Entity*);
void sub_0804474C(Entity*);
void sub_080449F8(Entity*);
void sub_08044B04(Entity*);
void sub_0804468C(VaatiBallEntity*);
void sub_080447E0(VaatiBallEntity*);
void sub_08044868(VaatiBallEntity*);
void sub_0804474C(VaatiBallEntity*);
void sub_080449F8(VaatiBallEntity*);
void sub_08044B04(VaatiBallEntity*);
void sub_08044DEC(VaatiBallEntity*);
extern void sub_08044E74(Entity*, u32);
extern void sub_08044E74(VaatiBallEntity*, u32);
void VaatiBall(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void VaatiBall(VaatiBallEntity* this) {
static void (*const actionFuncs[])(VaatiBallEntity*) = {
sub_0804468C, sub_0804474C, sub_080447E0, sub_08044868, sub_0804474C, sub_080449F8, sub_08044B04,
};
Entity* parent;
parent = this->parent;
if (this->action && this->action != 3) {
this->x.WORD += parent->x.WORD - *(int*)&parent->field_0x78;
this->y.WORD += parent->y.WORD - parent->field_0x7c.WORD;
Entity* parent = super->parent;
if (super->action && super->action != 3) {
super->x.WORD += parent->x.WORD - *(int*)&((VaatiBallEntity*)parent)->unk_78;
super->y.WORD += parent->y.WORD - ((VaatiBallEntity*)parent)->unk_7c;
}
actionFuncs[this->action](this);
actionFuncs[super->action](this);
if (this->cutsceneBeh.HALF.LO) {
this->health = -1;
if (this->unk_84) {
super->health = -1;
}
if (this->contactFlags & 0x80) {
if ((this->contactFlags & 0x3f) == 0 && this->action == 6) {
if (super->contactFlags & 0x80) {
if ((super->contactFlags & 0x3f) == 0 && super->action == 6) {
ModHealth(-2);
}
#ifdef EU
if (this->health < 0xfa) {
if (super->health < 0xfa) {
#else
if (this->health < 0xfd) {
if (super->health < 0xfd) {
#endif
this->spriteSettings.draw = 0;
COLLISION_OFF(this);
this->health = -1;
parent->field_0x80.HALF.LO--;
CreateDust(this);
super->spriteSettings.draw = 0;
COLLISION_OFF(super);
super->health = -1;
((VaatiBallEntity*)parent)->unk_80--;
CreateDust(super);
SoundReq(SFX_1C3);
}
}
}
void sub_0804468C(Entity* this) {
void sub_0804468C(VaatiBallEntity* this) {
const PosOffset* off;
static const PosOffset gUnk_080D1620[4] = { { -48, 0 }, { 0, -48 }, { 48, 0 }, { 0, 48 } };
this->collisionLayer = 3;
this->spriteRendering.b3 = 2;
this->spritePriority.b0 = 5;
this->cutsceneBeh.HALF.LO = 0;
switch (this->type) {
super->collisionLayer = 3;
super->spriteRendering.b3 = 2;
super->spritePriority.b0 = 5;
this->unk_84 = 0;
switch (super->type) {
case 0:
this->action = 1;
this->timer = 1;
this->direction = (this->field_0x78.HALF.HI * 8) & (0x3 | DirectionNorthWest);
this->field_0x78.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->spriteSettings.draw = 0;
off = &gUnk_080D1620[this->field_0x78.HALF.HI & 3];
PositionRelative(this->parent, this, Q_16_16(off->h), Q_16_16(off->v - 0x10));
this->z.HALF.HI = this->parent->z.HALF.HI;
InitAnimationForceUpdate(this, 0);
super->action = 1;
super->timer = 1;
super->direction = (this->unk_79 * 8) & (0x3 | DirectionNorthWest);
this->unk_78 = 0;
this->unk_83 = 0;
super->spriteSettings.draw = 0;
off = &gUnk_080D1620[this->unk_79 & 3];
PositionRelative(super->parent, super, Q_16_16(off->h), Q_16_16(off->v - 0x10));
super->z.HALF.HI = super->parent->z.HALF.HI;
InitAnimationForceUpdate(super, 0);
break;
case 1:
this->action = 3;
this->field_0x74.HALF.LO = 0;
this->field_0x82.HALF.HI = 1;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 1);
super->action = 3;
this->unk_74 = 0;
this->unk_83 = 1;
super->spriteSettings.draw = 1;
InitAnimationForceUpdate(super, 1);
break;
}
}
void sub_0804474C(Entity* this) {
switch (this->parent->action) {
void sub_0804474C(VaatiBallEntity* this) {
switch (super->parent->action) {
case 3:
this->action = 3;
this->field_0x74.HALF.LO = 0;
this->timer = 0;
super->action = 3;
this->unk_74 = 0;
super->timer = 0;
break;
case 5:
this->action = 5;
this->field_0x74.HALF.LO = 0;
this->subtimer = 1;
super->action = 5;
this->unk_74 = 0;
super->subtimer = 1;
break;
case 6:
this->action = 6;
this->field_0x74.HALF.LO = 0;
this->subtimer = 32;
super->action = 6;
this->unk_74 = 0;
super->subtimer = 32;
break;
case 2:
this->action = 2;
this->field_0x74.HALF.LO = 0;
this->hitType = 0;
super->action = 2;
this->unk_74 = 0;
super->hitType = 0;
break;
}
if (this->action != 1) {
UpdateAnimationSingleFrame(this);
if (super->action != 1) {
UpdateAnimationSingleFrame(super);
} else {
if (--this->timer == 0) {
this->timer = 2;
this->direction++;
this->direction &= 0x3 | DirectionNorthWest;
if (--super->timer == 0) {
super->timer = 2;
super->direction++;
super->direction &= 0x3 | DirectionNorthWest;
}
LinearMoveUpdate(this);
UpdateAnimationSingleFrame(this);
LinearMoveUpdate(super);
UpdateAnimationSingleFrame(super);
}
}
void sub_080447E0(Entity* this) {
Entity* vaati = this->parent;
void sub_080447E0(VaatiBallEntity* this) {
VaatiBallEntity* vaati = (VaatiBallEntity*)super->parent;
if (vaati->action == 1) {
this->action = 1;
this->hitType = 43;
if (vaati->base.action == 1) {
super->action = 1;
super->hitType = 43;
sub_08044E74(this, 0);
if (this->flags & ENT_COLLIDE)
this->spriteSettings.draw = 1;
if (super->flags & ENT_COLLIDE)
super->spriteSettings.draw = 1;
} else {
this->field_0x76.HALF.HI++;
this->field_0x76.HALF.HI &= 7;
if (this->flags & ENT_COLLIDE) {
if (this->field_0x76.HALF.HI & 1) {
this->spriteSettings.draw = 1;
this->unk_77++;
this->unk_77 &= 7;
if (super->flags & ENT_COLLIDE) {
if (this->unk_77 & 1) {
super->spriteSettings.draw = 1;
} else {
this->spriteSettings.draw = 0;
super->spriteSettings.draw = 0;
}
}
if (vaati->field_0x74.HALF.LO == 2) {
if (vaati->unk_74 == 2) {
sub_08044E74(this, 2);
}
}
}
extern void sub_08044DEC(Entity*);
void sub_08044868(VaatiBallEntity* this) {
VaatiBallEntity* vaati = (VaatiBallEntity*)super->parent;
void sub_08044868(Entity* this) {
Entity* vaati = this->parent;
switch (vaati->field_0x74.HALF.LO) {
switch (vaati->unk_74) {
case 0xfe:
if (this->field_0x82.HALF.HI && this->field_0x74.HALF.LO == 2)
if (this->unk_83 && this->unk_74 == 2)
DeleteThisEntity();
break;
case 0xff:
if (this->field_0x82.HALF.HI) {
switch (this->field_0x74.HALF.LO) {
if (this->unk_83) {
switch (this->unk_74) {
case 0:
if (this->frame & ANIM_DONE) {
this->field_0x74.HALF.LO = 1;
this->direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
this->speed = 0x180;
if (super->frame & ANIM_DONE) {
this->unk_74 = 1;
super->direction = sub_080045B4(super, vaati->base.x.HALF.HI, vaati->base.y.HALF.HI - 0x10);
super->speed = 0x180;
}
break;
case 1:
LinearMoveUpdate(this);
if (EntityWithinDistance(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc)) {
this->field_0x74.HALF.LO++;
this->x.HALF.HI = vaati->x.HALF.HI;
this->y.HALF.HI = vaati->y.HALF.HI - 0x10;
vaati->timer++;
LinearMoveUpdate(super);
if (EntityWithinDistance(super, vaati->base.x.HALF.HI, vaati->base.y.HALF.HI - 0x10, 0xc)) {
this->unk_74++;
super->x.HALF.HI = vaati->base.x.HALF.HI;
super->y.HALF.HI = vaati->base.y.HALF.HI - 0x10;
vaati->base.timer++;
} else {
this->direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
super->direction = sub_080045B4(super, vaati->base.x.HALF.HI, vaati->base.y.HALF.HI - 0x10);
}
break;
}
}
break;
case 1:
if (this->field_0x82.HALF.HI == 0) {
this->field_0x82.HALF.HI++;
this->spriteSettings.draw = 1;
if (this->unk_83 == 0) {
this->unk_83++;
super->spriteSettings.draw = 1;
}
sub_08044DEC(this);
if (*(u8*)&vaati->field_0x86 > 1) {
u8 draw = this->spriteSettings.draw;
if (draw == 1 && this->cutsceneBeh.HALF.LO == 0) {
vaati = CreateProjectileWithParent(this, V1_DARK_MAGIC_PROJECTILE, 0);
if (vaati->unk_86 > 1) {
u8 draw = super->spriteSettings.draw;
if (draw == 1 && this->unk_84 == 0) {
vaati = (VaatiBallEntity*)CreateProjectileWithParent(super, V1_DARK_MAGIC_PROJECTILE, 0);
if (vaati) {
vaati->type2 = 1;
vaati->parent = this;
this->cutsceneBeh.HALF.LO = 1;
this->hitType = 0;
vaati->base.type2 = 1;
vaati->base.parent = super;
this->unk_84 = 1;
super->hitType = 0;
}
}
}
this->timer = 32;
super->timer = 32;
break;
case 2:
if (this->timer)
if (--this->timer < 0x11)
LinearMoveUpdate(this);
if (super->timer)
if (--super->timer < 0x11)
LinearMoveUpdate(super);
break;
case 3: {
u8 draw;
sub_08044E74(this, 1);
draw = this->spriteSettings.draw;
draw = super->spriteSettings.draw;
if (draw == 1) {
COLLISION_ON(this);
COLLISION_ON(super);
} else {
COLLISION_OFF(this);
COLLISION_OFF(super);
}
break;
}
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
void sub_080449F8(Entity* this) {
Entity* vaati = this->parent;
void sub_080449F8(VaatiBallEntity* this) {
VaatiBallEntity* vaati = (VaatiBallEntity*)super->parent;
UpdateAnimationSingleFrame(this);
if (vaati->action == 1) {
UpdateAnimationSingleFrame(super);
if (vaati->base.action == 1) {
sub_08044E74(this, 0);
return;
}
switch (vaati->field_0x74.HALF.LO) {
switch (vaati->unk_74) {
case 0:
LinearMoveUpdate(this);
if (--this->timer)
LinearMoveUpdate(super);
if (--super->timer)
break;
if (this->field_0x78.HALF.LO == 0) {
this->field_0x78.HALF.LO++;
this->speed = 640;
if (this->unk_78 == 0) {
this->unk_78++;
super->speed = 640;
}
this->timer = 4;
this->direction++;
this->direction &= 0x3 | DirectionNorthWest;
if (vaati->field_0x80.HALF.LO == 0)
vaati->field_0x74.HALF.LO = 1;
super->timer = 4;
super->direction++;
super->direction &= 0x3 | DirectionNorthWest;
if (vaati->unk_80 == 0)
vaati->unk_74 = 1;
break;
case 1:
switch (this->timer) {
switch (super->timer) {
case 2:
if (vaati->field_0x80.HALF.LO == 0) {
this->subtimer = 0;
if (vaati->unk_80 == 0) {
super->subtimer = 0;
sub_08044E74(this, 0);
}
break;
case 1:
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(this);
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
this->timer = 2;
super->direction = (super->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(super);
super->direction = (super->direction + 0x10) & (0x3 | DirectionNorthWest);
super->timer = 2;
break;
case 3:
LinearMoveUpdate(this);
this->timer = 2;
LinearMoveUpdate(super);
super->timer = 2;
break;
case 4:
LinearMoveUpdate(this);
LinearMoveUpdate(this);
this->timer = 2;
LinearMoveUpdate(super);
LinearMoveUpdate(super);
super->timer = 2;
break;
}
break;
case 2:
if (this->field_0x74.HALF.LO == 0) {
if (this->unk_74 == 0) {
u8 draw;
this->field_0x74.HALF.LO++;
draw = this->spriteSettings.draw;
this->unk_74++;
draw = super->spriteSettings.draw;
if (draw) {
vaati = CreateProjectileWithParent(this, V1_EYE_LASER, 0);
vaati = (VaatiBallEntity*)CreateProjectileWithParent(super, V1_EYE_LASER, 0);
if (vaati) {
vaati->y.HALF.HI += 4;
vaati->parent = this;
this->child = vaati;
vaati->base.y.HALF.HI += 4;
vaati->base.parent = super;
super->child = &vaati->base;
}
}
}
break;
case 3:
if (this->subtimer) {
this->subtimer = 0;
if (super->subtimer) {
super->subtimer = 0;
}
break;
}
}
void sub_08044B04(Entity* this) {
Entity* vaati = this->parent;
void sub_08044B04(VaatiBallEntity* this) {
Entity* vaati = super->parent;
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
if (vaati->action == 1) {
sub_08044E74(this, 0);
this->timer = 32;
super->timer = 32;
return;
}
switch (vaati->field_0x74.HALF.LO) {
switch (((VaatiBallEntity*)vaati)->unk_74) {
case 0:
LinearMoveUpdate(this);
switch (this->field_0x74.HALF.LO) {
LinearMoveUpdate(super);
switch (this->unk_74) {
case 0:
if (--this->timer == 0) {
this->timer = this->field_0x78.HALF.LO ? 4 : 2;
this->direction++;
this->direction &= 0x3 | DirectionNorthWest;
if (--super->timer == 0) {
super->timer = this->unk_78 ? 4 : 2;
super->direction++;
super->direction &= 0x3 | DirectionNorthWest;
}
if (--this->subtimer == 0) {
if (this->timer != 2) {
this->subtimer = 1;
if (--super->subtimer == 0) {
if (super->timer != 2) {
super->subtimer = 1;
} else {
if (++this->field_0x78.HALF.LO > 2) {
this->field_0x74.HALF.LO++;
this->field_0x78.HALF.LO = 1;
this->timer = 4;
this->subtimer = 0;
if (++this->unk_78 > 2) {
this->unk_74++;
this->unk_78 = 1;
super->timer = 4;
super->subtimer = 0;
} else {
this->subtimer = 32;
super->subtimer = 32;
}
this->speed = this->field_0x78.HALF.LO ? 640 : 1280;
super->speed = this->unk_78 ? 640 : 1280;
}
}
break;
case 1:
if (--this->timer == 0) {
this->timer = 6;
this->direction = (this->direction + 1) & (0x3 | DirectionNorthWest);
if (++this->subtimer == 0x30) {
u32 direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
this->speed = 0;
this->direction = (direction + 16) & (0x3 | DirectionNorthWest);
this->timer = 16;
this->subtimer = 16;
this->field_0x74.HALF.LO++;
if (--super->timer == 0) {
super->timer = 6;
super->direction = (super->direction + 1) & (0x3 | DirectionNorthWest);
if (++super->subtimer == 0x30) {
u32 direction = sub_080045B4(super, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
super->speed = 0;
super->direction = (direction + 16) & (0x3 | DirectionNorthWest);
super->timer = 16;
super->subtimer = 16;
this->unk_74++;
}
}
break;
case 2:
if (this->subtimer == 0) {
switch (--this->timer) {
if (super->subtimer == 0) {
switch (--super->timer) {
case 12:
this->speed = 1280;
super->speed = 1280;
break;
case 0:
this->field_0x74.HALF.LO++;
this->direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
this->speed = 0;
this->timer = 4;
this->subtimer = 16;
this->unk_74++;
super->direction = sub_080045B4(super, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
super->speed = 0;
super->timer = 4;
super->subtimer = 16;
break;
case 4:
this->speed = 640;
super->speed = 640;
break;
}
} else {
if (--this->subtimer == 0)
this->speed = 640;
if (--super->subtimer == 0)
super->speed = 640;
}
break;
case 3:
if (this->subtimer) {
if (--this->subtimer == 0)
this->speed = 640;
if (super->subtimer) {
if (--super->subtimer == 0)
super->speed = 640;
} else {
if (this->timer) {
if (--this->timer == 0) {
this->speed = 1280;
if (super->timer) {
if (--super->timer == 0) {
super->speed = 1280;
SoundReq(SFX_14F);
}
}
if (this->field_0x78.HALF.HI == 3)
if (EntityWithinDistance(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc))
if (this->unk_79 == 3)
if (EntityWithinDistance(super, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10, 0xc))
vaati->timer++;
this->direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
super->direction = sub_080045B4(super, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10);
return;
}
break;
}
break;
case 1:
switch (this->field_0x74.HALF.LO) {
switch (this->unk_74) {
case 3:
this->field_0x74.HALF.LO = 1;
this->timer = 80;
COLLISION_OFF(this);
PositionRelative(vaati, this, 0, Q_16_16(-16.0));
if (this->subtimer)
this->spriteSettings.draw = 0;
this->unk_74 = 1;
super->timer = 80;
COLLISION_OFF(super);
PositionRelative(vaati, super, 0, Q_16_16(-16.0));
if (super->subtimer)
super->spriteSettings.draw = 0;
break;
case 1:
if (--this->timer == 0) {
this->field_0x74.HALF.LO = 0;
this->timer = 32;
this->subtimer = 4;
if (--super->timer == 0) {
this->unk_74 = 0;
super->timer = 32;
super->subtimer = 4;
}
break;
}
@ -422,30 +437,30 @@ void sub_08044B04(Entity* this) {
/* ... */
break;
case 3:
switch (this->field_0x74.HALF.LO) {
switch (this->unk_74) {
case 0:
if (this->subtimer) {
if (--this->subtimer == 0) {
if (super->subtimer) {
if (--super->subtimer == 0) {
sub_08044DEC(this);
this->field_0x74.HALF.LO = 1;
this->timer = 16;
this->unk_74 = 1;
super->timer = 16;
}
}
break;
case 1:
LinearMoveUpdate(this);
if (--this->timer == 0)
this->field_0x74.HALF.LO++;
LinearMoveUpdate(super);
if (--super->timer == 0)
this->unk_74++;
break;
case 2: {
u8 draw;
sub_08044E74(this, 1);
draw = this->spriteSettings.draw;
draw = super->spriteSettings.draw;
if (draw == 1) {
COLLISION_ON(this);
COLLISION_ON(super);
} else {
COLLISION_OFF(this);
COLLISION_OFF(super);
}
vaati->timer++;
break;
@ -455,7 +470,7 @@ void sub_08044B04(Entity* this) {
}
}
void sub_08044DEC(Entity* this) {
void sub_08044DEC(VaatiBallEntity* this) {
u32 off;
static const u8 gUnk_080D1628[4][4] = {
{ 16, 24, 0, 8 },
@ -464,62 +479,62 @@ void sub_08044DEC(Entity* this) {
{ 16, 24, 0, 8 },
};
if (this->parent->field_0x80.HALF.LO > this->field_0x78.HALF.HI) {
this->spriteSettings.draw = 1;
this->health = -1;
if (((VaatiBallEntity*)super->parent)->unk_80 > this->unk_79) {
super->spriteSettings.draw = 1;
super->health = -1;
} else {
this->spriteSettings.draw = 0;
super->spriteSettings.draw = 0;
}
COLLISION_OFF(this);
this->field_0x78.HALF.LO = 0;
this->speed = 0x300;
off = this->parent->field_0x80.HALF.LO - 1;
this->direction = gUnk_080D1628[off][this->field_0x78.HALF.HI];
PositionRelative(this->parent, this, 0, Q_16_16(-16.0));
COLLISION_OFF(super);
this->unk_78 = 0;
super->speed = 0x300;
off = ((VaatiBallEntity*)super->parent)->unk_80 - 1;
super->direction = gUnk_080D1628[off][this->unk_79];
PositionRelative(super->parent, super, 0, Q_16_16(-16.0));
}
void sub_08044E74(Entity* this, u32 state) {
this->action = 1;
this->field_0x74.HALF.LO = 0;
void sub_08044E74(VaatiBallEntity* this, u32 state) {
super->action = 1;
this->unk_74 = 0;
switch (state) {
case 2:
this->action = 2;
this->direction += DirectionWest;
this->direction &= 0x3 | DirectionNorthWest;
PositionRelative(this->parent, this, 0, Q_16_16(-16.0));
this->speed = 12288;
LinearMoveUpdate(this);
this->direction += DirectionEast;
this->direction &= 0x3 | DirectionNorthWest;
this->speed = 1280;
LinearMoveUpdate(this);
super->action = 2;
super->direction += DirectionWest;
super->direction &= 0x3 | DirectionNorthWest;
PositionRelative(super->parent, super, 0, Q_16_16(-16.0));
super->speed = 12288;
LinearMoveUpdate(super);
super->direction += DirectionEast;
super->direction &= 0x3 | DirectionNorthWest;
super->speed = 1280;
LinearMoveUpdate(super);
break;
case 1:
this->direction = (this->direction + 8) & (0x3 | DirectionNorthWest);
super->direction = (super->direction + 8) & (0x3 | DirectionNorthWest);
break;
case 0:
if (this->field_0x78.HALF.LO) {
switch (this->timer) {
if (this->unk_78) {
switch (super->timer) {
case 3 ... 4:
do {
LinearMoveUpdate(this);
} while (this->timer-- != 3);
LinearMoveUpdate(super);
} while (super->timer-- != 3);
break;
case 1:
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(this);
this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest);
super->direction = (super->direction + 0x10) & (0x3 | DirectionNorthWest);
LinearMoveUpdate(super);
super->direction = (super->direction + 0x10) & (0x3 | DirectionNorthWest);
break;
}
} else {
if (this->timer == 2) {
LinearMoveUpdate(this);
if (super->timer == 2) {
LinearMoveUpdate(super);
}
}
break;
}
this->timer = 1;
this->field_0x78.HALF.LO = 0;
this->speed = Q_8_8(5.0);
super->timer = 1;
this->unk_78 = 0;
super->speed = Q_8_8(5.0);
}

View File

@ -4,42 +4,53 @@
*
* @brief Vaati Eyes Macro enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
} VaatiEyesMacroEntity;
extern s16 gUnk_080B4488[];
void VaatiEyesMacro_OnTick(Entity*);
void VaatiEyesMacro_OnCollision(Entity*);
void VaatiEyesMacroFunction0Type0(Entity*);
void VaatiEyesMacroFunction0Type1(Entity*);
void VaatiEyesMacroFunction0Type2(Entity*);
void VaatiEyesMacroFunction0Type3(Entity*);
void VaatiEyesMacroFunction0Type0Action0(Entity*);
void VaatiEyesMacroFunction0Type0Action1(Entity*);
void VaatiEyesMacroFunction0Type1Action0(Entity*);
void VaatiEyesMacroFunction0Type1Action1(Entity*);
void sub_0802EF90(Entity*);
void sub_0802EFB8(Entity*);
void sub_0802EF58(Entity*);
void sub_0802F04C(Entity*);
void VaatiEyesMacro_OnTick(VaatiEyesMacroEntity*);
void VaatiEyesMacro_OnCollision(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type0(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type1(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type2(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type3(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type0Action0(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type0Action1(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type1Action0(VaatiEyesMacroEntity*);
void VaatiEyesMacroFunction0Type1Action1(VaatiEyesMacroEntity*);
void sub_0802EF90(VaatiEyesMacroEntity*);
void sub_0802EFB8(VaatiEyesMacroEntity*);
void sub_0802EF58(VaatiEyesMacroEntity*);
void sub_0802F04C(VaatiEyesMacroEntity*);
void (*const VaatiEyesMacro_Functions[])(Entity*) = {
VaatiEyesMacro_OnTick, VaatiEyesMacro_OnCollision, GenericKnockback, GenericDeath,
GenericConfused, VaatiEyesMacro_OnTick,
void (*const VaatiEyesMacro_Functions[])(VaatiEyesMacroEntity*) = {
VaatiEyesMacro_OnTick,
VaatiEyesMacro_OnCollision,
(void (*)(VaatiEyesMacroEntity*))GenericKnockback,
(void (*)(VaatiEyesMacroEntity*))GenericDeath,
(void (*)(VaatiEyesMacroEntity*))GenericConfused,
VaatiEyesMacro_OnTick,
};
void (*const vaatiEyesMacroFunction0Types[])(Entity*) = {
void (*const vaatiEyesMacroFunction0Types[])(VaatiEyesMacroEntity*) = {
VaatiEyesMacroFunction0Type0,
VaatiEyesMacroFunction0Type1,
VaatiEyesMacroFunction0Type2,
VaatiEyesMacroFunction0Type3,
};
void (*const vaatiEyesMacroFunction0Type0Actions[])(Entity*) = {
void (*const vaatiEyesMacroFunction0Type0Actions[])(VaatiEyesMacroEntity*) = {
VaatiEyesMacroFunction0Type0Action0,
VaatiEyesMacroFunction0Type0Action1,
};
void (*const vaatiEyesMacroFunction0Type1Actions[])(Entity*) = {
void (*const vaatiEyesMacroFunction0Type1Actions[])(VaatiEyesMacroEntity*) = {
VaatiEyesMacroFunction0Type1Action0,
VaatiEyesMacroFunction0Type1Action1,
};
@ -50,109 +61,109 @@ const u8 gUnk_080CDE70[] = {
const s8 gUnk_080CDE90[] = { -2, -3, -4, -5, -6, -5, -4, -3 };
const u16 gUnk_080CDE98[] = { 0xc0, 0x100, 0x140, 0x180 };
void VaatiEyesMacro(Entity* this) {
VaatiEyesMacro_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
void VaatiEyesMacro(VaatiEyesMacroEntity* this) {
VaatiEyesMacro_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
void VaatiEyesMacro_OnTick(Entity* this) {
vaatiEyesMacroFunction0Types[this->type](this);
if (this->type < 2) {
void VaatiEyesMacro_OnTick(VaatiEyesMacroEntity* this) {
vaatiEyesMacroFunction0Types[super->type](this);
if (super->type < 2) {
sub_0802EF90(this);
}
}
void VaatiEyesMacro_OnCollision(Entity* this) {
if (this->type == 0) {
if (this->health == 0) {
void VaatiEyesMacro_OnCollision(VaatiEyesMacroEntity* this) {
if (super->type == 0) {
if (super->health == 0) {
gRoomTransition.field_0x39 &= ~(1 << (gRoomTransition.field_0x3c + 2));
}
if (gRoomControls.room == 0) {
gRoomTransition.field_0x3a = this->health;
gRoomTransition.field_0x3a = super->health;
} else {
gRoomTransition.field_0x3b = this->health;
gRoomTransition.field_0x3b = super->health;
}
if (this->field_0x78.HALF.HI != this->health) {
if (this->unk_79 != super->health) {
EnqueueSFX(SFX_17A);
}
this->field_0x78.HALF.HI = this->health;
this->unk_79 = super->health;
} else {
if (this->type == 1) {
if (0 < this->iframes) {
this->iframes *= -1;
if (super->type == 1) {
if (0 < super->iframes) {
super->iframes *= -1;
}
if (this->health != 0xff) {
if (super->health != 0xff) {
EnqueueSFX(SFX_BUTTON_DEPRESS);
}
this->health = 0xff;
super->health = 0xff;
}
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, VaatiEyesMacro_Functions);
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)VaatiEyesMacro_Functions);
}
void VaatiEyesMacroFunction0Type0(Entity* this) {
vaatiEyesMacroFunction0Type0Actions[this->action](this);
void VaatiEyesMacroFunction0Type0(VaatiEyesMacroEntity* this) {
vaatiEyesMacroFunction0Type0Actions[super->action](this);
}
void VaatiEyesMacroFunction0Type0Action0(Entity* this) {
void VaatiEyesMacroFunction0Type0Action0(VaatiEyesMacroEntity* this) {
Manager* manager;
Entity* enemy;
if ((gEntCount < 0x47) && (manager = GetEmptyManager(), manager != NULL)) {
manager->kind = MANAGER;
manager->id = VAATI3_INSIDE_ARM_MANAGER;
manager->parent = (Entity*)this;
manager->parent = (Entity*)super;
AppendEntityToList((Entity*)manager, 8);
enemy = CreateEnemy(VAATI_EYES_MACRO, 2);
enemy->parent = this;
this->action = 1;
enemy->parent = super;
super->action = 1;
if (gRoomControls.room == 0) {
this->field_0x78.HALF.HI = this->health = gRoomTransition.field_0x3a;
this->unk_79 = super->health = gRoomTransition.field_0x3a;
} else {
this->field_0x78.HALF.HI = this->health = gRoomTransition.field_0x3b;
this->unk_79 = super->health = gRoomTransition.field_0x3b;
}
this->field_0x78.HALF.LO = Random();
this->unk_78 = Random();
sub_0802EFB8(this);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
sub_0802EF58(this);
}
}
void VaatiEyesMacroFunction0Type0Action1(Entity* this) {
void VaatiEyesMacroFunction0Type0Action1(VaatiEyesMacroEntity* this) {
sub_0802F04C(this);
GetNextFrame(this);
GetNextFrame(super);
}
void VaatiEyesMacroFunction0Type1(Entity* this) {
vaatiEyesMacroFunction0Type1Actions[this->action](this);
void VaatiEyesMacroFunction0Type1(VaatiEyesMacroEntity* this) {
vaatiEyesMacroFunction0Type1Actions[super->action](this);
}
void VaatiEyesMacroFunction0Type1Action0(Entity* this) {
void VaatiEyesMacroFunction0Type1Action0(VaatiEyesMacroEntity* this) {
Entity* entity;
u32 rand;
if (gEntCount < 0x47) {
entity = CreateEnemy(VAATI_EYES_MACRO, 3);
entity->parent = this;
this->action = 1;
entity->parent = super;
super->action = 1;
rand = Random();
this->timer = (rand & 3) + 1;
this->field_0x78.HALF.LO = Random() >> 8;
this->direction = gUnk_080CDE6C[rand >> 0x10 & 3];
InitializeAnimation(this, 1);
super->timer = (rand & 3) + 1;
this->unk_78 = Random() >> 8;
super->direction = gUnk_080CDE6C[rand >> 0x10 & 3];
InitializeAnimation(super, 1);
}
}
void VaatiEyesMacroFunction0Type1Action1(Entity* this) {
if (this->parent->next == NULL) {
COLLISION_OFF(this);
this->health = 0;
void VaatiEyesMacroFunction0Type1Action1(VaatiEyesMacroEntity* this) {
if (super->parent->next == NULL) {
COLLISION_OFF(super);
super->health = 0;
} else {
sub_0802F04C(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
@ -161,43 +172,43 @@ typedef struct xy {
u8 y;
} xy;
void VaatiEyesMacroFunction0Type2(Entity* this) {
void VaatiEyesMacroFunction0Type2(VaatiEyesMacroEntity* this) {
u32 uVar2;
xy* temp;
if (this->parent->next == NULL) {
if (super->parent->next == NULL) {
DeleteThisEntity();
}
if (this->action == 0) {
this->action = 1;
this->animationState = 0xff;
if (super->action == 0) {
super->action = 1;
super->animationState = 0xff;
}
CopyPositionAndSpriteOffset(this->parent, this);
uVar2 = (GetFacingDirection(this, &gPlayerEntity) + 1) & 0x1e;
CopyPositionAndSpriteOffset(super->parent, super);
uVar2 = (GetFacingDirection(super, &gPlayerEntity) + 1) & 0x1e;
temp = (xy*)&gUnk_080CDE70[uVar2];
if (temp->x != this->frameIndex) {
if (temp->y != this->frameIndex) {
this->frameIndex = temp->x;
if (temp->x != super->frameIndex) {
if (temp->y != super->frameIndex) {
super->frameIndex = temp->x;
}
}
this->y.HALF.HI++;
this->spriteOffsetY--;
super->y.HALF.HI++;
super->spriteOffsetY--;
}
void VaatiEyesMacroFunction0Type3(Entity* this) {
if (this->parent->next == NULL) {
void VaatiEyesMacroFunction0Type3(VaatiEyesMacroEntity* this) {
if (super->parent->next == NULL) {
DeleteThisEntity();
}
if (this->action == 0) {
this->action = 1;
this->frameIndex = 0x11;
this->spritePriority.b0 = 6;
if (super->action == 0) {
super->action = 1;
super->frameIndex = 0x11;
super->spritePriority.b0 = 6;
}
CopyPositionAndSpriteOffset(this->parent, this);
this->z.HALF.HI = 0;
CopyPositionAndSpriteOffset(super->parent, super);
super->z.HALF.HI = 0;
}
void sub_0802EF58(Entity* this) {
void sub_0802EF58(VaatiEyesMacroEntity* this) {
Entity* entity;
u32 i;
@ -206,18 +217,18 @@ void sub_0802EF58(Entity* this) {
if (entity != NULL) {
entity->type2 = i;
entity->collisionLayer = 1;
entity->parent = this;
entity->parent = super;
UpdateSpriteForCollisionLayer(entity);
CopyPosition(this, entity);
CopyPosition(super, entity);
}
}
}
void sub_0802EF90(Entity* this) {
this->z.HALF.HI = gUnk_080CDE90[this->field_0x78.HALF.LO++ >> 3 & 7];
void sub_0802EF90(VaatiEyesMacroEntity* this) {
super->z.HALF.HI = gUnk_080CDE90[this->unk_78++ >> 3 & 7];
}
void sub_0802EFB8(Entity* this) {
void sub_0802EFB8(VaatiEyesMacroEntity* this) {
u32 uVar1;
u32 rand;
u32 uVar3;
@ -227,74 +238,74 @@ void sub_0802EFB8(Entity* this) {
if ((rand >> 0x10 & 3) != 0) {
uVar1 = rand & 0x18;
} else {
uVar3 = GetFacingDirection(&gPlayerEntity, this);
uVar3 = GetFacingDirection(&gPlayerEntity, super);
uVar1 = (uVar3 + 4) & 0x18;
}
iVar4 = sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1);
iVar4 = sub_080B1B44(TILE(super->x.HALF.HI, super->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1);
if (iVar4 != 0) {
this->direction = DIR_NONE;
super->direction = DIR_NONE;
} else {
this->timer = (rand & 3) + 1;
this->direction = (uVar1 & 0x18);
this->speed = gUnk_080CDE98[rand >> 0x18 & 3];
super->timer = (rand & 3) + 1;
super->direction = (uVar1 & 0x18);
super->speed = gUnk_080CDE98[rand >> 0x18 & 3];
}
}
void sub_0802F04C(Entity* this) {
void sub_0802F04C(VaatiEyesMacroEntity* this) {
s32 oldX;
s32 oldY;
oldX = this->x.HALF.HI;
oldY = this->y.HALF.HI;
if (ProcessMovement0(this) == 0) {
oldX = super->x.HALF.HI;
oldY = super->y.HALF.HI;
if (ProcessMovement0(super) == 0) {
sub_0802EFB8(this);
return;
}
switch (this->direction >> 3) {
switch (super->direction >> 3) {
case 0: // UP
if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) {
this->timer--;
oldY = (this->y.HALF.HI & 0xfff0) + 8;
if (((oldY & 0xf) > 8) && ((super->y.HALF.HI & 0xf) < 9)) {
super->timer--;
oldY = (super->y.HALF.HI & 0xfff0) + 8;
}
if (this->timer == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
if (super->timer == 0) {
super->x.HALF.HI = oldX;
super->y.HALF.HI = oldY;
} else {
return;
}
break;
case 1: // RIGHT
if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) {
this->timer--;
oldX = (this->x.HALF.HI & 0xfff0) + 8;
if (((oldX & 0xf) < 8) && ((super->x.HALF.HI & 0xf) >= 8)) {
super->timer--;
oldX = (super->x.HALF.HI & 0xfff0) + 8;
}
if (this->timer == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
if (super->timer == 0) {
super->x.HALF.HI = oldX;
super->y.HALF.HI = oldY;
} else {
return;
}
break;
case 2: // DOWN
if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) {
this->timer--;
oldY = (this->y.HALF.HI & 0xfff0) + 8;
if (((oldY & 0xf) < 8) && ((super->y.HALF.HI & 0xf) >= 8)) {
super->timer--;
oldY = (super->y.HALF.HI & 0xfff0) + 8;
}
if (this->timer == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
if (super->timer == 0) {
super->x.HALF.HI = oldX;
super->y.HALF.HI = oldY;
} else {
return;
}
break;
default: // LEFT
if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) {
this->timer--;
oldX = (this->x.HALF.HI & 0xfff0) + 8;
if (((oldX & 0xf) >= 9) && ((super->x.HALF.HI & 0xf) < 9)) {
super->timer--;
oldX = (super->x.HALF.HI & 0xfff0) + 8;
}
if (this->timer == 0) {
this->x.HALF.HI = oldX;
this->y.HALF.HI = oldY;
if (super->timer == 0) {
super->x.HALF.HI = oldX;
super->y.HALF.HI = oldY;
} else {
return;
}

View File

@ -4,74 +4,83 @@
*
* @brief Vaati Projectile enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "screenTransitions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u16 unk_78;
} VaatiProjectileEntity;
extern Entity* gUnk_020000B0;
bool32 sub_0803E4A0(Entity*);
void VaatiProjectile_OnTick(Entity*);
void VaatiProjectile_OnCollision(Entity*);
void GenericKnockback2(Entity*);
void VaatiProjectile_OnDeath(Entity*);
void VaatiProjectile_OnGrabbed(Entity*);
void VaatiProjectileFunction0Action0(Entity*);
void VaatiProjectileFunction0Action1(Entity*);
void VaatiProjectileFunction0Action2(Entity*);
void VaatiProjectileFunction0Action3(Entity*);
void VaatiProjectileFunction0Action4(Entity*);
void VaatiProjectileFunction0Action5(Entity*);
void VaatiProjectileFunction0Action6(Entity*);
void VaatiProjectileFunction0Action7(Entity*);
void VaatiProjectileFunction0Action8(Entity*);
void VaatiProjectileFunction0Action9(Entity*);
void sub_0803E444(Entity*);
void sub_0803E480(Entity*);
void sub_0803E4D8(Entity*);
bool32 sub_0803E4A0(VaatiProjectileEntity*);
void VaatiProjectile_OnTick(VaatiProjectileEntity*);
void VaatiProjectile_OnCollision(VaatiProjectileEntity*);
void VaatiProjectile_OnDeath(VaatiProjectileEntity*);
void VaatiProjectile_OnGrabbed(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action0(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action1(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action2(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action3(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action4(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action5(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action6(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action7(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action8(VaatiProjectileEntity*);
void VaatiProjectileFunction0Action9(VaatiProjectileEntity*);
void sub_0803E444(VaatiProjectileEntity*);
void sub_0803E480(VaatiProjectileEntity*);
void sub_0803E4D8(VaatiProjectileEntity*);
void (*const VaatiProjectile_Functions[])(Entity*) = {
VaatiProjectile_OnTick, VaatiProjectile_OnCollision, GenericKnockback2, VaatiProjectile_OnDeath,
GenericConfused, VaatiProjectile_OnGrabbed,
void (*const VaatiProjectile_Functions[])(VaatiProjectileEntity*) = {
VaatiProjectile_OnTick,
VaatiProjectile_OnCollision,
(void (*)(VaatiProjectileEntity*))GenericKnockback2,
VaatiProjectile_OnDeath,
(void (*)(VaatiProjectileEntity*))GenericConfused,
VaatiProjectile_OnGrabbed,
};
void (*const vaatiProjectileFunction0Actions[])(Entity*) = {
void (*const vaatiProjectileFunction0Actions[])(VaatiProjectileEntity*) = {
VaatiProjectileFunction0Action0, VaatiProjectileFunction0Action1, VaatiProjectileFunction0Action2,
VaatiProjectileFunction0Action3, VaatiProjectileFunction0Action4, VaatiProjectileFunction0Action5,
VaatiProjectileFunction0Action6, VaatiProjectileFunction0Action7, VaatiProjectileFunction0Action8,
VaatiProjectileFunction0Action9,
};
void VaatiProjectile(Entity* this) {
void VaatiProjectile(VaatiProjectileEntity* this) {
if (sub_0803E4A0(this)) {
COLLISION_OFF(this);
this->health = 0;
this->parent = NULL;
COLLISION_OFF(super);
super->health = 0;
super->parent = NULL;
}
VaatiProjectile_Functions[GetNextFunction(this)](this);
VaatiProjectile_Functions[GetNextFunction(super)](this);
}
void VaatiProjectile_OnTick(Entity* this) {
vaatiProjectileFunction0Actions[this->action](this);
void VaatiProjectile_OnTick(VaatiProjectileEntity* this) {
vaatiProjectileFunction0Actions[super->action](this);
}
void VaatiProjectile_OnCollision(Entity* this) {
void VaatiProjectile_OnCollision(VaatiProjectileEntity* this) {
Entity* entity;
if (this->contactFlags == 0x80) {
if (super->contactFlags == 0x80) {
#ifndef EU
if (this->health != 0) {
if (super->health != 0) {
#endif
this->action = 5;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
super->action = 5;
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.spriteOrientation.flipY = this->spriteOrientation.flipY;
gPlayerEntity.spriteRendering.b3 = this->spriteRendering.b3;
gPlayerEntity.spriteOrientation.flipY = super->spriteOrientation.flipY;
gPlayerEntity.spriteRendering.b3 = super->spriteRendering.b3;
sub_0803E444(this);
#ifndef EU
SetPlayerControl(2);
entity = this->parent;
entity = super->parent;
if (entity != NULL) {
entity->flags = entity->flags & ~ENT_COLLIDE;
}
@ -82,188 +91,188 @@ void VaatiProjectile_OnCollision(Entity* this) {
}
#endif
}
EnemyFunctionHandlerAfterCollision(this, VaatiProjectile_Functions);
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)VaatiProjectile_Functions);
}
void VaatiProjectile_OnDeath(Entity* this) {
if (this->parent != NULL) {
this->parent->subtimer--;
this->parent = NULL;
void VaatiProjectile_OnDeath(VaatiProjectileEntity* this) {
if (super->parent != NULL) {
super->parent->subtimer--;
super->parent = NULL;
}
GenericDeath(this);
GenericDeath(super);
}
void VaatiProjectile_OnGrabbed(Entity* this) {
void VaatiProjectile_OnGrabbed(VaatiProjectileEntity* this) {
}
void VaatiProjectileFunction0Action0(Entity* this) {
void VaatiProjectileFunction0Action0(VaatiProjectileEntity* this) {
Entity* entity;
if (this->type == 0) {
if (super->type == 0) {
entity = CreateEnemy(VAATI_PROJECTILE, 1);
if (entity != NULL) {
entity->parent = this;
this->child = entity;
if (this->type2 == 0) {
this->action = 1;
this->z.HALF.HI = -0x18;
entity->parent = super;
super->child = entity;
if (super->type2 == 0) {
super->action = 1;
super->z.HALF.HI = -0x18;
} else {
this->action = 9;
this->z.HALF.HI = -0x80;
this->flags2 = 1;
super->action = 9;
super->z.HALF.HI = -0x80;
super->flags2 = 1;
}
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
} else {
this->action = 8;
COLLISION_OFF(this);
this->spriteOffsetY = 1;
this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY;
this->spriteRendering.b3 = this->parent->spriteRendering.b3;
this->spritePriority.b1 = 0;
PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
InitializeAnimation(this, 1);
super->action = 8;
COLLISION_OFF(super);
super->spriteOffsetY = 1;
super->spriteOrientation.flipY = super->parent->spriteOrientation.flipY;
super->spriteRendering.b3 = super->parent->spriteRendering.b3;
super->spritePriority.b1 = 0;
PositionRelative(super->parent, super, 0, Q_16_16(-1.0));
InitializeAnimation(super, 1);
}
}
void VaatiProjectileFunction0Action1(Entity* this) {
void VaatiProjectileFunction0Action1(VaatiProjectileEntity* this) {
sub_0803E480(this);
if (PlayerInRange(this, 0, 8) != 0) {
this->action = 2;
this->timer = 10;
InitializeAnimation(this->child, 2);
if (PlayerInRange(super, 0, 8) != 0) {
super->action = 2;
super->timer = 10;
InitializeAnimation(super->child, 2);
} else {
if (gUnk_020000B0 != NULL) {
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
LinearMoveUpdate(this);
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
LinearMoveUpdate(super);
}
}
GetNextFrame(this);
GetNextFrame(super);
}
void VaatiProjectileFunction0Action2(Entity* this) {
if (this->timer != 0) {
this->timer--;
void VaatiProjectileFunction0Action2(VaatiProjectileEntity* this) {
if (super->timer != 0) {
super->timer--;
} else {
if (++this->z.HALF.HI == 0) {
this->action = 3;
if (++super->z.HALF.HI == 0) {
super->action = 3;
}
}
GetNextFrame(this);
GetNextFrame(super);
}
void VaatiProjectileFunction0Action3(Entity* this) {
if (this->child->frame & ANIM_DONE) {
if (--this->z.HALF.HI <= -0x18) {
this->action = 4;
this->timer = (Random() & 0xf) + 15;
InitializeAnimation(this->child, 1);
void VaatiProjectileFunction0Action3(VaatiProjectileEntity* this) {
if (super->child->frame & ANIM_DONE) {
if (--super->z.HALF.HI <= -0x18) {
super->action = 4;
super->timer = (Random() & 0xf) + 15;
InitializeAnimation(super->child, 1);
}
GetNextFrame(this);
GetNextFrame(super);
}
}
void VaatiProjectileFunction0Action4(Entity* this) {
if (--this->timer == 0) {
this->action = 1;
this->direction = GetFacingDirection(this, &gPlayerEntity);
void VaatiProjectileFunction0Action4(VaatiProjectileEntity* this) {
if (--super->timer == 0) {
super->action = 1;
super->direction = GetFacingDirection(super, &gPlayerEntity);
}
GetNextFrame(this);
GetNextFrame(super);
}
void VaatiProjectileFunction0Action5(Entity* this) {
void VaatiProjectileFunction0Action5(VaatiProjectileEntity* this) {
sub_0803E444(this);
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
} else {
if (-0x18 < --this->z.HALF.HI) {
if (-0x18 < --super->z.HALF.HI) {
return;
}
this->action = 6;
this->timer = 20;
super->action = 6;
super->timer = 20;
}
}
void VaatiProjectileFunction0Action6(Entity* this) {
if (--this->timer == 0) {
this->action = 7;
this->direction = DirectionSouth;
this->speed = 0x300;
void VaatiProjectileFunction0Action6(VaatiProjectileEntity* this) {
if (--super->timer == 0) {
super->action = 7;
super->direction = DirectionSouth;
super->speed = 0x300;
}
sub_0803E444(this);
}
void VaatiProjectileFunction0Action7(Entity* this) {
void VaatiProjectileFunction0Action7(VaatiProjectileEntity* this) {
sub_0803E444(this);
LinearMoveUpdate(this);
LinearMoveUpdate(super);
sub_0803E4D8(this);
if ((gRoomControls.origin_y + gRoomControls.height + -0x10) <= this->y.HALF.HI) {
if ((gRoomControls.origin_y + gRoomControls.height + -0x10) <= super->y.HALF.HI) {
SetInitializationPriority();
// TODO this screen transition is to mazaal. Is this also the projectile for Mazaals shrink ray?
// TODO super screen transition is to mazaal. Is super also the projectile for Mazaals shrink ray?
DoExitTransition(&gUnk_0813AB94);
}
}
void VaatiProjectileFunction0Action8(Entity* this) {
if (this->parent->next == NULL) {
void VaatiProjectileFunction0Action8(VaatiProjectileEntity* this) {
if (super->parent->next == NULL) {
DeleteThisEntity();
}
PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
GetNextFrame(this);
PositionRelative(super->parent, super, 0, Q_16_16(-1.0));
GetNextFrame(super);
}
void VaatiProjectileFunction0Action9(Entity* this) {
this->x.HALF.HI = gPlayerEntity.x.HALF.HI;
this->y.HALF.HI = gPlayerEntity.y.HALF.HI;
if (this->z.HALF.HI < -8) {
if (this->animIndex != 2) {
this->timer = 0;
InitializeAnimation(this->child, 2);
void VaatiProjectileFunction0Action9(VaatiProjectileEntity* this) {
super->x.HALF.HI = gPlayerEntity.x.HALF.HI;
super->y.HALF.HI = gPlayerEntity.y.HALF.HI;
if (super->z.HALF.HI < -8) {
if (super->animIndex != 2) {
super->timer = 0;
InitializeAnimation(super->child, 2);
}
VaatiProjectileFunction0Action2(this);
} else {
this->z.HALF.HI += 8;
super->z.HALF.HI += 8;
}
}
void sub_0803E444(Entity* this) {
void sub_0803E444(VaatiProjectileEntity* this) {
ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
sub_0806FA90(this, this->contactedEntity, 0, -2);
sub_0806FA90(super, super->contactedEntity, 0, -2);
gPlayerEntity.spriteOffsetY += 0xe;
}
void sub_0803E480(Entity* this) {
if (this->field_0x78.HWORD >= 0x4b1) {
this->speed = 0x180;
void sub_0803E480(VaatiProjectileEntity* this) {
if (this->unk_78 >= 0x4b1) {
super->speed = 0x180;
} else {
this->field_0x78.HWORD++;
this->unk_78++;
}
}
bool32 sub_0803E4A0(Entity* this) {
bool32 sub_0803E4A0(VaatiProjectileEntity* this) {
#ifdef EU
bool32 ret;
if (gRoomTransition.field_0x39 == 0) {
return TRUE;
} else {
if (this->parent == NULL) {
if (super->parent == NULL) {
return FALSE;
}
ret = this->parent->next == NULL;
ret = super->parent->next == NULL;
}
return ret;
#else
bool32 ret;
if (gRoomTransition.field_0x39 != 0) {
if (this->parent == NULL) {
if (super->parent == NULL) {
return FALSE;
}
if (this->parent->health == 0) {
if (super->parent->health == 0) {
return TRUE;
} else {
ret = this->parent->next == NULL;
ret = super->parent->next == NULL;
}
} else {
return TRUE;
@ -272,10 +281,10 @@ bool32 sub_0803E4A0(Entity* this) {
#endif
}
void sub_0803E4D8(Entity* this) {
void sub_0803E4D8(VaatiProjectileEntity* this) {
u32 tile;
tile = TILE(this->x.HALF.HI, this->y.HALF.HI + 8);
tile = TILE(super->x.HALF.HI, super->y.HALF.HI + 8);
if (sub_080B1B44(tile, gPlayerEntity.collisionLayer) != 0xff) {
SetTile(0x4074, tile, gPlayerEntity.collisionLayer);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,35 +4,49 @@
*
* @brief Vaati Transfigured Eye enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "message.h"
#include "physics.h"
void sub_08045A00(Entity*);
void sub_08045A28(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[13];
/*0x75*/ u8 unk_75;
/*0x76*/ u8 unk_76;
/*0x77*/ u8 unused2[9];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unused3[1];
/*0x85*/ u8 unk_85;
} VaatiTransfiguredEyeEntity;
void VaatiTransfiguredEye_OnTick(Entity*);
void VaatiTransfiguredEye_OnCollision(Entity*);
void VaatiTransfiguredEye_OnDragged(Entity*);
void VaatiTransfiguredEyeFunction0Action0(Entity*);
void VaatiTransfiguredEyeFunction0Action1(Entity*);
void VaatiTransfiguredEyeFunction0Action2(Entity*);
void VaatiTransfiguredEyeFunction0Action3(Entity*);
void VaatiTransfiguredEyeFunction0Action4(Entity*);
void sub_08045A00(VaatiTransfiguredEyeEntity*);
void sub_08045A28(VaatiTransfiguredEyeEntity*);
void (*const VaatiTransfiguredEye_Functions[])(Entity*) = {
void VaatiTransfiguredEye_OnTick(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEye_OnCollision(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEye_OnDragged(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEyeFunction0Action0(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEyeFunction0Action1(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEyeFunction0Action2(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEyeFunction0Action3(VaatiTransfiguredEyeEntity*);
void VaatiTransfiguredEyeFunction0Action4(VaatiTransfiguredEyeEntity*);
void (*const VaatiTransfiguredEye_Functions[])(VaatiTransfiguredEyeEntity*) = {
VaatiTransfiguredEye_OnTick,
VaatiTransfiguredEye_OnCollision,
VaatiTransfiguredEye_OnTick,
GenericDeath,
GenericConfused,
(void (*)(VaatiTransfiguredEyeEntity*))GenericDeath,
(void (*)(VaatiTransfiguredEyeEntity*))GenericConfused,
VaatiTransfiguredEye_OnDragged,
};
void (*const vaatiTransfiguredEyeFunction0Actions[])(Entity*) = {
void (*const vaatiTransfiguredEyeFunction0Actions[])(VaatiTransfiguredEyeEntity*) = {
VaatiTransfiguredEyeFunction0Action0, VaatiTransfiguredEyeFunction0Action1, VaatiTransfiguredEyeFunction0Action2,
VaatiTransfiguredEyeFunction0Action3, VaatiTransfiguredEyeFunction0Action4,
};
@ -45,201 +59,201 @@ struct xy {
const struct xy gUnk_080D18B4[] = { { 0xe8, 0xf6 }, { 0xf6, 0xe8 }, { 0x0a, 0xe8 }, { 0x18, 0xf6 },
{ 0x18, 0x0a }, { 0x0a, 0x18 }, { 0xf6, 0x18 }, { 0xe8, 0x0a } };
void VaatiTransfiguredEye(Entity* this) {
EnemyFunctionHandler(this, VaatiTransfiguredEye_Functions);
void VaatiTransfiguredEye(VaatiTransfiguredEyeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)VaatiTransfiguredEye_Functions);
}
void VaatiTransfiguredEye_OnTick(Entity* this) {
vaatiTransfiguredEyeFunction0Actions[this->action](this);
void VaatiTransfiguredEye_OnTick(VaatiTransfiguredEyeEntity* this) {
vaatiTransfiguredEyeFunction0Actions[super->action](this);
}
void VaatiTransfiguredEye_OnCollision(Entity* this) {
void VaatiTransfiguredEye_OnCollision(VaatiTransfiguredEyeEntity* this) {
u8 bVar1;
Entity* pEVar4;
if (this->type != 0) {
pEVar4 = this->parent->parent;
if ((this->contactFlags & 0x80) != 0) {
bVar1 = this->contactFlags & 0x3f;
if (super->type != 0) {
pEVar4 = super->parent->parent;
if ((super->contactFlags & 0x80) != 0) {
bVar1 = super->contactFlags & 0x3f;
if ((bVar1 == 0xe) || (bVar1 == 0x15)) {
if (this->field_0x80.HALF.HI == 0) {
this->action = 3;
this->field_0x80.HALF.HI++;
InitializeAnimation(this, (this->type << 3) | (this->timer + 2));
InitializeAnimation(this->parent, (this->parent->type << 3) | (this->timer + 2));
if (this->unk_81 == 0) {
super->action = 3;
this->unk_81++;
InitializeAnimation(super, (super->type << 3) | (super->timer + 2));
InitializeAnimation(super->parent, (super->parent->type << 3) | (super->timer + 2));
}
if (this->timer != 0) {
if (super->timer != 0) {
SoundReq(SFX_17A);
} else {
SoundReq(SFX_ITEM_GLOVES_KNOCKBACK);
}
} else {
if (this->health != 0xff) {
this->health = 0xff;
if (this->timer != 0 && (pEVar4->field_0x80.HALF.HI != 0)) {
pEVar4->field_0x76.HALF.LO |= (1 << this->type2);
if (this->cutsceneBeh.HALF.HI == 0) {
this->cutsceneBeh.HALF.HI++;
InitializeAnimation(this, this->type << 3 | 6);
InitializeAnimation(this->parent, this->parent->type << 3 | 6);
if (super->health != 0xff) {
super->health = 0xff;
if (super->timer != 0 && (((VaatiTransfiguredEyeEntity*)pEVar4)->unk_81 != 0)) {
((VaatiTransfiguredEyeEntity*)pEVar4)->unk_76 |= (1 << super->type2);
if (this->unk_85 == 0) {
this->unk_85++;
InitializeAnimation(super, super->type << 3 | 6);
InitializeAnimation(super->parent, super->parent->type << 3 | 6);
}
}
}
}
}
}
EnemyFunctionHandlerAfterCollision(this, VaatiTransfiguredEye_Functions);
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)VaatiTransfiguredEye_Functions);
}
void VaatiTransfiguredEye_OnDragged(Entity* this) {
void VaatiTransfiguredEye_OnDragged(VaatiTransfiguredEyeEntity* this) {
}
void VaatiTransfiguredEyeFunction0Action0(Entity* this) {
void VaatiTransfiguredEyeFunction0Action0(VaatiTransfiguredEyeEntity* this) {
Entity* child;
u8 bVar2;
bVar2 = gMessage.state & MESSAGE_ACTIVE;
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
this->spriteSettings.draw = 0;
this->field_0x80.HALF.LO = bVar2;
this->field_0x80.HALF.HI = bVar2;
this->cutsceneBeh.HALF.HI = bVar2;
this->subtimer = bVar2;
this->field_0x82.HALF.LO = 0x30;
this->field_0x82.HALF.HI = bVar2;
if (this->type == 0) {
super->action = 1;
super->spriteSettings.draw = 0;
this->unk_80 = bVar2;
this->unk_81 = bVar2;
this->unk_85 = bVar2;
super->subtimer = bVar2;
this->unk_82 = 0x30;
this->unk_83 = bVar2;
if (super->type == 0) {
sub_08045A00(this);
child = CreateEnemy(VAATI_TRANSFIGURED_EYE, 1);
if (child != NULL) {
child->parent = this;
this->child = child;
child->timer = this->timer;
child->type2 = this->type2;
CopyPosition(this, child);
child->parent = super;
super->child = child;
child->timer = super->timer;
child->type2 = super->type2;
CopyPosition(super, child);
}
} else {
this->spriteOffsetY = 1;
super->spriteOffsetY = 1;
}
InitializeAnimation(this, (u32)this->type << 3 | 1);
InitializeAnimation(super, (u32)super->type << 3 | 1);
}
}
void VaatiTransfiguredEyeFunction0Action1(Entity* this) {
void VaatiTransfiguredEyeFunction0Action1(VaatiTransfiguredEyeEntity* this) {
sub_08045A28(this);
if (this->field_0x82.HALF.LO == 0) {
if ((this->frame & ANIM_DONE) != 0) {
if (this->type != 0) {
COLLISION_ON(this);
if (this->unk_82 == 0) {
if ((super->frame & ANIM_DONE) != 0) {
if (super->type != 0) {
COLLISION_ON(super);
}
this->action = 2;
InitializeAnimation(this, this->type << 3);
super->action = 2;
InitializeAnimation(super, super->type << 3);
}
} else {
if (--this->field_0x82.HALF.LO == 0) {
this->spriteSettings.draw = 1;
if (--this->unk_82 == 0) {
super->spriteSettings.draw = 1;
}
}
}
void VaatiTransfiguredEyeFunction0Action2(Entity* this) {
void VaatiTransfiguredEyeFunction0Action2(VaatiTransfiguredEyeEntity* this) {
Entity* parent;
sub_08045A28(this);
parent = this->parent;
if (this->type != 0) {
parent = super->parent;
if (super->type != 0) {
parent = parent->parent;
}
if ((parent->action == 3) && (parent->field_0x80.HALF.LO == 1)) {
this->action = 4;
this->subtimer = 0;
if (this->type != 0) {
COLLISION_OFF(this);
if (this->timer != 0) {
InitializeAnimation(this, this->type << 3 | 5);
InitializeAnimation(this->parent, this->parent->type << 3 | 5);
if ((parent->action == 3) && (((VaatiTransfiguredEyeEntity*)parent)->unk_80 == 1)) {
super->action = 4;
super->subtimer = 0;
if (super->type != 0) {
COLLISION_OFF(super);
if (super->timer != 0) {
InitializeAnimation(super, super->type << 3 | 5);
InitializeAnimation(super->parent, super->parent->type << 3 | 5);
} else {
InitializeAnimation(this, this->type << 3 | 4);
InitializeAnimation(this->parent, this->parent->type << 3 | 4);
InitializeAnimation(super, super->type << 3 | 4);
InitializeAnimation(super->parent, super->parent->type << 3 | 4);
}
}
}
}
void VaatiTransfiguredEyeFunction0Action3(Entity* this) {
void VaatiTransfiguredEyeFunction0Action3(VaatiTransfiguredEyeEntity* this) {
sub_08045A28(this);
if ((this->frame & ANIM_DONE) != 0) {
this->action = 2;
if (this->type != 0) {
if (this->timer == 0) {
this->hitType = 0x32;
if ((super->frame & ANIM_DONE) != 0) {
super->action = 2;
if (super->type != 0) {
if (super->timer == 0) {
super->hitType = 0x32;
} else {
this->parent->parent->field_0x76.HALF.LO |= (1 << this->type2);
this->hitType = 0x31;
((VaatiTransfiguredEyeEntity*)super->parent->parent)->unk_76 |= (1 << super->type2);
super->hitType = 0x31;
}
}
}
}
void VaatiTransfiguredEyeFunction0Action4(Entity* this) {
void VaatiTransfiguredEyeFunction0Action4(VaatiTransfiguredEyeEntity* this) {
Entity* parent;
sub_08045A28(this);
if (this->subtimer == 0) {
if ((this->frame & ANIM_DONE) != 0) {
this->subtimer = 32;
if (super->subtimer == 0) {
if ((super->frame & ANIM_DONE) != 0) {
super->subtimer = 32;
}
} else {
parent = this->parent;
if (this->type != 0) {
parent = super->parent;
if (super->type != 0) {
parent = parent->parent;
}
if ((parent->animationState < 3) && (parent->action != 3)) {
this->action = 1;
this->subtimer = 0;
this->field_0x80.HALF.HI = 0;
this->cutsceneBeh.HALF.HI = 0;
if (this->type != 0) {
this->hitType = 0x33;
super->action = 1;
super->subtimer = 0;
this->unk_81 = 0;
this->unk_85 = 0;
if (super->type != 0) {
super->hitType = 0x33;
}
if ((parent->field_0x74.HALF.HI >> this->type2 & 1U) != 0) {
this->timer = 1;
if ((((VaatiTransfiguredEyeEntity*)parent)->unk_75 >> super->type2 & 1U) != 0) {
super->timer = 1;
} else {
this->timer = 0;
super->timer = 0;
}
InitializeAnimation(this, this->type << 3 | 1);
InitializeAnimation(super, super->type << 3 | 1);
}
}
}
void sub_08045A00(Entity* this) {
const struct xy* t = &gUnk_080D18B4[this->type2];
PositionRelative(this->parent, this, Q_16_16(t->x), Q_16_16(t->y + 3));
void sub_08045A00(VaatiTransfiguredEyeEntity* this) {
const struct xy* t = &gUnk_080D18B4[super->type2];
PositionRelative(super->parent, super, Q_16_16(t->x), Q_16_16(t->y + 3));
}
void sub_08045A28(Entity* this) {
void sub_08045A28(VaatiTransfiguredEyeEntity* this) {
u32 frames;
u32 type;
if (this->field_0x82.HALF.LO == 0) {
GetNextFrame(this);
if (this->unk_82 == 0) {
GetNextFrame(super);
}
frames = this->frame & 0x70;
type = this->type;
frames = super->frame & 0x70;
type = super->type;
if (type == 0) {
sub_08045A00(this);
switch (this->field_0x82.HALF.HI) {
switch (this->unk_83) {
case 0:
switch (frames) {
case 0x20:
this->field_0x82.HALF.HI = 1;
ChangeObjPalette(this, 0x13e);
this->unk_83 = 1;
ChangeObjPalette(super, 0x13e);
break;
case 0x00:
case 0x40:
this->field_0x82.HALF.HI = 2;
ChangeObjPalette(this, 0x13f);
this->unk_83 = 2;
ChangeObjPalette(super, 0x13f);
break;
default:
break;
@ -248,12 +262,12 @@ void sub_08045A28(Entity* this) {
case 1:
switch (frames) {
case 0x10:
this->field_0x82.HALF.HI = type;
ChangeObjPalette(this, 0x13b);
this->unk_83 = type;
ChangeObjPalette(super, 0x13b);
break;
case 0:
this->field_0x82.HALF.HI = 2;
ChangeObjPalette(this, 0x13f);
this->unk_83 = 2;
ChangeObjPalette(super, 0x13f);
break;
default:
break;
@ -262,16 +276,16 @@ void sub_08045A28(Entity* this) {
case 2:
switch (frames) {
case 0x20:
this->field_0x82.HALF.HI = 1;
ChangeObjPalette(this, 0x13e);
this->unk_83 = 1;
ChangeObjPalette(super, 0x13e);
break;
case 0x10:
this->field_0x82.HALF.HI = 0;
ChangeObjPalette(this, 0x13b);
this->unk_83 = 0;
ChangeObjPalette(super, 0x13b);
break;
case 0x40:
this->field_0x82.HALF.HI = 2;
ChangeObjPalette(this, 0x13f);
this->unk_83 = 2;
ChangeObjPalette(super, 0x13f);
break;
default:
break;
@ -280,8 +294,8 @@ void sub_08045A28(Entity* this) {
case 3:
switch (frames) {
case 0:
this->field_0x82.HALF.HI = 2;
ChangeObjPalette(this, 0x13f);
this->unk_83 = 2;
ChangeObjPalette(super, 0x13f);
break;
default:
break;
@ -291,42 +305,42 @@ void sub_08045A28(Entity* this) {
break;
}
} else {
PositionRelative(this->parent, this, 0, Q_16_16(-1.0));
switch (this->field_0x82.HALF.HI) {
PositionRelative(super->parent, super, 0, Q_16_16(-1.0));
switch (this->unk_83) {
case 0:
switch (this->frame & 0x70) {
switch (super->frame & 0x70) {
case 0x10:
this->field_0x82.HALF.HI = 2;
ChangeObjPalette(this, 0x13b);
this->unk_83 = 2;
ChangeObjPalette(super, 0x13b);
break;
case 0x20:
this->field_0x82.HALF.HI = 1;
ChangeObjPalette(this, 0x13e);
this->unk_83 = 1;
ChangeObjPalette(super, 0x13e);
break;
default:
break;
}
break;
case 1: {
u32 temp = this->frame & 0x70;
u32 temp = super->frame & 0x70;
switch (temp) {
case 0:
this->field_0x82.HALF.HI = temp;
ChangeObjPalette(this, 0x13f);
this->unk_83 = temp;
ChangeObjPalette(super, 0x13f);
break;
case 0x10:
this->field_0x82.HALF.HI = 2;
ChangeObjPalette(this, 0x13b);
this->unk_83 = 2;
ChangeObjPalette(super, 0x13b);
break;
default:
break;
}
} break;
case 2:
switch (this->frame & 0x70) {
switch (super->frame & 0x70) {
case 0:
this->field_0x82.HALF.HI = this->frame & 0x70;
ChangeObjPalette(this, 0x13f);
this->unk_83 = super->frame & 0x70;
ChangeObjPalette(super, 0x13f);
break;
default:
break;

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
*
* @brief Vaati Wrath Eye enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#define NENT_DEPRECATED
#include "enemy/vaatiWrath.h"
#include "functions.h"
void sub_080485D8(Entity*);
@ -80,7 +80,7 @@ void VaatiWrathEyeAction3(Entity* this) {
const s8* ptr;
parent = this->parent;
if (parent->field_0x78.HALF.HI != 0) {
if (((VaatiWrathEntity*)parent)->unk_79 != 0) {
sub_080485D8(this);
} else {
ptr = &gUnk_080D1D98[this->type * 2];
@ -164,14 +164,14 @@ void VaatiWrathEyeAction7(Entity* this) {
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
CreateFx(this, FX_REFLECT2, 0x40);
this->parent->field_0x7a.HALF.HI |= 0x10 << this->type;
((VaatiWrathEntity*)this->parent)->unk_7b |= 0x10 << this->type;
} else {
if (--this->timer != 0) {
return;
}
this->action = 5;
this->timer = 0;
this->parent->field_0x7a.HALF.HI |= 1 << this->type;
((VaatiWrathEntity*)this->parent)->unk_7b |= 1 << this->type;
}
}
@ -196,7 +196,8 @@ void VaatiWrathEyeAction9(Entity* this) {
if ((this->frame & ANIM_DONE) != 0) {
this->action = 4;
this->timer = 1;
this->parent->field_0x7a.HALF.HI = (this->parent->field_0x7a.HALF.HI & 0xf) | (1 << this->type);
((VaatiWrathEntity*)this->parent)->unk_7b =
(((VaatiWrathEntity*)this->parent)->unk_7b & 0xf) | (1 << this->type);
}
}
@ -212,5 +213,5 @@ void sub_080485FC(Entity* this) {
ptr = &gUnk_080D1D98[this->type * 2];
sub_0806FA90(this->parent, this, ptr[0], ptr[1]);
this->z.HALF.HI = gUnk_080D1D78[this->type * 8 + (this->parent->field_0x78.HALF.LO >> 4 & 7)];
this->z.HALF.HI = gUnk_080D1D78[this->type * 8 + (((VaatiWrathEntity*)this->parent)->unk_78 >> 4 & 7)];
}

View File

@ -4,207 +4,219 @@
*
* @brief Wall Master enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
#include "screenTransitions.h"
void sub_0802A78C(Entity*);
void sub_0802A7D0(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} WallMasterEntity;
extern void (*const WallMaster_Functions[])(Entity*);
extern void (*const gUnk_080CD094[])(Entity*);
void sub_0802A78C(WallMasterEntity*);
void sub_0802A7D0(WallMasterEntity*);
extern void (*const WallMaster_Functions[])(WallMasterEntity*);
extern void (*const gUnk_080CD094[])(WallMasterEntity*);
extern const s8 gUnk_080CD0B0[];
void WallMaster(Entity* this) {
WallMaster_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
void WallMaster(WallMasterEntity* this) {
WallMaster_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
void WallMaster_OnTick(Entity* this) {
void WallMaster_OnTick(WallMasterEntity* this) {
sub_0802A78C(this);
gUnk_080CD094[this->action](this);
gUnk_080CD094[super->action](this);
}
void WallMaster_OnCollision(Entity* this) {
if (this->hitType != 0x75 && ((this->contactFlags & 0x7f) == 0 || (this->contactFlags & 0x7f) == 0x1e)) {
this->action = 5;
COLLISION_OFF(this);
this->field_0x7c.HALF.HI = gPlayerEntity.x.HALF.HI;
this->field_0x80.HWORD = gPlayerEntity.y.HALF.HI;
this->field_0x82.HWORD = gPlayerEntity.z.HALF.HI;
if (this->action != 3) {
InitializeAnimation(this, 1);
void WallMaster_OnCollision(WallMasterEntity* this) {
if (super->hitType != 0x75 && ((super->contactFlags & 0x7f) == 0 || (super->contactFlags & 0x7f) == 0x1e)) {
super->action = 5;
COLLISION_OFF(super);
this->unk_7e = gPlayerEntity.x.HALF.HI;
this->unk_80 = gPlayerEntity.y.HALF.HI;
this->unk_82 = gPlayerEntity.z.HALF.HI;
if (super->action != 3) {
InitializeAnimation(super, 1);
}
}
if (this->knockbackDuration != 0)
if (this->knockbackDuration > 4)
this->knockbackDuration -= 4;
if (super->knockbackDuration != 0)
if (super->knockbackDuration > 4)
super->knockbackDuration -= 4;
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, WallMaster_Functions);
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)WallMaster_Functions);
}
void WallMaster_OnGrabbed(Entity* this) {
void WallMaster_OnGrabbed(WallMasterEntity* this) {
/* ... */
}
void sub_0802A4E4(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->collisionLayer = 3;
this->field_0x7c.BYTES.byte1 = Random();
this->field_0x7a.HWORD = this->type2 * 0x3c;
this->field_0x7c.BYTES.byte0 = this->timer;
this->field_0x78.HWORD = this->timer * 0x3c;
UpdateSpriteForCollisionLayer(this);
void sub_0802A4E4(WallMasterEntity* this) {
sub_0804A720(super);
super->action = 1;
super->collisionLayer = 3;
this->unk_7d = Random();
this->unk_7a = super->type2 * 0x3c;
this->unk_7c = super->timer;
this->unk_78 = super->timer * 0x3c;
UpdateSpriteForCollisionLayer(super);
sub_0802A7D0(this);
}
void sub_0802A534(Entity* this) {
if (this->field_0x78.HWORD) {
this->field_0x78.HWORD--;
} else if (this->field_0x7a.HWORD == 0) {
void sub_0802A534(WallMasterEntity* this) {
if (this->unk_78) {
this->unk_78--;
} else if (this->unk_7a == 0) {
Entity* entity = sub_08049DF4(1);
if (entity != NULL) {
this->action = 2;
this->timer = 90;
COLLISION_ON(this);
this->spriteSettings.draw = 3;
this->x.HALF.HI = entity->x.HALF.HI;
this->y.HALF.HI = entity->y.HALF.HI;
this->z.HALF.HI = -0x80;
this->spritePriority.b1 = 1;
this->spriteSettings.shadow = 2;
InitializeAnimation(this, 2);
super->action = 2;
super->timer = 90;
COLLISION_ON(super);
super->spriteSettings.draw = 3;
super->x.HALF.HI = entity->x.HALF.HI;
super->y.HALF.HI = entity->y.HALF.HI;
super->z.HALF.HI = -0x80;
super->spritePriority.b1 = 1;
super->spriteSettings.shadow = 2;
InitializeAnimation(super, 2);
sub_0802A7D0(this);
}
}
}
void sub_0802A5B8(Entity* this) {
void sub_0802A5B8(WallMasterEntity* this) {
sub_0802A7D0(this);
if (this->timer) {
if (--this->timer == 0) {
if (super->timer) {
if (--super->timer == 0) {
EnqueueSFX(SFX_12D);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
} else {
this->z.HALF.HI += 3;
if (-1 < this->z.HALF.HI) {
this->action = 3;
this->spriteSettings.draw = 1;
this->z.HALF.HI = 0;
InitializeAnimation(this, 1);
super->z.HALF.HI += 3;
if (-1 < super->z.HALF.HI) {
super->action = 3;
super->spriteSettings.draw = 1;
super->z.HALF.HI = 0;
InitializeAnimation(super, 1);
}
}
}
/* Kids... don't try to optimize code like this... */
void sub_0802A610(Entity* this) {
/* Kids... don't try to optimize code like super... */
void sub_0802A610(WallMasterEntity* this) {
u32 flags;
GetNextFrame(this);
GetNextFrame(super);
sub_0802A7D0(this);
flags = this->frame & ANIM_DONE;
flags = super->frame & ANIM_DONE;
if (flags) {
this->action = 4;
this->timer = 30;
} else if (this->frame & 1) {
this->frame = flags;
this->hitType = 0x75;
super->action = 4;
super->timer = 30;
} else if (super->frame & 1) {
super->frame = flags;
super->hitType = 0x75;
}
}
void sub_0802A650(Entity* this) {
void sub_0802A650(WallMasterEntity* this) {
sub_0802A7D0(this);
this->z.HALF.HI -= 2;
if (-0xa0 > this->z.HALF.HI) {
this->action = 1;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
this->hitType = 0x74;
this->field_0x78.HWORD = this->field_0x7c.BYTES.byte0 * 0x3c;
super->z.HALF.HI -= 2;
if (-0xa0 > super->z.HALF.HI) {
super->action = 1;
COLLISION_OFF(super);
super->spriteSettings.draw = 0;
super->hitType = 0x74;
this->unk_78 = this->unk_7c * 0x3c;
}
}
void sub_0802A69C(Entity* this) {
void sub_0802A69C(WallMasterEntity* this) {
u32 flags;
sub_0802A7D0(this);
gPlayerState.field_0xa |= 0x80;
gPlayerState.mobility |= 0x80;
gPlayerEntity.x.HALF.HI = this->field_0x7c.HALF.HI;
gPlayerEntity.y.HALF.HI = this->field_0x80.HWORD;
gPlayerEntity.z.HALF.HI = this->field_0x82.HWORD;
gPlayerEntity.x.HALF.HI = this->unk_7e;
gPlayerEntity.y.HALF.HI = this->unk_80;
gPlayerEntity.z.HALF.HI = this->unk_82;
if (gPlayerEntity.z.HALF.HI != this->z.HALF.HI) {
if (gPlayerEntity.z.HALF.HI < this->z.HALF.HI) {
this->z.HALF.HI--;
if (gPlayerEntity.z.HALF.HI != super->z.HALF.HI) {
if (gPlayerEntity.z.HALF.HI < super->z.HALF.HI) {
super->z.HALF.HI--;
} else {
this->z.HALF.HI++;
super->z.HALF.HI++;
}
}
/* sigh... */
GetNextFrame(this);
flags = this->frame & ANIM_DONE;
GetNextFrame(super);
flags = super->frame & ANIM_DONE;
if (flags) {
this->action = 6;
this->timer = 30;
} else if (this->frame & 0x1) {
this->frame = flags;
this->spriteOffsetY = 3;
super->action = 6;
super->timer = 30;
} else if (super->frame & 0x1) {
super->frame = flags;
super->spriteOffsetY = 3;
gPlayerEntity.spriteSettings.draw = 0;
}
}
void sub_0802A734(Entity* this) {
void sub_0802A734(WallMasterEntity* this) {
sub_0802A7D0(this);
if (--this->timer == 0) {
if (--super->timer == 0) {
SetInitializationPriority();
DoExitTransition(gWallMasterScreenTransitions[gArea.dungeon_idx]);
} else {
this->z.WORD -= Q_16_16(2);
super->z.WORD -= Q_16_16(2);
gPlayerState.field_0xa |= 0x80;
gPlayerState.mobility |= 0x80;
}
}
void sub_0802A78C(Entity* this) {
if (this->action != 0) {
if (sub_08049FDC(this, 1)) {
if (this->field_0x78.HWORD == 0) {
if (this->field_0x7a.HWORD) {
this->field_0x7a.HWORD--;
void sub_0802A78C(WallMasterEntity* this) {
if (super->action != 0) {
if (sub_08049FDC(super, 1)) {
if (this->unk_78 == 0) {
if (this->unk_7a) {
this->unk_7a--;
}
}
} else {
this->field_0x7a.HWORD = this->type2 * 0x3c + 1;
this->unk_7a = super->type2 * 0x3c + 1;
}
}
}
void sub_0802A7D0(Entity* this) {
u32 unk = gUnk_080CD0B0[(this->field_0x7c.BYTES.byte1++ >> 3) & 7] + 0x100;
SetAffineInfo(this, unk, unk, 0);
void sub_0802A7D0(WallMasterEntity* this) {
u32 unk = gUnk_080CD0B0[(this->unk_7d++ >> 3) & 7] + 0x100;
SetAffineInfo(super, unk, unk, 0);
}
// clang-format off
void (*const WallMaster_Functions[])(Entity*) = {
void (*const WallMaster_Functions[])(WallMasterEntity*) = {
WallMaster_OnTick,
WallMaster_OnCollision,
GenericKnockback2,
GenericDeath,
GenericConfused,
(void (*)(WallMasterEntity*))GenericKnockback2,
(void (*)(WallMasterEntity*))GenericDeath,
(void (*)(WallMasterEntity*))GenericConfused,
WallMaster_OnGrabbed,
};
void (*const gUnk_080CD094[])(Entity*) = {
void (*const gUnk_080CD094[])(WallMasterEntity*) = {
sub_0802A4E4,
sub_0802A534,
sub_0802A5B8,

View File

@ -4,204 +4,213 @@
*
* @brief Wall Master 2 enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
#include "screenTransitions.h"
extern void GenericKnockback2(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u16 unk_7c;
} WallMaster2Entity;
extern Entity* gUnk_020000B0;
void sub_0802CF64(Entity*);
void sub_0802CF8C(Entity*);
void sub_0802CFD8(Entity*);
void sub_0802CF64(WallMaster2Entity*);
void sub_0802CF8C(WallMaster2Entity*);
void sub_0802CFD8(WallMaster2Entity*);
extern void (*const WallMaster2_Functions[])(Entity*);
extern void (*const gUnk_080CD714[])(Entity*);
extern void (*const WallMaster2_Functions[])(WallMaster2Entity*);
extern void (*const gUnk_080CD714[])(WallMaster2Entity*);
extern const u16 gUnk_080CD728[];
extern const u16 gUnk_080CD730[];
extern const s8 gUnk_080CD740[];
void WallMaster2(Entity* this) {
WallMaster2_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
void WallMaster2(WallMaster2Entity* this) {
WallMaster2_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
void WallMaster2_OnTick(Entity* this) {
gUnk_080CD714[this->action](this);
void WallMaster2_OnTick(WallMaster2Entity* this) {
gUnk_080CD714[super->action](this);
}
void WallMaster2_OnCollision(Entity* this) {
u8 bVar1 = this->contactFlags & 0x7f;
switch (this->contactFlags & 0x7f) {
void WallMaster2_OnCollision(WallMaster2Entity* this) {
u8 bVar1 = super->contactFlags & 0x7f;
switch (super->contactFlags & 0x7f) {
case 0 ... 1:
case 0x1e:
this->action = 3;
COLLISION_OFF(this);
InitializeAnimation(this, 1);
super->action = 3;
COLLISION_OFF(super);
InitializeAnimation(super, 1);
gPlayerEntity.flags &= ~ENT_COLLIDE;
break;
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, WallMaster2_Functions);
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)WallMaster2_Functions);
}
void WallMaster2_OnGrabbed(Entity* this) {
void WallMaster2_OnGrabbed(WallMaster2Entity* this) {
/* ... */
}
void sub_0802CCE0(Entity* this) {
void sub_0802CCE0(WallMaster2Entity* this) {
u32 tmp;
sub_0804A720(this);
this->action = 1;
this->timer = 60;
this->subtimer = Random();
this->spriteSettings.shadow = 2;
this->animationState = 0xff;
this->z.HALF.HI = -2;
this->collisionLayer = 3;
sub_0804A720(super);
super->action = 1;
super->timer = 60;
super->subtimer = Random();
super->spriteSettings.shadow = 2;
super->animationState = 0xff;
super->z.HALF.HI = -2;
super->collisionLayer = 3;
tmp = Random();
this->field_0x7a.HALF.LO = tmp;
this->field_0x7a.HALF.HI = (tmp >> 8) & 0x60;
this->field_0x7c.HALF.LO = 0;
UpdateSpriteForCollisionLayer(this);
InitializeAnimation(this, 0);
this->unk_7a = tmp;
this->unk_7b = (tmp >> 8) & 0x60;
this->unk_7c = 0;
UpdateSpriteForCollisionLayer(super);
InitializeAnimation(super, 0);
sub_0802CF64(this);
sub_0802CFD8(this);
}
void sub_0802CD54(Entity* this) {
GetNextFrame(this);
void sub_0802CD54(WallMaster2Entity* this) {
GetNextFrame(super);
sub_0802CFD8(this);
if ((this->field_0x7c.HALF_U.LO == 0 || --this->field_0x7c.HALF_U.LO == 0) && sub_08049FDC(this, 1)) {
if (this->field_0x7a.HALF.HI) {
--this->field_0x7a.HALF.HI;
if ((this->unk_7c == 0 || --this->unk_7c == 0) && sub_08049FDC(super, 1)) {
if (this->unk_7b) {
--this->unk_7b;
} else {
u32 tmp;
this->action = 2;
super->action = 2;
tmp = Random() >> 0x10;
this->timer = tmp;
this->speed = 0xc0;
this->field_0x78.HWORD = gUnk_080CD728[Random() & 3];
this->field_0x7a.HALF.HI = (tmp >> 8) & 0x60;
super->timer = tmp;
super->speed = 0xc0;
this->unk_78 = gUnk_080CD728[Random() & 3];
this->unk_7b = (tmp >> 8) & 0x60;
return;
}
}
if (--this->timer == 0) {
this->timer = 60;
if (--super->timer == 0) {
super->timer = 60;
sub_0802CF64(this);
}
LinearMoveUpdate(this);
LinearMoveUpdate(super);
}
void sub_0802CDE8(Entity* this) {
if (--this->field_0x78.HWORD && sub_08049FDC(this, 1)) {
if ((this->timer++ & 3) == 0) {
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
void sub_0802CDE8(WallMaster2Entity* this) {
if (--this->unk_78 && sub_08049FDC(super, 1)) {
if ((super->timer++ & 3) == 0) {
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
sub_0802CF8C(this);
}
LinearMoveUpdate(this);
LinearMoveUpdate(super);
} else {
this->action = 1;
this->timer = 60;
this->speed = 0x60;
this->field_0x7c.HALF.LO = (Random() & 0x38) + 0x96;
super->action = 1;
super->timer = 60;
super->speed = 0x60;
this->unk_7c = (Random() & 0x38) + 0x96;
}
GetNextFrame(this);
GetNextFrame(super);
sub_0802CFD8(this);
}
void sub_0802CE68(Entity* this) {
void sub_0802CE68(WallMaster2Entity* this) {
u8 frames;
gPlayerState.field_0xa |= 0x80;
gPlayerState.mobility |= 0x80;
gPlayerState.flags |= PL_DISABLE_ITEMS;
if (!EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 4)) {
this->direction = GetFacingDirection(this, &gPlayerEntity);
LinearMoveUpdate(this);
if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 4)) {
super->direction = GetFacingDirection(super, &gPlayerEntity);
LinearMoveUpdate(super);
}
sub_0802CFD8(this);
GetNextFrame(this);
frames = this->frame & ANIM_DONE;
GetNextFrame(super);
frames = super->frame & ANIM_DONE;
if (frames) {
this->action = 4;
this->timer = 30;
} else if (this->frame & 1) {
this->frame = frames;
super->action = 4;
super->timer = 30;
} else if (super->frame & 1) {
super->frame = frames;
gPlayerEntity.spriteSettings.draw = 0;
}
}
void sub_0802CEF4(Entity* this) {
void sub_0802CEF4(WallMaster2Entity* this) {
sub_0802CFD8(this);
if (--this->timer == 0) {
if (--super->timer == 0) {
SetInitializationPriority();
DoExitTransition(gWallMasterScreenTransitions[gArea.dungeon_idx]);
} else {
this->z.WORD -= Q_16_16(2);
if (this->z.HALF.HI < -0x30) {
this->spriteSettings.shadow = 1;
super->z.WORD -= Q_16_16(2);
if (super->z.HALF.HI < -0x30) {
super->spriteSettings.shadow = 1;
}
gPlayerState.field_0xa |= 0x80;
gPlayerState.mobility |= 0x80;
}
}
void sub_0802CF64(Entity* this) {
if (sub_08049FA0(this)) {
this->direction = Direction8Round(Random());
void sub_0802CF64(WallMaster2Entity* this) {
if (sub_08049FA0(super)) {
super->direction = Direction8Round(Random());
} else {
this->direction = Direction8RoundUp(sub_08049EE4(this));
super->direction = Direction8RoundUp(sub_08049EE4(super));
}
sub_0802CF8C(this);
}
void sub_0802CF8C(Entity* this) {
void sub_0802CF8C(WallMaster2Entity* this) {
int iVar1;
u32 dir;
const u16* ptr;
dir = Direction8RoundUp(this->direction);
if (dir - Direction8FromAnimationState(this->animationState) + 6 > 12) {
this->animationState = Direction8ToAnimationState(dir);
dir = Direction8RoundUp(super->direction);
if (dir - Direction8FromAnimationState(super->animationState) + 6 > 12) {
super->animationState = Direction8ToAnimationState(dir);
iVar1 = (dir >> 3) * 2;
ptr = &gUnk_080CD730[iVar1];
this->field_0x74.HWORD = ptr[0];
this->field_0x76.HWORD = ptr[1];
} else if (((this->direction + 1) & 7) > 2 && (Direction8ToAnimationState(dir) != this->animationState)) {
this->animationState = Direction8ToAnimationState(dir);
this->unk_74 = ptr[0];
this->unk_76 = ptr[1];
} else if (((super->direction + 1) & 7) > 2 && (Direction8ToAnimationState(dir) != super->animationState)) {
super->animationState = Direction8ToAnimationState(dir);
iVar1 = (dir >> 3) * 2;
ptr = &gUnk_080CD730[iVar1];
this->field_0x74.HWORD = ptr[0];
this->field_0x76.HWORD = ptr[1];
this->unk_74 = ptr[0];
this->unk_76 = ptr[1];
}
}
void sub_0802CFD8(Entity* this) {
u32 unk = gUnk_080CD740[(this->field_0x7a.HALF.LO++ >> 3) & 7];
SetAffineInfo(this, (s16)this->field_0x74.HWORD + unk, 0x100 + unk, this->field_0x76.HWORD);
void sub_0802CFD8(WallMaster2Entity* this) {
u32 unk = gUnk_080CD740[(this->unk_7a++ >> 3) & 7];
SetAffineInfo(super, (s16)this->unk_74 + unk, 0x100 + unk, this->unk_76);
}
// clang-format off
void (*const WallMaster2_Functions[])(Entity*) = {
void (*const WallMaster2_Functions[])(WallMaster2Entity*) = {
WallMaster2_OnTick,
WallMaster2_OnCollision,
GenericKnockback2,
GenericDeath,
GenericConfused,
(void (*)(WallMaster2Entity*)) GenericKnockback2,
(void (*)(WallMaster2Entity*)) GenericDeath,
(void (*)(WallMaster2Entity*)) GenericConfused,
WallMaster2_OnGrabbed,
};
void (*const gUnk_080CD714[])(Entity*) = {
void (*const gUnk_080CD714[])(WallMaster2Entity*) = {
sub_0802CCE0,
sub_0802CD54,
sub_0802CDE8,

View File

@ -4,163 +4,177 @@
*
* @brief Wisp enemy
*/
//#define NENT_DEPRECATED
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
#include "object.h"
#include "save.h"
static void sub_08033744(Entity* this);
void Wisp_OnTick(Entity* this);
void Wisp_OnCollision(Entity* this);
void Wisp_OnGrabbed(Entity* this);
void sub_08033674(Entity* this);
void sub_080336A8(Entity* this);
void sub_080336DC(Entity* this);
void sub_08033650(Entity* this);
void sub_08033658(Entity* this);
void sub_08033660(Entity* this);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[20];
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u8 unused2[2];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} WispEntity;
static void (*const Wisp_Functions[])(Entity*) = {
Wisp_OnTick, Wisp_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Wisp_OnGrabbed,
static void sub_08033744(WispEntity* this);
void Wisp_OnTick(WispEntity* this);
void Wisp_OnCollision(WispEntity* this);
void Wisp_OnGrabbed(WispEntity* this);
void sub_08033674(WispEntity* this);
void sub_080336A8(WispEntity* this);
void sub_080336DC(WispEntity* this);
void sub_08033650(WispEntity* this);
void sub_08033658(WispEntity* this);
void sub_08033660(WispEntity* this);
static void (*const Wisp_Functions[])(WispEntity*) = {
Wisp_OnTick,
Wisp_OnCollision,
(void (*)(WispEntity*))GenericKnockback,
(void (*)(WispEntity*))GenericDeath,
(void (*)(WispEntity*))GenericConfused,
Wisp_OnGrabbed,
};
void Wisp(Entity* this) {
EnemyFunctionHandler(this, Wisp_Functions);
void Wisp(WispEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Wisp_Functions);
}
void Wisp_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void Wisp_OnTick(WispEntity* this) {
static void (*const actionFuncs[])(WispEntity*) = {
sub_08033674,
sub_080336A8,
sub_080336DC,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void Wisp_OnCollision(Entity* this) {
void Wisp_OnCollision(WispEntity* this) {
u32 bits;
Entity* entity;
bits = this->contactFlags;
bits = super->contactFlags;
if ((bits & 0x80) == 0) {
return;
}
switch ((s32)bits & 0x3f) {
case 0:
this->action = 2;
this->spriteSettings.draw = FALSE;
COLLISION_OFF(this);
this->field_0x7c.HALF.LO = 0x27c;
super->action = 2;
super->spriteSettings.draw = FALSE;
COLLISION_OFF(super);
this->unk_7c = 0x27c;
gPlayerState.flags |= PL_DRUGGED;
gSave.stats.effect = this->type + 1;
gSave.stats.effect = super->type + 1;
gSave.stats.effectTimer = 600;
if (this->type == 0) {
if (super->type == 0) {
break;
}
DeleteThisEntity();
break;
case 0xe:
case 0x15:
this->health = 0;
super->health = 0;
break;
case 0x14:
COLLISION_OFF(this);
this->iframes = 0;
this->spriteSettings.draw = FALSE;
entity = CreateFx(this, FX_DEATH, 0);
COLLISION_OFF(super);
super->iframes = 0;
super->spriteSettings.draw = FALSE;
entity = CreateFx(super, FX_DEATH, 0);
if (entity != NULL) {
this->child = entity;
this->timer = 14;
CopyPosition(this, entity);
super->child = entity;
super->timer = 14;
CopyPosition(super, entity);
}
DeleteThisEntity();
break;
}
}
void Wisp_OnGrabbed(Entity* this) {
static void (*const subActionFuncs[])(Entity*) = {
void Wisp_OnGrabbed(WispEntity* this) {
static void (*const subActionFuncs[])(WispEntity*) = {
sub_08033650,
sub_08033658,
sub_08033660,
};
if (sub_0806F520(this)) {
subActionFuncs[this->subAction](this);
if (sub_0806F520(super)) {
subActionFuncs[super->subAction](this);
}
}
void sub_08033650(Entity* this) {
this->subAction = 2;
void sub_08033650(WispEntity* this) {
super->subAction = 2;
}
void sub_08033658(Entity* this) {
sub_0806F4E8(this);
void sub_08033658(WispEntity* this) {
sub_0806F4E8(super);
}
void sub_08033660(Entity* this) {
if (sub_0806F3E4(this)) {
GenericDeath(this);
void sub_08033660(WispEntity* this) {
if (sub_0806F3E4(super)) {
GenericDeath(super);
}
}
void sub_08033674(Entity* this) {
sub_0804A720(this);
this->timer = 0;
this->action = 1;
this->gustJarFlags = 1;
this->field_0x80.HWORD = this->x.HALF.HI;
this->field_0x82.HWORD = this->y.HALF.HI;
void sub_08033674(WispEntity* this) {
sub_0804A720(super);
super->timer = 0;
super->action = 1;
super->gustJarFlags = 1;
this->unk_80 = super->x.HALF.HI;
this->unk_82 = super->y.HALF.HI;
sub_08033744(this);
InitializeAnimation(this, this->type2);
InitializeAnimation(super, super->type2);
}
void sub_080336A8(Entity* this) {
if (--this->timer == 0) {
void sub_080336A8(WispEntity* this) {
if (--super->timer == 0) {
sub_08033744(this);
} else if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
} else if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
}
ProcessMovement0(this);
GetNextFrame(this);
ProcessMovement0(super);
GetNextFrame(super);
}
void sub_080336DC(Entity* this) {
switch ((u16)-- this->field_0x7c.HALF.LO) {
void sub_080336DC(WispEntity* this) {
switch ((u16)-- this->unk_7c) {
case 0x24:
this->x.HALF.HI = this->field_0x80.HWORD;
this->y.HALF.HI = this->field_0x82.HWORD;
super->x.HALF.HI = this->unk_80;
super->y.HALF.HI = this->unk_82;
break;
case 0x18:
CreateDust(this);
CreateDust(super);
break;
case 0xc:
this->spriteSettings.draw = TRUE;
super->spriteSettings.draw = TRUE;
break;
case 0x0:
this->action = 1;
COLLISION_ON(this);
super->action = 1;
COLLISION_ON(super);
sub_08033744(this);
break;
}
}
static void sub_08033744(Entity* this) {
static void sub_08033744(WispEntity* this) {
u32 temp;
u32 rand = (u32)Random() % 256;
static const u8 gUnk_080CEBA4[] = { 30, 45, 60, 75, 1, 90, 105, 120 };
// 8 potential options
this->timer = gUnk_080CEBA4[(rand & 0x70) >> 4];
super->timer = gUnk_080CEBA4[(rand & 0x70) >> 4];
// 4 potential options
temp = ((rand & 0xc) * 2);
// 75% chance to pass
if ((sub_08049FA0(this) == 0) && ((rand % 4) != 0)) {
temp = sub_08049EE4(this);
if ((sub_08049FA0(super) == 0) && ((rand % 4) != 0)) {
temp = sub_08049EE4(super);
// 50% chance to pass
if ((rand & 0x80) != 0) {
@ -171,5 +185,5 @@ static void sub_08033744(Entity* this) {
temp &= 0x18;
}
}
this->direction = temp;
super->direction = temp;
}

View File

@ -15,7 +15,7 @@ extern u16 gUnk_0800275C[];
extern u8 gUnk_0811BE38[];
void ItemPegasusBoots(ItemBehavior* this, u32 index) {
static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior * beh, u32) = {
static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior* beh, u32) = {
sub_080768F8,
sub_08076964,
sub_08076A88,

View File

@ -37,14 +37,14 @@ typedef struct struct_08108764 {
u16 unk_06;
u16 unk_08;
u16 unk_0a;
} * unk_0c;
}* unk_0c;
struct {
u8 unk_00;
u8 unk_01;
u8 unk_02[2];
u16 unk_04;
u16 unk_06;
} * unk_10;
}* unk_10;
} struct_08108764;
extern struct_08108764 gUnk_08108764[];

View File

@ -488,7 +488,9 @@ void sub_0805A9CC(TempleOfDropletsManager* this) {
gScreen.bg3.updated = 1;
}
extern struct { u8 unk_00[0x20]; } gUnk_085A97A0[];
extern struct {
u8 unk_00[0x20];
} gUnk_085A97A0[];
void sub_0805AA58(TempleOfDropletsManager* this) {
if (--super->timer == 0) {

View File

@ -21,11 +21,11 @@ void sub_080658BC(MalonEntity* this);
void sub_08065900(MalonEntity* this);
void Malon(MalonEntity* this) {
static void (*const actionFuncs[])(Entity * this) = {
static void (*const actionFuncs[])(Entity* this) = {
sub_08065864,
sub_08065880,
};
static void (*const scriptedActionFuncs[])(MalonEntity * this) = {
static void (*const scriptedActionFuncs[])(MalonEntity* this) = {
sub_08065888,
sub_080658BC,
sub_08065900,

View File

@ -20,7 +20,7 @@ void sub_08066CCC(Entity*);
void sub_08066CF8(Entity*);
void Zelda(Entity* this) {
static void (*const gUnk_08110BD8[])(Entity * ent) = {
static void (*const gUnk_08110BD8[])(Entity* ent) = {
sub_08066CCC,
sub_08066CF8,
};