Create some enemy structs

This commit is contained in:
octorock
2023-07-30 23:56:42 +02:00
parent b28f865051
commit c63a86fbca
102 changed files with 5134 additions and 4744 deletions
+82 -82
View File
@@ -156,108 +156,108 @@ typedef enum {
/*0x66*/ ENEMY_66
} Enemy;
void Octorok(Entity*);
void Chuchu(Entity*);
void Leever(Entity*);
void Peahat(Entity*);
void Rollobite(Entity*);
void DarkNut(Entity*);
void HangingSeed(Entity*);
void Beetle(Entity*);
void Keese(Entity*);
void DoorMimic(Entity*);
void RockChuchu(Entity*);
void SpinyChuchu(Entity*);
void CuccoChickAggr(Entity*);
void Moldorm(Entity*);
void EnemyE(Entity*);
void Moldworm(Entity*);
void Sluggula(Entity*);
void Pesto(Entity*);
void Puffstool(Entity*);
void ChuchuBoss(Entity*);
void LikeLike(Entity*);
void SpearMoblin(Entity*);
void BusinessScrub(Entity*);
void RupeeLike(Entity*);
void Madderpillar(Entity*);
void WaterDrop(Entity*);
void WallMaster(Entity*);
void BombPeahat(Entity*);
void Spark(Entity*);
void Chaser(Entity*);
void SpikedBeetle(Entity*);
void SensorBladeTrap(Entity*);
void Helmasaur(Entity*);
void FallingBoulder(Entity*);
void Bobomb(Entity*);
void WallMaster2(Entity*);
void Octorok();
void Chuchu();
void Leever();
void Peahat();
void Rollobite();
void DarkNut();
void HangingSeed();
void Beetle();
void Keese();
void DoorMimic();
void RockChuchu();
void SpinyChuchu();
void CuccoChickAggr();
void Moldorm();
void EnemyE();
void Moldworm();
void Sluggula();
void Pesto();
void Puffstool();
void ChuchuBoss();
void LikeLike();
void SpearMoblin();
void BusinessScrub();
void RupeeLike();
void Madderpillar();
void WaterDrop();
void WallMaster();
void BombPeahat();
void Spark();
void Chaser();
void SpikedBeetle();
void SensorBladeTrap();
void Helmasaur();
void FallingBoulder();
void Bobomb();
void WallMaster2();
void Gleerok();
void VaatiEyesMacro(Entity*);
void Tektite(Entity*);
void VaatiEyesMacro();
void Tektite();
void WizzrobeWind();
void WizzrobeFire();
void WizzrobeIce();
void Armos();
void Eyegore();
void Rope(Entity*);
void SmallPesto(Entity*);
void AcroBandit(Entity*);
void BladeTrap(Entity*);
void Keaton(Entity*);
void Crow(Entity*);
void Rope();
void SmallPesto();
void AcroBandit();
void BladeTrap();
void Keaton();
void Crow();
void Mulldozer();
void Bombarossa(Entity*);
void Wisp(Entity*);
void SpinyBeetle(Entity*);
void MazaalHead(Entity*);
void MazaalMacro(Entity*);
void MazaalHand(Entity*);
void Bombarossa();
void Wisp();
void SpinyBeetle();
void MazaalHead();
void MazaalMacro();
void MazaalHand();
void OctorokBoss();
void FlyingPot(Entity*);
void Gibdo(Entity*);
void OctorokGolden(Entity*);
void TektiteGolden(Entity*);
void RopeGolden(Entity*);
void FlyingPot();
void Gibdo();
void OctorokGolden();
void TektiteGolden();
void RopeGolden();
void CloudPiranha();
void ScissorsBeetle(Entity*);
void CuccoAggr(Entity*);
void ScissorsBeetle();
void CuccoAggr();
void Stalfos();
void FlyingSkull(Entity*);
void MazaalBracelet(Entity*);
void Takkuri(Entity*);
void BowMoblin(Entity*);
void Lakitu(Entity*);
void LakituCloud(Entity*);
void TorchTrap(Entity*);
void VaatiRebornEnemy(Entity*);
void VaatiProjectile(Entity*);
void BallChainSoldier(Entity*);
void FlyingSkull();
void MazaalBracelet();
void Takkuri();
void BowMoblin();
void Lakitu();
void LakituCloud();
void TorchTrap();
void VaatiRebornEnemy();
void VaatiProjectile();
void BallChainSoldier();
void Enemy4D();
void Ghini();
void VaatiTransfigured(Entity*);
void VaatiTransfigured();
void Enemy50();
void VaatiWrath(Entity*);
void VaatiArm(Entity*);
void Dust(Entity*);
void VaatiBall(Entity*);
void Slime(Entity*);
void MiniSlime(Entity*);
void FireballGuy(Entity*);
void MiniFireballGuy(Entity*);
void VaatiTransfiguredEye(Entity*);
void BusinessScrubPrologue(Entity*);
void VaatiWrath();
void VaatiArm();
void Dust();
void VaatiBall();
void Slime();
void MiniSlime();
void FireballGuy();
void MiniFireballGuy();
void VaatiTransfiguredEye();
void BusinessScrubPrologue();
void GyorgFemale();
void GyorgMale();
void Curtain(Entity*);
void VaatiWrathEye(Entity*);
void Curtain();
void VaatiWrathEye();
void GyorgChild();
void GyorgFemaleEye();
void GyorgMaleEye();
void GyorgFemaleMouth();
void Enemy64();
void TreeItem(Entity*);
void Enemy66(Entity*);
void TreeItem();
void Enemy66();
extern void (*const gUnk_080012C8[])(Entity*);
+341 -325
View File
@@ -4,85 +4,101 @@
*
* @brief Acro Bandits enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unused2[1];
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ u16 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ union SplitHWord unk_74;
/*0x76*/ union SplitHWord unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unused6[1];
/*0x7c*/ Entity* unk_7c;
} AcroBanditEntity;
extern Entity* gUnk_020000B0;
static void sub_08031E48(Entity* this, Entity* child);
static void sub_08032290(Entity* this);
static bool32 sub_080322A4(Entity* this);
static void sub_08032338(Entity* this);
static void sub_080322E8(Entity* this);
static bool32 sub_08031E04(Entity* this);
static void sub_08031E48(AcroBanditEntity* this, AcroBanditEntity* child);
static void sub_08032290(AcroBanditEntity* this);
static bool32 sub_080322A4(AcroBanditEntity* this);
static void sub_08032338(AcroBanditEntity* this);
static void sub_080322E8(AcroBanditEntity* this);
static bool32 sub_08031E04(AcroBanditEntity* this);
void AcroBandit_OnTick(Entity* this);
void AcroBandit_OnCollision(Entity* this);
void AcroBandit_OnKnockback(Entity* this);
void GenericDeath(Entity* this);
void GenericConfused(Entity* this);
void AcroBandit_OnGrabbed(Entity* this);
void AcroBandit_Type0(Entity* this);
void AcroBandit_Type1(Entity* this);
void AcroBandit_Type0Action0(Entity* this);
void AcroBandit_Type0Action1(Entity* this);
void AcroBandit_Type0Action2(Entity* this);
void AcroBandit_Type0Action3(Entity* this);
void AcroBandit_Type0Action4(Entity* this);
void AcroBandit_Type0Action5(Entity* this);
void AcroBandit_Type0Action6(Entity* this);
void AcroBandit_Type0Action7(Entity* this);
void AcroBandit_Type0Action8(Entity* this);
void AcroBandit_Type1Init(Entity* this);
void AcroBandit_Type1Action1(Entity* this);
void AcroBandit_Type1Action2(Entity* this);
void AcroBandit_Type1Action3(Entity* this);
void AcroBandit_Type1Action4(Entity* this);
void AcroBandit_Type1Action5(Entity* this);
void AcroBandit_Type1Action6(Entity* this);
void AcroBandit_Type1Action7(Entity* this);
void AcroBandit_Type1Action8(Entity* this);
void AcroBandit_Type1Action9(Entity* this);
void AcroBandit_OnTick(AcroBanditEntity* this);
void AcroBandit_OnCollision(AcroBanditEntity* this);
void AcroBandit_OnKnockback(AcroBanditEntity* this);
void AcroBandit_OnGrabbed(AcroBanditEntity* this);
void AcroBandit_Type0(AcroBanditEntity* this);
void AcroBandit_Type1(AcroBanditEntity* this);
void AcroBandit_Type0Action0(AcroBanditEntity* this);
void AcroBandit_Type0Action1(AcroBanditEntity* this);
void AcroBandit_Type0Action2(AcroBanditEntity* this);
void AcroBandit_Type0Action3(AcroBanditEntity* this);
void AcroBandit_Type0Action4(AcroBanditEntity* this);
void AcroBandit_Type0Action5(AcroBanditEntity* this);
void AcroBandit_Type0Action6(AcroBanditEntity* this);
void AcroBandit_Type0Action7(AcroBanditEntity* this);
void AcroBandit_Type0Action8(AcroBanditEntity* this);
void AcroBandit_Type1Init(AcroBanditEntity* this);
void AcroBandit_Type1Action1(AcroBanditEntity* this);
void AcroBandit_Type1Action2(AcroBanditEntity* this);
void AcroBandit_Type1Action3(AcroBanditEntity* this);
void AcroBandit_Type1Action4(AcroBanditEntity* this);
void AcroBandit_Type1Action5(AcroBanditEntity* this);
void AcroBandit_Type1Action6(AcroBanditEntity* this);
void AcroBandit_Type1Action7(AcroBanditEntity* this);
void AcroBandit_Type1Action8(AcroBanditEntity* this);
void AcroBandit_Type1Action9(AcroBanditEntity* this);
static void (*const AcroBandit_Functions[])(Entity*) = {
static void (*const AcroBandit_Functions[])(AcroBanditEntity*) = {
AcroBandit_OnTick, AcroBandit_OnCollision, AcroBandit_OnKnockback,
GenericDeath, GenericConfused, AcroBandit_OnGrabbed,
(void (*)(AcroBanditEntity*))GenericDeath, (void (*)(AcroBanditEntity*))GenericConfused, AcroBandit_OnGrabbed,
};
void AcroBandit(Entity* this) {
void AcroBandit(AcroBanditEntity* this) {
s32 index;
index = sub_080012DC(this);
index = sub_080012DC(super);
if (index) {
if ((this->gustJarState & 1) == 0)
if ((super->gustJarState & 1) == 0)
sub_08032338(this);
gUnk_080012C8[index](this);
gUnk_080012C8[index](super);
} else {
AcroBandit_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
AcroBandit_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
}
void AcroBandit_OnTick(Entity* this) {
static void (*const typeFuncs[])(Entity*) = {
void AcroBandit_OnTick(AcroBanditEntity* this) {
static void (*const typeFuncs[])(AcroBanditEntity*) = {
AcroBandit_Type0,
AcroBandit_Type1,
};
typeFuncs[this->type](this);
typeFuncs[super->type](this);
}
void AcroBandit_OnCollision(Entity* this) {
void AcroBandit_OnCollision(AcroBanditEntity* this) {
Entity* brother;
if (this->contactFlags != 0x80 && this->contactFlags != 0x81) {
if (this->type == 1) {
if (this->action < 7 && this->knockbackDuration != 0) {
brother = this->child;
if (super->contactFlags != 0x80 && super->contactFlags != 0x81) {
if (super->type == 1) {
if (super->action < 7 && super->knockbackDuration != 0) {
brother = super->child;
if (brother != NULL) {
brother->parent = this->parent;
brother->parent = super->parent;
do {
brother->action = 5;
brother->spritePriority.b1 = 1;
@@ -90,469 +106,469 @@ void AcroBandit_OnCollision(Entity* this) {
brother->iframes = -12;
} while (brother = brother->child, brother != NULL);
}
if (this->parent != NULL) {
this->parent->child = this->child;
if (super->parent != NULL) {
super->parent->child = super->child;
} else {
if (this->child != NULL)
this->parent = this;
if (super->child != NULL)
super->parent = super;
}
this->action = 9;
this->spritePriority.b1 = 1;
if (this->knockbackDirection < 0x10) {
this->spriteSettings.flipX = 0;
super->action = 9;
super->spritePriority.b1 = 1;
if (super->knockbackDirection < 0x10) {
super->spriteSettings.flipX = 0;
} else {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
}
InitializeAnimation(this, 14);
InitializeAnimation(super, 14);
}
if (this->health == 0) {
this->knockbackDirection = DirectionNormalize((this->knockbackDirection + (7 & Random())) - 4);
this->knockbackDuration += this->type2 * 3;
if (super->health == 0) {
super->knockbackDirection = DirectionNormalize((super->knockbackDirection + (7 & Random())) - 4);
super->knockbackDuration += super->type2 * 3;
sub_08032338(this);
}
}
if (this->knockbackDuration != 0 && this->frame & 0x10) {
if (this->type == 0) {
this->action = 8;
if (super->knockbackDuration != 0 && super->frame & 0x10) {
if (super->type == 0) {
super->action = 8;
} else {
this->action = 9;
super->action = 9;
}
if (this->knockbackDirection < 0x10) {
this->spriteSettings.flipX = 0;
if (super->knockbackDirection < 0x10) {
super->spriteSettings.flipX = 0;
} else {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
}
this->spritePriority.b1 = 1;
InitializeAnimation(this, 14);
super->spritePriority.b1 = 1;
InitializeAnimation(super, 14);
}
}
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, AcroBandit_Functions);
EnemyFunctionHandlerAfterCollision(super, AcroBandit_Functions);
}
void AcroBandit_OnKnockback(Entity* this) {
if (this->iframes > 0)
GravityUpdate(this, Q_8_8(24.0));
void AcroBandit_OnKnockback(AcroBanditEntity* this) {
if (super->iframes > 0)
GravityUpdate(super, Q_8_8(24.0));
GenericKnockback(this);
GenericKnockback(super);
}
void AcroBandit_OnGrabbed(Entity* this) {
void AcroBandit_OnGrabbed(AcroBanditEntity* this) {
}
void AcroBandit_Type0(Entity* this) {
static void (*const AcroBandit_Type0_Actions[])(Entity*) = {
void AcroBandit_Type0(AcroBanditEntity* this) {
static void (*const AcroBandit_Type0_Actions[])(AcroBanditEntity*) = {
AcroBandit_Type0Action0, AcroBandit_Type0Action1, AcroBandit_Type0Action2,
AcroBandit_Type0Action3, AcroBandit_Type0Action4, AcroBandit_Type0Action5,
AcroBandit_Type0Action6, AcroBandit_Type0Action7, AcroBandit_Type0Action8,
};
AcroBandit_Type0_Actions[this->action](this);
AcroBandit_Type0_Actions[super->action](this);
}
void AcroBandit_Type0Action0(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
this->field_0x78.HALF.HI = Random();
void AcroBandit_Type0Action0(AcroBanditEntity* this) {
sub_0804A720(super);
super->action = 1;
this->unk_74.HWORD = super->x.HALF.HI;
this->unk_76.HWORD = super->y.HALF.HI;
this->unk_79 = Random();
}
void AcroBandit_Type0Action1(Entity* this) {
void AcroBandit_Type0Action1(AcroBanditEntity* this) {
u32 rand;
s32 x;
s32 y;
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
} else {
if (sub_08049FDC(this, 1)) {
if (sub_08049FDC(super, 1)) {
rand = Random();
x = this->field_0x74.HWORD + ((s32)rand % 5) * 0x10 - 0x20;
y = this->field_0x76.HWORD + ((s32)(rand >> 4) % 5) * 0x10 - 0x20;
if (sub_080B1B18(x, y, this->collisionLayer) == 0) {
this->action = 2;
this->spriteSettings.draw = 1;
this->x.HALF.HI = x;
this->y.HALF.HI = y;
InitializeAnimation(this, 0);
x = this->unk_74.HWORD + ((s32)rand % 5) * 0x10 - 0x20;
y = this->unk_76.HWORD + ((s32)(rand >> 4) % 5) * 0x10 - 0x20;
if (sub_080B1B18(x, y, super->collisionLayer) == 0) {
super->action = 2;
super->spriteSettings.draw = 1;
super->x.HALF.HI = x;
super->y.HALF.HI = y;
InitializeAnimation(super, 0);
}
}
}
}
void AcroBandit_Type0Action2(Entity* this) {
void AcroBandit_Type0Action2(AcroBanditEntity* this) {
static const u8 timers[] = { 2, 2, 2, 3, 3, 3, 3, 4 };
GetNextFrame(this);
if (this->frame & 1) {
this->frame = 0;
COLLISION_ON(this);
GetNextFrame(super);
if (super->frame & 1) {
super->frame = 0;
COLLISION_ON(super);
} else {
if (this->frame & ANIM_DONE) {
this->action = 0x3;
this->timer = timers[Random() & 7];
InitializeAnimation(this, 1);
if (super->frame & ANIM_DONE) {
super->action = 0x3;
super->timer = timers[Random() & 7];
InitializeAnimation(super, 1);
}
}
}
void AcroBandit_Type0Action3(Entity* this) {
void AcroBandit_Type0Action3(AcroBanditEntity* this) {
if (sub_08031E04(this)) {
this->action = 5;
if (this->x.HALF.HI > gUnk_020000B0->x.HALF.HI) {
this->spriteSettings.flipX = 0;
super->action = 5;
if (super->x.HALF.HI > gUnk_020000B0->x.HALF.HI) {
super->spriteSettings.flipX = 0;
} else {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
}
InitializeAnimation(this, 3);
InitializeAnimation(super, 3);
} else {
if ((this->frame & 1) && this->timer) {
this->frame &= 0xfe;
this->timer--;
if ((super->frame & 1) && super->timer) {
super->frame &= 0xfe;
super->timer--;
}
GetNextFrame(this);
if (this->timer == 0) {
this->action = 4;
COLLISION_OFF(this);
InitializeAnimation(this, 2);
GetNextFrame(super);
if (super->timer == 0) {
super->action = 4;
COLLISION_OFF(super);
InitializeAnimation(super, 2);
}
}
}
void AcroBandit_Type0Action4(Entity* this) {
void AcroBandit_Type0Action4(AcroBanditEntity* this) {
static const u8 timers[] = { 60, 60, 90, 120, 120, 120, 120, 150 };
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = timers[Random() & 7];
this->spriteSettings.draw = 0;
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = timers[Random() & 7];
super->spriteSettings.draw = 0;
}
}
void AcroBandit_Type0Action5(Entity* this) {
Entity *a, *b;
void AcroBandit_Type0Action5(AcroBanditEntity* this) {
AcroBanditEntity *a, *b;
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
if (gEntCount < MAX_ENTITIES - 4) {
u32 tmp = Random();
tmp &= 3;
a = CreateEnemy(ACRO_BANDIT, 1);
a->type2 = 0;
a->parent = NULL;
a->field_0x74.HALF.LO = tmp;
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->child = CreateEnemy(ACRO_BANDIT, 1);
a->base.child = CreateEnemy(ACRO_BANDIT, 1);
b = a->child;
b->type2 = 1;
b->parent = a;
b->field_0x74.HALF.LO = tmp;
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->child = CreateEnemy(ACRO_BANDIT, 1);
b->base.child = CreateEnemy(ACRO_BANDIT, 1);
a = b->child;
a->type2 = 2;
a->parent = b;
a->field_0x74.HALF.LO = tmp;
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->child = CreateEnemy(ACRO_BANDIT, 1);
a->base.child = CreateEnemy(ACRO_BANDIT, 1);
b = a->child;
b->type2 = 3;
b->parent = a;
b->field_0x74.HALF.LO = tmp;
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->child = CreateEnemy(ACRO_BANDIT, 1);
b->base.child = CreateEnemy(ACRO_BANDIT, 1);
a = b->child;
a->type2 = 4;
a->parent = b;
a->child = NULL;
a->field_0x74.HALF.LO = tmp;
a = (AcroBanditEntity*) b->base.child;
a->base.type2 = 4;
a->base.parent = &b->base;
a->base.child = NULL;
a->unk_74.HALF.LO = tmp;
sub_08031E48(this, a);
this->action = 6;
this->timer = 20;
this->spritePriority.b0 = 7;
InitializeAnimation(this, 7);
super->action = 6;
super->timer = 20;
super->spritePriority.b0 = 7;
InitializeAnimation(super, 7);
}
} else {
if (this->frame & 1) {
this->frame = 0;
COLLISION_OFF(this);
if (super->frame & 1) {
super->frame = 0;
COLLISION_OFF(super);
}
}
}
void AcroBandit_Type0Action6(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 7;
COLLISION_OFF(this);
this->timer = 5;
this->spriteSettings.draw = 0;
void AcroBandit_Type0Action6(AcroBanditEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 7;
COLLISION_OFF(super);
super->timer = 5;
super->spriteSettings.draw = 0;
}
}
void AcroBandit_Type0Action7(Entity* this) {
if ((this->timer & 0xF) == 0) {
if (this->timer == 80) {
DeleteEntity(this);
void AcroBandit_Type0Action7(AcroBanditEntity* this) {
if ((super->timer & 0xF) == 0) {
if (super->timer == 80) {
DeleteEntity(super);
} else {
this->action = 1;
this->timer = 180;
super->action = 1;
super->timer = 180;
}
}
}
void AcroBandit_Type0Action8(Entity* this) {
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = 180;
this->spriteSettings.draw = 0;
void AcroBandit_Type0Action8(AcroBanditEntity* this) {
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = 180;
super->spriteSettings.draw = 0;
} else {
GetNextFrame(this);
if ((this->frame & 0xf) == 2) {
COLLISION_OFF(this);
GetNextFrame(super);
if ((super->frame & 0xf) == 2) {
COLLISION_OFF(super);
}
}
}
static bool32 sub_08031E04(Entity* this) {
static bool32 sub_08031E04(AcroBanditEntity* this) {
static const s8 gUnk_080CE5C0[] = { -32, 0, 0, 32, 32, 0, 0, 0 };
Entity* ent;
Entity* entity;
const s8* tmp;
ent = sub_08049DF4(1);
if (ent == NULL)
entity = sub_08049DF4(1);
if (entity == NULL)
return FALSE;
tmp = &gUnk_080CE5C0[this->frame & 6];
return EntityWithinDistance(this, ent->x.HALF.HI + tmp[0], ent->y.HALF.HI + tmp[1], 0x50);
tmp = &gUnk_080CE5C0[super->frame & 6];
return EntityWithinDistance(super, entity->x.HALF.HI + tmp[0], entity->y.HALF.HI + tmp[1], 0x50);
}
static void sub_08031E48(Entity* this, Entity* child) {
CopyPosition(this, child);
child->field_0x6c.HALF.LO = this->field_0x6c.HALF.LO;
child->field_0x70.HALF.LO = this->field_0x70.HALF.LO;
child->field_0x70.HALF.HI = this->field_0x70.HALF.HI;
child->field_0x6e.HALF.LO = this->field_0x6e.HALF.LO;
child->field_0x6e.HALF.HI = this->field_0x6e.HALF.HI;
child->field_0x7c.WORD = (s32)this;
static void sub_08031E48(AcroBanditEntity* this, AcroBanditEntity* child) {
CopyPosition(super, &child->base);
child->unk_6c = this->unk_6c;
child->unk_70 = this->unk_70;
child->unk_72 = this->unk_72;
child->unk_6e = this->unk_6e;
child->unk_6f = this->unk_6f;
child->unk_7c = super;
}
void AcroBandit_Type1(Entity* this) {
static void (*const AcroBandit_Type1_Actions[])(Entity*) = {
void AcroBandit_Type1(AcroBanditEntity* this) {
static void (*const AcroBandit_Type1_Actions[])(AcroBanditEntity*) = {
AcroBandit_Type1Init, AcroBandit_Type1Action1, AcroBandit_Type1Action2, AcroBandit_Type1Action3,
AcroBandit_Type1Action4, AcroBandit_Type1Action5, AcroBandit_Type1Action6, AcroBandit_Type1Action7,
AcroBandit_Type1Action8, AcroBandit_Type1Action9,
};
AcroBandit_Type1_Actions[this->action](this);
AcroBandit_Type1_Actions[super->action](this);
}
void AcroBandit_Type1Init(Entity* this) {
this->action = 1;
this->spritePriority.b1 = 1;
this->zVelocity = Q_16_16(4.0);
this->z.HALF.HI = (4 - this->type2) * 0xe;
this->field_0x78.HALF.HI = Random();
InitializeAnimation(this, 4);
void AcroBandit_Type1Init(AcroBanditEntity* this) {
super->action = 1;
super->spritePriority.b1 = 1;
super->zVelocity = Q_16_16(4.0);
super->z.HALF.HI = (4 - super->type2) * 0xe;
this->unk_79 = Random();
InitializeAnimation(super, 4);
}
void AcroBandit_Type1Action1(Entity* this) {
void AcroBandit_Type1Action1(AcroBanditEntity* this) {
int draw;
this->z.WORD -= this->zVelocity;
this->zVelocity -= Q_16_16(3.0 / 32.0);
super->z.WORD -= super->zVelocity;
super->zVelocity -= Q_16_16(3.0 / 32.0);
if (this->z.HALF.HI < 1) {
draw = this->spriteSettings.draw;
if (super->z.HALF.HI < 1) {
draw = super->spriteSettings.draw;
if (!draw)
EnqueueSFX(SFX_12B);
this->spriteSettings.draw = 1;
super->spriteSettings.draw = 1;
}
draw = this->spriteSettings.draw;
draw = super->spriteSettings.draw;
if (draw == 1)
GetNextFrame(this);
GetNextFrame(super);
if (this->zVelocity <= 0) {
this->action = 2;
COLLISION_ON(this);
InitializeAnimation(this, 5);
if (super->zVelocity <= 0) {
super->action = 2;
COLLISION_ON(super);
InitializeAnimation(super, 5);
}
}
void AcroBandit_Type1Action2(Entity* this) {
void AcroBandit_Type1Action2(AcroBanditEntity* this) {
static const u16 banditGravity[] = { Q_8_8(22.0), Q_8_8(19.0), Q_8_8(16.0), Q_8_8(13.0), Q_8_8(11.0) };
GravityUpdate(this, banditGravity[this->type2]);
if (this->type2 * -0xe <= this->z.HALF.HI) {
this->action = 3;
this->timer = 20;
this->z.HALF.HI = this->type2 * -0xe;
if (this->parent != NULL)
this->spritePriority.b1 = 0;
InitializeAnimation(this, 6);
GravityUpdate(super, banditGravity[super->type2]);
if (super->type2 * -0xe <= super->z.HALF.HI) {
super->action = 3;
super->timer = 20;
super->z.HALF.HI = super->type2 * -0xe;
if (super->parent != NULL)
super->spritePriority.b1 = 0;
InitializeAnimation(super, 6);
}
}
void AcroBandit_Type1Action3(Entity* this) {
GetNextFrame(this);
if ((this->frame & ANIM_DONE) && ((this->parent != NULL) || (--this->timer == 0))) {
this->action = 4;
this->direction = sub_08049F84(this, 1);
*(u8*)&this->field_0x76 = 0;
if (this->child != NULL) {
InitializeAnimation(this, 9);
void AcroBandit_Type1Action3(AcroBanditEntity* this) {
GetNextFrame(super);
if ((super->frame & ANIM_DONE) && ((super->parent != NULL) || (--super->timer == 0))) {
super->action = 4;
super->direction = sub_08049F84(super, 1);
this->unk_76.HALF.LO = 0;
if (super->child != NULL) {
InitializeAnimation(super, 9);
} else {
InitializeAnimation(this, 8);
InitializeAnimation(super, 8);
}
}
}
void AcroBandit_Type1Action4(Entity* this) {
void AcroBandit_Type1Action4(AcroBanditEntity* this) {
Entity* parent;
if (!sub_080322A4(this)) {
parent = this->parent;
parent = super->parent;
if (parent == NULL) {
if (sub_08049FDC(this, 1)) {
if ((++this->field_0x78.HALF.HI & 7) == 0) {
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
if (sub_08049FDC(super, 1)) {
if ((++this->unk_79 & 7) == 0) {
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
}
this->field_0x76.HALF.LO = 0;
this->unk_76.HALF.LO = 0;
} else {
if (this->field_0x76.HALF.LO) {
(this->field_0x76.HALF.LO)--;
sub_08004596(this, this->field_0x7a.HALF.LO);
if (this->unk_76.HALF.LO) {
(this->unk_76.HALF.LO)--;
sub_08004596(super, this->unk_7a);
} else {
this->field_0x76.HALF.LO = 0x10;
if (sub_08049FA0(this) == 0 && (Random() & 1)) {
this->field_0x7a.HALF.LO = sub_08049EE4(this);
this->unk_76.HALF.LO = 0x10;
if (sub_08049FA0(super) == 0 && (Random() & 1)) {
this->unk_7a = sub_08049EE4(super);
} else {
this->field_0x7a.HALF.LO = Random() & 30;
this->unk_7a = Random() & 30;
}
}
}
if (this->direction & 0xf)
this->spriteSettings.flipX = (this->direction >> 4 ^ 1);
if (super->direction & 0xf)
super->spriteSettings.flipX = (super->direction >> 4 ^ 1);
ProcessMovement0(this);
ProcessMovement0(super);
} else {
if (this->field_0x76.HALF.HI == 0) {
if (EntityWithinDistance(this, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) {
this->field_0x76.HALF.HI = 1;
this->direction = GetFacingDirection(this, parent);
if (this->unk_76.HALF.HI == 0) {
if (EntityWithinDistance(super, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) {
this->unk_76.HALF.HI = 1;
super->direction = GetFacingDirection(super, parent);
sub_080322E8(this);
LinearMoveUpdate(this);
LinearMoveUpdate(super);
}
} else {
this->direction = GetFacingDirection(this, parent);
super->direction = GetFacingDirection(super, parent);
sub_080322E8(this);
LinearMoveUpdate(this);
if (this->x.HALF.HI == parent->x.HALF.HI && this->y.HALF.HI == parent->y.HALF.HI)
this->field_0x76.HALF.HI = 0;
LinearMoveUpdate(super);
if (super->x.HALF.HI == parent->x.HALF.HI && super->y.HALF.HI == parent->y.HALF.HI)
this->unk_76.HALF.HI = 0;
}
}
GetNextFrame(this);
GetNextFrame(super);
}
}
void AcroBandit_Type1Action5(Entity* this) {
if (GravityUpdate(this, Q_8_8(32.0)))
void AcroBandit_Type1Action5(AcroBanditEntity* this) {
if (GravityUpdate(super, Q_8_8(32.0)))
return;
sub_08032290(this);
}
void AcroBandit_Type1Action6(Entity* this) {
void AcroBandit_Type1Action6(AcroBanditEntity* this) {
static const u8 fallDirections[] = { 0x8, 0x1c, 0x11, 0x2, 0x15, 0xc, 0x0, 0x15, 0x6, 0x19,
0x10, 0x4, 0x19, 0xa, 0x1d, 0x14, 0x8, 0x1d, 0xe, 0x1 };
Entity* tmp;
u32 dir;
if (this->timer == 0) {
this->action = 7;
dir = fallDirections[this->field_0x74.HALF.LO * 5 + this->type2];
this->direction = dir;
if (super->timer == 0) {
super->action = 7;
dir = fallDirections[this->unk_74.HALF.LO * 5 + super->type2];
super->direction = dir;
if (dir >= 0x10) {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
} else {
this->spriteSettings.flipX = 0;
super->spriteSettings.flipX = 0;
}
this->speed = 0xf0;
this->zVelocity = Q_16_16(1.125);
this->spritePriority.b1 = 1;
InitializeAnimation(this, 12);
super->speed = 0xf0;
super->zVelocity = Q_16_16(1.125);
super->spritePriority.b1 = 1;
InitializeAnimation(super, 12);
}
if (this->child == NULL) {
for (tmp = this->parent; tmp != NULL; tmp = tmp->parent) {
if (super->child == NULL) {
for (tmp = super->parent; tmp != NULL; tmp = tmp->parent) {
if (tmp->health != 0)
tmp->timer = 0;
}
this->timer = 0;
super->timer = 0;
}
}
void AcroBandit_Type1Action7(Entity* this) {
ProcessMovement2(this);
void AcroBandit_Type1Action7(AcroBanditEntity* this) {
ProcessMovement2(super);
if (sub_080044EC(this, 0x2000) == 0)
this->action = 8;
if (sub_080044EC(super, 0x2000) == 0)
super->action = 8;
}
void AcroBandit_Type1Action8(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
this->frame = 0;
this->frameDuration = (Random() & 0x30) + 30;
void AcroBandit_Type1Action8(AcroBanditEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
super->frame = 0;
super->frameDuration = (Random() & 0x30) + 30;
} else {
if (this->frame & ANIM_DONE) {
this->action = 9;
InitializeAnimation(this, 13);
if (super->frame & ANIM_DONE) {
super->action = 9;
InitializeAnimation(super, 13);
}
}
}
void AcroBandit_Type1Action9(Entity* this) {
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
if (this->frame & ANIM_DONE) {
((Entity*)this->field_0x7c.WORD)->timer--;
void AcroBandit_Type1Action9(AcroBanditEntity* this) {
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
if (super->frame & ANIM_DONE) {
this->unk_7c->timer--;
DeleteEntity(this);
DeleteEntity(super);
} else {
GetNextFrame(this);
GetNextFrame(super);
if ((this->frame & 0xf) == 2)
COLLISION_OFF(this);
if ((super->frame & 0xf) == 2)
COLLISION_OFF(super);
}
}
}
static void sub_08032290(Entity* this) {
this->action = 6;
this->timer = 12;
InitializeAnimation(this, 11);
static void sub_08032290(AcroBanditEntity* this) {
super->action = 6;
super->timer = 12;
InitializeAnimation(super, 11);
}
static bool32 sub_080322A4(Entity* this) {
if (this->child != NULL && (this->child->z.HALF.HI + 8) >= this->z.HALF.HI) {
if (this->z.HALF.HI) {
this->action = 5;
this->z.HALF.HI = this->child->z.HALF.HI + 8;
InitializeAnimation(this, 11);
static bool32 sub_080322A4(AcroBanditEntity* this) {
if (super->child != NULL && (super->child->z.HALF.HI + 8) >= super->z.HALF.HI) {
if (super->z.HALF.HI) {
super->action = 5;
super->z.HALF.HI = super->child->z.HALF.HI + 8;
InitializeAnimation(super, 11);
return TRUE;
} else {
sub_08032290(this);
@@ -562,25 +578,25 @@ static bool32 sub_080322A4(Entity* this) {
return FALSE;
}
static void sub_080322E8(Entity* this) {
if (this->field_0x78.HALF.LO) {
if (--this->field_0x78.HALF.LO == 0) {
u32 flipX = this->spriteSettings.flipX;
this->spriteSettings.flipX = flipX ^ 1;
static void sub_080322E8(AcroBanditEntity* this) {
if (this->unk_78) {
if (--this->unk_78 == 0) {
u32 flipX = super->spriteSettings.flipX;
super->spriteSettings.flipX = flipX ^ 1;
}
} else {
u8 tmp = this->direction;
u8 tmp = super->direction;
if (tmp & 0xF) {
tmp >>= 4;
tmp ^= 1;
if (tmp != this->spriteSettings.flipX) {
this->field_0x78.HALF.LO = 6;
if (tmp != super->spriteSettings.flipX) {
this->unk_78 = 6;
}
}
}
}
static void sub_08032338(Entity* this) {
if ((((Entity*)this->field_0x7c.WORD)->timer += 15) != 80)
this->field_0x6c.HALF.LO = 0;
static void sub_08032338(AcroBanditEntity* this) {
if ((this->unk_7c->timer += 15) != 80)
this->unk_6c = 0;
}
+3 -5
View File
@@ -4,15 +4,13 @@
*
* @brief Armos enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "collision.h"
#include "common.h"
#include "enemy.h"
#include "flags.h"
#include "functions.h"
#include "hitbox.h"
#include "common.h"
#include "flags.h"
#include "collision.h"
typedef struct {
/*0x00*/ Entity base;
+12 -6
View File
@@ -1,6 +1,12 @@
/**
* @file ballChainSoldier.c
* @ingroup Enemies
*
* @brief Ball Chain Soldier enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -57,14 +63,14 @@ void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) {
}
void BallChainSoldier_Init(BallChainSoldierEntity* this) {
Entity* ent;
Entity* entity;
sub_0804A720(super);
ent = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
if (ent == NULL)
entity = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
if (entity == NULL)
return;
ent->parent = super;
super->child = ent;
entity->parent = super;
super->child = entity;
COLLISION_ON(super);
super->spriteSettings.draw = 1;
super->animationState = Random() & 3;
+187 -180
View File
@@ -4,44 +4,51 @@
*
* @brief Beetle enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
u32 sub_08021D00(Entity*);
void sub_08021D44(Entity* this, u32 direction);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[30];
/*0x86*/ u8 unk_86;
/*0x87*/ u8 unk_87;
} BeetleEntity;
extern void (*const Beetle_Functions[])(Entity*);
extern void (*const gUnk_080CB5A8[])(Entity*);
extern void (*const gUnk_080CB5C8[])(Entity*);
extern void (*const gUnk_080CB5D4[])(Entity*);
u32 sub_08021D00(BeetleEntity*);
void sub_08021D44(BeetleEntity* this, u32 direction);
extern void (*const Beetle_Functions[])(BeetleEntity*);
extern void (*const gUnk_080CB5A8[])(BeetleEntity*);
extern void (*const gUnk_080CB5C8[])(BeetleEntity*);
extern void (*const gUnk_080CB5D4[])(BeetleEntity*);
extern const s8 gUnk_080CB5DC[];
extern const s8 gUnk_080CB5E4[];
void Beetle(Entity* this) {
EnemyFunctionHandler(this, Beetle_Functions);
void Beetle(BeetleEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Beetle_Functions);
}
void Beetle_OnTick(Entity* this) {
gUnk_080CB5A8[this->action](this);
void Beetle_OnTick(BeetleEntity* this) {
gUnk_080CB5A8[super->action](this);
}
void Beetle_OnCollision(Entity* this) {
switch (this->contactFlags) {
void Beetle_OnCollision(BeetleEntity* this) {
switch (super->contactFlags) {
case 0x80:
if (gPlayerState.framestate == PL_STATE_CLIMB) {
Beetle_OnTick(this);
} else {
this->action = 5;
this->timer = 180;
this->subtimer = 0;
COLLISION_OFF(this);
this->spritePriority.b0 = 3;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->z.HALF.HI = -1;
((u8*)&this->field_0x86)[1] = 1;
InitializeAnimation(this, 6);
super->action = 5;
super->timer = 180;
super->subtimer = 0;
COLLISION_OFF(super);
super->spritePriority.b0 = 3;
CopyPositionAndSpriteOffset(&gPlayerEntity, super);
super->z.HALF.HI = -1;
this->unk_87 = 1;
InitializeAnimation(super, 6);
}
break;
case 0x93:
@@ -49,288 +56,288 @@ void Beetle_OnCollision(Entity* this) {
break;
}
if (this->health == 0)
this->knockbackDuration = 0;
if (super->health == 0)
super->knockbackDuration = 0;
EnemyFunctionHandlerAfterCollision(this, Beetle_Functions);
EnemyFunctionHandlerAfterCollision(super, Beetle_Functions);
}
void Beetle_OnDeath(Entity* this) {
if (this->type == 0) {
GenericDeath(this);
void Beetle_OnDeath(BeetleEntity* this) {
if (super->type == 0) {
GenericDeath(super);
} else {
Entity* ent = this->parent;
if (ent != NULL) {
ent->subtimer--;
this->parent = NULL;
Entity* entity = super->parent;
if (entity != NULL) {
entity->subtimer--;
super->parent = NULL;
}
CreateDeathFx(this, 0xf0, 0);
CreateDeathFx(super, 0xf0, 0);
}
}
void Beetle_OnGrabbed(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080CB5C8[this->subAction](this);
void Beetle_OnGrabbed(BeetleEntity* this) {
if (sub_0806F520(super)) {
gUnk_080CB5C8[super->subAction](this);
} else {
this->action = 3;
this->z.HALF.HI = 0;
InitializeAnimation(this, 2);
super->action = 3;
super->z.HALF.HI = 0;
InitializeAnimation(super, 2);
}
}
void sub_0802187C(Entity* this) {
this->subAction = 2;
void sub_0802187C(BeetleEntity* this) {
super->subAction = 2;
}
void nullsub_130(Entity* this) {
void nullsub_130(BeetleEntity* this) {
}
void sub_08021888(Entity* this) {
if (sub_0806F3E4(this))
void sub_08021888(BeetleEntity* this) {
if (sub_0806F3E4(super))
Beetle_OnDeath(this);
}
void Beetle_Initialize(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->gustJarFlags = 1;
InitializeAnimation(this, 3);
void Beetle_Initialize(BeetleEntity* this) {
sub_0804A720(super);
super->action = 1;
super->gustJarFlags = 1;
InitializeAnimation(super, 3);
}
void sub_080218B4(Entity* this) {
gUnk_080CB5D4[this->type2](this);
void sub_080218B4(BeetleEntity* this) {
gUnk_080CB5D4[super->type2](this);
}
void sub_080218CC(Entity* this) {
if (this->subAction == 0) {
this->subAction = 1;
this->spriteSettings.draw = 1;
this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
this->speed = 0x100;
this->zVelocity = Q_16_16(1.125);
void sub_080218CC(BeetleEntity* this) {
if (super->subAction == 0) {
super->subAction = 1;
super->spriteSettings.draw = 1;
super->direction = ((sub_08049F84(super, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
super->speed = 0x100;
super->zVelocity = Q_16_16(1.125);
}
GetNextFrame(this);
if (this->frame & 1) {
ProcessMovement2(this);
if (sub_080044EC(this, 0x1c00) == 0)
this->frameDuration = 1;
GetNextFrame(super);
if (super->frame & 1) {
ProcessMovement2(super);
if (sub_080044EC(super, 0x1c00) == 0)
super->frameDuration = 1;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = (Random() & 0x38) + 8;
this->subtimer = 1;
COLLISION_ON(this);
this->speed = 0x180;
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = (Random() & 0x38) + 8;
super->subtimer = 1;
COLLISION_ON(super);
super->speed = 0x180;
InitializeAnimation(super, 0);
}
}
void sub_08021984(Entity* this) {
if (this->subAction == 0) {
this->subAction = 1;
COLLISION_ON(this);
this->spriteSettings.draw = 3;
this->z.HALF.HI = -0x80;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
void sub_08021984(BeetleEntity* this) {
if (super->subAction == 0) {
super->subAction = 1;
COLLISION_ON(super);
super->spriteSettings.draw = 3;
super->z.HALF.HI = -0x80;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
EnqueueSFX(SFX_12D);
}
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 2;
this->timer = 16;
this->subtimer = 1;
this->spriteSettings.draw = 1;
this->speed = 0x180;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
super->action = 2;
super->timer = 16;
super->subtimer = 1;
super->spriteSettings.draw = 1;
super->speed = 0x180;
this->unk_86 = 60;
InitializeAnimation(super, 0);
UpdateSpriteForCollisionLayer(super);
}
}
void sub_08021A10(Entity* this) {
GetNextFrame(this);
if (EntityInRectRadius(this, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) {
if (--this->timer == 0) {
this->action = 3;
this->timer = (Random() & 0x3f) + 30;
sub_08021D44(this, this->direction);
InitializeAnimation(this, 2);
void sub_08021A10(BeetleEntity* this) {
GetNextFrame(super);
if (EntityInRectRadius(super, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) {
if (--super->timer == 0) {
super->action = 3;
super->timer = (Random() & 0x3f) + 30;
sub_08021D44(this, super->direction);
InitializeAnimation(super, 2);
}
}
}
void sub_08021A64(Entity* this) {
void sub_08021A64(BeetleEntity* this) {
if (!sub_08021D00(this)) {
if (--this->timer == 0) {
this->action = 2;
this->timer = (Random() & 0x1F) + 30;
InitializeAnimation(this, 0);
if (--super->timer == 0) {
super->action = 2;
super->timer = (Random() & 0x1F) + 30;
InitializeAnimation(super, 0);
}
if (--this->subtimer == 0) {
if (--super->subtimer == 0) {
u32 tmp;
this->subtimer = 8;
tmp = sub_08049F84(this, 1);
super->subtimer = 8;
tmp = sub_08049F84(super, 1);
if (tmp == 0xff) {
this->action = 7;
InitializeAnimation(this, 1);
super->action = 7;
InitializeAnimation(super, 1);
return;
}
sub_08021D44(this, tmp);
}
ProcessMovement0(this);
GetNextFrame(this);
ProcessMovement0(super);
GetNextFrame(super);
}
}
void sub_08021AD8(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
if (this->timer != 0) {
void sub_08021AD8(BeetleEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
if (super->timer != 0) {
u32 tmp;
this->timer = 0;
tmp = sub_08049F84(this, 1);
super->timer = 0;
tmp = sub_08049F84(super, 1);
if (tmp == 0xff) {
this->action = 2;
this->timer = 8;
InitializeAnimation(this, 0);
super->action = 2;
super->timer = 8;
InitializeAnimation(super, 0);
return;
}
this->direction = (u8)tmp;
super->direction = (u8)tmp;
EnqueueSFX(SFX_PLY_JUMP);
}
ProcessMovement2(this);
if (!GravityUpdate(this, Q_8_8(24.0)))
this->frameDuration = 1;
ProcessMovement2(super);
if (!GravityUpdate(super, Q_8_8(24.0)))
super->frameDuration = 1;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = 20;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = 20;
this->unk_86 = 60;
InitializeAnimation(super, 0);
}
}
void sub_08021B64(Entity* this) {
void sub_08021B64(BeetleEntity* this) {
if (gPlayerState.flags & PL_DROWNING) {
this->action = 3;
this->z.WORD = 0;
InitializeAnimation(this, 2);
super->action = 3;
super->z.WORD = 0;
InitializeAnimation(super, 2);
} else {
s32 iVar4 = 1;
if (gPlayerState.framestate != PL_STATE_JUMP && gPlayerState.framestate != PL_STATE_CAPE) {
if (sub_0807953C())
iVar4 = this->type * 3 + 8;
iVar4 = super->type * 3 + 8;
iVar4 = this->timer - iVar4;
iVar4 = super->timer - iVar4;
if (iVar4 < 0)
iVar4 = 0;
this->timer = (u8)iVar4;
super->timer = (u8)iVar4;
}
if (gPlayerState.flags & (PL_DISABLE_ITEMS | PL_CAPTURED))
iVar4 = 0;
if (iVar4 == 0) {
this->action = 6;
this->zVelocity = Q_16_16(1.0);
((u8*)&this->field_0x86)[1] = 0;
super->action = 6;
super->zVelocity = Q_16_16(1.0);
this->unk_87 = 0;
if (gPlayerEntity.direction != 0xff) {
this->direction = 0x10 ^ gPlayerEntity.direction;
super->direction = 0x10 ^ gPlayerEntity.direction;
} else {
this->direction = (gPlayerEntity.animationState << 2) ^ 0x10;
super->direction = (gPlayerEntity.animationState << 2) ^ 0x10;
}
InitializeAnimation(this, 5);
InitializeAnimation(super, 5);
} else {
gPlayerState.mobility |= 0x80;
gPlayerState.speed_modifier -= 0x50;
gPlayerState.attachedBeetleCount++;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->x.HALF.HI += gUnk_080CB5E4[(this->subtimer++ & 0xe) >> 1];
this->z.HALF.HI--;
GetNextFrame(this);
CopyPositionAndSpriteOffset(&gPlayerEntity, super);
super->x.HALF.HI += gUnk_080CB5E4[(super->subtimer++ & 0xe) >> 1];
super->z.HALF.HI--;
GetNextFrame(super);
}
}
}
void sub_08021C58(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
ProcessMovement2(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0)
this->frameDuration = 1;
void sub_08021C58(BeetleEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
ProcessMovement2(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0)
super->frameDuration = 1;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = 60;
this->subtimer = 1;
COLLISION_ON(this);
this->spritePriority.b0 = 4;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = 60;
super->subtimer = 1;
COLLISION_ON(super);
super->spritePriority.b0 = 4;
this->unk_86 = 60;
InitializeAnimation(super, 0);
}
}
void sub_08021CD0(Entity* this) {
if ((this->frame & ANIM_DONE) == 0)
GetNextFrame(this);
void sub_08021CD0(BeetleEntity* this) {
if ((super->frame & ANIM_DONE) == 0)
GetNextFrame(super);
if (sub_08049F84(this, 1) == 0xff)
if (sub_08049F84(super, 1) == 0xff)
return;
this->action = 3;
InitializeAnimation(this, 2);
super->action = 3;
InitializeAnimation(super, 2);
}
u32 sub_08021D00(Entity* this) {
u32 sub_08021D00(BeetleEntity* this) {
u32 ret;
if (((u8*)&this->field_0x86)[0]) {
((u8*)&this->field_0x86)[0]--;
if (this->unk_86) {
this->unk_86--;
ret = 0;
} else if (PlayerInRange(this, 1, 0x10) == 0) {
} else if (PlayerInRange(super, 1, 0x10) == 0) {
ret = 0;
} else {
this->action = 4;
this->timer = 1;
this->zVelocity = Q_16_16(1.5);
InitializeAnimation(this, 4);
super->action = 4;
super->timer = 1;
super->zVelocity = Q_16_16(1.5);
InitializeAnimation(super, 4);
ret = 1;
}
return ret;
}
void sub_08021D44(Entity* this, u32 direction) {
void sub_08021D44(BeetleEntity* this, u32 direction) {
direction = DirectionRoundUp(direction);
this->direction = direction;
super->direction = direction;
if (DirectionIsHorizontal(direction)) {
this->speed = 0x180;
super->speed = 0x180;
} else {
this->speed = 0xc0;
super->speed = 0xc0;
}
}
// clang-format off
void (*const Beetle_Functions[])(Entity*) = {
void (*const Beetle_Functions[])(BeetleEntity*) = {
Beetle_OnTick,
Beetle_OnCollision,
GenericKnockback,
(void (*)(BeetleEntity*))GenericKnockback,
Beetle_OnDeath,
GenericConfused,
(void (*)(BeetleEntity*))GenericConfused,
Beetle_OnGrabbed,
};
void (*const gUnk_080CB5A8[])(Entity*) = {
void (*const gUnk_080CB5A8[])(BeetleEntity*) = {
Beetle_Initialize,
sub_080218B4,
sub_08021A10,
@@ -341,13 +348,13 @@ void (*const gUnk_080CB5A8[])(Entity*) = {
sub_08021CD0,
};
void (*const gUnk_080CB5C8[])(Entity*) = {
void (*const gUnk_080CB5C8[])(BeetleEntity*) = {
sub_0802187C,
nullsub_130,
sub_08021888,
};
void (*const gUnk_080CB5D4[])(Entity*) = {
void (*const gUnk_080CB5D4[])(BeetleEntity*) = {
sub_080218CC,
sub_08021984,
};
+19 -13
View File
@@ -4,26 +4,32 @@
*
* @brief Blade Trap enemy
*/
#include "sound.h"
#define NENT_DEPRECATED
#include "entity.h"
#include "room.h"
#include "object.h"
#include "room.h"
#include "sound.h"
void BladeTrap(Entity* this) {
if (this->action == 0) {
this->action = 1;
this->child = GetCurrentRoomProperty(this->type);
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
} BladeTrapEntity;
void BladeTrap(BladeTrapEntity* this) {
if (super->action == 0) {
super->action = 1;
super->child = GetCurrentRoomProperty(super->type);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
}
if (!(this->direction & 0x80)) {
LinearMoveUpdate(this);
if (!(super->direction & 0x80)) {
LinearMoveUpdate(super);
}
if (!(--this->field_0x74.HWORD)) {
if (!(this->direction & 0x80)) {
if (!(--this->unk_74)) {
if (!(super->direction & 0x80)) {
EnqueueSFX(SFX_METAL_CLINK);
}
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
}
}
+182 -173
View File
@@ -4,38 +4,47 @@
*
* @brief Bobomb enemy
*/
#define NENT_DEPRECATED
#include "asm.h"
#include "collision.h"
#include "sound.h"
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
#include "sound.h"
void sub_0802CB68(Entity*);
void sub_0802CBC4(Entity*);
void sub_0802CC18(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} BobombEntity;
extern void (*const Bobomb_Functions[])(Entity*);
extern void (*const gUnk_080CD5EC[])(Entity*);
extern void (*const gUnk_080CD600[])(Entity*);
extern void (*const gUnk_080CD618[])(Entity*);
void sub_0802CB68(BobombEntity* this);
void sub_0802CBC4(BobombEntity* this);
void sub_0802CC18(BobombEntity* this);
void Bobomb(Entity* this) {
EnemyFunctionHandler(this, Bobomb_Functions);
extern void (*const Bobomb_Functions[])(BobombEntity*);
extern void (*const gUnk_080CD5EC[])(BobombEntity*);
extern void (*const gUnk_080CD600[])(BobombEntity*);
extern void (*const gUnk_080CD618[])(BobombEntity*);
void Bobomb(BobombEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Bobomb_Functions);
}
void Bobomb_OnTick(Entity* this) {
gUnk_080CD5EC[this->action](this);
void Bobomb_OnTick(BobombEntity* this) {
gUnk_080CD5EC[super->action](this);
}
void Bobomb_OnCollision(Entity* this) {
if (this->contactFlags & 0x80) {
switch (this->contactFlags & 0x7f) {
void Bobomb_OnCollision(BobombEntity* this) {
if (super->contactFlags & 0x80) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
if (this->field_0x82.HALF.LO) {
this->knockbackDuration = 0;
if (this->unk_82) {
super->knockbackDuration = 0;
gPlayerEntity.knockbackDuration = 4;
}
return;
@@ -43,276 +52,276 @@ void Bobomb_OnCollision(Entity* this) {
case 0x14:
case 0x15:
case 0x16:
this->action = 3;
this->knockbackDuration = 0;
super->action = 3;
super->knockbackDuration = 0;
sub_0802CBC4(this);
return;
}
this->field_0x82.HALF.LO++;
this->field_0x80.HALF.LO = 28;
switch (this->field_0x82.HALF.LO) {
this->unk_82++;
this->unk_80 = 28;
switch (this->unk_82) {
case 1:
sub_0802CB68(this);
EnqueueSFX(SFX_14D);
break;
case 2:
this->action = 3;
this->hitType = 0x6e;
this->subtimer = 1;
this->zVelocity = Q_16_16(1.5);
this->speed = 0;
this->field_0x80.HALF.HI = 1;
InitializeAnimation(this, this->direction >> 4 | 6);
super->action = 3;
super->hitType = 0x6e;
super->subtimer = 1;
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_81 = 1;
InitializeAnimation(super, super->direction >> 4 | 6);
break;
}
}
EnemyFunctionHandlerAfterCollision(this, Bobomb_Functions);
EnemyFunctionHandlerAfterCollision(super, Bobomb_Functions);
}
void Bobomb_OnGrabbed(Entity* this) {
if (this->subAction < 3 && !sub_0806F520(this)) {
this->subAction = 0;
this->subtimer = 1;
this->z.HALF.HI = 0;
if (this->field_0x82.HALF.LO != 2) {
this->speed = this->field_0x82.HALF.LO ? 0x200 : 0x80;
void Bobomb_OnGrabbed(BobombEntity* this) {
if (super->subAction < 3 && !sub_0806F520(super)) {
super->subAction = 0;
super->subtimer = 1;
super->z.HALF.HI = 0;
if (this->unk_82 != 2) {
super->speed = this->unk_82 ? 0x200 : 0x80;
}
this->zVelocity = Q_16_16(1.5);
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
super->zVelocity = Q_16_16(1.5);
this->unk_83 = 0;
this->unk_81 = 0;
} else {
this->z.HALF.HI = -1;
gUnk_080CD600[this->subAction](this);
if (this->timer != 0) {
GetNextFrame(this);
super->z.HALF.HI = -1;
gUnk_080CD600[super->subAction](this);
if (super->timer != 0) {
GetNextFrame(super);
}
}
}
void sub_0802C820(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
void sub_0802C820(BobombEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_0802C82C(Entity* this) {
sub_0806F4E8(this);
void sub_0802C82C(BobombEntity* this) {
sub_0806F4E8(super);
}
void sub_0802C834(Entity* this) {
sub_0806F3E4(this);
void sub_0802C834(BobombEntity* this) {
sub_0806F3E4(super);
}
void sub_0802C83C(Entity* this) {
if (this->field_0x82.HALF.LO) {
if (--this->timer == 0) {
this->action = 3;
void sub_0802C83C(BobombEntity* this) {
if (this->unk_82) {
if (--super->timer == 0) {
super->action = 3;
switch (gPlayerEntity.animationState & 6) {
case 2:
this->x.HALF.HI -= 6;
super->x.HALF.HI -= 6;
break;
case 6:
this->x.HALF.HI += 6;
super->x.HALF.HI += 6;
break;
}
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
COLLISION_OFF(this);
this->hitType = 0x6e;
COLLISION_OFF(super);
super->hitType = 0x6e;
}
} else {
this->field_0x82.HALF.LO = 2;
this->timer = 120;
InitializeAnimation(this, (this->direction >> 4) | 6);
COLLISION_OFF(this);
this->hitType = 0x6e;
this->unk_82 = 2;
super->timer = 120;
InitializeAnimation(super, (super->direction >> 4) | 6);
COLLISION_OFF(super);
super->hitType = 0x6e;
}
}
void nullsub_149(Entity* this) {
void nullsub_149(BobombEntity* this) {
/* ... */
}
void sub_0802C8B8(Entity* this) {
this->action = 3;
void sub_0802C8B8(BobombEntity* this) {
super->action = 3;
sub_0802CBC4(this);
}
void Bobomb_OnDeath(Entity* this) {
GenericDeath(this);
this->spriteSettings.draw = 0;
void Bobomb_OnDeath(BobombEntity* this) {
GenericDeath(super);
super->spriteSettings.draw = 0;
}
void sub_0802C8D8(Entity* this) {
this->action = 1;
this->timer = 60;
this->subtimer = 0;
this->direction = (Random() & 0x18) | 4;
this->carryFlags = 0;
this->gustJarFlags = 0x12;
this->field_0x82.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->direction >> 4);
void sub_0802C8D8(BobombEntity* this) {
super->action = 1;
super->timer = 60;
super->subtimer = 0;
super->direction = (Random() & 0x18) | 4;
super->carryFlags = 0;
super->gustJarFlags = 0x12;
this->unk_82 = 0;
this->unk_83 = 0;
this->unk_80 = 0;
this->unk_81 = 0;
InitializeAnimation(super, super->direction >> 4);
}
void sub_0802C91C(Entity* this) {
GetNextFrame(this);
ProcessMovement0(this);
if (this->field_0x82.HALF.LO) {
if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
InitializeAnimation(this, (this->direction >> 4) | 2);
void sub_0802C91C(BobombEntity* this) {
GetNextFrame(super);
ProcessMovement0(super);
if (this->unk_82) {
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, (super->direction >> 4) | 2);
}
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
if ((this->timer & 0xf) == 8) {
CreateDustSmall(this);
if ((super->timer & 0xf) == 8) {
CreateDustSmall(super);
}
sub_0802CC18(this);
}
} else {
if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
InitializeAnimation(this, this->direction >> 4);
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, super->direction >> 4);
}
if (--this->timer == 0) {
this->timer = 60;
this->direction = (this->direction + 8) & 0x1c;
InitializeAnimation(this, this->direction >> 4);
if (--super->timer == 0) {
super->timer = 60;
super->direction = (super->direction + 8) & 0x1c;
InitializeAnimation(super, super->direction >> 4);
}
}
}
void sub_0802C9B8(Entity* this) {
gUnk_080CD618[this->subAction](this);
void sub_0802C9B8(BobombEntity* this) {
gUnk_080CD618[super->subAction](this);
}
void sub_0802C9D0(Entity* this) {
this->subAction = 1;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
this->field_0x82.HALF.HI = 1;
void sub_0802C9D0(BobombEntity* this) {
super->subAction = 1;
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
this->unk_83 = 1;
sub_0802CC18(this);
InitializeAnimation(this, (this->direction >> 4) | 6);
GetNextFrame(this);
InitializeAnimation(super, (super->direction >> 4) | 6);
GetNextFrame(super);
}
void sub_0802CA10(Entity* this) {
void sub_0802CA10(BobombEntity* this) {
if (gPlayerState.heldObject != 5) {
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(this);
GetNextFrame(super);
}
} else {
this->field_0x82.HALF.HI = 2;
this->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c;
this->unk_83 = 2;
super->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c;
sub_0802CC18(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_0802CA6C(Entity* this) {
if (--this->timer == 0) {
void sub_0802CA6C(BobombEntity* this) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_0802CA94(Entity* this) {
this->action = 3;
COLLISION_OFF(this);
this->subtimer = 1;
this->spritePriority.b1 = 1;
this->zVelocity = Q_16_16(1.5);
this->speed = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
this->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c;
InitializeAnimation(this, (this->direction >> 4) | 6);
void sub_0802CA94(BobombEntity* this) {
super->action = 3;
COLLISION_OFF(super);
super->subtimer = 1;
super->spritePriority.b1 = 1;
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_83 = 0;
this->unk_81 = 0;
super->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c;
InitializeAnimation(super, (super->direction >> 4) | 6);
}
void sub_0802CAF8(Entity* this) {
if (--this->timer == 0) {
void sub_0802CAF8(BobombEntity* this) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) {
if (this->unk_81 && sub_080044EC(super, 0x2800) == 1) {
EnqueueSFX(SFX_PLACE_OBJ);
}
sub_0802CC18(this);
RegisterCarryEntity(this);
if (this->subtimer && this->z.HALF.HI == 0) {
this->subtimer = 0;
COLLISION_ON(this);
this->hitType = 0x6e;
RegisterCarryEntity(super);
if (super->subtimer && super->z.HALF.HI == 0) {
super->subtimer = 0;
COLLISION_ON(super);
super->hitType = 0x6e;
}
GetNextFrame(this);
GetNextFrame(super);
}
}
void nullsub_150(Entity* this) {
void nullsub_150(BobombEntity* this) {
/* ... */
}
void sub_0802CB68(Entity* this) {
this->action = 1;
this->subAction = 0;
this->direction = Random() & 0x18;
this->direction |= 4;
COLLISION_ON(this);
if (this->field_0x82.HALF.LO) {
this->timer = 200;
this->speed = 0x200;
InitializeAnimation(this, (this->direction >> 4) | 2);
void sub_0802CB68(BobombEntity* this) {
super->action = 1;
super->subAction = 0;
super->direction = Random() & 0x18;
super->direction |= 4;
COLLISION_ON(super);
if (this->unk_82) {
super->timer = 200;
super->speed = 0x200;
InitializeAnimation(super, (super->direction >> 4) | 2);
} else {
this->timer = 60;
this->speed = 0x80;
InitializeAnimation(this, this->direction >> 4);
super->timer = 60;
super->speed = 0x80;
InitializeAnimation(super, super->direction >> 4);
}
}
void sub_0802CBC4(Entity* this) {
Entity* ent;
void sub_0802CBC4(BobombEntity* this) {
Entity* entity;
this->action = 4;
this->spriteSettings.draw = 0;
COLLISION_OFF(this);
this->health = 0;
if (this->field_0x82.HALF.HI) {
super->action = 4;
super->spriteSettings.draw = 0;
COLLISION_OFF(super);
super->health = 0;
if (this->unk_83) {
PlayerDropHeldObject();
}
FreeCarryEntity(this);
FreeCarryEntity(super);
ent = CreateObjectWithParent(this, SMOKE_PARTICLE, 0, 0);
if (ent != NULL) {
ent->collisionLayer = this->collisionLayer;
entity = CreateObjectWithParent(super, SMOKE_PARTICLE, 0, 0);
if (entity != NULL) {
entity->collisionLayer = super->collisionLayer;
}
}
void sub_0802CC18(Entity* this) {
if (--this->field_0x80.HALF.LO == 0) {
this->field_0x80.HALF.LO = 28;
void sub_0802CC18(BobombEntity* this) {
if (--this->unk_80 == 0) {
this->unk_80 = 28;
EnqueueSFX(SFX_14D);
}
}
// clang-format off
void (*const Bobomb_Functions[])(Entity*) = {
void (*const Bobomb_Functions[])(BobombEntity*) = {
Bobomb_OnTick,
Bobomb_OnCollision,
GenericKnockback,
(void (*)(BobombEntity*))GenericKnockback,
Bobomb_OnDeath,
GenericConfused,
(void (*)(BobombEntity*))GenericConfused,
Bobomb_OnGrabbed,
};
void (*const gUnk_080CD5EC[])(Entity*) = {
void (*const gUnk_080CD5EC[])(BobombEntity*) = {
sub_0802C8D8,
sub_0802C91C,
sub_0802C9B8,
@@ -320,7 +329,7 @@ void (*const gUnk_080CD5EC[])(Entity*) = {
nullsub_150,
};
void (*const gUnk_080CD600[])(Entity*) = {
void (*const gUnk_080CD600[])(BobombEntity*) = {
sub_0802C820,
sub_0802C82C,
sub_0802C834,
@@ -329,7 +338,7 @@ void (*const gUnk_080CD600[])(Entity*) = {
sub_0802C8B8,
};
void (*const gUnk_080CD618[])(Entity*) = {
void (*const gUnk_080CD618[])(BobombEntity*) = {
sub_0802C9D0,
sub_0802CA10,
sub_0802CA6C,
+414 -401
View File
File diff suppressed because it is too large Load Diff
+12 -6
View File
@@ -1,8 +1,14 @@
/**
* @file bombarossa.c
* @ingroup Enemies
*
* @brief Bombarossa enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "room.h"
#include "entity.h"
#include "object.h"
#include "room.h"
typedef struct {
Entity base;
@@ -39,12 +45,12 @@ void Bombarossa_OnTick(BombarossaEntity* this) {
}
void Bombarossa_OnCollision(BombarossaEntity* this) {
Entity* ent;
Entity* entity;
switch (super->contactFlags & 0x7f) {
default:
ent = CreateObject(SMOKE_PARTICLE, 0, 0);
if (ent != NULL) {
CopyPosition(super, ent);
entity = CreateObject(SMOKE_PARTICLE, 0, 0);
if (entity != NULL) {
CopyPosition(super, entity);
}
DeleteThisEntity();
case 1:
+6 -8
View File
@@ -4,11 +4,9 @@
*
* @brief Bow Moblin enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -270,16 +268,16 @@ void sub_0803C4B0(BowMoblinEntity* this) {
bool32 sub_0803C568(BowMoblinEntity* this) {
if (this->unk_0x81 == 0) {
Entity* ent = sub_08049DF4(1);
if (ent != NULL) {
Entity* entity = sub_08049DF4(1);
if (entity != NULL) {
if (this->unk_0x82 == 2) {
if (sub_0806FC80(super, ent, 0x30)) {
if (sub_0806FC80(super, entity, 0x30)) {
return TRUE;
}
}
if (sub_0806FC80(super, ent, 0x40)) {
u32 direction = (GetFacingDirection(super, ent) + 4) & 0x18;
if (sub_0806FC80(super, entity, 0x40)) {
u32 direction = (GetFacingDirection(super, entity) + 4) & 0x18;
direction = direction >> 2;
if (direction == super->animationState) {
return TRUE;
+245 -230
View File
@@ -4,35 +4,16 @@
*
* @brief Business Scrub enemy
*/
#define NENT_DEPRECATED
#include "asm.h"
#include "enemy.h"
#include "message.h"
#include "save.h"
#include "npc.h"
#include "functions.h"
#include "game.h"
#include "item.h"
#include "kinstone.h"
void sub_08028E9C(Entity*);
void sub_08028EDC(Entity*);
bool32 sub_08028F98(Entity*, u32);
bool32 sub_08028FDC(Entity*);
void sub_08028FFC(Entity*);
void sub_08029078(Entity*);
void sub_080290E0(Entity*, u32);
void sub_080290FC(Entity*);
bool32 sub_0802915C(Entity*);
bool32 BusinessScrub_CheckRefillFitsBag(Entity*);
void sub_0802922C(Entity*);
void sub_0802925C(Entity*);
extern const struct SalesOffering gUnk_080CC954[];
extern const u8 kinstoneTypes[];
extern void (*const BusinessScrub_Functions[])(Entity*);
extern void (*const BusinessScrub_Actions[])(Entity*);
extern const u8 gUnk_080CCA04[];
#include "message.h"
#include "npc.h"
#include "save.h"
struct SalesOffering {
u8 field_0x0;
@@ -45,131 +26,165 @@ struct SalesOffering {
u16 local_flag;
};
void BusinessScrub(Entity* this) {
EnemyFunctionHandler(this, BusinessScrub_Functions);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ const struct SalesOffering* unk_7c;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unused2[4];
/*0x86*/ u16 unk_86;
} BusinessScrubEntity;
void sub_08028E9C(BusinessScrubEntity*);
void sub_08028EDC(BusinessScrubEntity*);
bool32 sub_08028F98(BusinessScrubEntity*, u32);
bool32 sub_08028FDC(BusinessScrubEntity*);
void sub_08028FFC(BusinessScrubEntity*);
void sub_08029078(BusinessScrubEntity*);
void sub_080290E0(BusinessScrubEntity*, u32);
void sub_080290FC(BusinessScrubEntity*);
bool32 sub_0802915C(BusinessScrubEntity*);
bool32 BusinessScrub_CheckRefillFitsBag(BusinessScrubEntity*);
void sub_0802922C(BusinessScrubEntity*);
void sub_0802925C(BusinessScrubEntity*);
extern const struct SalesOffering gUnk_080CC954[];
extern const u8 kinstoneTypes[];
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);
}
void BusinessScrub_OnTick(Entity* this) {
BusinessScrub_Actions[this->action](this);
void BusinessScrub_OnTick(BusinessScrubEntity* this) {
BusinessScrub_Actions[super->action](this);
}
void BusinessScrub_OnCollision(Entity* this) {
Entity* pEVar1;
void BusinessScrub_OnCollision(BusinessScrubEntity* this) {
Entity* fx;
if (this->hitType == 1 && (this->contactFlags & 0x7f) == 0x42) {
this->action = 3;
this->subAction = 0;
this->timer = 40;
COLLISION_OFF(this);
if (super->hitType == 1 && (super->contactFlags & 0x7f) == 0x42) {
super->action = 3;
super->subAction = 0;
super->timer = 40;
COLLISION_OFF(super);
sub_080290E0(this, 4);
pEVar1 = CreateFx(this, FX_BUSH, 0);
if (pEVar1 != NULL) {
pEVar1->z.HALF.HI -= 8;
fx = CreateFx(super, FX_BUSH, 0);
if (fx != NULL) {
fx->z.HALF.HI -= 8;
}
EnqueueSFX(SFX_EM_DEKUSCRUB_HIT);
}
}
void BusinessScrub_OnGrabbed(Entity* this) {
void BusinessScrub_OnGrabbed(BusinessScrubEntity* this) {
/* ... */
}
void BusinessScrub_Action0(Entity* this) {
this->subtimer = 0;
this->field_0x78.HWORD = this->x.HALF.HI;
this->field_0x7a.HWORD = this->y.HALF.HI;
this->animationState = 0;
this->direction = 0x10;
void BusinessScrub_Action0(BusinessScrubEntity* this) {
super->subtimer = 0;
this->unk_78 = super->x.HALF.HI;
this->unk_7a = super->y.HALF.HI;
super->animationState = 0;
super->direction = 0x10;
sub_08028E9C(this);
if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) {
this->action = 4;
this->timer = 120;
this->spritePriority.b1 = 1;
if ((*(u8*)this->unk_7c & 1) || CheckFlags(this->unk_86)) {
super->action = 4;
super->timer = 120;
super->spritePriority.b1 = 1;
sub_0802925C(this);
sub_080290E0(this, 0);
} else {
this->timer = 0;
this->field_0x76.HWORD = COORD_TO_TILE(this);
this->field_0x74.HWORD = GetTileIndex(this->field_0x76.HWORD, this->collisionLayer);
this->hurtType = 0x41;
super->timer = 0;
this->unk_76 = COORD_TO_TILE(super);
this->unk_74 = GetTileIndex(this->unk_76, super->collisionLayer);
super->hurtType = 0x41;
sub_08028FFC(this);
}
}
void BusinessScrub_Action1(Entity* this) {
if (this->timer != 0) {
this->timer--;
void BusinessScrub_Action1(BusinessScrubEntity* this) {
if (super->timer != 0) {
super->timer--;
} else if (sub_08028F98(this, 0)) {
sub_08029078(this);
this->subAction = 0;
this->subtimer = 1;
super->subAction = 0;
super->subtimer = 1;
}
}
void BusinessScrub_Action2(Entity* this) {
void BusinessScrub_Action2(BusinessScrubEntity* this) {
u32 unk;
GetNextFrame(this);
switch (this->subAction) {
GetNextFrame(super);
switch (super->subAction) {
case 0:
unk = 1;
if (this->frame & ANIM_DONE) {
this->subAction = 1;
this->timer = 60;
this->subtimer = 16;
if (super->frame & ANIM_DONE) {
super->subAction = 1;
super->timer = 60;
super->subtimer = 16;
sub_08028FDC(this);
sub_080290E0(this, 1);
}
break;
case 1:
unk = 1;
if (--this->timer == 0) {
this->subAction = 2;
this->timer = 32;
this->subtimer = 0;
if (--super->timer == 0) {
super->subAction = 2;
super->timer = 32;
super->subtimer = 0;
sub_08028FDC(this);
sub_080290E0(this, 2);
} else if (--this->subtimer == 0) {
} else if (--super->subtimer == 0) {
if (sub_08028FDC(this)) {
sub_080290E0(this, 1);
}
this->subtimer = 16;
super->subtimer = 16;
}
break;
case 2:
unk = 1;
sub_080290FC(this);
if (this->frame & 1) {
Entity* ent = CreateProjectileWithParent(this, DEKU_SEED_PROJECTILE, 0);
if (ent != NULL) {
ent->parent = this;
ent->direction = this->direction;
this->frame &= ~1;
this->subAction = 3;
if (super->frame & 1) {
Entity* entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
if (entity != NULL) {
entity->parent = super;
entity->direction = super->direction;
super->frame &= ~1;
super->subAction = 3;
}
}
break;
case 3:
unk = 2;
if (this->frame & ANIM_DONE) {
this->subAction = 4;
this->timer = 80;
if (super->frame & ANIM_DONE) {
super->subAction = 4;
super->timer = 80;
sub_080290E0(this, 1);
}
break;
case 4:
unk = 2;
if (--this->timer == 0) {
if (--super->timer == 0) {
if (sub_08028F98(this, 0)) {
this->subAction = 1;
this->timer = 60;
this->subtimer = 16;
super->subAction = 1;
super->timer = 60;
super->subtimer = 16;
sub_08028FDC(this);
} else {
sub_08028FFC(this);
this->subAction = 0;
this->timer = 80;
this->subtimer = 0;
super->subAction = 0;
super->timer = 80;
super->subtimer = 0;
}
return;
}
@@ -178,73 +193,73 @@ void BusinessScrub_Action2(Entity* this) {
if (!sub_08028F98(this, unk)) {
sub_08028FFC(this);
this->subAction = 0;
this->timer = 80;
this->subtimer = 0;
super->subAction = 0;
super->timer = 80;
super->subtimer = 0;
}
}
void BusinessScrub_Action3(Entity* this) {
void BusinessScrub_Action3(BusinessScrubEntity* this) {
Entity* iVar1;
switch (this->subAction) {
switch (super->subAction) {
case 0:
if (this->timer == 0) {
if (this->frame & ANIM_DONE) {
this->subAction = 1;
if (super->timer == 0) {
if (super->frame & ANIM_DONE) {
super->subAction = 1;
sub_08028FDC(this);
sub_080290E0(this, 5);
this->spritePriority.b1 = 1;
super->spritePriority.b1 = 1;
}
} else {
this->timer--;
super->timer--;
}
break;
case 1:
if (this->frame & ANIM_DONE) {
this->action = 4;
this->subAction = 0;
this->timer = 30;
this->subtimer = 5;
if (super->frame & ANIM_DONE) {
super->action = 4;
super->subAction = 0;
super->timer = 30;
super->subtimer = 5;
sub_080290E0(this, 0);
iVar1 = Create0x68FX(this, FX_STARS);
iVar1 = Create0x68FX(super, FX_STARS);
if (iVar1 != NULL) {
iVar1->spritePriority.b0 = 3;
iVar1->z.HALF.HI -= 12;
SetDefaultPriority(iVar1, PRIO_MESSAGE);
}
SetFlag(this->field_0x86.HWORD);
SetFlag(this->unk_86);
sub_0802925C(this);
}
break;
}
GetNextFrame(this);
sub_0800445C(this);
GetNextFrame(super);
sub_0800445C(super);
}
extern void sub_0804AA1C(Entity*);
void sub_08028F0C(Entity*);
void sub_08028F0C(BusinessScrubEntity*);
void BusinessScrub_Action4(Entity* this) {
if (--this->timer == 0) {
this->timer = 48;
if (this->subtimer) {
if (--this->subtimer == 0) {
sub_0804AA1C(this);
void BusinessScrub_Action4(BusinessScrubEntity* this) {
if (--super->timer == 0) {
super->timer = 48;
if (super->subtimer) {
if (--super->subtimer == 0) {
sub_0804AA1C(super);
}
} else if (sub_08028FDC(this) || this->field_0x80.HALF.LO) {
this->field_0x80.HALF.LO = 0;
} else if (sub_08028FDC(this) || this->unk_80) {
this->unk_80 = 0;
sub_080290E0(this, 0);
}
}
GetNextFrame(this);
sub_0800445C(this);
GetNextFrame(super);
sub_0800445C(super);
sub_08028F0C(this);
}
void BusinessScrub_Action5(Entity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
void BusinessScrub_Action5(BusinessScrubEntity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->unk_7c;
u32 subtype;
if ((gMessage.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) {
@@ -264,9 +279,9 @@ void BusinessScrub_Action5(Entity* this) {
CreateItemEntity(offer->offeredItem, subtype, 0);
this->action = 6;
this->timer = 4;
this->field_0x80.HALF.HI = 0;
super->action = 6;
super->timer = 4;
this->unk_81 = 0;
sub_080290E0(this, 3);
#if defined(USA) || defined(DEMO_USA)
SetLocalFlag(KS_B06);
@@ -274,12 +289,12 @@ void BusinessScrub_Action5(Entity* this) {
return;
case 1: // refill, bottle, specific kinstone
CreateItemEntity(offer->offeredItem, offer->item_subtype, 0);
this->timer = 4;
super->timer = 4;
sub_0802922C(this);
return;
case 2: // grip ring
CreateItemEntity(offer->offeredItem, offer->item_subtype, 0);
this->timer = 8;
super->timer = 8;
sub_0802922C(this);
return;
}
@@ -291,95 +306,95 @@ void BusinessScrub_Action5(Entity* this) {
}
}
sub_0800445C(this);
this->action = 4;
this->timer = 48;
sub_0800445C(super);
super->action = 4;
super->timer = 48;
sub_080290E0(this, 0);
}
void BusinessScrub_Action6(Entity* this) {
void BusinessScrub_Action6(BusinessScrubEntity* this) {
if (gPlayerEntity.action == PLAYER_ITEMGET) {
if (this->field_0x80.HALF.HI == 0) {
if (this->unk_81 == 0) {
SetPlayerControl(1);
this->field_0x80.HALF.HI = 1;
this->unk_81 = 1;
}
} else {
MessageFromTarget(TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02));
this->action = 4;
this->field_0x80.HALF.HI = 0;
this->timer = 1;
super->action = 4;
this->unk_81 = 0;
super->timer = 1;
sub_08028EDC(this);
SetPlayerControl(0);
sub_0800445C(this);
GetNextFrame(this);
sub_0800445C(super);
GetNextFrame(super);
}
}
void BusinessScrub_Action7(Entity* this) {
void BusinessScrub_Action7(BusinessScrubEntity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
struct SalesOffering* offer = (struct SalesOffering*)this->unk_7c;
this->action = 4;
this->subAction = gMessage.doTextBox & 0x7f;
this->timer = 1;
super->action = 4;
super->subAction = gMessage.doTextBox & 0x7f;
super->timer = 1;
if (!CheckLocalFlag(offer->local_flag)) {
SetLocalFlag(offer->local_flag);
}
SetPlayerControl(0);
}
sub_0800445C(this);
GetNextFrame(this);
sub_0800445C(super);
GetNextFrame(super);
}
void BusinessScrub_Action8(Entity* this) {
if (UpdateFuseInteraction(this)) {
this->action = 4;
this->timer = 1;
void BusinessScrub_Action8(BusinessScrubEntity* this) {
if (UpdateFuseInteraction(super)) {
super->action = 4;
super->timer = 1;
}
}
bool32 sub_08029198(const struct SalesOffering*);
void sub_08028E9C(Entity* this) {
const struct SalesOffering* offer = &gUnk_080CC954[this->type];
void sub_08028E9C(BusinessScrubEntity* this) {
const struct SalesOffering* offer = &gUnk_080CC954[super->type];
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->local_flag];
}
this->field_0x7c.WORD = (u32)offer;
this->field_0x80.HALF.LO = 0;
this->unk_7c = offer;
this->unk_80 = 0;
}
void sub_08028EDC(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
void sub_08028EDC(BusinessScrubEntity* this) {
const struct SalesOffering* offer = this->unk_7c;
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->local_flag];
this->field_0x7c.WORD = (u32)offer;
this->unk_7c = offer;
}
}
void sub_08028F0C(Entity* this) {
if (this->interactType == 2) {
this->action = 8;
this->interactType = 0;
sub_0806F118(this);
} else if (this->interactType != 0) {
void sub_08028F0C(BusinessScrubEntity* this) {
if (super->interactType == 2) {
super->action = 8;
super->interactType = 0;
sub_0806F118(super);
} else if (super->interactType != 0) {
u16 dialog;
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
this->interactType = 0;
sub_0804AA1C(this);
this->direction = (GetAnimationState(this) << 3);
super->interactType = 0;
sub_0804AA1C(super);
super->direction = (GetAnimationState(super) << 3);
sub_080290E0(this, 3);
this->field_0x80.HALF.LO = 1;
this->timer = 32;
this->subtimer = 0;
this->unk_80 = 1;
super->timer = 32;
super->subtimer = 0;
if (sub_08029198(offer)) {
dialog = offer->field_0x6;
} else {
if ((offer->field_0x0 & 0xfc) != 0xc) {
this->action = 5;
super->action = 5;
} else {
this->action = 7;
super->action = 7;
}
dialog = offer->field_0x4;
SetPlayerControl(1);
@@ -389,16 +404,16 @@ void sub_08028F0C(Entity* this) {
}
}
bool32 sub_08028F98(Entity* this, u32 param_2) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL || EntityInRectRadius(this, ent, 0x28, 0x28)) {
bool32 sub_08028F98(BusinessScrubEntity* this, u32 param_2) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL || EntityInRectRadius(super, entity, 0x28, 0x28)) {
return FALSE;
}
if (param_2 != 2) {
u32 distance = param_2 ? 0x58 : 0x50;
if (!EntityInRectRadius(this, ent, distance, distance)) {
if (!EntityInRectRadius(super, entity, distance, distance)) {
return FALSE;
}
}
@@ -406,67 +421,67 @@ bool32 sub_08028F98(Entity* this, u32 param_2) {
return TRUE;
}
bool32 sub_08028FDC(Entity* this) {
u32 direction = DirectionRoundUp(sub_08049F84(this, 1));
if (direction == this->direction) {
bool32 sub_08028FDC(BusinessScrubEntity* this) {
u32 direction = DirectionRoundUp(sub_08049F84(super, 1));
if (direction == super->direction) {
return FALSE;
} else {
this->direction = direction;
super->direction = direction;
return TRUE;
}
}
void sub_08028FFC(Entity* this) {
this->action = 1;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
UnloadGFXSlots(this);
UnloadOBJPalette(this);
this->spriteVramOffset = 0xe8;
this->palette.b.b0 = 2;
this->palette.b.b4 = 2;
this->spriteIndex = 0xa7;
this->x.HALF.HI = this->field_0x78.HWORD;
this->y.HALF.HI = this->field_0x7a.HWORD;
InitializeAnimation(this, 0);
SetTile(0x4022, this->field_0x76.HWORD, this->collisionLayer);
void sub_08028FFC(BusinessScrubEntity* this) {
super->action = 1;
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
UnloadGFXSlots(super);
UnloadOBJPalette(super);
super->spriteVramOffset = 0xe8;
super->palette.b.b0 = 2;
super->palette.b.b4 = 2;
super->spriteIndex = 0xa7;
super->x.HALF.HI = this->unk_78;
super->y.HALF.HI = this->unk_7a;
InitializeAnimation(super, 0);
SetTile(0x4022, this->unk_76, super->collisionLayer);
}
void sub_08029078(Entity* this) {
this->action = 2;
COLLISION_ON(this);
this->spritePriority.b1 = 1;
if (LoadFixedGFX(this, 0x72) == 0) {
DeleteEntity(this);
void sub_08029078(BusinessScrubEntity* this) {
super->action = 2;
COLLISION_ON(super);
super->spritePriority.b1 = 1;
if (LoadFixedGFX(super, 0x72) == 0) {
DeleteEntity(super);
} else {
LoadObjPalette(this, 0x6e);
this->spriteIndex = 0xd0;
LoadObjPalette(super, 0x6e);
super->spriteIndex = 0xd0;
sub_08028FDC(this);
sub_080290E0(this, 1);
SetTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer);
SetTile(this->unk_74, this->unk_76, super->collisionLayer);
}
}
void sub_080290E0(Entity* this, u32 param_2) {
InitializeAnimation(this, this->direction >> 3 | gUnk_080CCA04[param_2]);
void sub_080290E0(BusinessScrubEntity* this, u32 param_2) {
InitializeAnimation(super, super->direction >> 3 | gUnk_080CCA04[param_2]);
}
void sub_080290FC(Entity* this) {
if (this->timer != 0) {
this->timer--;
if ((this->timer < 16) && ((this->timer & 1) == 0)) {
s32 sVar3 = ((this->direction & 0x10) != 0) ? -1 : 1;
if ((this->direction & 8) != 0) {
this->x.HALF.HI += ((this->timer & 8) != 0) ? -sVar3 : sVar3;
void sub_080290FC(BusinessScrubEntity* this) {
if (super->timer != 0) {
super->timer--;
if ((super->timer < 16) && ((super->timer & 1) == 0)) {
s32 sVar3 = ((super->direction & 0x10) != 0) ? -1 : 1;
if ((super->direction & 8) != 0) {
super->x.HALF.HI += ((super->timer & 8) != 0) ? -sVar3 : sVar3;
} else {
this->y.HALF.HI += ((this->timer & 8) != 0) ? sVar3 : -sVar3;
super->y.HALF.HI += ((super->timer & 8) != 0) ? sVar3 : -sVar3;
}
}
}
}
bool32 sub_0802915C(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
bool32 sub_0802915C(BusinessScrubEntity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
switch (offer->offeredItem) {
case ITEM_GRIP_RING:
@@ -511,8 +526,8 @@ bool32 sub_08029198(const struct SalesOffering* offer) {
return TRUE;
}
bool32 BusinessScrub_CheckRefillFitsBag(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
bool32 BusinessScrub_CheckRefillFitsBag(BusinessScrubEntity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
switch (offer->offeredItem) {
case ITEM_BOMBS10:
@@ -528,11 +543,11 @@ bool32 BusinessScrub_CheckRefillFitsBag(Entity* this) {
return FALSE;
}
void sub_0802922C(Entity* this) {
void sub_0802922C(BusinessScrubEntity* this) {
const struct SalesOffering* offer;
this->action = 6;
this->field_0x80.HALF.HI = 0;
offer = (const struct SalesOffering*)this->field_0x7c.WORD;
super->action = 6;
this->unk_81 = 0;
offer = (const struct SalesOffering*)this->unk_7c;
switch (offer->offeredItem) {
case ITEM_BOTTLE1:
@@ -547,17 +562,17 @@ void sub_0802922C(Entity* this) {
}
}
void sub_0802925C(Entity* this) {
AddInteractableWhenBigFuser(this, GetFusionToOffer(this));
void sub_0802925C(BusinessScrubEntity* this) {
AddInteractableWhenBigFuser(super, GetFusionToOffer(super));
}
void sub_08029270(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
InitializeAnimation(this, 0xe);
void sub_08029270(BusinessScrubEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
InitializeAnimation(super, 0xe);
} else {
GetNextFrame(this);
GetNextFrame(super);
}
}
@@ -580,16 +595,16 @@ const struct SalesOffering gUnk_080CC954[] = {
const u8 kinstoneTypes[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 };
void (*const BusinessScrub_Functions[])(Entity*) = {
void (*const BusinessScrub_Functions[])(BusinessScrubEntity*) = {
BusinessScrub_OnTick,
BusinessScrub_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(BusinessScrubEntity*))GenericKnockback,
(void (*)(BusinessScrubEntity*))GenericDeath,
(void (*)(BusinessScrubEntity*))GenericConfused,
BusinessScrub_OnGrabbed,
};
void (*const BusinessScrub_Actions[])(Entity*) = {
void (*const BusinessScrub_Actions[])(BusinessScrubEntity*) = {
BusinessScrub_Action0,
BusinessScrub_Action1,
BusinessScrub_Action2,
+34 -28
View File
@@ -1,6 +1,12 @@
/**
* @file businessScrubPrologue.c
* @ingroup Enemies
*
* @brief Business Scrub Prologue enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -39,7 +45,7 @@ void BusinessScrubPrologue_OnTick(BusinessScrubPrologueEntity* this) {
}
void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) {
Entity* ent;
Entity* entity;
if (super->hitType == 1) {
if ((super->contactFlags & 0x7f) == 0x42) {
super->action = 4;
@@ -47,9 +53,9 @@ void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) {
super->timer = 40;
super->flags &= ~ENT_COLLIDE;
sub_08046030(this, 4);
ent = CreateFx(super, FX_BUSH, 0);
if (ent != NULL) {
ent->z.HALF.HI -= 8;
entity = CreateFx(super, FX_BUSH, 0);
if (entity != NULL) {
entity->z.HALF.HI -= 8;
}
gPlayerState.field_0x27[0] = 0xff;
@@ -93,7 +99,7 @@ void nullsub_24(BusinessScrubPrologueEntity* this) {
}
void sub_08045CE0(BusinessScrubPrologueEntity* this) {
Entity* ent;
Entity* entity;
u32 r6;
GetNextFrame(super);
@@ -122,10 +128,10 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) {
r6 = 1;
sub_0804604C(this);
if (super->frame & 1) {
ent = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
if (ent != NULL) {
ent->parent = super;
ent->direction = super->direction;
entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
if (entity != NULL) {
entity->parent = super;
entity->direction = super->direction;
super->frame &= 0xfe;
super->subAction = 3;
}
@@ -165,7 +171,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) {
}
void sub_08045E14(BusinessScrubPrologueEntity* this) {
Entity* ent;
Entity* entity;
gPlayerState.field_0x27[0] = 0xff;
switch (super->subAction) {
case 0:
@@ -185,11 +191,11 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) {
super->action = 5;
super->subAction = 0;
sub_08046030(this, 0);
ent = Create0x68FX(super, FX_STARS);
if (ent != NULL) {
ent->spritePriority.b0 = 3;
ent->z.HALF.HI -= 0xc;
SetDefaultPriority(ent, PRIO_MESSAGE);
entity = Create0x68FX(super, FX_STARS);
if (entity != NULL) {
entity->spritePriority.b0 = 3;
entity->z.HALF.HI -= 0xc;
SetDefaultPriority(entity, PRIO_MESSAGE);
}
}
break;
@@ -233,12 +239,12 @@ void nullsub_25(BusinessScrubPrologueEntity* this) {
}
bool32 sub_08045F54(BusinessScrubPrologueEntity* this, u32 arg2) {
Entity* ent = sub_08049DF4(1);
Entity* entity = sub_08049DF4(1);
u32 r3;
if (ent == NULL)
if (entity == NULL)
return 0;
if (EntityInRectRadius(super, ent, 0x20, 0x20))
if (EntityInRectRadius(super, entity, 0x20, 0x20))
return 0;
if (arg2 == 2)
return 1;
@@ -247,7 +253,7 @@ bool32 sub_08045F54(BusinessScrubPrologueEntity* this, u32 arg2) {
r3 = 0x58;
}
if (EntityInRectRadius(super, ent, r3, r3))
if (EntityInRectRadius(super, entity, r3, r3))
return 1;
return 0;
}
@@ -292,17 +298,17 @@ void sub_0804604C(BusinessScrubPrologueEntity* this) {
void sub_08046078(BusinessScrubPrologueEntity* this) {
s32 index;
Entity* ent;
Entity* entity;
const u16* ptr;
gPlayerState.field_0x27[0] = 0;
ptr = gUnk_080D1A4E;
for (index = 0; index <= 4; index++) {
ent = CreateFx(super, FX_DEATH, 0x40);
entity = CreateFx(super, FX_DEATH, 0x40);
if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + *ptr;
if (entity != NULL) {
entity->x.HALF.HI = gRoomControls.origin_x + *ptr;
ptr++;
ent->y.HALF.HI = gRoomControls.origin_y + *ptr;
entity->y.HALF.HI = gRoomControls.origin_y + *ptr;
ptr++;
}
}
@@ -314,9 +320,9 @@ void sub_08046078(BusinessScrubPrologueEntity* this) {
RestorePrevTileEntity(0x7a6, 1);
RestorePrevTileEntity(0x7a7, 1);
ent = CreateFx(super, FX_BIG_EXPLOSION2, 0x40);
if (ent != NULL) {
CopyPosition(super, ent);
entity = CreateFx(super, FX_BIG_EXPLOSION2, 0x40);
if (entity != NULL) {
CopyPosition(super, entity);
EnqueueSFX(SFX_184);
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Chaser enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
+425 -413
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -1,14 +1,13 @@
#define NENT_DEPRECATED
/**
* @file chuchuBoss.c
* @ingroup Enemies
*
* @brief Chuchu Boss enemy
*/
#include "global.h"
#define NENT_DEPRECATED
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
typedef struct {
u8 unk_00;
-2
View File
@@ -4,9 +4,7 @@
*
* @brief Cloud Piranha enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "collision.h"
#include "enemy.h"
#include "functions.h"
+7 -1
View File
@@ -1,6 +1,12 @@
/**
* @file crow.c
* @ingroup Enemies
*
* @brief Crow enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
+15 -9
View File
@@ -1,6 +1,12 @@
/**
* @file cuccoAggr.c
* @ingroup Enemies
*
* @brief Cucco Aggr enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -292,13 +298,13 @@ bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this) {
void sub_080391B4(CuccoAggrEntity* this) {
if (this->unk_7a) {
if ((this->unk_7b++ & 0x1f) == 0) {
Entity* ent = CreateEnemy(CUCCO_AGGR, 2);
if (ent != NULL) {
Entity* entity = CreateEnemy(CUCCO_AGGR, 2);
if (entity != NULL) {
u32 rand = (Random() & 0x17);
const PosOffset* ptr = &gCuccoAggrSpawnPoints[rand];
ent->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
ent->y.HALF.HI = gRoomControls.scroll_y + ptr->y;
ent->collisionLayer = super->collisionLayer;
entity->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
entity->y.HALF.HI = gRoomControls.scroll_y + ptr->y;
entity->collisionLayer = super->collisionLayer;
}
}
}
@@ -317,10 +323,10 @@ void sub_08039218(CuccoAggrEntity* this) {
}
void CuccoAggr_CreateFx(CuccoAggrEntity* this) {
Entity* ent = CreateFx(super, gCuccoAggrFx[super->type], 0);
Entity* entity = CreateFx(super, gCuccoAggrFx[super->type], 0);
if (ent != NULL) {
ent->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
if (entity != NULL) {
entity->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Cucco Chick Aggr enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
+7
View File
@@ -1,3 +1,10 @@
/**
* @file curtain.c
* @ingroup Enemies
*
* @brief Curtain enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
+299 -283
View File
@@ -4,38 +4,54 @@
*
* @brief Dark Nut enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u8 unk_74;
/*0x75*/ u8 unk_75;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unused2[7];
/*0x84*/ u8 unk_84;
} DarkNutEntity;
typedef struct {
u8 field_0x0;
u8 field_0x1;
} PACKED stuct_080CAB14;
void sub_08021218(Entity*, u32, u32);
void sub_0802124C(Entity*);
void sub_08021218(DarkNutEntity*, u32, u32);
void sub_0802124C(DarkNutEntity*);
u32 sub_08021274(u32, u32);
void sub_08021390(Entity*);
void sub_080213B0(Entity*);
void sub_080213D0(Entity*, u32);
void sub_080213F0(Entity*);
void sub_08021400(Entity*);
void sub_08021414(Entity*);
void sub_08021424(Entity*);
u32 sub_080214FC(Entity*);
void sub_08021540(Entity*);
void sub_08021588(Entity*);
void sub_0802159C(Entity*);
void sub_08021600(Entity*);
void sub_08021644(Entity*);
u32 sub_08021664(Entity*, Entity*);
u32 sub_0802169C(Entity*, Entity*);
void sub_08021390(DarkNutEntity*);
void sub_080213B0(DarkNutEntity*);
void sub_080213D0(DarkNutEntity*, u32);
void sub_080213F0(DarkNutEntity*);
void sub_08021400(DarkNutEntity*);
void sub_08021414(DarkNutEntity*);
void sub_08021424(DarkNutEntity*);
u32 sub_080214FC(DarkNutEntity*);
void sub_08021540(DarkNutEntity*);
void sub_08021588(DarkNutEntity*);
void sub_0802159C(DarkNutEntity*);
void sub_08021600(DarkNutEntity*);
void sub_08021644(DarkNutEntity*);
u32 sub_08021664(DarkNutEntity*, Entity*);
u32 sub_0802169C(DarkNutEntity*, Entity*);
extern Entity* gUnk_020000B0;
extern void (*const DarkNut_Functions[])(Entity*);
extern void (*const gUnk_080CAAB0[])(Entity*);
extern void (*const DarkNut_Functions[])(DarkNutEntity*);
extern void (*const gUnk_080CAAB0[])(DarkNutEntity*);
extern const s8 gUnk_080CAB00[];
extern const s8 gUnk_080CAB04[];
@@ -49,150 +65,150 @@ extern const u8 gUnk_080CAB4A[];
extern const u8 gUnk_080CAB52[];
extern const u8 gUnk_080CAB68[];
extern void (*const gUnk_080CAB58[])(Entity*);
extern void (*const gUnk_080CAB58[])(DarkNutEntity*);
void DarkNut(Entity* this) {
EnemyFunctionHandler(this, DarkNut_Functions);
SetChildOffset(this, 0, 1, -22);
void DarkNut(DarkNutEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)DarkNut_Functions);
SetChildOffset(super, 0, 1, -22);
}
void DarkNut_OnTick(Entity* this) {
gUnk_080CAAB0[this->action](this);
void DarkNut_OnTick(DarkNutEntity* this) {
gUnk_080CAAB0[super->action](this);
}
void DarkNut_OnCollision(Entity* this) {
switch (this->contactFlags & 0x7f) {
void DarkNut_OnCollision(DarkNutEntity* this) {
switch (super->contactFlags & 0x7f) {
case 0x1c:
this->action = 11;
this->timer = gUnk_080CAB0C[this->type];
this->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10));
super->action = 11;
super->timer = gUnk_080CAB0C[super->type];
super->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10));
sub_08021588(this);
Create0x68FX(this, FX_STARS);
Create0x68FX(super, FX_STARS);
break;
case 0x16:
this->action = 11;
this->timer = gUnk_080CAB10[this->type];
this->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10));
super->action = 11;
super->timer = gUnk_080CAB10[super->type];
super->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10));
sub_08021588(this);
Create0x68FX(this, FX_STARS);
Create0x68FX(super, FX_STARS);
break;
case 0x4b:
if (this->action == 13 || this->action == 15 || this->action == 19 || this->action == 18)
if (super->action == 13 || super->action == 15 || super->action == 19 || super->action == 18)
break;
switch (this->field_0x78.HALF.HI) {
switch (this->unk_79) {
case 8 ... 12:
this->field_0x7a.HALF.LO = gUnk_080CAB04[this->type];
this->unk_7a = gUnk_080CAB04[super->type];
break;
case 4 ... 6:
this->field_0x7a.HALF.LO = gUnk_080CAB00[this->type];
this->unk_7a = gUnk_080CAB00[super->type];
break;
default:
this->field_0x7a.HALF.LO = 0;
this->unk_7a = 0;
break;
}
this->action = 10;
sub_08021218(this, 0xb, this->animationState);
super->action = 10;
sub_08021218(this, 0xb, super->animationState);
EnqueueSFX(SFX_15D);
sub_08021588(this);
break;
case 0x4c:
if (this->action == 15) {
if (super->action == 15) {
u8 bVar3 = 0xff;
if (this->child != NULL) {
bVar3 = this->child->contactFlags & 0x7f;
if (super->child != NULL) {
bVar3 = super->child->contactFlags & 0x7f;
}
if (bVar3 == 2) {
sub_080213D0(this, gUnk_080CAB08[this->type]);
sub_080213D0(this, gUnk_080CAB08[super->type]);
} else {
sub_080213D0(this, 0);
}
}
break;
default:
if (this->health != this->field_0x78.HALF.LO) {
if (super->health != this->unk_78) {
sub_08021588(this);
sub_08021390(this);
sub_0804AA1C(this);
sub_0804AA1C(super);
}
break;
}
this->field_0x78.HALF.LO = this->health;
EnemyFunctionHandlerAfterCollision(this, DarkNut_Functions);
this->unk_78 = super->health;
EnemyFunctionHandlerAfterCollision(super, DarkNut_Functions);
}
void DarkNut_OnGrabbed(Entity* this) {
void DarkNut_OnGrabbed(DarkNutEntity* this) {
}
void sub_08020D70(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x74.HALF.HI = 0;
this->field_0x78.HALF.LO = this->health;
this->animationState = -1;
void sub_08020D70(DarkNutEntity* this) {
sub_0804A720(super);
super->action = 1;
this->unk_75 = 0;
this->unk_78 = super->health;
super->animationState = -1;
sub_08021218(this, 0, 2);
}
void sub_08020D9C(Entity* this) {
if (sub_08049FDC(this, 1))
void sub_08020D9C(DarkNutEntity* this) {
if (sub_08049FDC(super, 1))
sub_080213F0(this);
}
void sub_08020DB4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020DB4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_08020DD4(Entity* this) {
void sub_08020DD4(DarkNutEntity* this) {
if (sub_080214FC(this)) {
sub_080213F0(this);
} else if (--this->field_0x76.HWORD == 0) {
this->action = 5;
sub_08021218(this, 5, this->animationState);
} else if (--this->unk_76 == 0) {
super->action = 5;
sub_08021218(this, 5, super->animationState);
} else {
if (--this->timer == 0)
if (--super->timer == 0)
sub_08021540(this);
ProcessMovement0(this);
UpdateAnimationSingleFrame(this);
ProcessMovement0(super);
UpdateAnimationSingleFrame(super);
}
}
void sub_08020E28(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020E28(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_080213B0(this);
}
void sub_08020E48(Entity* this) {
void sub_08020E48(DarkNutEntity* this) {
if (sub_080214FC(this)) {
sub_080213F0(this);
} else {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_080213B0(this);
}
}
void sub_08020E78(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020E78(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_08020E98(Entity* this) {
if (PlayerInRange(this, 1, 56)) {
void sub_08020E98(DarkNutEntity* this) {
if (PlayerInRange(super, 1, 56)) {
if (sub_0802169C(this, gUnk_020000B0)) {
this->action = 8;
sub_08021218(this, 7, this->animationState);
super->action = 8;
sub_08021218(this, 7, super->animationState);
} else {
this->direction = GetFacingDirection(gUnk_020000B0, this);
if (ProcessMovement0(this) == 0) {
this->action = 8;
sub_08021218(this, 7, this->animationState);
super->direction = GetFacingDirection(gUnk_020000B0, super);
if (ProcessMovement0(super) == 0) {
super->action = 8;
sub_08021218(this, 7, super->animationState);
} else {
this->direction = DirectionTurnAround(this->direction);
super->direction = DirectionTurnAround(super->direction);
sub_0802124C(this);
sub_08021644(this);
}
@@ -201,35 +217,35 @@ void sub_08020E98(Entity* this) {
if (gUnk_020000B0 == NULL) {
sub_08021414(this);
} else {
this->direction = GetFacingDirection(this, gUnk_020000B0);
ProcessMovement0(this);
super->direction = GetFacingDirection(super, gUnk_020000B0);
ProcessMovement0(super);
sub_0802124C(this);
sub_08021644(this);
}
}
}
void sub_08020F28(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020F28(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_08021400(this);
}
void sub_08020F48(Entity* this) {
if (PlayerInRange(this, 1, 0x48)) {
void sub_08020F48(DarkNutEntity* this) {
if (PlayerInRange(super, 1, 0x48)) {
if (sub_08021664(this, gUnk_020000B0)) {
u32 uVar2 = sub_0804A044(this, gUnk_020000B0, 9);
u32 uVar2 = sub_0804A044(super, gUnk_020000B0, 9);
if (uVar2 == 0xff) {
sub_08021424(this);
} else {
Entity* pEVar3;
this->action = 14;
super->action = 14;
sub_08021218(this, 13, uVar2 >> 3);
pEVar3 = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 1);
pEVar3 = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 1);
if (pEVar3) {
pEVar3->parent = this;
this->child = pEVar3;
pEVar3->parent = super;
super->child = pEVar3;
}
}
} else {
@@ -240,155 +256,155 @@ void sub_08020F48(Entity* this) {
}
}
void sub_08020FAC(Entity* this) {
if (this->frame & ANIM_DONE) {
if (this->field_0x7a.HALF.LO) {
this->field_0x7a.HALF.LO--;
void sub_08020FAC(DarkNutEntity* this) {
if (super->frame & ANIM_DONE) {
if (this->unk_7a) {
this->unk_7a--;
} else {
this->iframes = -8;
super->iframes = -8;
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
void sub_08020FE4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (--this->timer == 0) {
this->action = 12;
sub_08021218(this, 9, this->animationState);
sub_0804AA1C(this);
void sub_08020FE4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (--super->timer == 0) {
super->action = 12;
sub_08021218(this, 9, super->animationState);
sub_0804AA1C(super);
}
}
void sub_08021010(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
this->hitType = 0x56;
void sub_08021010(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
super->hitType = 0x56;
sub_080213F0(this);
}
}
void sub_08021038(Entity* this) {
if (this->child == NULL && this->frame) {
Entity* pEVar2 = (Entity*)CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 0);
void sub_08021038(DarkNutEntity* this) {
if (super->child == NULL && super->frame) {
Entity* pEVar2 = (Entity*)CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 0);
if (pEVar2) {
pEVar2->parent = this;
this->child = pEVar2;
pEVar2->parent = super;
super->child = pEVar2;
}
EnqueueSFX(SFX_10E);
}
if (this->frame & ANIM_DONE) {
if (super->frame & ANIM_DONE) {
sub_08021588(this);
if (this->field_0x7c.BYTES.byte0) {
this->field_0x7c.BYTES.byte0--;
if (this->unk_7c) {
this->unk_7c--;
} else {
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
if (this->frame == 4)
this->hitType = 81;
UpdateAnimationSingleFrame(super);
if (super->frame == 4)
super->hitType = 81;
}
}
void sub_080210A8(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & 1) {
this->frame = 0;
void sub_080210A8(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & 1) {
super->frame = 0;
sub_08021588(this);
EnqueueSFX(SFX_15D);
} else if (this->frame & ANIM_DONE) {
} else if (super->frame & ANIM_DONE) {
sub_08021390(this);
}
}
void sub_080210E4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & 1) {
Entity* ent;
void sub_080210E4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & 1) {
Entity* entity;
this->frame &= ~1;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 2);
if (ent != NULL) {
ent->parent = this;
this->child = ent;
super->frame &= ~1;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 2);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
}
EnqueueSFX(SFX_10E);
}
sub_08021644(this);
if ((this->frame & 0x10) && (!ProcessMovement0(this) || (this->child && (this->child->contactFlags & 0x80)))) {
if ((super->frame & 0x10) && (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & 0x80)))) {
sub_080213D0(this, 0);
} else {
if (--this->field_0x76.HWORD == 0)
if (--this->unk_76 == 0)
sub_080213D0(this, 0);
}
}
void sub_08021170(Entity* this) {
if (this->frame & ANIM_DONE) {
if (this->field_0x7a.HALF.HI) {
this->field_0x7a.HALF.HI--;
void sub_08021170(DarkNutEntity* this) {
if (super->frame & ANIM_DONE) {
if (this->unk_7b) {
this->unk_7b--;
} else {
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
void sub_080211A0(Entity* this) {
void sub_080211A0(DarkNutEntity* this) {
if (sub_080214FC(this)) {
sub_08021390(this);
} else {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_080213B0(this);
}
}
void sub_080211D0(Entity* this)
void sub_080211D0(DarkNutEntity* this)
{
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
sub_0802159C(this);
if (this->frame & ANIM_DONE)
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_080211F4(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_080211F4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
sub_08021600(this);
if (this->frame & ANIM_DONE)
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_08021218(Entity* this, u32 param_2, u32 param_3) {
void sub_08021218(DarkNutEntity* this, u32 param_2, u32 param_3) {
const stuct_080CAB14* unk;
if (this->field_0x74.HALF.LO == param_2 && this->animationState == param_3)
if (this->unk_74 == param_2 && super->animationState == param_3)
return;
this->animationState = param_3;
this->field_0x74.HALF.LO = param_2;
super->animationState = param_3;
this->unk_74 = param_2;
unk = &gUnk_080CAB14[param_2];
this->spriteIndex = unk->field_0x1;
InitAnimationForceUpdate(this, unk->field_0x0 + param_3);
super->spriteIndex = unk->field_0x1;
InitAnimationForceUpdate(super, unk->field_0x0 + param_3);
}
void sub_0802124C(Entity* this) {
u32 iVar1 = sub_08021274(this->animationState, this->direction);
void sub_0802124C(DarkNutEntity* this) {
u32 iVar1 = sub_08021274(super->animationState, super->direction);
if (iVar1 != 0xff) {
sub_08021218(this, this->field_0x74.HALF.LO, iVar1);
sub_08021218(this, this->unk_74, iVar1);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
@@ -404,103 +420,103 @@ u32 sub_08021274(u32 animationState, u32 dir) {
return dir;
}
void sub_080212B0(Entity* this) {
void sub_080212B0(DarkNutEntity* this) {
u8 tmp;
switch (this->field_0x74.HALF.HI) {
switch (this->unk_75) {
default:
this->field_0x74.HALF.HI = 1;
this->unk_75 = 1;
tmp = gUnk_080CAB3A[Random() & 7];
break;
case 1:
this->field_0x74.HALF.HI = 2;
this->unk_75 = 2;
tmp = gUnk_080CAB42[Random() & 7];
break;
case 2:
this->field_0x74.HALF.HI = 0;
this->unk_75 = 0;
tmp = gUnk_080CAB4A[Random() & 7];
break;
}
if (this->type < 2 && tmp == 2)
if (super->type < 2 && tmp == 2)
tmp = gUnk_080CAB52[Random() & 3];
this->child = NULL;
super->child = NULL;
gUnk_080CAB58[tmp](this);
}
void sub_08021328(Entity* this) {
this->action = 13;
this->field_0x7c.BYTES.byte0 = gUnk_080CAB68[this->type];
sub_08021218(this, 0xc, this->animationState);
void sub_08021328(DarkNutEntity* this) {
super->action = 13;
this->unk_7c = gUnk_080CAB68[super->type];
sub_08021218(this, 0xc, super->animationState);
}
void sub_0802134C(Entity* this) {
this->action = 15;
this->direction = DirectionFromAnimationState(this->animationState);
this->speed = 0x200;
this->field_0x76.HWORD = 0x78;
sub_08021218(this, 0xe, this->animationState);
void sub_0802134C(DarkNutEntity* this) {
super->action = 15;
super->direction = DirectionFromAnimationState(super->animationState);
super->speed = 0x200;
this->unk_76 = 0x78;
sub_08021218(this, 0xe, super->animationState);
}
void sub_08021370(Entity* this) {
this->action = 18;
sub_08021218(this, 0x10, this->animationState);
void sub_08021370(DarkNutEntity* this) {
super->action = 18;
sub_08021218(this, 0x10, super->animationState);
}
void sub_08021380(Entity* this) {
this->action = 19;
sub_08021218(this, 0x11, this->animationState);
void sub_08021380(DarkNutEntity* this) {
super->action = 19;
sub_08021218(this, 0x11, super->animationState);
}
void sub_08021390(Entity* this) {
this->action = 7;
this->speed = 0x200;
this->hitType = 0x56;
sub_08021218(this, 6, this->animationState);
void sub_08021390(DarkNutEntity* this) {
super->action = 7;
super->speed = 0x200;
super->hitType = 0x56;
sub_08021218(this, 6, super->animationState);
}
void sub_080213B0(Entity* this) {
this->action = 3;
this->timer = 1;
this->speed = 0xc0;
this->field_0x76.HWORD = 0xf0;
sub_08021218(this, 3, this->animationState);
void sub_080213B0(DarkNutEntity* this) {
super->action = 3;
super->timer = 1;
super->speed = 0xc0;
this->unk_76 = 0xf0;
sub_08021218(this, 3, super->animationState);
}
void sub_080213D0(Entity* this, u32 param_2) {
this->action = 16;
this->field_0x7a.HALF.HI = param_2;
sub_08021218(this, 0xf, this->animationState);
void sub_080213D0(DarkNutEntity* this, u32 param_2) {
super->action = 16;
this->unk_7b = param_2;
sub_08021218(this, 0xf, super->animationState);
sub_08021588(this);
}
void sub_080213F0(Entity* this) {
this->action = 6;
sub_08021218(this, 1, this->animationState);
void sub_080213F0(DarkNutEntity* this) {
super->action = 6;
sub_08021218(this, 1, super->animationState);
}
void sub_08021400(Entity* this) {
this->action = 9;
this->speed = 0x60;
sub_08021218(this, 10, this->animationState);
void sub_08021400(DarkNutEntity* this) {
super->action = 9;
super->speed = 0x60;
sub_08021218(this, 10, super->animationState);
}
void sub_08021414(Entity* this) {
this->action = 17;
sub_08021218(this, 5, this->animationState);
void sub_08021414(DarkNutEntity* this) {
super->action = 17;
sub_08021218(this, 5, super->animationState);
}
void sub_08021424(Entity* this) {
void sub_08021424(DarkNutEntity* this) {
s32 x, y;
u32 tmp;
u32 dir = GetFacingDirection(this, gUnk_020000B0);
tmp = sub_08021274(this->animationState, dir);
u32 dir = GetFacingDirection(super, gUnk_020000B0);
tmp = sub_08021274(super->animationState, dir);
if (tmp != 0xff) {
sub_08021218(this, this->field_0x74.HALF.LO, tmp);
sub_08021218(this, this->unk_74, tmp);
} else {
tmp = this->animationState;
tmp = super->animationState;
}
switch (tmp) {
@@ -522,122 +538,122 @@ void sub_08021424(Entity* this) {
break;
}
if (!(6 < (x - this->x.HALF.HI) + 3U) && !(4 < (y - this->y.HALF.HI) + 2U)) {
if (!(6 < (x - super->x.HALF.HI) + 3U) && !(4 < (y - super->y.HALF.HI) + 2U)) {
sub_080212B0(this);
} else {
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
if (!ProcessMovement0(this)) {
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, x, y);
if (!ProcessMovement0(super)) {
sub_080212B0(this);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
}
u32 sub_080214FC(Entity* this) {
u32 sub_080214FC(DarkNutEntity* this) {
u32 direction;
if (!sub_08049FDC(this, 1))
if (!sub_08049FDC(super, 1))
return 0;
direction = GetFacingDirection(this, gUnk_020000B0);
if (4 < (direction - (this->frame & 0x1f)) - 2)
direction = GetFacingDirection(super, gUnk_020000B0);
if (4 < (direction - (super->frame & 0x1f)) - 2)
return 0;
this->animationState = DirectionToAnimationState(direction);
super->animationState = DirectionToAnimationState(direction);
return 1;
}
void sub_08021540(Entity* this) {
void sub_08021540(DarkNutEntity* this) {
u32 tmp, tmp2;
u32 rand;
rand = Random();
if (!sub_08049FA0(this) && (rand & 1)) {
tmp2 = DirectionRoundUp(sub_08049EE4(this));
if (!sub_08049FA0(super) && (rand & 1)) {
tmp2 = DirectionRoundUp(sub_08049EE4(super));
} else {
tmp2 = DirectionRound(rand >> 0x10);
}
this->direction = tmp2;
super->direction = tmp2;
tmp = sub_08021274(this->animationState, tmp2);
tmp = sub_08021274(super->animationState, tmp2);
if (tmp != 0xff)
sub_08021218(this, 3, tmp);
this->timer = 30;
super->timer = 30;
}
void sub_08021588(Entity* this) {
if (this->child != NULL) {
this->child->parent = NULL;
this->child = NULL;
void sub_08021588(DarkNutEntity* this) {
if (super->child != NULL) {
super->child->parent = NULL;
super->child = NULL;
}
}
void sub_0802159C(Entity* this) {
if (this->frame == 1) {
Entity* ent;
void sub_0802159C(DarkNutEntity* this) {
if (super->frame == 1) {
Entity* entity;
this->frame = 0;
this->hitType = 0x51;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 3);
if (ent != NULL) {
ent->parent = this;
this->child = ent;
super->frame = 0;
super->hitType = 0x51;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 3);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
}
EnqueueSFX(SFX_116);
} else if (this->frame == 2) {
this->frame = 0;
} else if (super->frame == 2) {
super->frame = 0;
sub_08021588(this);
} else if (this->frame & 0x20) {
this->frame &= ~0x20;
} else if (super->frame & 0x20) {
super->frame &= ~0x20;
EnqueueSFX(SFX_115);
}
}
void sub_08021600(Entity* this) {
if (this->frame == 1) {
Entity* ent;
void sub_08021600(DarkNutEntity* this) {
if (super->frame == 1) {
Entity* entity;
this->frame = 0;
this->hitType = 0x51;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 4);
if (ent != NULL) {
ent->parent = this;
this->child = ent;
super->frame = 0;
super->hitType = 0x51;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 4);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
}
EnqueueSFX(SFX_10E);
} else if (this->frame == 2) {
this->frame = 0;
} else if (super->frame == 2) {
super->frame = 0;
sub_08021588(this);
}
}
void sub_08021644(Entity* this) {
if (this->frame & 0x20) {
this->frame &= ~0x20;
void sub_08021644(DarkNutEntity* this) {
if (super->frame & 0x20) {
super->frame &= ~0x20;
EnqueueSFX(SFX_PLY_LAND);
}
}
u32 sub_08021664(Entity* this, Entity* ent) {
switch (this->animationState) {
u32 sub_08021664(DarkNutEntity* this, Entity* entity) {
switch (super->animationState) {
case 0:
return sub_08049F1C(this, ent, 0x22);
return sub_08049F1C(super, entity, 0x22);
case 1:
return sub_08049F1C(this, ent, 0x1a);
return sub_08049F1C(super, entity, 0x1a);
case 2:
return sub_08049F1C(this, ent, 0x13);
return sub_08049F1C(super, entity, 0x13);
case 3:
return sub_08049F1C(this, ent, 0x1a);
return sub_08049F1C(super, entity, 0x1a);
}
return 0;
}
u32 sub_0802169C(Entity* this, Entity* ent) {
u32 sub_0802169C(DarkNutEntity* this, Entity* entity) {
u32 ret;
switch (this->animationState) {
switch (super->animationState) {
case 0:
ret = 0x2c;
break;
@@ -652,7 +668,7 @@ u32 sub_0802169C(Entity* this, Entity* ent) {
return 0;
}
if (sub_08049F1C(this, ent, ret)) {
if (sub_08049F1C(super, entity, ret)) {
return 0;
} else {
return 1;
@@ -660,15 +676,15 @@ u32 sub_0802169C(Entity* this, Entity* ent) {
}
// clang-format off
void (*const DarkNut_Functions[])(Entity*) = {
void (*const DarkNut_Functions[])(DarkNutEntity*) = {
DarkNut_OnTick,
DarkNut_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(DarkNutEntity*))GenericKnockback,
(void (*)(DarkNutEntity*))GenericDeath,
(void (*)(DarkNutEntity*))GenericConfused,
DarkNut_OnGrabbed,
};
void (*const gUnk_080CAAB0[])(Entity*) = {
void (*const gUnk_080CAAB0[])(DarkNutEntity*) = {
sub_08020D70,
sub_08020D9C,
sub_08020DB4,
@@ -749,7 +765,7 @@ const u8 gUnk_080CAB52[] = {
0, 3, 1, 0, 0, 0
};
void (*const gUnk_080CAB58[])(Entity*) = {
void (*const gUnk_080CAB58[])(DarkNutEntity*) = {
sub_08021328,
sub_0802134C,
sub_08021370,
+72 -63
View File
@@ -4,20 +4,29 @@
*
* @brief Door Mimic enemy
*/
#include "sound.h"
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "sound.h"
void sub_080221C0(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
} DoorMimicEntity;
void sub_080221C0(DoorMimicEntity*);
typedef struct {
s8 h;
s8 v;
} PACKED PosOffset;
extern void (*const DoorMimic_Functions[])(Entity*);
extern void (*const gUnk_080CB74C[])(Entity*);
extern void (*const DoorMimic_Functions[])(DoorMimicEntity*);
extern void (*const gUnk_080CB74C[])(DoorMimicEntity*);
extern const s8 gUnk_080CB764[];
extern const PosOffset gUnk_080CB76C[4][6];
@@ -26,111 +35,111 @@ extern const Hitbox* const* const gUnk_080CB8A4[];
extern s16 gUnk_080B4488[];
void DoorMimic(Entity* this) {
DoorMimic_Functions[GetNextFunction(this)](this);
this->hitbox = (Hitbox*)gUnk_080CB8A4[this->type2][this->frameIndex];
void DoorMimic(DoorMimicEntity* this) {
DoorMimic_Functions[GetNextFunction(super)](this);
super->hitbox = (Hitbox*)gUnk_080CB8A4[super->type2][super->frameIndex];
}
void DoorMimic_OnTick(Entity* this) {
gUnk_080CB74C[this->action](this);
void DoorMimic_OnTick(DoorMimicEntity* this) {
gUnk_080CB74C[super->action](this);
}
void DoorMimic_OnCollision(Entity* this) {
EnemyFunctionHandlerAfterCollision(this, DoorMimic_Functions);
void DoorMimic_OnCollision(DoorMimicEntity* this) {
EnemyFunctionHandlerAfterCollision(super, DoorMimic_Functions);
}
void DoorMimic_OnDeath(Entity* this) {
SetTile((u16)this->field_0x7c.HALF.LO, (u16)this->field_0x7c.HALF.HI, this->collisionLayer);
CreateFx(this, FX_POT_SHATTER, 0);
sub_08049CF4(this);
void DoorMimic_OnDeath(DoorMimicEntity* this) {
SetTile(this->unk_7c, this->unk_7e, super->collisionLayer);
CreateFx(super, FX_POT_SHATTER, 0);
sub_08049CF4(super);
DeleteThisEntity();
}
void sub_08022034(Entity* this) {
this->action = 1;
this->type2 = this->type & 3;
this->spritePriority.b0 = 5;
this->field_0x78.HWORD = gUnk_080CB764[this->type2 * 2 + 0] + this->x.HALF.HI;
this->field_0x7a.HWORD = gUnk_080CB764[this->type2 * 2 + 1] + this->y.HALF.HI;
InitializeAnimation(this, this->type2);
void sub_08022034(DoorMimicEntity* this) {
super->action = 1;
super->type2 = super->type & 3;
super->spritePriority.b0 = 5;
this->unk_78 = gUnk_080CB764[super->type2 * 2 + 0] + super->x.HALF.HI;
this->unk_7a = gUnk_080CB764[super->type2 * 2 + 1] + super->y.HALF.HI;
InitializeAnimation(super, super->type2);
sub_080221C0(this);
}
void sub_0802209C(Entity* this) {
if (this->timer == 0) {
if (CheckPlayerProximity(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) {
this->action = 2;
this->timer = 18;
InitializeAnimation(this, this->type2 + 4);
void sub_0802209C(DoorMimicEntity* this) {
if (super->timer == 0) {
if (CheckPlayerProximity(this->unk_78, this->unk_7a, 0x10, 0x10)) {
super->action = 2;
super->timer = 18;
InitializeAnimation(super, super->type2 + 4);
}
} else {
this->timer--;
super->timer--;
}
}
void sub_080220D8(Entity* this) {
if (--this->timer == 0)
this->action = 3;
void sub_080220D8(DoorMimicEntity* this) {
if (--super->timer == 0)
super->action = 3;
}
void sub_080220F0(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
void sub_080220F0(DoorMimicEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
const PosOffset* off;
u32 i;
this->action = 4;
this->timer = 120;
this->damage = 0;
off = gUnk_080CB76C[this->type2];
super->action = 4;
super->timer = 120;
super->damage = 0;
off = gUnk_080CB76C[super->type2];
for (i = 0; i < 6; i++, off++) {
Entity* fx = CreateFx(this, FX_DASH, 0);
Entity* fx = CreateFx(super, FX_DASH, 0);
if (fx) {
fx->x.HALF.HI += off->h;
fx->y.HALF.HI += off->v;
}
}
EnqueueSFX(SFX_PLACE_OBJ);
} else if (this->frame & 1) {
this->damage = 4;
} else if (super->frame & 1) {
super->damage = 4;
}
}
void sub_08022174(Entity* this) {
sub_0800445C(this);
if (--this->timer == 0) {
this->action = 5;
InitializeAnimation(this, this->type2 + 8);
void sub_08022174(DoorMimicEntity* this) {
sub_0800445C(super);
if (--super->timer == 0) {
super->action = 5;
InitializeAnimation(super, super->type2 + 8);
}
}
void sub_08022198(Entity* this) {
sub_0800445C(this);
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = 90;
void sub_08022198(DoorMimicEntity* this) {
sub_0800445C(super);
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = 90;
}
}
void sub_080221C0(Entity* this) {
u32 tile = COORD_TO_TILE(this) + gUnk_080B4488[this->type2];
this->field_0x7c.HALF.HI = tile;
this->field_0x7c.HALF.LO = GetTileIndex(tile, this->collisionLayer);
SetTile(gUnk_080CB79C[this->type2], tile, this->collisionLayer);
void sub_080221C0(DoorMimicEntity* this) {
u32 tile = COORD_TO_TILE(super) + gUnk_080B4488[super->type2];
this->unk_7e = tile;
this->unk_7c = GetTileIndex(tile, super->collisionLayer);
SetTile(gUnk_080CB79C[super->type2], tile, super->collisionLayer);
}
// clang-format off
void (*const DoorMimic_Functions[])(Entity*) = {
void (*const DoorMimic_Functions[])(DoorMimicEntity*) = {
DoorMimic_OnTick,
DoorMimic_OnCollision,
GenericKnockback,
(void (*)(DoorMimicEntity*))GenericKnockback,
DoorMimic_OnDeath,
GenericConfused,
(void (*)(DoorMimicEntity*))GenericConfused,
DoorMimic_OnTick,
};
void (*const gUnk_080CB74C[])(Entity*) = {
void (*const gUnk_080CB74C[])(DoorMimicEntity*) = {
sub_08022034,
sub_0802209C,
sub_080220D8,
+12 -6
View File
@@ -1,12 +1,18 @@
/**
* @file dust.c
* @ingroup Enemies
*
* @brief Dust enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "hitbox.h"
#include "player.h"
#include "physics.h"
#include "room.h"
#include "asm.h"
#include "enemy.h"
#include "entity.h"
#include "hitbox.h"
#include "object.h"
#include "physics.h"
#include "player.h"
#include "room.h"
typedef struct {
Entity base;
+2 -3
View File
@@ -2,12 +2,11 @@
* @file enemy4D.c
* @ingroup Enemies
*
* @brief enemy 4D
* @brief Enemy4D enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
+1 -3
View File
@@ -4,12 +4,10 @@
*
* @brief Enemy50 enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "area.h"
#include "enemy.h"
#include "functions.h"
#include "area.h"
#include "player.h"
typedef struct {
+1 -3
View File
@@ -4,12 +4,10 @@
*
* @brief Enemy64 enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "functions.h"
#include "fade.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
+7
View File
@@ -1,3 +1,10 @@
/**
* @file enemy66.c
* @ingroup Enemies
*
* @brief Enemy66 enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
void (*const gUnk_080D2ABC[])(Entity*);
+2 -2
View File
@@ -2,9 +2,9 @@
* @file enemyE.c
* @ingroup Enemies
*
* @brief enemy E
* @brief EnemyE enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
+2 -4
View File
@@ -4,14 +4,12 @@
*
* @brief Eyegore enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "functions.h"
#include "fade.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
+106 -95
View File
@@ -4,109 +4,120 @@
*
* @brief Falling Boulder enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
void sub_0802C4B0(Entity*);
void sub_0802C62C(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[18];
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
/*0x84*/ u32 unk_84;
} FallingBoulderEntity;
extern void (*const FallingBoulder_Functions[])(Entity*);
extern void (*const gUnk_080CD558[])(Entity*);
void sub_0802C4B0(FallingBoulderEntity* this);
void sub_0802C62C(FallingBoulderEntity* this);
extern void (*const FallingBoulder_Functions[])(FallingBoulderEntity*);
extern void (*const gUnk_080CD558[])(FallingBoulderEntity*);
extern const u16 gUnk_080CD568[];
extern const u8 gUnk_080CD580[];
extern const s16 gUnk_080CD58C[];
void FallingBoulder(Entity* this) {
EnemyFunctionHandler(this, FallingBoulder_Functions);
void FallingBoulder(FallingBoulderEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)FallingBoulder_Functions);
}
void FallingBoulder_OnTick(Entity* this) {
gUnk_080CD558[this->action](this);
void FallingBoulder_OnTick(FallingBoulderEntity* this) {
gUnk_080CD558[super->action](this);
}
void FallingBoulder_OnCollision(Entity* this) {
void FallingBoulder_OnCollision(FallingBoulderEntity* this) {
/* ... */
}
void FallingBoulder_OnGrabbed(Entity* this) {
void FallingBoulder_OnGrabbed(FallingBoulderEntity* this) {
/* ... */
}
void sub_0802C258(Entity* this) {
sub_0804A720(this);
this->zVelocity = Q_16_16(2.0);
this->timer = 2;
this->field_0x7a.HWORD = Random() & 0x70;
switch (this->type) {
void sub_0802C258(FallingBoulderEntity* this) {
sub_0804A720(super);
super->zVelocity = Q_16_16(2.0);
super->timer = 2;
this->unk_7a = Random() & 0x70;
switch (super->type) {
case 1:
this->field_0x7a.HWORD |= 0x100;
this->unk_7a |= 0x100;
break;
case 2:
this->field_0x7a.HWORD |= 0x200;
this->unk_7a |= 0x200;
break;
}
this->field_0x80.HWORD = this->x.HALF.HI;
this->field_0x82.HWORD = this->y.HALF.HI;
this->z.HALF.HI = -0x10;
this->collisionLayer = 3;
this->spriteRendering.b3 = 1;
this->spritePriority.b0 = 2;
this->field_0x7c.HALF.LO = 0;
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
this->unk_80 = super->x.HALF.HI;
this->unk_82 = super->y.HALF.HI;
super->z.HALF.HI = -0x10;
super->collisionLayer = 3;
super->spriteRendering.b3 = 1;
super->spritePriority.b0 = 2;
this->unk_7c = 0;
this->unk_7e = COORD_TO_TILE(super);
sub_0802C62C(this);
sub_0802C4B0(this);
}
void sub_0802C318(Entity* this) {
if (--this->field_0x7a.HWORD == 0) {
this->action = 2;
void sub_0802C318(FallingBoulderEntity* this) {
if (--this->unk_7a == 0) {
super->action = 2;
}
}
void sub_0802C334(Entity* this) {
register Entity* ent asm("r2");
void sub_0802C334(FallingBoulderEntity* this) {
register Entity* entity asm("r2");
u32 diff;
u16 tmp;
if (this->field_0x7c.HALF_U.LO == 0) {
if (this->unk_7c == 0) {
u32 tmp = gRoomControls.origin_y;
ent = &gPlayerEntity;
if (ent == NULL)
entity = &gPlayerEntity;
if (entity == NULL)
return;
if (ent->y.HALF.HI - tmp <= 0x38) {
if (entity->y.HALF.HI - tmp <= 0x38) {
return;
}
this->field_0x7c.HALF_U.LO = 1;
this->spriteSettings.draw = 1;
this->unk_7c = 1;
super->spriteSettings.draw = 1;
}
GetNextFrame(this);
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
if (sub_080044EC(this, *(u32*)&this->cutsceneBeh) == 1) {
GetNextFrame(super);
this->unk_7e = COORD_TO_TILE(super);
if (sub_080044EC(super, this->unk_84) == 1) {
EnqueueSFX(0x14c);
COLLISION_ON(this);
this->field_0x7a.HWORD = 0xc;
COLLISION_ON(super);
this->unk_7a = 0xc;
sub_0802C4B0(this);
} else {
s32 y;
if (this->field_0x7a.HWORD) {
tmp = --this->field_0x7a.HWORD;
if (this->unk_7a) {
tmp = --this->unk_7a;
switch (tmp) {
case 0:
COLLISION_OFF(this);
COLLISION_OFF(super);
break;
case 8:
if (this->type2 != 0 && !sub_08049FA0(this)) {
if (super->type2 != 0 && !sub_08049FA0(super)) {
diff = 0;
for (y = 1; y > -1; y--) {
ent = CreateFx(this, FX_ROCK2, 0);
if (ent) {
ent->x.HALF.HI = ent->x.HALF.HI + 12 - diff;
entity = CreateFx(super, FX_ROCK2, 0);
if (entity) {
entity->x.HALF.HI = entity->x.HALF.HI + 12 - diff;
}
diff += 0x18;
}
sub_0802C62C(this);
this->field_0x7a.HWORD = (Random() & 0xff) | 0x100;
this->unk_7a = (Random() & 0xff) | 0x100;
return;
}
break;
@@ -115,37 +126,37 @@ void sub_0802C334(Entity* this) {
{
FORCE_REGISTER(RoomControls * tmp, r0) = &gRoomControls;
y = tmp->origin_y + tmp->height - this->y.HALF.HI;
y = tmp->origin_y + tmp->height - super->y.HALF.HI;
}
if (y >= 5) {
ProcessMovement1(this);
ProcessMovement1(super);
} else {
LinearMoveUpdate(this);
if (this->z.HALF.HI - y > 0x38) {
LinearMoveUpdate(super);
if (super->z.HALF.HI - y > 0x38) {
sub_0802C62C(this);
this->field_0x7a.HWORD = (Random() & 0x7f) | 0x80;
if (this->type == 3) {
this->action = 3;
this->unk_7a = (Random() & 0x7f) | 0x80;
if (super->type == 3) {
super->action = 3;
}
}
}
}
this->collisionLayer = 3;
this->spritePriority.b0 = 1;
UpdateSpriteForCollisionLayer(this);
super->collisionLayer = 3;
super->spritePriority.b0 = 1;
UpdateSpriteForCollisionLayer(super);
}
void nullsub_148(Entity* this) {
void nullsub_148(FallingBoulderEntity* this) {
/* ... */
}
void sub_0802C4B0(Entity* this) {
void sub_0802C4B0(FallingBoulderEntity* this) {
u32 offset;
u32 index;
u32 rand;
switch (GetTileIndex(this->field_0x7c.HALF_U.HI, this->collisionLayer)) {
switch (GetTileIndex(this->unk_7e, super->collisionLayer)) {
case 0x1ab ... 0x1af:
offset = 8;
break;
@@ -160,78 +171,78 @@ void sub_0802C4B0(Entity* this) {
rand = Random() & 7;
if (rand & 4) {
if (rand & 3) {
this->speed = gUnk_080CD568[offset | 2];
super->speed = gUnk_080CD568[offset | 2];
} else {
this->speed = gUnk_080CD568[offset | 0];
super->speed = gUnk_080CD568[offset | 0];
}
} else {
if (rand & 3) {
this->speed = gUnk_080CD568[offset | 1];
super->speed = gUnk_080CD568[offset | 1];
} else {
this->speed = gUnk_080CD568[offset | 3];
super->speed = gUnk_080CD568[offset | 3];
}
}
rand = Random() & 7;
if (rand & 4) {
if (this->timer != 0) {
this->timer = 0;
InitializeAnimation(this, 0);
if (super->timer != 0) {
super->timer = 0;
InitializeAnimation(super, 0);
}
if (rand & 3) {
this->direction = gUnk_080CD580[offset | 1];
super->direction = gUnk_080CD580[offset | 1];
} else {
this->direction = gUnk_080CD580[offset | 0];
super->direction = gUnk_080CD580[offset | 0];
}
} else {
if (this->timer != 1) {
this->timer = 1;
InitializeAnimation(this, 1);
if (super->timer != 1) {
super->timer = 1;
InitializeAnimation(super, 1);
}
if (rand & 3) {
this->direction = gUnk_080CD580[offset | 2];
super->direction = gUnk_080CD580[offset | 2];
} else {
this->direction = gUnk_080CD580[offset | 3];
super->direction = gUnk_080CD580[offset | 3];
}
}
rand = Random() & 7;
this->zVelocity = Q_16_16(2.0);
super->zVelocity = Q_16_16(2.0);
if (rand & 4) {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 1];
this->unk_84 = gUnk_080CD58C[offset | 1];
} else {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 3];
this->unk_84 = gUnk_080CD58C[offset | 3];
}
} else {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 2];
this->unk_84 = gUnk_080CD58C[offset | 2];
} else {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 0];
this->unk_84 = gUnk_080CD58C[offset | 0];
}
}
}
void sub_0802C62C(Entity* this) {
this->action = 1;
this->y.HALF.HI = this->field_0x82.HWORD;
this->x.HALF.HI = this->field_0x80.HWORD;
this->spriteSettings.draw = 0;
COLLISION_OFF(this);
this->field_0x7c.HALF.LO = 0;
void sub_0802C62C(FallingBoulderEntity* this) {
super->action = 1;
super->y.HALF.HI = this->unk_82;
super->x.HALF.HI = this->unk_80;
super->spriteSettings.draw = 0;
COLLISION_OFF(super);
this->unk_7c = 0;
}
// clang-format off
void (*const FallingBoulder_Functions[])(Entity*) = {
void (*const FallingBoulder_Functions[])(FallingBoulderEntity*) = {
FallingBoulder_OnTick,
FallingBoulder_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(FallingBoulderEntity*))GenericKnockback,
(void (*)(FallingBoulderEntity*))GenericDeath,
(void (*)(FallingBoulderEntity*))GenericConfused,
FallingBoulder_OnGrabbed,
};
void (*const gUnk_080CD558[])(Entity*) = {
void (*const gUnk_080CD558[])(FallingBoulderEntity*) = {
sub_0802C258,
sub_0802C318,
sub_0802C334,
+66 -60
View File
@@ -4,135 +4,141 @@
*
* @brief Fireball Guy enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[28];
/*0x84*/ u8 unk_84;
} FireballGuyEntity;
typedef struct {
s8 h, v;
} PACKED PosOffset;
extern void sub_08045524(Entity*);
extern void sub_08045524(FireballGuyEntity*);
void sub_08045178(Entity*, Entity*, int, int);
void FireballGuy_OnTick(Entity*);
void FireballGuy_OnCollision(Entity*);
void FireballGuy_OnGrabbed(Entity*);
void FireballGuy_Init(Entity*);
void FireballGuy_Action1(Entity*);
void FireballGuy_Action2(Entity*);
void FireballGuy_OnTick(FireballGuyEntity*);
void FireballGuy_OnCollision(FireballGuyEntity*);
void FireballGuy_OnGrabbed(FireballGuyEntity*);
void FireballGuy_Init(FireballGuyEntity*);
void FireballGuy_Action1(FireballGuyEntity*);
void FireballGuy_Action2(FireballGuyEntity*);
static void (*const FireballGuy_Functions[])(Entity*) = {
FireballGuy_OnTick, FireballGuy_OnCollision, GenericKnockback, GenericDeath, GenericConfused, FireballGuy_OnGrabbed,
static void (*const FireballGuy_Functions[])(FireballGuyEntity*) = {
FireballGuy_OnTick, FireballGuy_OnCollision, (void (*)(FireballGuyEntity*))GenericKnockback, (void (*)(FireballGuyEntity*))GenericDeath, (void (*)(FireballGuyEntity*))GenericConfused, FireballGuy_OnGrabbed,
};
void FireballGuy(Entity* this) {
EnemyFunctionHandler(this, FireballGuy_Functions);
void FireballGuy(FireballGuyEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)FireballGuy_Functions);
}
void FireballGuy_OnTick(Entity* this) {
static void (*const FireballGuy_Actions[])(Entity*) = {
void FireballGuy_OnTick(FireballGuyEntity* this) {
static void (*const FireballGuy_Actions[])(FireballGuyEntity*) = {
FireballGuy_Init,
FireballGuy_Action1,
FireballGuy_Action2,
};
FireballGuy_Actions[this->action](this);
FireballGuy_Actions[super->action](this);
}
void FireballGuy_OnCollision(Entity* this) {
if (this->health && this->cutsceneBeh.HALF.LO != this->health) {
this->action = 2;
void FireballGuy_OnCollision(FireballGuyEntity* this) {
if (super->health && this->unk_84 != super->health) {
super->action = 2;
} else {
EnemyFunctionHandlerAfterCollision(this, FireballGuy_Functions);
EnemyFunctionHandlerAfterCollision(super, FireballGuy_Functions);
}
}
void FireballGuy_OnGrabbed(Entity* this) {
void FireballGuy_OnGrabbed(FireballGuyEntity* this) {
}
void FireballGuy_Init(Entity* this) {
this->action = 1;
this->timer = 0;
this->spriteSettings.draw = 1;
this->speed = 0x80;
this->cutsceneBeh.HALF.LO = this->health;
this->collisionFlags |= 0x10;
sub_0804A720(this);
InitializeAnimation(this, 0);
void FireballGuy_Init(FireballGuyEntity* this) {
super->action = 1;
super->timer = 0;
super->spriteSettings.draw = 1;
super->speed = 0x80;
this->unk_84 = super->health;
super->collisionFlags |= 0x10;
sub_0804A720(super);
InitializeAnimation(super, 0);
sub_08045524(this);
}
void FireballGuy_Action1(Entity* this) {
ProcessMovement2(this);
GetNextFrame(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0)
void FireballGuy_Action1(FireballGuyEntity* this) {
ProcessMovement2(super);
GetNextFrame(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0)
sub_08045524(this);
}
/* Split FireballGuy into new ones */
void FireballGuy_Action2(Entity* this) {
void FireballGuy_Action2(FireballGuyEntity* this) {
// Entity count per form
static const u8 typeEntityCount[4] = { 2, 3, 4, 5 };
static const PosOffset gUnk_080D1810[4] = { { 6, 0 }, { -6, 0 }, { 0, 6 }, { 0, -6 } };
Entity* entities[4];
Entity* ent;
Entity* entity;
s32 count, i;
const PosOffset* off;
u32 tmp;
/* Can we create enough new entities? */
count = typeEntityCount[this->type];
count = typeEntityCount[super->type];
if (MAX_ENTITIES + 1 - count <= gEntCount)
return;
/* Create 2-5 new MiniFireballGuy */
for (i = 0; i < count; i++)
entities[i] = CreateEnemy(MINI_FIREBALL_GUY, this->type);
entities[i] = CreateEnemy(MINI_FIREBALL_GUY, super->type);
off = gUnk_080D1810;
for (i = 0; i < count; i++) {
ent = entities[i];
ent->child = entities[(i + 1) % count];
ent->parent = entities[(i + count - 1) % count];
entity = entities[i];
entity->child = entities[(i + 1) % count];
entity->parent = entities[(i + count - 1) % count];
tmp = 0;
ent->type2 = 1;
ent->z.HALF.HI = tmp;
ent->iframes = -0x10;
entity->type2 = 1;
entity->z.HALF.HI = tmp;
entity->iframes = -0x10;
/* Set MiniFireballGuy offset relative to killed slime. */
sub_08045178(this, ent, off->h, off->v);
sub_08045178(super, entity, off->h, off->v);
off++;
}
ent = CreateFx(this, FX_DEATH, 0);
if (ent != NULL)
CopyPosition(this, ent);
entity = CreateFx(super, FX_DEATH, 0);
if (entity != NULL)
CopyPosition(super, entity);
DeleteEntity(this);
DeleteEntity(super);
}
u32 sub_0804A024(Entity*, u32, u32);
void sub_08045524(Entity* this) {
void sub_08045524(FireballGuyEntity* this) {
u32 tmp, tmp1, tmp2;
this->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(this, 1, 8);
super->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(super, 1, 8);
if (tmp != 0xff && (Random() & 3) == 0) {
this->timer = Random() & 3;
this->direction = DirectionRound(tmp);
super->timer = Random() & 3;
super->direction = DirectionRound(tmp);
} else {
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
return;
}
this->timer = Random() & 3;
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
tmp1 = sub_08049EE4(this);
super->timer = Random() & 3;
if (sub_08049FA0(super) == 0 && (Random() & 3)) {
tmp1 = sub_08049EE4(super);
tmp2 = Random() & 8;
tmp2 += 0xfc;
this->direction = DirectionRound(tmp1 + tmp2);
super->direction = DirectionRound(tmp1 + tmp2);
} else {
this->direction = DirectionRound(Random());
super->direction = DirectionRound(Random());
}
}
}
+1 -1
View File
@@ -6,8 +6,8 @@
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "functions.h"
#include "enemy.h"
#include "functions.h"
#include "player.h"
#include "room.h"
+13 -7
View File
@@ -1,7 +1,13 @@
/**
* @file flyingSkull.c
* @ingroup Enemies
*
* @brief Flying Skull enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "hitbox.h"
@@ -132,16 +138,16 @@ void sub_08039DD8(FlyingSkullEntity* this) {
RegisterCarryEntity(super);
} else {
if ((gPlayerState.flags & PL_MINISH) == 0) {
Entity* ent = &gPlayerEntity;
if (EntityWithinDistance(super, ent->x.HALF.HI, ent->y.HALF.HI, 0x30)) {
Entity* player = &gPlayerEntity;
if (EntityWithinDistance(super, player->x.HALF.HI, player->y.HALF.HI, 0x30)) {
if (super->type == 1) {
super->action = 3;
super->timer = 30;
} else {
ent = CreateEnemy(STALFOS, super->type - 2);
if (ent != NULL) {
ent->type2 = 1;
CopyPosition(super, ent);
player = CreateEnemy(STALFOS, super->type - 2);
if (player != NULL) {
player->type2 = 1;
CopyPosition(super, player);
SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer);
DeleteEntity(super);
}
+1 -3
View File
@@ -4,12 +4,10 @@
*
* @brief Ghini enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "area.h"
#include "enemy.h"
#include "functions.h"
#include "area.h"
#include "physics.h"
typedef struct {
+13 -15
View File
@@ -4,12 +4,10 @@
*
* @brief Gibdo enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
typedef struct {
Entity base;
@@ -409,23 +407,23 @@ void Gibdo_CreateObjects(GibdoEntity* this) {
}
void Gibdo_MoveObjectsToStalfos(GibdoEntity* this, Entity* that) {
Entity* ent = this->field_0x80;
Entity* entity = this->field_0x80;
if (ent != NULL) {
ent->timer = 15;
ent->parent = that;
if (entity != NULL) {
entity->timer = 15;
entity->parent = that;
}
ent = this->field_0x84;
if (ent != NULL) {
ent->timer = 15;
ent->parent = that;
entity = this->field_0x84;
if (entity != NULL) {
entity->timer = 15;
entity->parent = that;
}
ent = super->child;
if (ent != NULL) {
ent->timer = 15;
ent->parent = that;
entity = super->child;
if (entity != NULL) {
entity->timer = 15;
entity->parent = that;
}
}
+20 -14
View File
@@ -1,10 +1,16 @@
/**
* @file gleerok.c
* @ingroup Enemies
*
* @brief Gleerok enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "player.h"
#include "screen.h"
#include "entity.h"
#include "functions.h"
#include "object.h"
#include "player.h"
#include "screen.h"
typedef struct {
union SplitHWord unk0;
@@ -19,7 +25,7 @@ typedef struct {
/*0x2e*/ u16 filler_2e;
/*0x30*/ u8 unk_30[6];
/*0x36*/ u8 filler_36[0x2];
/*0x38*/ Entity* ent;
/*0x38*/ Entity* entity1;
/*0x3c*/ Entity* entities[5];
/*0x50*/ Entity* ent2;
} Gleerok_HeapStruct;
@@ -485,7 +491,7 @@ void sub_0802D714(GleerokEntity* this) {
super->child = enemy;
if (enemy) {
enemy->parent = super;
heap->ent = super->child;
heap->entity1 = super->child;
((GleerokEntity*)(super->child))->unk_84 = heap;
}
@@ -612,7 +618,7 @@ void sub_0802D86C(GleerokEntity* this) {
super->child = enemy;
if (enemy) {
enemy->parent = super->parent;
this->unk_84->ent = super->child;
this->unk_84->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = this->unk_84;
}
@@ -633,7 +639,7 @@ void sub_0802D86C(GleerokEntity* this) {
if (enemy) {
enemy->parent = super->parent;
super->timer = this->unk_84->filler[0].unk0.HALF.HI;
this->unk_84->ent = super->child;
this->unk_84->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = this->unk_84;
}
@@ -689,7 +695,7 @@ void sub_0802D86C(GleerokEntity* this) {
super->child = CreateEnemy(GLEEROK, 4);
if (super->child) {
super->child->parent = super->parent;
this->unk_84->ent = super->child;
this->unk_84->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = this->unk_84;
CopyPosition(super, ((volatile Entity*)super)->child);
DeleteThisEntity();
@@ -1097,7 +1103,7 @@ void sub_0802E300(GleerokEntity* this) {
u32 index;
Gleerok_HeapStruct2* ptr;
u8* ptr2;
Entity* ent;
Entity* entity;
Gleerok_HeapStruct* heap;
if ((this->unk_79 & 0x80) == 0) {
this->unk_7c.HALF.LO--;
@@ -1144,11 +1150,11 @@ void sub_0802E300(GleerokEntity* this) {
super->type2 = 0;
*ptr2 = 0;
InitializeAnimation(super, 0x4d);
ent = CreateEnemy(GLEEROK, 5);
super->child = ent;
entity = CreateEnemy(GLEEROK, 5);
super->child = entity;
if (super->child != NULL) {
super->child->parent = super;
heap->ent = super->child;
heap->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = heap;
}
@@ -1368,7 +1374,7 @@ void sub_0802E7E4(Gleerok_HeapStruct* this) {
this->entities[i + 1]->spritePriority.b0 = bVar6;
}
}
this->ent->spritePriority.b0 = 0;
this->entity1->spritePriority.b0 = 0;
} else {
bVar6 = 5;
@@ -1388,7 +1394,7 @@ void sub_0802E7E4(Gleerok_HeapStruct* this) {
this->entities[i + 1]->spritePriority.b0 = bVar6;
}
}
this->ent->spritePriority.b0 = 6;
this->entity1->spritePriority.b0 = 6;
}
}
+8 -3
View File
@@ -1,9 +1,14 @@
/**
* @file gyorgChild.c
* @ingroup Enemies
*
* @brief Gyorg Child enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "room.h"
#include "asm.h"
#include "functions.h"
#include "enemy/gyorg.h"
#include "functions.h"
#include "room.h"
void GyorgChild_OnTick(GyorgChildEntity*);
void GyorgChild_OnCollision(GyorgChildEntity*);
+30 -24
View File
@@ -1,3 +1,9 @@
/**
* @file gyorgFemale.c
* @ingroup Enemies
*
* @brief Gyorg Female enemy
*/
#define NENT_DEPRECATED
#include "asm.h"
#include "collision.h"
@@ -51,32 +57,32 @@ void GyorgFemale(Entity* this) {
}
void GyorgFemale_Setup(GyorgFemaleEntity* this) {
Entity* tmp;
Entity* entity;
if (gEntCount > 0x3d)
return;
tmp = CreateProjectile(GYORG_TAIL);
tmp->type = 0;
tmp->parent = super;
((GyorgHeap*)super->myHeap)->tail = (GenericEntity*)tmp;
tmp = CreateEnemy(GYORG_FEMALE_MOUTH, 0);
tmp->parent = super;
((GyorgHeap*)super->myHeap)->mouth = (GyorgFemaleMouthEntity*)tmp;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 0);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 1);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 2);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 3);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 4);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 5);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 6);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 7);
tmp->parent = super;
entity = CreateProjectile(GYORG_TAIL);
entity->type = 0;
entity->parent = super;
((GyorgHeap*)super->myHeap)->tail = (GenericEntity*)entity;
entity = CreateEnemy(GYORG_FEMALE_MOUTH, 0);
entity->parent = super;
((GyorgHeap*)super->myHeap)->mouth = (GyorgFemaleMouthEntity*)entity;
entity = CreateEnemy(GYORG_FEMALE_EYE, 0);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 1);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 2);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 3);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 4);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 5);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 6);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 7);
entity->parent = super;
super->action = 1;
super->spriteOrientation.flipY = 2;
super->spriteRendering.b3 = 2;
+9 -4
View File
@@ -1,10 +1,15 @@
/**
* @file gyorgFemaleEye.c
* @ingroup Enemies
*
* @brief Gyorg Female Eye enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "player.h"
#include "functions.h"
#include "enemy/gyorg.h"
#include "entity.h"
#include "functions.h"
#include "player.h"
void GyorgFemaleEye_OnTick(GyorgFemaleEyeEntity*);
void GyorgFemaleEye_OnCollision(GyorgFemaleEyeEntity*);
+7 -2
View File
@@ -1,8 +1,13 @@
/**
* @file gyorgFemaleMouth.c
* @ingroup Enemies
*
* @brief Gyorg Female Mouth enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy/gyorg.h"
#include "player.h"
#include "room.h"
#include "enemy/gyorg.h"
extern const Hitbox gUnk_080D28DC;
extern const Hitbox gUnk_080D28E4;
+3 -5
View File
@@ -4,15 +4,13 @@
*
* @brief Gyorg Male enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "effects.h"
#include "enemy.h"
#include "player.h"
#include "enemy/gyorg.h"
#include "fileselect.h"
#include "functions.h"
#include "effects.h"
#include "enemy/gyorg.h"
#include "player.h"
// todo: wrong types
extern void sub_080A1D70(Entity*, u32);
+1 -3
View File
@@ -4,12 +4,10 @@
*
* @brief GyorgMaleEye enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "functions.h"
#include "fade.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
+2 -2
View File
@@ -4,9 +4,9 @@
*
* @brief Hanging Seed enemy
*/
#include "entity.h"
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern void (*const HangingSeed_Functions[])(Entity*);
+214 -207
View File
@@ -4,317 +4,324 @@
*
* @brief Helmasaur enemy
*/
#include "enemy.h"
#include "object.h"
#include "functions.h"
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
} HelmasaurEntity;
extern u32 sub_0804A024(Entity*, u32, u32);
void sub_0802C18C(Entity*);
void sub_0802C218(Entity*);
void sub_0802C1C0(Entity*);
u32 sub_0802C020(Entity*);
void sub_0802C058(Entity*, u32);
bool32 sub_0802C06C(Entity*);
void sub_0802C1CC(Entity*);
bool32 sub_0802C0E8(Entity*);
void sub_0802C18C(HelmasaurEntity*);
void sub_0802C218(HelmasaurEntity*);
void sub_0802C1C0(HelmasaurEntity*);
u32 sub_0802C020(HelmasaurEntity*);
void sub_0802C058(HelmasaurEntity*, u32);
bool32 sub_0802C06C(HelmasaurEntity*);
void sub_0802C1CC(HelmasaurEntity*);
bool32 sub_0802C0E8(HelmasaurEntity*);
extern void (*const Helmasaur_Functions[])(Entity*);
extern void (*const gUnk_080CD3FC[])(Entity*);
extern void (*const gUnk_080CD408[])(Entity*);
extern void (*const gUnk_080CD42C[])(Entity*);
extern void (*const gUnk_080CD438[])(Entity*);
extern void (*const gUnk_080CD450[])(Entity*);
extern void (*const Helmasaur_Functions[])(HelmasaurEntity*);
extern void (*const gUnk_080CD3FC[])(HelmasaurEntity*);
extern void (*const gUnk_080CD408[])(HelmasaurEntity*);
extern void (*const gUnk_080CD42C[])(HelmasaurEntity*);
extern void (*const gUnk_080CD438[])(HelmasaurEntity*);
extern void (*const gUnk_080CD450[])(HelmasaurEntity*);
extern const s8 gUnk_080CD45C[];
extern const s8 gUnk_080CD464[];
void Helmasaur(Entity* this) {
if (this->type == 0) {
EnemyFunctionHandler(this, Helmasaur_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Helmasaur(HelmasaurEntity* this) {
if (super->type == 0) {
EnemyFunctionHandler(super, (EntityActionArray)Helmasaur_Functions);
SetChildOffset(super, 0, 1, -0x10);
} else {
gUnk_080CD3FC[this->action](this);
gUnk_080CD3FC[super->action](this);
}
}
void Helmasaur_OnTick(Entity* this) {
gUnk_080CD408[this->action](this);
void Helmasaur_OnTick(HelmasaurEntity* this) {
gUnk_080CD408[super->action](this);
}
void Helmasaur_OnCollision(Entity* this) {
if (this->hitType != 0x19) {
switch (this->contactFlags & 0x7f) {
void Helmasaur_OnCollision(HelmasaurEntity* this) {
if (super->hitType != 0x19) {
switch (super->contactFlags & 0x7f) {
case 0:
case 2:
case 3:
if (this->action == 4) {
this->knockbackDuration = 0;
if (super->action == 4) {
super->knockbackDuration = 0;
sub_0802C218(this);
}
break;
}
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Helmasaur_Functions);
EnemyFunctionHandlerAfterCollision(super, Helmasaur_Functions);
}
void Helmasaur_OnGrabbed(Entity* this) {
if (this->hitType != 0x19) {
if (sub_0806F520(this)) {
gUnk_080CD42C[this->subAction](this);
void Helmasaur_OnGrabbed(HelmasaurEntity* this) {
if (super->hitType != 0x19) {
if (sub_0806F520(super)) {
gUnk_080CD42C[super->subAction](this);
}
} else if (2 < this->subAction || sub_0806F520(this)) {
gUnk_080CD438[this->subAction](this);
} else if (2 < super->subAction || sub_0806F520(super)) {
gUnk_080CD438[super->subAction](this);
}
}
void sub_0802BC74(Entity* this) {
void sub_0802BC74(HelmasaurEntity* this) {
sub_0802C1C0(this);
this->subAction = 1;
this->gustJarTolerance = 60;
this->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1);
InitializeAnimation(this, this->animationState);
super->subAction = 1;
super->gustJarTolerance = 60;
super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1);
InitializeAnimation(super, super->animationState);
}
void sub_0802BCA0(Entity* this) {
sub_0806F4E8(this);
void sub_0802BCA0(HelmasaurEntity* this) {
sub_0806F4E8(super);
}
void sub_0802BCA8(Entity* this) {
if (this->hitType != 0x19) {
Entity* ent;
void sub_0802BCA8(HelmasaurEntity* this) {
if (super->hitType != 0x19) {
Entity* entity;
this->action = 7;
this->timer = 90;
this->zVelocity = Q_16_16(1.5);
this->hitType = 0x19;
this->gustJarState = this->gustJarState & 0xfb;
this->gustJarFlags = 0x12;
ent = CreateEnemy(HELMASAUR, 1);
if (ent != NULL) {
ent->animationState = this->animationState;
CopyPosition(this, ent);
super->action = 7;
super->timer = 90;
super->zVelocity = Q_16_16(1.5);
super->hitType = 0x19;
super->gustJarState = super->gustJarState & 0xfb;
super->gustJarFlags = 0x12;
entity = CreateEnemy(HELMASAUR, 1);
if (entity != NULL) {
entity->animationState = super->animationState;
CopyPosition(super, entity);
}
InitializeAnimation(this, this->animationState + 4);
InitializeAnimation(super, super->animationState + 4);
}
}
void sub_0802BCFC(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
void sub_0802BCFC(HelmasaurEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_0802BD08(Entity* this) {
sub_0806F3E4(this);
void sub_0802BD08(HelmasaurEntity* this) {
sub_0806F3E4(super);
}
void sub_0802BD10(Entity* this) {
COLLISION_OFF(this);
UpdateAnimationVariableFrames(this, 2);
void sub_0802BD10(HelmasaurEntity* this) {
COLLISION_OFF(super);
UpdateAnimationVariableFrames(super, 2);
}
void nullsub_145(Entity* this) {
void nullsub_145(HelmasaurEntity* this) {
/* ... */
}
void sub_0802BD28(Entity* this) {
if (this->flags & ENT_COLLIDE) {
COLLISION_ON(this);
this->gustJarState &= ~0x4;
void sub_0802BD28(HelmasaurEntity* this) {
if (super->flags & ENT_COLLIDE) {
COLLISION_ON(super);
super->gustJarState &= ~0x4;
} else {
this->health = 0;
super->health = 0;
}
}
void sub_0802BD54(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x78.HALF.LO = Random();
this->gustJarTolerance = 60;
this->field_0x78.HALF.HI = 0xff;
this->direction = DirectionRound(Random());
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState);
void sub_0802BD54(HelmasaurEntity* this) {
sub_0804A720(super);
super->action = 1;
this->unk_78 = Random();
super->gustJarTolerance = 60;
this->unk_79 = 0xff;
super->direction = DirectionRound(Random());
super->animationState = super->direction >> 3;
InitializeAnimation(super, super->animationState);
}
void sub_0802BD8C(Entity* this) {
if (this->timer) {
this->timer--;
void sub_0802BD8C(HelmasaurEntity* this) {
if (super->timer) {
super->timer--;
} else {
u32 direction;
if (sub_08049FDC(this, 1)) {
direction = sub_0804A024(this, 1, 0x10);
if (direction != 0xff && direction != this->field_0x78.HALF.HI) {
if (sub_08049FDC(super, 1)) {
direction = sub_0804A024(super, 1, 0x10);
if (direction != 0xff && direction != this->unk_79) {
sub_0802C058(this, direction);
return;
}
}
direction = sub_0802C020(this);
if (direction != this->direction) {
if (direction != super->direction) {
sub_0802C058(this, direction);
}
}
}
void sub_0802BDE0(Entity* this) {
void sub_0802BDE0(HelmasaurEntity* this) {
if (sub_0802C06C(this)) {
this->action = 3;
this->timer = 60;
this->field_0x78.HALF.HI = 0xff;
super->action = 3;
super->timer = 60;
this->unk_79 = 0xff;
} else {
this->action = 1;
this->timer = (Random() & 0xf) + 15;
this->field_0x78.HALF.HI = this->direction;
super->action = 1;
super->timer = (Random() & 0xf) + 15;
this->unk_79 = super->direction;
}
}
void sub_0802BE18(Entity* this) {
UpdateAnimationVariableFrames(this, 2);
if (--this->timer == 0) {
this->action = 4;
this->timer = 30;
this->speed = 0x300;
void sub_0802BE18(HelmasaurEntity* this) {
UpdateAnimationVariableFrames(super, 2);
if (--super->timer == 0) {
super->action = 4;
super->timer = 30;
super->speed = 0x300;
} else {
sub_0802C18C(this);
}
}
void sub_0802BE48(Entity* this) {
if (!ProcessMovement2(this)) {
void sub_0802BE48(HelmasaurEntity* this) {
if (!ProcessMovement2(super)) {
sub_0802C218(this);
InitScreenShake(8, 0);
} else {
GetNextFrame(this);
GetNextFrame(super);
sub_0802C1CC(this);
if (sub_0802C0E8(this)) {
this->action = 5;
super->action = 5;
}
}
}
void sub_0802BE80(Entity* this) {
this->speed -= 0x20;
if (0xff < this->speed) {
void sub_0802BE80(HelmasaurEntity* this) {
super->speed -= 0x20;
if (0xff < super->speed) {
sub_0802C1CC(this);
}
if (this->speed > 0) {
ProcessMovement2(this);
if (super->speed > 0) {
ProcessMovement2(super);
sub_0802C18C(this);
} else {
sub_0802C1C0(this);
this->timer += 30;
super->timer += 30;
}
}
void sub_0802BEBC(Entity* this) {
this->direction ^= 0x10;
ProcessMovement2(this);
this->direction ^= 0x10;
if (!sub_080044EC(this, Q_16_16(0.125))) {
void sub_0802BEBC(HelmasaurEntity* this) {
super->direction ^= 0x10;
ProcessMovement2(super);
super->direction ^= 0x10;
if (!sub_080044EC(super, Q_16_16(0.125))) {
sub_0802C1C0(this);
}
}
void sub_0802BEEC(Entity* this) {
if (this->timer != 0) {
if ((--this->timer & 0x1F) == 0) {
this->animationState ^= 2;
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 4);
void sub_0802BEEC(HelmasaurEntity* this) {
if (super->timer != 0) {
if ((--super->timer & 0x1F) == 0) {
super->animationState ^= 2;
super->direction = super->animationState << 3;
InitializeAnimation(super, super->animationState + 4);
}
} else if (!GravityUpdate(this, Q_8_8(28.0))) {
this->action = 8;
this->timer = 30;
this->speed = 0x120;
} else if (!GravityUpdate(super, Q_8_8(28.0))) {
super->action = 8;
super->timer = 30;
super->speed = 0x120;
}
}
void sub_0802BF3C(Entity* this) {
ProcessMovement0(this);
GetNextFrame(this);
if (--this->timer == 0) {
void sub_0802BF3C(HelmasaurEntity* this) {
ProcessMovement0(super);
GetNextFrame(super);
if (--super->timer == 0) {
u32 sprite;
this->timer = 30;
this->direction = sub_0802C020(this);
sprite = this->direction >> 3;
if (sprite != this->animationState) {
this->animationState = sprite;
InitializeAnimation(this, sprite + 4);
super->timer = 30;
super->direction = sub_0802C020(this);
sprite = super->direction >> 3;
if (sprite != super->animationState) {
super->animationState = sprite;
InitializeAnimation(super, sprite + 4);
}
}
}
void sub_0802BF78(Entity* this) {
this->action = 1;
this->flags2 = 4;
this->gustJarFlags = 1;
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 8);
void sub_0802BF78(HelmasaurEntity* this) {
super->action = 1;
super->flags2 = 4;
super->gustJarFlags = 1;
super->direction = super->animationState << 3;
InitializeAnimation(super, super->animationState + 8);
}
void sub_0802BF98(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080CD450[this->subAction](this);
void sub_0802BF98(HelmasaurEntity* this) {
if (sub_0806F520(super)) {
gUnk_080CD450[super->subAction](this);
} else {
this->action = 2;
this->timer = 30;
COLLISION_OFF(this);
super->action = 2;
super->timer = 30;
COLLISION_OFF(super);
}
}
void sub_0802BFD0(Entity* this) {
this->subAction = 2;
void sub_0802BFD0(HelmasaurEntity* this) {
super->subAction = 2;
}
void sub_0802BFD8(Entity* this) {
sub_0806F4E8(this);
void sub_0802BFD8(HelmasaurEntity* this) {
sub_0806F4E8(super);
}
void sub_0802BFE0(Entity* this) {
if (sub_0806F3E4(this)) {
DeleteEntity(this);
void sub_0802BFE0(HelmasaurEntity* this) {
if (sub_0806F3E4(super)) {
DeleteEntity(super);
}
}
void sub_0802BFF4(Entity* this) {
this->spriteSettings.draw ^= 1;
if (--this->timer == 0) {
DeleteEntity(this);
void sub_0802BFF4(HelmasaurEntity* this) {
super->spriteSettings.draw ^= 1;
if (--super->timer == 0) {
DeleteEntity(super);
}
}
u32 sub_0802C020(Entity* this) {
u32 sub_0802C020(HelmasaurEntity* this) {
u32 uVar1 = Random();
if (sub_08049FA0(this) || (uVar1 & 1))
if (sub_08049FA0(super) || (uVar1 & 1))
return DirectionRound(uVar1);
return (sub_08049EE4(this) + (uVar1 >> 0x10 & 1) * 4) & 0x18;
return (sub_08049EE4(super) + (uVar1 >> 0x10 & 1) * 4) & 0x18;
}
void sub_0802C058(Entity* this, u32 param_2) {
this->action = 2;
this->direction = param_2;
this->animationState = param_2 >> 3;
InitializeAnimation(this, this->animationState);
void sub_0802C058(HelmasaurEntity* this, u32 param_2) {
super->action = 2;
super->direction = param_2;
super->animationState = param_2 >> 3;
InitializeAnimation(super, super->animationState);
}
bool32 sub_0802C06C(Entity* this) {
u32 x = this->x.HALF.HI + this->hitbox->offset_x;
u32 y = this->y.HALF.HI + this->hitbox->offset_y;
u32 xdiff = gUnk_080CD45C[(this->direction >> 2) + 0];
u32 ydiff = gUnk_080CD45C[(this->direction >> 2) + 1];
bool32 sub_0802C06C(HelmasaurEntity* this) {
u32 x = super->x.HALF.HI + super->hitbox->offset_x;
u32 y = super->y.HALF.HI + super->hitbox->offset_y;
u32 xdiff = gUnk_080CD45C[(super->direction >> 2) + 0];
u32 ydiff = gUnk_080CD45C[(super->direction >> 2) + 1];
u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u8* layer = super->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u32 i;
for (i = 0; i < 8; i++) {
@@ -329,15 +336,15 @@ bool32 sub_0802C06C(Entity* this) {
bool32 sub_0806FC24(u32, u32);
bool32 sub_0802C0E8(Entity* this) {
if (--this->timer == 0) {
bool32 sub_0802C0E8(HelmasaurEntity* this) {
if (--super->timer == 0) {
return TRUE;
} else {
const s8* ptr = &gUnk_080CD45C[this->direction >> 2];
s32 x = this->x.HALF.HI + this->hitbox->offset_x + ptr[0] * 6;
s32 y = this->y.HALF.HI + this->hitbox->offset_y + ptr[1] * 6;
const s8* ptr = &gUnk_080CD45C[super->direction >> 2];
s32 x = super->x.HALF.HI + super->hitbox->offset_x + ptr[0] * 6;
s32 y = super->y.HALF.HI + super->hitbox->offset_y + ptr[1] * 6;
u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u8* layer = super->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u32 ret = FALSE;
if (!sub_0806FC24(TILE(x, y), 9)) {
if (IsTileCollision(layer, x, y, 0)) {
@@ -350,50 +357,50 @@ bool32 sub_0802C0E8(Entity* this) {
}
}
void sub_0802C18C(Entity* this) {
this->field_0x78.HALF.LO--;
if ((this->field_0x78.HALF.LO & 7) == 0) {
Entity* ent = CreateObject(SPECIAL_FX, FX_DASH, 0x40);
if (ent != NULL) {
PositionRelative(this, ent, 0, Q_16_16(1.0));
void sub_0802C18C(HelmasaurEntity* this) {
this->unk_78--;
if ((this->unk_78 & 7) == 0) {
Entity* entity = CreateObject(SPECIAL_FX, FX_DASH, 0x40);
if (entity != NULL) {
PositionRelative(super, entity, 0, Q_16_16(1.0));
}
}
}
void sub_0802C1C0(Entity* this) {
this->action = 1;
this->timer = 30;
void sub_0802C1C0(HelmasaurEntity* this) {
super->action = 1;
super->timer = 30;
}
void sub_0802C1CC(Entity* this) {
const s8* ptr = &gUnk_080CD464[this->animationState << 2];
sub_08008796(this, 9, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1]);
sub_08008796(this, 9, this->x.HALF.HI + ptr[2], this->y.HALF.HI + ptr[3]);
void sub_0802C1CC(HelmasaurEntity* this) {
const s8* ptr = &gUnk_080CD464[super->animationState << 2];
sub_08008796(super, 9, super->x.HALF.HI + ptr[0], super->y.HALF.HI + ptr[1]);
sub_08008796(super, 9, super->x.HALF.HI + ptr[2], super->y.HALF.HI + ptr[3]);
}
void sub_0802C218(Entity* this) {
this->action = 6;
this->speed = Q_8_8(0.875);
this->zVelocity = Q_16_16(1.5);
void sub_0802C218(HelmasaurEntity* this) {
super->action = 6;
super->speed = Q_8_8(0.875);
super->zVelocity = Q_16_16(1.5);
}
// clang-format off
void (*const Helmasaur_Functions[])(Entity*) = {
void (*const Helmasaur_Functions[])(HelmasaurEntity*) = {
Helmasaur_OnTick,
Helmasaur_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(HelmasaurEntity*))GenericKnockback,
(void (*)(HelmasaurEntity*))GenericDeath,
(void (*)(HelmasaurEntity*))GenericConfused,
Helmasaur_OnGrabbed,
};
void (*const gUnk_080CD3FC[])(Entity*) = {
void (*const gUnk_080CD3FC[])(HelmasaurEntity*) = {
sub_0802BF78,
sub_0802BF98,
sub_0802BFF4,
};
void (*const gUnk_080CD408[])(Entity*) = {
void (*const gUnk_080CD408[])(HelmasaurEntity*) = {
sub_0802BD54,
sub_0802BD8C,
sub_0802BDE0,
@@ -405,13 +412,13 @@ void (*const gUnk_080CD408[])(Entity*) = {
sub_0802BF3C,
};
void (*const gUnk_080CD42C[])(Entity*) = {
void (*const gUnk_080CD42C[])(HelmasaurEntity*) = {
sub_0802BC74,
sub_0802BCA0,
sub_0802BCA8,
};
void (*const gUnk_080CD438[])(Entity*) = {
void (*const gUnk_080CD438[])(HelmasaurEntity*) = {
sub_0802BCFC,
sub_0802BCA0,
sub_0802BD08,
@@ -420,7 +427,7 @@ void (*const gUnk_080CD438[])(Entity*) = {
sub_0802BD28,
};
void (*const gUnk_080CD450[])(Entity*) = {
void (*const gUnk_080CD450[])(HelmasaurEntity*) = {
sub_0802BFD0,
sub_0802BFD8,
sub_0802BFE0,
+139 -129
View File
@@ -4,206 +4,216 @@
*
* @brief keaton enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
extern Entity* gUnk_020000B0;
void Keaton_OnTick(Entity*);
void Keaton_OnCollision(Entity*);
void Keaton_OnGrabbed(Entity*);
void Keaton_Init(Entity*);
void Keaton_Action1(Entity*);
void Keaton_Action2(Entity*);
void Keaton_Action3(Entity*);
void Keaton_Action4(Entity*);
void Keaton_Action5(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unused2[1];
/*0x7b*/ u8 unk_7b;
} KeatonEntity;
static void (*const Keaton_Functions[])(Entity*) = {
Keaton_OnTick, Keaton_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Keaton_OnGrabbed,
extern Entity* gUnk_020000B0;
void Keaton_OnTick(KeatonEntity*);
void Keaton_OnCollision(KeatonEntity*);
void Keaton_OnGrabbed(KeatonEntity*);
void Keaton_Init(KeatonEntity*);
void Keaton_Action1(KeatonEntity*);
void Keaton_Action2(KeatonEntity*);
void Keaton_Action3(KeatonEntity*);
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,
};
bool32 sub_080325E8(Entity* this);
void sub_08032650(Entity* this);
void sub_0803269C(Entity* this, u32 direction);
void sub_080326FC(Entity* this);
bool32 sub_0803271C(Entity* this);
void sub_08032740(Entity* this);
void sub_0803275C(Entity* this);
void sub_08032784(Entity* this);
void sub_08032794(Entity* this);
void sub_080327C8(Entity* this);
void sub_080327E0(Entity* this);
bool32 sub_080325E8(KeatonEntity* this);
void sub_08032650(KeatonEntity* this);
void sub_0803269C(KeatonEntity* this, u32 direction);
void sub_080326FC(KeatonEntity* this);
bool32 sub_0803271C(KeatonEntity* this);
void sub_08032740(KeatonEntity* this);
void sub_0803275C(KeatonEntity* this);
void sub_08032784(KeatonEntity* this);
void sub_08032794(KeatonEntity* this);
void sub_080327C8(KeatonEntity* this);
void sub_080327E0(KeatonEntity* this);
void Keaton(Entity* this) {
EnemyFunctionHandler(this, Keaton_Functions);
SetChildOffset(this, 0, 1, -18);
void Keaton(KeatonEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Keaton_Functions);
SetChildOffset(super, 0, 1, -18);
}
void Keaton_OnTick(Entity* this) {
static void (*const Keaton_Actions[])(Entity*) = {
void Keaton_OnTick(KeatonEntity* this) {
static void (*const Keaton_Actions[])(KeatonEntity*) = {
Keaton_Init, Keaton_Action1, Keaton_Action2, Keaton_Action3, Keaton_Action4, Keaton_Action5,
};
Keaton_Actions[this->action](this);
Keaton_Actions[super->action](this);
}
void Keaton_OnCollision(Entity* this) {
void Keaton_OnCollision(KeatonEntity* this) {
u32 var;
if (this->action != 3 && this->action != 4) {
this->action = 3;
this->timer = 12;
this->direction = DirectionTurnAround(DirectionRoundUp(this->knockbackDirection));
InitAnimationForceUpdate(this, this->direction >> 3);
} else if (this->contactFlags == 0xCC) {
if (this->confusedTime == 0) {
if (super->action != 3 && super->action != 4) {
super->action = 3;
super->timer = 12;
super->direction = DirectionTurnAround(DirectionRoundUp(super->knockbackDirection));
InitAnimationForceUpdate(super, super->direction >> 3);
} else if (super->contactFlags == 0xCC) {
if (super->confusedTime == 0) {
sub_0803275C(this);
}
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Keaton_Functions);
EnemyFunctionHandlerAfterCollision(super, Keaton_Functions);
}
void Keaton_OnGrabbed(Entity* this) {
void Keaton_OnGrabbed(KeatonEntity* this) {
}
void Keaton_Init(Entity* this) {
sub_0804A720(this);
this->animationState = 0;
InitAnimationForceUpdate(this, 0);
void Keaton_Init(KeatonEntity* this) {
sub_0804A720(super);
super->animationState = 0;
InitAnimationForceUpdate(super, 0);
sub_080326FC(this);
sub_08032740(this);
}
void Keaton_Action1(Entity* this) {
void Keaton_Action1(KeatonEntity* this) {
if (!sub_080325E8(this) && !sub_0803271C(this)) {
this->timer--;
if (this->timer == 0) {
super->timer--;
if (super->timer == 0) {
sub_08032650(this);
}
if (!ProcessMovement0(this)) {
this->timer = 1;
if (!ProcessMovement0(super)) {
super->timer = 1;
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
void Keaton_Action2(Entity* this) {
void Keaton_Action2(KeatonEntity* this) {
if (!sub_080325E8(this)) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
sub_080326FC(this);
sub_08032740(this);
}
}
}
void Keaton_Action3(Entity* this) {
if (this->timer != 0) {
this->timer--;
if (this->timer == 0) {
this->subtimer = 30;
this->animationState = this->direction / 8;
InitAnimationForceUpdate(this, this->animationState + 4);
void Keaton_Action3(KeatonEntity* this) {
if (super->timer != 0) {
super->timer--;
if (super->timer == 0) {
super->subtimer = 30;
super->animationState = super->direction / 8;
InitAnimationForceUpdate(super, super->animationState + 4);
} else {
return;
}
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(this);
this->subtimer--;
if (this->subtimer == 0) {
this->action = 4;
this->speed = 0x1E0;
this->field_0x76.HWORD = 0x46;
this->field_0x78.HWORD = 0;
*(((u8*)&this->field_0x7a) + 1) = 0;
UpdateAnimationSingleFrame(super);
UpdateAnimationSingleFrame(super);
super->subtimer--;
if (super->subtimer == 0) {
super->action = 4;
super->speed = 0x1E0;
this->unk_76 = 0x46;
this->unk_78 = 0;
this->unk_7b = 0;
sub_080327C8(this);
} else {
if ((this->subtimer & 0x3) == 0) {
if ((super->subtimer & 0x3) == 0) {
sub_08032794(this);
}
}
}
void Keaton_Action4(Entity* this) {
if (this->child && (this->child->contactFlags & 0x80)) {
void Keaton_Action4(KeatonEntity* this) {
if (super->child && (super->child->contactFlags & 0x80)) {
sub_0803275C(this);
return;
}
if (--this->field_0x76.HWORD == 0 || !ProcessMovement2(this)) {
if (--this->unk_76 == 0 || !ProcessMovement2(super)) {
sub_0803275C(this);
return;
}
UpdateAnimationSingleFrame(this);
if ((this->field_0x76.HWORD & 0x7) == 0) {
UpdateAnimationSingleFrame(super);
if ((this->unk_76 & 0x7) == 0) {
sub_08032794(this);
}
}
void Keaton_Action5(Entity* this) {
this->timer--;
if ((this->timer == 0) && !sub_080325E8(this)) {
void Keaton_Action5(KeatonEntity* this) {
super->timer--;
if ((super->timer == 0) && !sub_080325E8(this)) {
sub_08032784(this);
}
}
u32 sub_080325E8(Entity* this) {
if ((sub_08049FA0(this) && sub_08049FDC(this, 1)) && (EntityInRectRadius(this, gUnk_020000B0, 0x68, 0x40) != 0)) {
if (((GetFacingDirection(this, gUnk_020000B0) - (DirectionRound(this->frame)) + 2) & 0x1F) < 5) {
this->action = 3;
this->timer = 12;
this->direction = DirectionRound(this->frame);
u32 sub_080325E8(KeatonEntity* this) {
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;
super->direction = DirectionRound(super->frame);
return TRUE;
}
}
return FALSE;
}
void sub_08032650(Entity* this) {
void sub_08032650(KeatonEntity* this) {
static const u8 gUnk_080CE7E0[] = { 60, 60, 90, 90, 90, 90, 120, 120, 120, 120, 120, 120, 120, 120, 150, 150 };
u32 rand = Random();
this->timer = gUnk_080CE7E0[rand & 0xF];
if (!((sub_08049FA0(this) == 0) && ((rand >> 8 & 1) == 0))) {
this->direction = DirectionRound(rand >> 0x10);
super->timer = gUnk_080CE7E0[rand & 0xF];
if (!((sub_08049FA0(super) == 0) && ((rand >> 8 & 1) == 0))) {
super->direction = DirectionRound(rand >> 0x10);
} else {
this->direction = DirectionRoundUp(sub_08049EE4(this));
super->direction = DirectionRoundUp(sub_08049EE4(super));
}
sub_0803269C(this, this->direction);
sub_0803269C(this, super->direction);
}
void sub_0803269C(Entity* this, u32 direction) {
void sub_0803269C(KeatonEntity* this, u32 direction) {
u32 uVar1;
if (((direction - 3) & 7) < 3) {
uVar1 = DirectionToAnimationState(direction);
if (((this->animationState - uVar1) & 3) > 1) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, (this->animIndex & 0xFC) + uVar1);
if (((super->animationState - uVar1) & 3) > 1) {
super->animationState = uVar1;
InitAnimationForceUpdate(super, (super->animIndex & 0xFC) + uVar1);
}
} else {
uVar1 = DirectionToAnimationState(direction);
if (uVar1 != this->animationState) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, (this->animIndex & 0xFC) + uVar1);
if (uVar1 != super->animationState) {
super->animationState = uVar1;
InitAnimationForceUpdate(super, (super->animIndex & 0xFC) + uVar1);
}
}
}
void sub_080326FC(Entity* this) {
void sub_080326FC(KeatonEntity* this) {
static const u16 gUnk_080CE7F0[] = { 0xd2, 0xd2, 0xf0, 0xf0, 0x10e, 0x10e, 0x10e, 0x10e,
0x12c, 0x12c, 0x12c, 0x12c, 0x12c, 0x12c, 0x12c, 0x12c };
this->field_0x74.HWORD = gUnk_080CE7F0[Random() & 0xF];
this->unk_74 = gUnk_080CE7F0[Random() & 0xF];
}
bool32 sub_0803271C(Entity* this) {
this->field_0x74.HWORD--;
if (this->field_0x74.HWORD == 0) {
bool32 sub_0803271C(KeatonEntity* this) {
this->unk_74--;
if (this->unk_74 == 0) {
sub_08032784(this);
return TRUE;
} else {
@@ -211,52 +221,52 @@ bool32 sub_0803271C(Entity* this) {
}
}
void sub_08032740(Entity* this) {
this->action = 1;
this->speed = 0x80;
InitializeAnimation(this, this->animationState);
void sub_08032740(KeatonEntity* this) {
super->action = 1;
super->speed = 0x80;
InitializeAnimation(super, super->animationState);
sub_08032650(this);
}
void sub_0803275C(Entity* this) {
this->action = 5;
this->timer = 45;
this->speed = 0x80;
InitAnimationForceUpdate(this, this->animationState);
sub_0803269C(this, this->direction);
void sub_0803275C(KeatonEntity* this) {
super->action = 5;
super->timer = 45;
super->speed = 0x80;
InitAnimationForceUpdate(super, super->animationState);
sub_0803269C(this, super->direction);
sub_080327E0(this);
}
void sub_08032784(Entity* this) {
this->action = 2;
InitAnimationForceUpdate(this, this->animationState + 8);
void sub_08032784(KeatonEntity* this) {
super->action = 2;
InitAnimationForceUpdate(super, super->animationState + 8);
}
void sub_08032794(Entity* this) {
void sub_08032794(KeatonEntity* this) {
Entity* target;
const s8* temp;
static const s8 gUnk_080CE810[] = { 0, 2, -4, 0, 0, -11, 4, 0 };
target = CreateFx(this, FX_DASH, 0x40);
target = CreateFx(super, FX_DASH, 0x40);
if (target != NULL) {
temp = &gUnk_080CE810[this->animationState * 2];
PositionRelative(this, target, Q_16_16(temp[0]), Q_16_16(temp[1]));
temp = &gUnk_080CE810[super->animationState * 2];
PositionRelative(super, target, Q_16_16(temp[0]), Q_16_16(temp[1]));
}
}
void sub_080327C8(Entity* this) {
void sub_080327C8(KeatonEntity* this) {
Entity* child;
child = CreateProjectileWithParent(this, KEATON_DAGGER, 0);
child = CreateProjectileWithParent(super, KEATON_DAGGER, 0);
if (child != NULL) {
child->parent = this;
this->child = child;
child->parent = super;
super->child = child;
}
}
void sub_080327E0(Entity* this) {
if (this->child != NULL) {
this->child->parent = NULL;
this->child = NULL;
void sub_080327E0(KeatonEntity* this) {
if (super->child != NULL) {
super->child->parent = NULL;
super->child = NULL;
}
}
-1
View File
@@ -4,7 +4,6 @@
*
* @brief Keese enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
+153 -145
View File
@@ -4,23 +4,31 @@
*
* @brief Lakitu enemy
*/
#include "global.h"
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
#include "player.h"
extern void (*const LakituActionFuncs[])(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;
} LakituEntity;
extern void (*const LakituActionFuncs[])(LakituEntity*);
// Forward references to functions in lakitu.c
extern void sub_0803CAD0(Entity*);
extern void sub_0803CBAC(Entity*);
extern void sub_0803CA84(Entity*, u32);
extern bool32 sub_0803CA4C(Entity*);
extern bool32 sub_0803CB04(Entity*);
extern void Lakitu_SpawnLightning(Entity*);
extern void sub_0803CB34(Entity*);
extern void sub_0803CC08(Entity* this);
extern void sub_0803CAD0(LakituEntity* this);
extern void sub_0803CBAC(LakituEntity* this);
extern void sub_0803CA84(LakituEntity* this, u32);
extern bool32 sub_0803CA4C(LakituEntity* this);
extern bool32 sub_0803CB04(LakituEntity* this);
extern void Lakitu_SpawnLightning(LakituEntity* this);
extern void sub_0803CB34(LakituEntity* this);
extern void sub_0803CC08(LakituEntity* this);
enum {
INIT,
@@ -39,36 +47,36 @@ typedef struct {
} PACKED OffsetCoords;
// Variables
extern void (*const Lakitu_Functions[])(Entity*);
extern void (*const gUnk_080D0128[])(Entity*);
extern void (*const gUnk_080D0148[])(Entity*);
extern void (*const Lakitu_Functions[])(LakituEntity*);
extern void (*const gUnk_080D0128[])(LakituEntity*);
extern void (*const gUnk_080D0148[])(LakituEntity*);
extern const OffsetCoords gUnk_080D0154[];
void Lakitu(Entity* this) {
EnemyFunctionHandler(this, Lakitu_Functions);
void Lakitu(LakituEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Lakitu_Functions);
SetChildOffset(this, 0, 1, -16);
SetChildOffset(super, 0, 1, -16);
}
void Lakitu_OnTick(Entity* this) {
if (this->action != 0 && this->action != 7) {
void Lakitu_OnTick(LakituEntity* this) {
if (super->action != 0 && super->action != 7) {
sub_0803CAD0(this);
}
LakituActionFuncs[this->action](this);
LakituActionFuncs[super->action](this);
}
void Lakitu_OnCollision(Entity* this) {
if ((this->contactFlags & 0x7f) == 0x1d) {
this->zVelocity = Q_16_16(2.0);
void Lakitu_OnCollision(LakituEntity* this) {
if ((super->contactFlags & 0x7f) == 0x1d) {
super->zVelocity = Q_16_16(2.0);
sub_0803CBAC(this);
} else {
if (this->hitType == 0x43) {
Entity* fx = CreateFx(this, FX_DEATH, 0);
if (super->hitType == 0x43) {
Entity* fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
u32 angle = (this->knockbackDirection ^ 0x10) << 3;
u32 angle = (super->knockbackDirection ^ 0x10) << 3;
s32 sine;
sine = gSineTable[angle];
@@ -88,163 +96,163 @@ void Lakitu_OnCollision(Entity* this) {
}
}
if (this->confusedTime) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Lakitu_Functions);
EnemyFunctionHandlerAfterCollision(super, Lakitu_Functions);
}
void Lakitu_OnGrabbed(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080D0148[this->subAction](this);
void Lakitu_OnGrabbed(LakituEntity* this) {
if (sub_0806F520(super)) {
gUnk_080D0148[super->subAction](this);
}
}
void sub_0803C844(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_0803C844(LakituEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_0803C850(Entity* this) {
Entity* cloud = this->child;
void sub_0803C850(LakituEntity* this) {
Entity* cloud = super->child;
if (cloud != NULL) {
cloud->spriteOffsetX = this->spriteOffsetX;
cloud->spriteOffsetX = super->spriteOffsetX;
}
sub_0806F4E8(this);
sub_0806F4E8(super);
}
void sub_0803C86C(Entity* this) {
void sub_0803C86C(LakituEntity* this) {
sub_0803CBAC(this);
this->child = NULL;
super->child = NULL;
}
void Lakitu_Initialize(Entity* this) {
Entity* cloud = CreateProjectileWithParent(this, 17, 0);
void Lakitu_Initialize(LakituEntity* this) {
Entity* cloud = CreateProjectileWithParent(super, 17, 0);
if (cloud == NULL) {
return;
}
cloud->parent = this;
this->child = cloud;
cloud->parent = super;
super->child = cloud;
sub_0804A720(this);
sub_0804A720(super);
this->action = HIDDEN;
super->action = HIDDEN;
this->z.HALF.HI = -2;
super->z.HALF.HI = -2;
this->spriteOffsetY = 0xff;
super->spriteOffsetY = 0xff;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
}
void Lakitu_Hide(Entity* this) {
void Lakitu_Hide(LakituEntity* this) {
sub_0803CA84(this, 0);
if (sub_0803CA4C(this)) {
this->action = END_HIDE;
this->spriteSettings.draw = 1;
super->action = END_HIDE;
super->spriteSettings.draw = 1;
}
}
void Lakitu_EndHide(Entity* this) {
UpdateAnimationSingleFrame(this);
void Lakitu_EndHide(LakituEntity* this) {
UpdateAnimationSingleFrame(super);
if (this->frame & ANIM_DONE) {
this->action = IDLE;
this->timer = 60;
if (super->frame & ANIM_DONE) {
super->action = IDLE;
super->timer = 60;
this->hitType = 0x42;
super->hitType = 0x42;
InitAnimationForceUpdate(this, this->animationState + 4);
InitAnimationForceUpdate(super, super->animationState + 4);
}
}
void Lakitu_Idle(Entity* this) {
void Lakitu_Idle(LakituEntity* this) {
if (sub_0803CB04(this)) {
return;
}
if (!sub_0803CA4C(this)) {
this->action = BEGIN_HIDE;
super->action = BEGIN_HIDE;
this->hitType = 0x43;
InitAnimationForceUpdate(this, this->animationState + 0xc);
super->hitType = 0x43;
InitAnimationForceUpdate(super, super->animationState + 0xc);
} else {
sub_0803CA84(this, 4);
}
}
void Lakitu_BeginHide(Entity* this) {
UpdateAnimationSingleFrame(this);
void Lakitu_BeginHide(LakituEntity* this) {
UpdateAnimationSingleFrame(super);
if (this->frame & ANIM_DONE) {
this->action = HIDDEN;
this->spriteSettings.draw = 0;
if (super->frame & ANIM_DONE) {
super->action = HIDDEN;
super->spriteSettings.draw = 0;
InitAnimationForceUpdate(this, this->animationState);
InitAnimationForceUpdate(super, super->animationState);
}
}
void Lakitu_Lightning(Entity* this) {
UpdateAnimationSingleFrame(this);
void Lakitu_Lightning(LakituEntity* this) {
UpdateAnimationSingleFrame(super);
if (!(this->frame & ANIM_DONE)) {
if (!(super->frame & ANIM_DONE)) {
return;
}
Lakitu_SpawnLightning(this);
this->action = LIGHTNING_DELAY;
this->hitType = 0x42;
super->action = LIGHTNING_DELAY;
super->hitType = 0x42;
if ((Random() & 1) && !this->field_0x78.HALF.HI) {
this->timer = 15;
if ((Random() & 1) && !this->unk_79) {
super->timer = 15;
this->field_0x78.HALF.HI = TRUE;
this->unk_79 = TRUE;
} else {
this->timer = 30;
super->timer = 30;
this->field_0x78.HALF.HI = FALSE;
this->unk_79 = FALSE;
InitAnimationForceUpdate(this->child, this->animationState);
InitAnimationForceUpdate(super->child, super->animationState);
}
}
void Lakitu_LightningDelay(Entity* this) {
this->timer--;
void Lakitu_LightningDelay(LakituEntity* this) {
super->timer--;
if (this->timer != 0) {
if (super->timer != 0) {
return;
}
if (this->field_0x78.HALF.HI == 1) {
if (this->unk_79 == 1) {
sub_0803CB34(this);
} else {
this->action = IDLE;
this->timer = 180;
super->action = IDLE;
super->timer = 180;
InitAnimationForceUpdate(this, this->animationState + 4);
InitAnimationForceUpdate(super, super->animationState + 4);
}
}
void Lakitu_Cloudless(Entity* this) {
if (GravityUpdate(this, Q_8_8(24.0)) == 0 && this->animIndex <= 19) {
InitAnimationForceUpdate(this, this->animationState + 20);
void Lakitu_Cloudless(LakituEntity* this) {
if (GravityUpdate(super, Q_8_8(24.0)) == 0 && super->animIndex <= 19) {
InitAnimationForceUpdate(super, super->animationState + 20);
this->spritePriority.b1 = 0;
super->spritePriority.b1 = 0;
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
sub_0803CC08(this);
}
bool32 sub_0803CA4C(Entity* this) {
if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) {
if (EntityInRectRadius(this, &gPlayerEntity, 0x70, 0x50)) {
bool32 sub_0803CA4C(LakituEntity* this) {
if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) {
if (EntityInRectRadius(super, &gPlayerEntity, 0x70, 0x50)) {
return TRUE;
}
}
@@ -252,158 +260,158 @@ bool32 sub_0803CA4C(Entity* this) {
return FALSE;
}
void sub_0803CA84(Entity* this, u32 unkParameter) {
u32 altAnimState = GetFacingDirection(this, &gPlayerEntity);
void sub_0803CA84(LakituEntity* this, u32 unkParameter) {
u32 altAnimState = GetFacingDirection(super, &gPlayerEntity);
if (((altAnimState - 3) & 7) > 2 || ((this->animationState - (altAnimState >> 3)) & 3) > 1) {
if (((altAnimState - 3) & 7) > 2 || ((super->animationState - (altAnimState >> 3)) & 3) > 1) {
altAnimState = DirectionRoundUp(altAnimState) >> 3;
if (altAnimState != this->animationState) {
this->animationState = altAnimState;
if (altAnimState != super->animationState) {
super->animationState = altAnimState;
InitAnimationForceUpdate(this, altAnimState + unkParameter);
InitAnimationForceUpdate(this->child, altAnimState);
InitAnimationForceUpdate(super, altAnimState + unkParameter);
InitAnimationForceUpdate(super->child, altAnimState);
}
}
}
void sub_0803CAD0(Entity* this) {
if (!EntityWithinDistance(this, this->field_0x74.HWORD, this->field_0x76.HWORD, 1)) {
this->direction =
CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74.HWORD, this->field_0x76.HWORD);
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);
ProcessMovement2(this);
ProcessMovement2(super);
}
}
bool32 sub_0803CB04(Entity* this) {
bool32 sub_0803CB04(LakituEntity* this) {
bool32 ret;
u8 delay;
delay = --this->timer;
delay = --super->timer;
if (delay != 0) {
ret = FALSE;
} else {
sub_0803CB34(this);
this->field_0x78.HALF.HI = delay;
this->unk_79 = delay;
InitAnimationForceUpdate(this->child, this->animationState + 4);
InitAnimationForceUpdate(super->child, super->animationState + 4);
ret = TRUE;
}
return ret;
}
void sub_0803CB34(Entity* this) {
this->action = LIGHTNING_THROW;
this->hitType = 0xa6;
void sub_0803CB34(LakituEntity* this) {
super->action = LIGHTNING_THROW;
super->hitType = 0xa6;
this->field_0x78.HALF.LO = GetFacingDirection(this, &gPlayerEntity);
this->unk_78 = GetFacingDirection(super, &gPlayerEntity);
InitAnimationForceUpdate(this, this->animationState + 8);
InitAnimationForceUpdate(super, super->animationState + 8);
}
void Lakitu_SpawnLightning(Entity* this) {
void Lakitu_SpawnLightning(LakituEntity* this) {
Entity* lightning;
const OffsetCoords* offset;
lightning = CreateProjectileWithParent(this, LAKITU_LIGHTNING, 0);
lightning = CreateProjectileWithParent(super, LAKITU_LIGHTNING, 0);
if (lightning == NULL) {
return;
}
offset = &gUnk_080D0154[this->animationState];
offset = &gUnk_080D0154[super->animationState];
lightning->direction = this->field_0x78.HALF.LO;
lightning->direction = this->unk_78;
PositionRelative(this, lightning, Q_16_16(offset->x), Q_16_16(offset->y));
PositionRelative(super, lightning, Q_16_16(offset->x), Q_16_16(offset->y));
EnqueueSFX(SFX_193);
}
void sub_0803CBAC(Entity* this) {
void sub_0803CBAC(LakituEntity* this) {
Entity* cloud;
cloud = this->child;
cloud = super->child;
if (cloud != NULL) {
cloud->flags |= ENT_COLLIDE;
cloud->hitType = 0x43;
}
this->action = CLOUDLESS;
this->spriteSettings.draw = 1;
super->action = CLOUDLESS;
super->spriteSettings.draw = 1;
this->spritePriority.b1 = 1;
super->spritePriority.b1 = 1;
this->flags2 &= 0x7b;
super->flags2 &= 0x7b;
this->hitType = 0x42;
super->hitType = 0x42;
InitAnimationForceUpdate(this, this->animationState + 16);
InitAnimationForceUpdate(super, super->animationState + 16);
}
void sub_0803CC08(Entity* this) {
void sub_0803CC08(LakituEntity* this) {
Entity* cloud;
Entity* fx;
const s32 diff = Q_8_8(3.0 / 128.0);
cloud = this->child;
cloud = super->child;
if (cloud == NULL) {
return;
}
if ((u32)(cloud->z.HALF.HI - this->z.HALF.HI) > 2) {
if ((u32)(cloud->z.HALF.HI - super->z.HALF.HI) > 2) {
return;
}
if (this->zVelocity >= 0) {
if (super->zVelocity >= 0) {
return;
}
if (!EntityWithinDistance(this, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
if (!EntityWithinDistance(super, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
return;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI += diff;
fx->y.HALF.HI += diff;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI -= diff;
fx->y.HALF.HI += diff;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI += diff;
fx->y.HALF.HI -= diff;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI -= diff;
fx->y.HALF.HI -= diff;
}
this->child = NULL;
super->child = NULL;
DeleteEntity(cloud);
}
void (*const Lakitu_Functions[])(Entity*) = {
Lakitu_OnTick, Lakitu_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Lakitu_OnGrabbed,
void (*const Lakitu_Functions[])(LakituEntity*) = {
Lakitu_OnTick, Lakitu_OnCollision, (void (*)(LakituEntity*))GenericKnockback, (void (*)(LakituEntity*))GenericDeath, (void (*)(LakituEntity*))GenericConfused, Lakitu_OnGrabbed,
};
void (*const LakituActionFuncs[])(Entity*) = {
void (*const LakituActionFuncs[])(LakituEntity*) = {
Lakitu_Initialize, Lakitu_Hide, Lakitu_EndHide, Lakitu_Idle,
Lakitu_BeginHide, Lakitu_Lightning, Lakitu_LightningDelay, Lakitu_Cloudless,
};
void (*const gUnk_080D0148[])(Entity*) = {
void (*const gUnk_080D0148[])(LakituEntity*) = {
sub_0803C844,
sub_0803C850,
sub_0803C86C,
+77 -67
View File
@@ -4,58 +4,66 @@
*
* @brief Lakitu Cloud enemy
*/
#include "global.h"
#define NENT_DEPRECATED
#include "asm.h"
#include "entity.h"
#include "player.h"
#include "effects.h"
#include "enemy.h"
#include "physics.h"
#include "room.h"
#include "entity.h"
#include "object.h"
#include "physics.h"
#include "player.h"
#include "room.h"
extern void (*const LakituCloud_Functions[6])(Entity*);
extern void (*const gUnk_080D0430[3])(Entity*);
extern void (*const gUnk_080D043C[3])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u8 unused2[2];
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
} LakituCloudEntity;
void sub_0803CE14(Entity*);
void sub_0803CE3C(Entity*);
extern void (*const LakituCloud_Functions[6])(LakituCloudEntity*);
extern void (*const gUnk_080D0430[3])(LakituCloudEntity*);
extern void (*const gUnk_080D043C[3])(LakituCloudEntity*);
void LakituCloud(Entity* this) {
LakituCloud_Functions[GetNextFunction(this)](this);
void sub_0803CE14(LakituCloudEntity*);
void sub_0803CE3C(LakituCloudEntity*);
void LakituCloud(LakituCloudEntity* this) {
LakituCloud_Functions[GetNextFunction(super)](this);
}
void LakituCloud_OnTick(Entity* this) {
gUnk_080D0430[this->action](this);
void LakituCloud_OnTick(LakituCloudEntity* this) {
gUnk_080D0430[super->action](this);
}
void LakituCloud_OnKnockback(Entity* this) {
this->knockbackDuration = 0;
void LakituCloud_OnKnockback(LakituCloudEntity* this) {
super->knockbackDuration = 0;
LakituCloud_OnTick(this);
}
void LakituCloud_OnGrabbed(Entity* this) {
if (!sub_0806F520(this)) {
if (this->subAction == 2) {
void LakituCloud_OnGrabbed(LakituCloudEntity* this) {
if (!sub_0806F520(super)) {
if (super->subAction == 2) {
sub_0803CE3C(this);
}
} else {
gUnk_080D043C[this->subAction](this);
gUnk_080D043C[super->subAction](this);
}
}
void sub_0803CD2C(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_0803CD2C(LakituCloudEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_0803CD38(Entity* this) {
sub_0806F4E8(this);
void sub_0803CD38(LakituCloudEntity* this) {
sub_0806F4E8(super);
}
void sub_0803CD40(Entity* this) {
if (!sub_0806F3E4(this)) {
void sub_0803CD40(LakituCloudEntity* this) {
if (!sub_0806F3E4(super)) {
return;
}
@@ -67,101 +75,103 @@ void sub_0803CD40(Entity* this) {
sub_0803CE3C(this);
}
void sub_0803CD6C(Entity* this) {
void sub_0803CD6C(LakituCloudEntity* this) {
Entity* lakitu;
this->action = 1;
this->z.HALF.HI = -2;
super->action = 1;
super->z.HALF.HI = -2;
// Set parent to lakitu
lakitu = GetCurrentRoomProperty(this->type);
this->child = lakitu;
this->parent = lakitu;
lakitu = GetCurrentRoomProperty(super->type);
super->child = lakitu;
super->parent = lakitu;
this->field_0x78.HWORD = this->x.HALF.HI;
this->field_0x7a.HWORD = this->y.HALF.HI;
this->unk_78 = super->x.HALF.HI;
this->unk_7a = super->y.HALF.HI;
InitAnimationForceUpdate(this, 4);
InitAnimationForceUpdate(super, 4);
sub_0803CE14(this);
}
void sub_0803CDA8(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_0803CDA8(LakituCloudEntity* this) {
UpdateAnimationSingleFrame(super);
if ((this->direction & 0x80) == 0) {
LinearMoveUpdate(this);
if ((super->direction & 0x80) == 0) {
LinearMoveUpdate(super);
}
if (--this->field_0x74.HWORD << 0x10 == 0) {
if (--this->unk_74 << 0x10 == 0) {
sub_0803CE14(this);
}
}
void sub_0803CDD8(Entity* this) {
void sub_0803CDD8(LakituCloudEntity* this) {
u8 one;
u8 draw;
draw = this->spriteSettings.draw;
draw = super->spriteSettings.draw;
one = 1;
this->spriteSettings.draw = draw ^ one;
super->spriteSettings.draw = draw ^ one;
this->timer--;
super->timer--;
if (this->timer == 0) {
this->action = 1;
if (super->timer == 0) {
super->action = 1;
COLLISION_ON(this);
COLLISION_ON(super);
this->spriteSettings.draw = one;
super->spriteSettings.draw = one;
}
}
void sub_0803CE14(Entity* this) {
void sub_0803CE14(LakituCloudEntity* this) {
u8 direction;
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
direction = this->direction;
direction = super->direction;
if (direction & 0x80) {
return;
}
direction = direction / 8 + 4;
InitAnimationForceUpdate(this, direction);
InitAnimationForceUpdate(super, direction);
}
void sub_0803CE3C(Entity* this) {
CreateFx(this, FX_DEATH, 0);
void sub_0803CE3C(LakituCloudEntity* this) {
CreateFx(super, FX_DEATH, 0);
this->action = 2;
this->timer = 60;
super->action = 2;
super->timer = 60;
COLLISION_OFF(this);
COLLISION_OFF(super);
this->gustJarState &= 0xfb;
super->gustJarState &= 0xfb;
this->x.HALF.HI = this->field_0x78.HWORD;
this->y.HALF.HI = this->field_0x7a.HWORD;
super->x.HALF.HI = this->unk_78;
super->y.HALF.HI = this->unk_7a;
this->child = this->parent;
super->child = super->parent;
sub_0803CE14(this);
}
void (*const LakituCloud_Functions[])(Entity*) = {
void (*const LakituCloud_Functions[])(LakituCloudEntity*) = {
LakituCloud_OnTick, LakituCloud_OnTick, LakituCloud_OnKnockback,
GenericDeath, GenericConfused, LakituCloud_OnGrabbed,
(void (*)(LakituCloudEntity*))
GenericDeath, (void (*)(LakituCloudEntity*))
GenericConfused, LakituCloud_OnGrabbed,
};
void (*const gUnk_080D0430[])(Entity*) = {
void (*const gUnk_080D0430[])(LakituCloudEntity*) = {
sub_0803CD6C,
sub_0803CDA8,
sub_0803CDD8,
};
void (*const gUnk_080D043C[])(Entity*) = {
void (*const gUnk_080D043C[])(LakituCloudEntity*) = {
sub_0803CD2C,
sub_0803CD38,
sub_0803CD40,
+84 -78
View File
@@ -4,20 +4,26 @@
*
* @brief Leever enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
} LeeverEntity;
extern u32 sub_080B1B18(s32, s32, u32);
extern u32 sub_080B1AB4(s32, s32, u32);
extern Entity* gUnk_020000B0;
bool32 Leever_PlayerInRange(Entity*, s32);
void Leever_Move(Entity*);
void Leever_Move(LeeverEntity*);
extern void (*const Leever_Functions[])(Entity*);
extern void (*const gLeeverActions[])(Entity*);
extern void (*const Leever_Functions[])(LeeverEntity*);
extern void (*const gLeeverActions[])(LeeverEntity*);
extern const s8 gLeeverDrift[];
extern const u16 gUnk_080CA4CA[];
@@ -32,95 +38,95 @@ enum {
LeeverForm_Blue,
};
void Leever(Entity* this) {
EnemyFunctionHandler(this, Leever_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Leever(LeeverEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Leever_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void Leever_OnTick(Entity* this) {
gLeeverActions[this->action](this);
void Leever_OnTick(LeeverEntity* this) {
gLeeverActions[super->action](this);
}
void Leever_OnCollision(Entity* this) {
if (this->contactFlags == 0x80) {
if (this->action == 3) {
this->field_0x74.HWORD = 1;
void Leever_OnCollision(LeeverEntity* this) {
if (super->contactFlags == 0x80) {
if (super->action == 3) {
this->unk_74 = 1;
}
} else {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
}
EnemyFunctionHandlerAfterCollision(this, Leever_Functions);
EnemyFunctionHandlerAfterCollision(super, Leever_Functions);
}
void Leever_OnDeath(Entity* this) {
if (this->type == LeeverForm_Red) {
GenericDeath(this);
void Leever_OnDeath(LeeverEntity* this) {
if (super->type == LeeverForm_Red) {
GenericDeath(super);
} else {
CreateDeathFx(this, 0xf1, 0);
CreateDeathFx(super, 0xf1, 0);
}
}
void Leever_Initialize(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->timer = Random();
void Leever_Initialize(LeeverEntity* this) {
sub_0804A720(super);
super->action = 1;
super->timer = Random();
}
void Leever_Idle(Entity* this) {
if (--this->timer == 0) {
if (Leever_PlayerInRange(this, Random() & 0x1f)) {
this->action = 2;
this->spriteSettings.draw = TRUE;
this->direction = (GetFacingDirection(this, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & 0x1f;
InitializeAnimation(this, LeeverAnimation_DigUp);
UpdateSpriteForCollisionLayer(this);
void Leever_Idle(LeeverEntity* this) {
if (--super->timer == 0) {
if (Leever_PlayerInRange(super, Random() & 0x1f)) {
super->action = 2;
super->spriteSettings.draw = TRUE;
super->direction = (GetFacingDirection(super, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & 0x1f;
InitializeAnimation(super, LeeverAnimation_DigUp);
UpdateSpriteForCollisionLayer(super);
} else {
this->timer = DirectionRound(Random()) + 8;
super->timer = DirectionRound(Random()) + 8;
}
}
}
void Leever_DigUp(Entity* this) {
GetNextFrame(this);
void Leever_DigUp(LeeverEntity* this) {
GetNextFrame(super);
if (this->frame & ANIM_DONE) {
this->action = 3;
if (this->type == LeeverForm_Red) {
this->field_0x74.HWORD = 180;
if (super->frame & ANIM_DONE) {
super->action = 3;
if (super->type == LeeverForm_Red) {
this->unk_74 = 180;
} else {
this->field_0x74.HWORD = 110;
this->unk_74 = 110;
}
InitializeAnimation(this, LeeverAnimation_Attack);
} else if ((this->frame & 1) != 0) {
this->frame &= 0xfe;
COLLISION_ON(this);
InitializeAnimation(super, LeeverAnimation_Attack);
} else if ((super->frame & 1) != 0) {
super->frame &= 0xfe;
COLLISION_ON(super);
}
}
void Leever_Attack(Entity* this) {
void Leever_Attack(LeeverEntity* this) {
Leever_Move(this);
GetNextFrame(this);
GetNextFrame(super);
if (--this->field_0x74.HWORD == 0) {
this->action = 4;
COLLISION_OFF(this);
InitializeAnimation(this, LeeverAnimation_DigDown);
if (--this->unk_74 == 0) {
super->action = 4;
COLLISION_OFF(super);
InitializeAnimation(super, LeeverAnimation_DigDown);
}
}
void Leever_DigDown(Entity* this) {
void Leever_DigDown(LeeverEntity* this) {
Leever_Move(this);
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = 240;
this->spriteSettings.draw = FALSE;
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = 240;
super->spriteSettings.draw = FALSE;
}
}
u32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
u32 sub_0801FDE4(Entity* entity, s32 x, s32 y) {
u32 uVar3;
const u16* puVar4;
@@ -130,9 +136,9 @@ u32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
uVar3 = sub_080B1AB4(x, y, gUnk_020000B0->collisionLayer);
for (puVar4 = gUnk_080CA4CA; *puVar4 != (u16)-1;) {
if (*puVar4++ == uVar3) {
ent->x.HALF.HI = (x & 0xfff0) + 8;
ent->y.HALF.HI = (y & 0xfff0) + 8;
ent->collisionLayer = gUnk_020000B0->collisionLayer;
entity->x.HALF.HI = (x & 0xfff0) + 8;
entity->y.HALF.HI = (y & 0xfff0) + 8;
entity->collisionLayer = gUnk_020000B0->collisionLayer;
return 1;
}
}
@@ -140,12 +146,12 @@ u32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
}
}
bool32 Leever_PlayerInRange(Entity* ent, s32 arg2) {
bool32 Leever_PlayerInRange(Entity* entity, s32 arg2) {
s32 sin, cos;
s32 x, y;
u32 i;
if (sub_08049FDC(ent, 1) == 0) {
if (sub_08049FDC(entity, 1) == 0) {
return 0;
} else {
x = gUnk_020000B0->x.WORD;
@@ -155,7 +161,7 @@ bool32 Leever_PlayerInRange(Entity* ent, s32 arg2) {
for (i = 0; i < 8; i++) {
x += sin;
y += -cos;
if (sub_0801FDE4(ent, x >> 0x10, y >> 0x10) == 0) {
if (sub_0801FDE4(entity, x >> 0x10, y >> 0x10) == 0) {
return 0;
}
}
@@ -163,37 +169,37 @@ bool32 Leever_PlayerInRange(Entity* ent, s32 arg2) {
}
}
void Leever_Move(Entity* this) {
if (sub_08049FDC(this, 1) == 0) {
this->field_0x74.HWORD = 1;
void Leever_Move(LeeverEntity* this) {
if (sub_08049FDC(super, 1) == 0) {
this->unk_74 = 1;
}
this->speed = (this->frame & 0xf) * 0x20;
if (this->type == LeeverForm_Red) {
if ((this->subtimer++ & 0xf) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
super->speed = (super->frame & 0xf) * 0x20;
if (super->type == LeeverForm_Red) {
if ((super->subtimer++ & 0xf) == 0) {
sub_08004596(super, sub_0800132C(super, gUnk_020000B0));
}
} else {
this->speed += 0x40;
if ((this->subtimer++ & 0x7) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
super->speed += 0x40;
if ((super->subtimer++ & 0x7) == 0) {
sub_08004596(super, sub_0800132C(super, gUnk_020000B0));
}
}
ProcessMovement0(this);
ProcessMovement0(super);
}
// clang-format off
void (*const Leever_Functions[])(Entity*) = {
void (*const Leever_Functions[])(LeeverEntity*) = {
Leever_OnTick,
Leever_OnCollision,
GenericKnockback,
(void (*)(LeeverEntity*))GenericKnockback,
Leever_OnDeath,
GenericConfused,
(void (*)(LeeverEntity*))GenericConfused,
Leever_OnTick,
};
void (*const gLeeverActions[])(Entity*) = {
void (*const gLeeverActions[])(LeeverEntity*) = {
Leever_Initialize,
Leever_Idle,
Leever_DigUp,
+3 -4
View File
@@ -4,13 +4,12 @@
*
* @brief Like Like enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "message.h"
#include "save.h"
#include "object.h"
#include "item.h"
#include "message.h"
#include "object.h"
#include "save.h"
typedef struct {
Entity base;
+265 -243
View File
@@ -4,49 +4,71 @@
*
* @brief Madderpillar enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "hitbox.h"
void sub_08029E0C(Entity*);
void sub_08029EEC(Entity*);
void sub_0802A098(Entity*);
void sub_0802A16C(Entity*);
void sub_0802A058(Entity*);
bool32 sub_0802A14C(Entity*);
void sub_0802A18C(Entity*);
bool32 sub_08029FE4(Entity*);
void sub_08029FB4(Entity*, u32, u32);
void sub_0802A0F8(Entity*);
void sub_08029F0C(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u8 unk_74;
/*0x75*/ u8 unk_75;
/*0x76*/ u8 unused2[1];
/*0x77*/ u8 unk_77;
/*0x78*/ union SplitHWord unk_78;
/*0x7a*/ union SplitHWord unk_7a;
/*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;
} MadderpillarEntity;
void sub_08029E0C(MadderpillarEntity* this);
void sub_08029EEC(MadderpillarEntity* this);
void sub_0802A098(MadderpillarEntity* this);
void sub_0802A16C(MadderpillarEntity* this);
void sub_0802A058(MadderpillarEntity* this);
bool32 sub_0802A14C(MadderpillarEntity* this);
void sub_0802A18C(MadderpillarEntity* this);
bool32 sub_08029FE4(MadderpillarEntity* this);
void sub_08029FB4(MadderpillarEntity* this, u32, u32);
void sub_0802A0F8(MadderpillarEntity* this);
void sub_08029F0C(MadderpillarEntity* this);
extern s16 gUnk_080B4488[];
extern void (*const gUnk_080CCD44[])(Entity*);
extern void (*const Madderpillar_Functions[])(Entity*);
extern void (*const gUnk_080CCD78[])(Entity*);
extern void (*const gUnk_080CCD88[])(Entity*);
extern void (*const gUnk_080CCD44[])(MadderpillarEntity*);
extern void (*const Madderpillar_Functions[])(MadderpillarEntity*);
extern void (*const gUnk_080CCD78[])(MadderpillarEntity*);
extern void (*const gUnk_080CCD88[])(MadderpillarEntity*);
extern const u8 gUnk_080CCDA0[];
extern void (*const gUnk_080CCDA8[])(Entity*);
extern void (*const gUnk_080CCDA8[])(MadderpillarEntity*);
extern const u8 gUnk_080CCDC8[];
extern const u16 gUnk_080CCDD4[];
void Madderpillar(Entity* this) {
gUnk_080CCD44[this->type](this);
void Madderpillar(MadderpillarEntity* this) {
gUnk_080CCD44[super->type](this);
}
void sub_08029870(Entity* this) {
Madderpillar_Functions[GetNextFunction(this)](this);
void sub_08029870(MadderpillarEntity* this) {
Madderpillar_Functions[GetNextFunction(super)](this);
}
void Madderpillar_OnTick(Entity* this) {
gUnk_080CCD78[this->action](this);
void Madderpillar_OnTick(MadderpillarEntity* this) {
gUnk_080CCD78[super->action](this);
}
void Madderpillar_OnCollision(Entity* this) {
if (this->action == 1) {
switch (this->contactFlags & 0x7f) {
void Madderpillar_OnCollision(MadderpillarEntity* this) {
if (super->action == 1) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
case 2:
@@ -57,273 +79,273 @@ void Madderpillar_OnCollision(Entity* this) {
case 0x1e:
break;
default:
this->action = 2;
this->timer = 0;
this->hitType = 0x6b;
this->field_0x76.HALF.HI = 0;
ChangeObjPalette(this, 0x7f);
super->action = 2;
super->timer = 0;
super->hitType = 0x6b;
this->unk_77 = 0;
ChangeObjPalette(super, 0x7f);
EnqueueSFX(SFX_HIT);
this->child->action = 2;
super->child->action = 2;
break;
}
}
EnemyFunctionHandlerAfterCollision(this, Madderpillar_Functions);
EnemyFunctionHandlerAfterCollision(super, Madderpillar_Functions);
}
void Madderpillar_OnDeath(Entity* this) {
if (this->subtimer) {
this->subtimer--;
void Madderpillar_OnDeath(MadderpillarEntity* this) {
if (super->subtimer) {
super->subtimer--;
} else {
GenericDeath(this);
GenericDeath(super);
}
}
void Madderpillar_OnGrabbed(Entity* this) {
void Madderpillar_OnGrabbed(MadderpillarEntity* this) {
/* ... */
}
void sub_0802999C(Entity* this) {
void sub_0802999C(MadderpillarEntity* this) {
if (gEntCount < 0x44) {
Entity *ent1, *ent2, *ent3, *ent4, *ent5, *ent6;
ent1 = CreateEnemy(MADDERPILLAR, 1);
ent1->parent = this;
PositionRelative(this, ent1, 0, 5);
this->child = ent1;
ent1->parent = super;
PositionRelative(super, ent1, 0, 5);
super->child = ent1;
ent2 = CreateEnemy(MADDERPILLAR, 2);
ent2->parent = this;
PositionRelative(this, ent2, 0, 4);
ent2->parent = super;
PositionRelative(super, ent2, 0, 4);
ent1->child = ent2;
ent3 = CreateEnemy(MADDERPILLAR, 3);
ent3->parent = this;
PositionRelative(this, ent3, 0, 3);
ent3->parent = super;
PositionRelative(super, ent3, 0, 3);
ent2->child = ent3;
ent4 = CreateEnemy(MADDERPILLAR, 4);
ent4->parent = this;
PositionRelative(this, ent4, 0, 2);
ent4->parent = super;
PositionRelative(super, ent4, 0, 2);
ent3->child = ent4;
ent5 = CreateEnemy(MADDERPILLAR, 5);
ent5->parent = this;
PositionRelative(this, ent5, 0, 1);
ent5->parent = super;
PositionRelative(super, ent5, 0, 1);
ent4->child = ent5;
ent6 = CreateEnemy(MADDERPILLAR, 6);
ent6->child = this;
ent6->parent = this;
PositionRelative(this, ent6, 0, 0);
ent6->child = super;
ent6->parent = super;
PositionRelative(super, ent6, 0, 0);
ent5->child = ent6;
this->action = 1;
COLLISION_ON(this);
this->direction = DirectionRound(Random());
this->speed = 0xa0;
this->animationState = 0xff;
this->y.WORD += 6;
this->parent = this;
this->field_0x74.HALF.LO = 0xff;
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
super->action = 1;
COLLISION_ON(super);
super->direction = DirectionRound(Random());
super->speed = 0xa0;
super->animationState = 0xff;
super->y.WORD += 6;
super->parent = super;
this->unk_74 = 0xff;
this->unk_75 = 0;
this->unk_77 = 1;
sub_08029E0C(this);
sub_08029EEC(this);
}
}
void sub_08029A94(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08029A94(MadderpillarEntity* this) {
UpdateAnimationSingleFrame(super);
sub_0802A098(this);
}
void sub_08029AA4(Entity* this) {
if (this->field_0x76.HALF.HI != 0) {
this->action = 3;
this->speed = 0x108;
this->hitType = 0x6a;
this->field_0x7a.HWORD = 0x168;
this->field_0x74.HALF.HI = 4;
void sub_08029AA4(MadderpillarEntity* this) {
if (this->unk_77 != 0) {
super->action = 3;
super->speed = 0x108;
super->hitType = 0x6a;
this->unk_7a.HWORD = 0x168;
this->unk_75 = 4;
sub_08029EEC(this);
EnqueueSFX(SFX_19D);
}
}
void sub_08029AE0(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08029AE0(MadderpillarEntity* this) {
UpdateAnimationSingleFrame(super);
sub_0802A16C(this);
sub_0802A098(this);
if (--this->field_0x7a.HWORD == 0) {
this->action = 1;
this->speed = 0xa0;
this->field_0x74.HALF.HI = 0;
if (--this->unk_7a.HWORD == 0) {
super->action = 1;
super->speed = 0xa0;
this->unk_75 = 0;
sub_08029EEC(this);
ChangeObjPalette(this, 0x77);
ChangeObjPalette(super, 0x77);
EnqueueSFX(SFX_182);
}
}
void sub_08029B2C(Entity* this) {
void sub_08029B2C(MadderpillarEntity* this) {
if (sub_0802A14C(this)) {
if (this->field_0x86.HALF.LO) {
if (--this->timer == 0) {
CreateFx(this, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(this);
if (this->unk_86) {
if (--super->timer == 0) {
CreateFx(super, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(super);
}
} else {
COLLISION_OFF(this);
this->timer = -(this->type * 15 - 90);
this->field_0x86.HALF.LO = 1;
COLLISION_OFF(super);
super->timer = -(super->type * 15 - 90);
this->unk_86 = 1;
}
} else {
gUnk_080CCD88[this->action](this);
gUnk_080CCD88[super->action](this);
}
}
void sub_08029B90(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
void sub_08029B90(MadderpillarEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
sub_0802A058(this);
if (this->type < 2) {
InitializeAnimation(this, 0);
if (super->type < 2) {
InitializeAnimation(super, 0);
} else {
InitializeAnimation(this, 4);
InitializeAnimation(super, 4);
}
}
void sub_08029BC4(Entity* this) {
void sub_08029BC4(MadderpillarEntity* this) {
u32 uVar1;
u32 uVar2;
sub_0802A18C(this);
uVar1 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
uVar1 = super->x.HALF.HI;
uVar2 = super->y.HALF.HI;
if (sub_08029FE4(this)) {
u32 index;
if (this->type < 2) {
if (super->type < 2) {
index = 0;
} else {
index = 4;
}
InitializeAnimation(this, this->animationState + index);
InitializeAnimation(super, super->animationState + index);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
sub_08029FB4(this, super->x.HALF.HI - uVar1, super->y.HALF.HI - uVar2);
}
void sub_08029C08(Entity* this) {
this->action = 3;
this->timer = gUnk_080CCDA0[this->type];
this->hitType = 0x6b;
this->child->action = 2;
void sub_08029C08(MadderpillarEntity* this) {
super->action = 3;
super->timer = gUnk_080CCDA0[super->type];
super->hitType = 0x6b;
super->child->action = 2;
}
void sub_08029C2C(Entity* this) {
if (--this->timer == 0) {
this->action = 4;
ChangeObjPalette(this, 0x7f);
void sub_08029C2C(MadderpillarEntity* this) {
if (--super->timer == 0) {
super->action = 4;
ChangeObjPalette(super, 0x7f);
EnqueueSFX(SFX_MENU_CANCEL);
}
}
void sub_08029C50(Entity* this) {
if (this->parent->field_0x76.HALF.HI != 0) {
this->action = 5;
this->hitType = 0x6a;
void sub_08029C50(MadderpillarEntity* this) {
if (((MadderpillarEntity*)super->parent)->unk_77 != 0) {
super->action = 5;
super->hitType = 0x6a;
}
}
void sub_08029C6C(Entity* this) {
void sub_08029C6C(MadderpillarEntity* this) {
sub_0802A18C(this);
sub_08029BC4(this);
if (this->parent->action != 3) {
this->action = 1;
ChangeObjPalette(this, 0x77);
if (super->parent->action != 3) {
super->action = 1;
ChangeObjPalette(super, 0x77);
} else {
sub_0802A16C(this);
}
}
void sub_08029C98(Entity* this) {
void sub_08029C98(MadderpillarEntity* this) {
if (sub_0802A14C(this)) {
CreateFx(this, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(this);
CreateFx(super, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(super);
} else {
gUnk_080CCDA8[this->action](this);
gUnk_080CCDA8[super->action](this);
}
}
void sub_08029CCC(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
void sub_08029CCC(MadderpillarEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
sub_0802A058(this);
InitializeAnimation(this, 8);
InitializeAnimation(super, 8);
}
void sub_08029CF0(Entity* this) {
void sub_08029CF0(MadderpillarEntity* this) {
if (sub_08029FE4(this)) {
InitializeAnimation(this, this->animationState + 8);
InitializeAnimation(super, super->animationState + 8);
}
}
void sub_08029D08(Entity* this) {
this->action = 3;
this->timer = 71;
void sub_08029D08(MadderpillarEntity* this) {
super->action = 3;
super->timer = 71;
}
void sub_08029D14(Entity* this) {
if (this->timer != 0) {
if (--this->timer == 0) {
InitializeAnimation(this, this->animationState + 0xc);
ChangeObjPalette(this, 0x7f);
void sub_08029D14(MadderpillarEntity* this) {
if (super->timer != 0) {
if (--super->timer == 0) {
InitializeAnimation(super, super->animationState + 0xc);
ChangeObjPalette(super, 0x7f);
EnqueueSFX(SFX_MENU_CANCEL);
}
} else {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 4;
this->timer = 120;
this->hitType = 0x6c;
this->hitbox = (Hitbox*)&gUnk_080FD298;
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 4;
super->timer = 120;
super->hitType = 0x6c;
super->hitbox = (Hitbox*)&gUnk_080FD298;
EnqueueSFX(SFX_6B);
}
}
}
void sub_08029D78(Entity* this) {
void sub_08029D78(MadderpillarEntity* this) {
sub_0802A0F8(this);
if (--this->timer == 0) {
this->action = 5;
this->hitType = 0x6a;
this->hitbox = (Hitbox*)&gUnk_080FD2A0;
InitializeAnimation(this, this->animationState + 0x10);
if (--super->timer == 0) {
super->action = 5;
super->hitType = 0x6a;
super->hitbox = (Hitbox*)&gUnk_080FD2A0;
InitializeAnimation(super, super->animationState + 0x10);
}
}
void sub_08029DAC(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 6;
this->parent->field_0x76.HALF.HI = 1;
InitializeAnimation(this, this->animationState + 8);
void sub_08029DAC(MadderpillarEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 6;
((MadderpillarEntity*)super->parent)->unk_77 = 1;
InitializeAnimation(super, super->animationState + 8);
}
}
void sub_08029DDC(Entity* this) {
this->action = 7;
void sub_08029DDC(MadderpillarEntity* this) {
super->action = 7;
}
void sub_08029DE4(Entity* this) {
void sub_08029DE4(MadderpillarEntity* this) {
sub_08029CF0(this);
if (this->parent->action != 3) {
this->action = 1;
ChangeObjPalette(this, 0x77);
if (super->parent->action != 3) {
super->action = 1;
ChangeObjPalette(super, 0x77);
} else {
sub_0802A16C(this);
}
}
void sub_08029E0C(Entity* this) {
void sub_08029E0C(MadderpillarEntity* this) {
u32 tile;
s32 uVar4;
s32 iVar3;
@@ -333,16 +355,16 @@ void sub_08029E0C(Entity* this) {
u32 local_24;
u32 dir;
uVar2 = (this->direction >> 3) * 3;
uVar2 = (super->direction >> 3) * 3;
ptr = &gUnk_080CCDC8[uVar2];
uVar4 = (Random() & 1) * 2 - 1;
iVar3 = ((s32)Random() & 0xf) % 3;
tile = COORD_TO_TILE(this);
tile = COORD_TO_TILE(super);
for (i = 0; i < 3; i++) {
dir = ptr[iVar3];
if (sub_080B1B44(gUnk_080B4488[dir >> 3] + tile, this->collisionLayer) == 0) {
if (sub_080B1B44(gUnk_080B4488[dir >> 3] + tile, super->collisionLayer) == 0) {
local_24 = dir;
if (this->direction - this->field_0x74.HALF.LO != dir - this->direction)
if (super->direction - this->unk_74 != dir - super->direction)
break;
}
iVar3 = (iVar3 + uVar4 + 3) % 3;
@@ -352,61 +374,61 @@ void sub_08029E0C(Entity* this) {
dir = local_24;
}
if (this->field_0x74.HALF.LO != this->direction) {
this->field_0x74.HALF.LO = this->direction;
if (this->unk_74 != super->direction) {
this->unk_74 = super->direction;
}
this->direction = dir;
super->direction = dir;
sub_08029F0C(this);
}
void sub_08029EEC(Entity* this) {
u32 uVar1 = (this->direction >> 3) + this->field_0x74.HALF.HI;
if (uVar1 != this->animationState) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, uVar1);
void sub_08029EEC(MadderpillarEntity* this) {
u32 uVar1 = (super->direction >> 3) + this->unk_75;
if (uVar1 != super->animationState) {
super->animationState = uVar1;
InitAnimationForceUpdate(super, uVar1);
}
}
void sub_08029F0C(Entity* this) {
switch (this->direction >> 3) {
void sub_08029F0C(MadderpillarEntity* this) {
switch (super->direction >> 3) {
case 0:
this->field_0x78.HWORD = this->y.HALF.HI - 0x10;
this->unk_78.HWORD = super->y.HALF.HI - 0x10;
break;
case 1:
this->field_0x78.HWORD = this->x.HALF.HI + 0x10;
this->unk_78.HWORD = super->x.HALF.HI + 0x10;
break;
case 2:
this->field_0x78.HWORD = this->y.HALF.HI + 0x10;
this->unk_78.HWORD = super->y.HALF.HI + 0x10;
break;
case 3:
this->field_0x78.HWORD = this->x.HALF.HI - 0x10;
this->unk_78.HWORD = super->x.HALF.HI - 0x10;
break;
}
}
bool32 sub_08029F48(Entity* this) {
switch (this->direction >> 3) {
bool32 sub_08029F48(MadderpillarEntity* this) {
switch (super->direction >> 3) {
case 0:
if (this->y.HALF.HI <= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD;
if (super->y.HALF.HI <= this->unk_78.HWORD) {
super->y.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 1:
if (this->x.HALF.HI >= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD;
if (super->x.HALF.HI >= this->unk_78.HWORD) {
super->x.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 2:
if (this->y.HALF.HI >= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD;
if (super->y.HALF.HI >= this->unk_78.HWORD) {
super->y.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 3:
if (this->x.HALF.HI <= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD;
if (super->x.HALF.HI <= this->unk_78.HWORD) {
super->x.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
@@ -415,23 +437,23 @@ bool32 sub_08029F48(Entity* this) {
return FALSE;
}
void sub_08029FB4(Entity* this, u32 x, u32 y) {
u8* dst = (u8*)&this->child->field_0x78;
s32 unk = this->parent->field_0x7c.BYTES.byte2;
void sub_08029FB4(MadderpillarEntity* this, u32 x, u32 y) {
u8* dst = (u8*)&((MadderpillarEntity*)super->child)->unk_78;
s32 unk = ((MadderpillarEntity*)super->parent)->unk_7e;
u8 idx = unk % 0xe;
dst[idx] = ((x + 8) & 0xf) | (((y + 8) & 0xf) << 4);
}
/* The optimizer is strong within you. */
bool32 sub_08029FE4(Entity* this) {
bool32 sub_08029FE4(MadderpillarEntity* this) {
u8 state;
u8* dst = (u8*)&this->field_0x78;
s32 unk = this->parent->field_0x7c.BYTES.byte2 + 1;
u8* dst = (u8*)&this->unk_78;
s32 unk = ((MadderpillarEntity*)super->parent)->unk_7e + 1;
s8 iVar6 = (dst[unk % 0xe] & 0xf) - 8;
s8 iVar5 = (dst[unk % 0xe] >> 4) - 8;
this->x.HALF.HI += iVar6;
this->y.HALF.HI += iVar5;
GetNextFrame(this);
super->x.HALF.HI += iVar6;
super->y.HALF.HI += iVar5;
GetNextFrame(super);
state = 0xff;
if (iVar6 != 0) {
@@ -450,72 +472,72 @@ bool32 sub_08029FE4(Entity* this) {
}
}
if (state != 0xff && state != this->animationState) {
this->animationState = state;
if (state != 0xff && state != super->animationState) {
super->animationState = state;
return TRUE;
} else {
return FALSE;
}
}
void sub_0802A058(Entity* this) {
this->field_0x78.HALF.LO = 0x88;
this->field_0x78.HALF.HI = 0x88;
this->field_0x7a.HALF.LO = 0x88;
this->field_0x7a.HALF.HI = 0x88;
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->cutsceneBeh.HALF.LO = 0x88;
this->cutsceneBeh.HALF.HI = 0x88;
void sub_0802A058(MadderpillarEntity* this) {
this->unk_78.HALF.LO = 0x88;
this->unk_78.HALF.HI = 0x88;
this->unk_7a.HALF.LO = 0x88;
this->unk_7a.HALF.HI = 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;
}
void sub_0802A098(Entity* this) {
void sub_0802A098(MadderpillarEntity* this) {
u32 uVar1;
u32 uVar2;
s32 unk = (++this->field_0x7c.BYTES.byte2, this->field_0x7c.BYTES.byte2);
s32 unk = (++this->unk_7e, this->unk_7e);
u8 idx = unk % 0xe;
if (idx == 0) {
this->field_0x7c.BYTES.byte2 = 0;
this->unk_7e = 0;
}
uVar1 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
ProcessMovement0(this);
uVar1 = super->x.HALF.HI;
uVar2 = super->y.HALF.HI;
ProcessMovement0(super);
if (sub_08029F48(this)) {
sub_08029E0C(this);
sub_08029EEC(this);
EnqueueSFX(SFX_PLACE_OBJ);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
sub_08029FB4(this, super->x.HALF.HI - uVar1, super->y.HALF.HI - uVar2);
}
void sub_0802A0F8(Entity* this) {
if (this->health != 0) {
if ((this->contactFlags & 0x80) && this->iframes != 0) {
Entity* ent = this;
void sub_0802A0F8(MadderpillarEntity* this) {
if (super->health != 0) {
if ((super->contactFlags & 0x80) && super->iframes != 0) {
Entity* entity = super;
u32 i;
for (i = 0; i < 6; i++) {
ent = ent->child;
ent->iframes = this->iframes;
entity = entity->child;
entity->iframes = super->iframes;
}
}
} else {
this->parent->flags &= ~ENT_COLLIDE;
this->parent->health = 0;
this->parent->subtimer = 105;
super->parent->flags &= ~ENT_COLLIDE;
super->parent->health = 0;
super->parent->subtimer = 105;
}
}
bool32 sub_0802A14C(Entity* this) {
bool32 sub_0802A14C(MadderpillarEntity* this) {
u32 ret = FALSE;
if (this->parent->health == 0 || this->field_0x86.HALF.LO) {
if (super->parent->health == 0 || this->unk_86) {
ret = TRUE;
} else {
ret = FALSE;
@@ -523,13 +545,13 @@ bool32 sub_0802A14C(Entity* this) {
return ret;
}
void sub_0802A16C(Entity* this) {
ChangeObjPalette(this, gUnk_080CCDD4[this->parent->field_0x7a.HWORD >> 2 & 3]);
void sub_0802A16C(MadderpillarEntity* this) {
ChangeObjPalette(super, gUnk_080CCDD4[((MadderpillarEntity*)super->parent)->unk_7a.HWORD >> 2 & 3]);
}
void sub_0802A18C(Entity* this) {
if (this->contactFlags & 0x80) {
switch (this->contactFlags & 0x7f) {
void sub_0802A18C(MadderpillarEntity* this) {
if (super->contactFlags & 0x80) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
case 2:
@@ -547,7 +569,7 @@ void sub_0802A18C(Entity* this) {
}
// clang-format off
void (*const gUnk_080CCD44[])(Entity*) = {
void (*const gUnk_080CCD44[])(MadderpillarEntity*) = {
sub_08029870,
sub_08029B2C,
sub_08029B2C,
@@ -557,23 +579,23 @@ void (*const gUnk_080CCD44[])(Entity*) = {
sub_08029C98,
};
void (*const Madderpillar_Functions[])(Entity*) = {
void (*const Madderpillar_Functions[])(MadderpillarEntity*) = {
Madderpillar_OnTick,
Madderpillar_OnCollision,
Madderpillar_OnTick,
Madderpillar_OnDeath,
GenericConfused,
(void (*)(MadderpillarEntity*))GenericConfused,
Madderpillar_OnGrabbed,
};
void (*const gUnk_080CCD78[])(Entity*) = {
void (*const gUnk_080CCD78[])(MadderpillarEntity*) = {
sub_0802999C,
sub_08029A94,
sub_08029AA4,
sub_08029AE0,
};
void (*const gUnk_080CCD88[])(Entity*) = {
void (*const gUnk_080CCD88[])(MadderpillarEntity*) = {
sub_08029B90,
sub_08029BC4,
sub_08029C08,
@@ -592,7 +614,7 @@ const u8 gUnk_080CCDA0[] = {
0x00,
};
void (*const gUnk_080CCDA8[])(Entity*) = {
void (*const gUnk_080CCDA8[])(MadderpillarEntity*) = {
sub_08029CCC,
sub_08029CF0,
sub_08029D08,
+44 -22
View File
@@ -4,11 +4,33 @@
*
* @brief Mazaal Bracelet enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u32 unk_74;
// // Overlap of 4
// /*0x74*/ u8 unk_74;
// /*0x75*/ u8 unk_75;
/*0x76*/ u8 unused2[2];
/*0x78*/ u32 unk_78;
// // Overlap of 4
// /*0x78*/ u16 unk_78;
/*0x7a*/ u8 unused3[2];
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unk_80;
// // Overlap of 1
// /*0x80*/ u16 unk_80;
/*0x82*/ u8 unused4[2];
/*0x84*/ u8 unk_84;
} MazaalBraceletEntity;
void sub_0803B538(Entity*);
u32 sub_0803B4E4(Entity*);
@@ -134,27 +156,27 @@ void MazaalBracelet_OnTick(Entity* this) {
}
void MazaalBracelet_OnCollision(Entity* this) {
Entity* ent;
Entity* entity;
if (this->type < 2) {
if (this->action != 0x2b) {
if ((0 < this->iframes) && ((this->contactFlags == 0x95 || (this->contactFlags == 0x8e)))) {
this->action = 0x28;
COLLISION_OFF(this);
ent = this->parent;
ent->field_0x7c.BYTES.byte1 = ent->field_0x7c.BYTES.byte1 | (this->type == 0 ? 1 : 2);
ent->field_0x80.HALF.LO = (this->type == 0 ? 1 : 2) | ent->field_0x80.HALF.LO;
ent = this->child;
ent->iframes = this->iframes;
ent = (*(Entity**)&this->field_0x74);
ent->iframes = this->iframes;
entity = this->parent;
entity->field_0x7c.BYTES.byte1 = entity->field_0x7c.BYTES.byte1 | (this->type == 0 ? 1 : 2);
entity->field_0x80.HALF.LO = (this->type == 0 ? 1 : 2) | entity->field_0x80.HALF.LO;
entity = this->child;
entity->iframes = this->iframes;
entity = (*(Entity**)&this->field_0x74);
entity->iframes = this->iframes;
SoundReq(SFX_BOSS_HIT);
}
} else {
ent = this->child;
ent->iframes = this->iframes;
ent = (*(Entity**)&this->field_0x74);
ent->iframes = this->iframes;
entity = this->child;
entity->iframes = this->iframes;
entity = (*(Entity**)&this->field_0x74);
entity->iframes = this->iframes;
InitializeAnimation(this, 0x18);
InitAnimationForceUpdate(this->child, 9);
SoundReq(SFX_BOSS_HIT);
@@ -1357,10 +1379,10 @@ void sub_0803BA80(Entity* this) {
}
void sub_0803BA8C(Entity* this, u32 unk) {
u32 sVar2;
u32 palette;
u32 tmp;
sVar2 = 0;
palette = 0;
tmp = this->field_0x74.HALF.LO & 0xe0;
if ((this->field_0x74.HALF.LO & 0xe0) == 0) {
if (this->field_0x74.HALF.LO == 0) {
@@ -1368,9 +1390,9 @@ void sub_0803BA8C(Entity* this, u32 unk) {
this->field_0x74.HALF.HI = 0;
}
if (this->type == 2) {
sVar2 = gUnk_080CFD30[this->field_0x74.HALF.HI];
palette = gUnk_080CFD30[this->field_0x74.HALF.HI];
} else {
sVar2 = gUnk_080CFD44[this->field_0x74.HALF.HI];
palette = gUnk_080CFD44[this->field_0x74.HALF.HI];
}
}
this->field_0x74.HALF.LO++;
@@ -1381,14 +1403,14 @@ void sub_0803BA8C(Entity* this, u32 unk) {
if ((tmp & 0x80) == 0) {
this->field_0x74.HALF.LO |= 0x80;
if ((tmp & 0x20) != 0) {
sVar2 = gUnk_080CFD58[this->type - 2];
palette = gUnk_080CFD58[this->type - 2];
} else {
sVar2 = gUnk_080CFD5C[this->type - 2];
palette = gUnk_080CFD5C[this->type - 2];
}
}
}
if (sVar2 != 0) {
ChangeObjPalette(this, sVar2);
if (palette != 0) {
ChangeObjPalette(this, palette);
(*(Entity**)&this->parent->field_0x78)->palette.b.b0 = this->palette.raw << 0x1c >> 0x1c;
(*(Entity**)&this->parent->field_0x78)->palette.b.b4 = this->palette.b.b0;
this->parent->child->palette.b.b0 = this->palette.raw << 0x1c >> 0x1c;
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Mazaal Hand enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "hitbox.h"
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Mazaal Head enemy
*/
//#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
+111 -101
View File
@@ -4,46 +4,56 @@
*
* @brief Mazaal Macro enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "screenTransitions.h"
#include "script.h"
#include "structures.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[5];
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unused2[10];
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unused3[10];
/*0x84*/ ScriptExecutionContext* context;
} MazaalMacroEntity;
extern void sub_0807B600(u32);
extern const u16 script_MazaalMacroDefeated[];
void sub_08034E18(Entity*);
void sub_08034FA0(Entity*);
u32 sub_08035084(Entity*);
void sub_08034F70(Entity*);
void sub_08035120(Entity*);
void sub_08035050(Entity*);
void sub_08034E18(MazaalMacroEntity* this);
void sub_08034FA0(MazaalMacroEntity* this);
u32 sub_08035084(MazaalMacroEntity* this);
void sub_08034F70(MazaalMacroEntity* this);
void sub_08035120(MazaalMacroEntity* this);
void sub_08035050(MazaalMacroEntity* this);
void MazaalMacro_OnTick(Entity* this);
void MazaalMacro_OnCollision(Entity* this);
void MazaalMacro_OnDeath(Entity* this);
void sub_08034CC4(Entity* this);
void sub_08034D4C(Entity* this);
void sub_08034DC8(Entity* this);
void sub_08034E30(Entity* this);
void sub_08034E68(Entity* this);
void sub_08034EC0(Entity* this);
void sub_08034ED8(Entity* this);
void sub_08034EE4(Entity* this);
void sub_08034F58(Entity* this);
void MazaalMacro_OnTick(MazaalMacroEntity* this);
void MazaalMacro_OnCollision(MazaalMacroEntity* this);
void MazaalMacro_OnDeath(MazaalMacroEntity* this);
void sub_08034CC4(MazaalMacroEntity* this);
void sub_08034D4C(MazaalMacroEntity* this);
void sub_08034DC8(MazaalMacroEntity* this);
void sub_08034E30(MazaalMacroEntity* this);
void sub_08034E68(MazaalMacroEntity* this);
void sub_08034EC0(MazaalMacroEntity* this);
void sub_08034ED8(MazaalMacroEntity* this);
void sub_08034EE4(MazaalMacroEntity* this);
void sub_08034F58(MazaalMacroEntity* this);
void (*const MazaalMacro_Functions[])(Entity*) = {
MazaalMacro_OnTick, MazaalMacro_OnCollision, GenericKnockback, MazaalMacro_OnDeath, GenericConfused,
void (*const MazaalMacro_Functions[])(MazaalMacroEntity*) = {
MazaalMacro_OnTick, MazaalMacro_OnCollision, (void (*)(MazaalMacroEntity*))GenericKnockback, MazaalMacro_OnDeath, (void (*)(MazaalMacroEntity*))GenericConfused,
};
void (*const gUnk_080CEEA4[])(Entity*) = {
void (*const gUnk_080CEEA4[])(MazaalMacroEntity*) = {
sub_08034CC4,
sub_08034D4C,
sub_08034DC8,
};
void (*const gUnk_080CEEB0[])(Entity*) = {
void (*const gUnk_080CEEB0[])(MazaalMacroEntity*) = {
sub_08034E30, sub_08034E68, sub_08034EC0, sub_08034ED8, sub_08034EE4, sub_08034F58,
};
@@ -52,101 +62,101 @@ const u8 gUnk_080CEECC[] = { 0x58, 0x68, 0x88, 0x68, 0xb8, 0x68, 0x58, 0xa8, 0x8
const s16 gUnk_080CEED8[] = { -0x82, -0x81, -0x80, -0x7f, -0x7e, -0x42, -0x41, -0x40, -0x3f, -0x3e, -2, -1,
1, 2, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x7e, 0x7f, 0x80, 0x81, 0x82 };
void MazaalMacro(Entity* this) {
MazaalMacro_Functions[GetNextFunction(this)](this);
void MazaalMacro(MazaalMacroEntity* this) {
MazaalMacro_Functions[GetNextFunction(super)](this);
}
void MazaalMacro_OnTick(Entity* this) {
if (this->type != 2) {
gUnk_080CEEA4[this->action](this);
void MazaalMacro_OnTick(MazaalMacroEntity* this) {
if (super->type != 2) {
gUnk_080CEEA4[super->action](this);
} else {
sub_08034E18(this);
}
}
void MazaalMacro_OnCollision(Entity* this) {
void MazaalMacro_OnCollision(MazaalMacroEntity* this) {
sub_08034FA0(this);
EnemyFunctionHandlerAfterCollision(this, MazaalMacro_Functions);
EnemyFunctionHandlerAfterCollision(super, MazaalMacro_Functions);
}
void MazaalMacro_OnDeath(Entity* this) {
GenericDeath(this);
void MazaalMacro_OnDeath(MazaalMacroEntity* this) {
GenericDeath(super);
}
void sub_08034CC4(Entity* this) {
void sub_08034CC4(MazaalMacroEntity* this) {
Entity* entity;
if (sub_08035084(this) != 0) {
this->action = this->type + 1;
this->subtimer = 0;
this->field_0x6c.HALF.HI |= 1;
this->field_0x78.HWORD = 0x4b0;
super->action = super->type + 1;
super->subtimer = 0;
this->unk_6d |= 1;
this->unk_78 = 0x4b0;
sub_08034F70(this);
InitializeAnimation(this, this->type);
SetTile(0x4022, COORD_TO_TILE(this), this->collisionLayer);
InitializeAnimation(super, super->type);
SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer);
entity = CreateEnemy(MAZAAL_MACRO, 2);
if (entity != NULL) {
this->child = entity;
entity->parent = this;
CopyPosition(this, entity);
super->child = entity;
entity->parent = super;
CopyPosition(super, entity);
}
}
}
void sub_08034D4C(Entity* this) {
void sub_08034D4C(MazaalMacroEntity* this) {
Entity* entity;
GetNextFrame(this);
if (--this->field_0x78.HWORD == 0) {
if ((this->subtimer < 8) && (entity = CreateEnemy(VAATI_PROJECTILE, 0), entity != (Entity*)0x0)) {
GetNextFrame(super);
if (--this->unk_78 == 0) {
if ((super->subtimer < 8) && (entity = CreateEnemy(VAATI_PROJECTILE, 0), entity != (Entity*)0x0)) {
entity->direction = (s32)Random() % 5 + 0xc;
entity->x.HALF.HI = (gRoomControls.width / 2) + gRoomControls.origin_x;
entity->y.HALF.HI = gRoomControls.origin_y + 8;
entity->collisionLayer = 3;
entity->parent = this;
entity->parent = super;
UpdateSpriteForCollisionLayer(entity);
this->field_0x78.HWORD = 600;
this->subtimer = this->subtimer + 1;
this->unk_78 = 600;
super->subtimer = super->subtimer + 1;
} else {
this->field_0x78.HWORD = 0x78;
this->unk_78 = 0x78;
}
}
}
void sub_08034DC8(Entity* this) {
void sub_08034DC8(MazaalMacroEntity* this) {
if (gRoomTransition.field_0x39 == 0) {
CreateFx(this, FX_GIANT_EXPLOSION4, 0);
RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer);
CreateFx(super, FX_GIANT_EXPLOSION4, 0);
RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer);
DeleteThisEntity();
}
}
void sub_08034E18(Entity* this) {
gUnk_080CEEB0[this->action](this);
void sub_08034E18(MazaalMacroEntity* this) {
gUnk_080CEEB0[super->action](this);
}
void sub_08034E30(Entity* this) {
this->action = this->parent->type + 1;
this->collisionLayer = 2;
this->spritePriority.b0 = 7;
this->spritePriority.b1 = 0;
UpdateSpriteForCollisionLayer(this);
InitializeAnimation(this, 2);
void sub_08034E30(MazaalMacroEntity* this) {
super->action = super->parent->type + 1;
super->collisionLayer = 2;
super->spritePriority.b0 = 7;
super->spritePriority.b1 = 0;
UpdateSpriteForCollisionLayer(super);
InitializeAnimation(super, 2);
}
void sub_08034E68(Entity* this) {
void sub_08034E68(MazaalMacroEntity* this) {
ScriptExecutionContext* scriptExecutionContext;
if (this->parent->next == NULL) {
if (this->spriteSettings.draw != 0) {
this->spriteSettings.draw = 0;
if (super->parent->next == NULL) {
if (super->spriteSettings.draw != 0) {
super->spriteSettings.draw = 0;
sub_08035120(this);
}
if (gRoomTransition.field_0x39 == 0) {
if (PlayerCanBeMoved()) {
this->action = 3;
scriptExecutionContext = StartCutscene(this, (u16*)script_MazaalMacroDefeated);
*(ScriptExecutionContext**)&this->cutsceneBeh = scriptExecutionContext;
super->action = 3;
scriptExecutionContext = StartCutscene(super, (u16*)script_MazaalMacroDefeated);
this->context = scriptExecutionContext;
}
} else {
DeleteThisEntity();
@@ -154,24 +164,24 @@ void sub_08034E68(Entity* this) {
}
}
void sub_08034EC0(Entity* this) {
if (this->parent->next == NULL) {
void sub_08034EC0(MazaalMacroEntity* this) {
if (super->parent->next == NULL) {
sub_08035120(this);
DeleteThisEntity();
}
}
void sub_08034ED8(Entity* this) {
ExecuteScriptForEntity(this, NULL);
void sub_08034ED8(MazaalMacroEntity* this) {
ExecuteScriptForEntity(super, NULL);
}
void sub_08034EE4(Entity* this) {
void sub_08034EE4(MazaalMacroEntity* this) {
u32 randomValue;
Entity* entity;
if ((++this->timer & 0xf) == 0) {
if ((++super->timer & 0xf) == 0) {
randomValue = Random();
entity = CreateFx(this, gUnk_080CEEC8[randomValue & 3], 0);
entity = CreateFx(super, gUnk_080CEEC8[randomValue & 3], 0);
if (entity != NULL) {
entity->x.HALF.HI = (((randomValue >> 2) & 0x77) << 1) + 1 + gRoomControls.scroll_x;
entity->y.HALF.HI = ((randomValue >> 9) & 0x7e) + 1 + gRoomControls.scroll_y;
@@ -179,59 +189,59 @@ void sub_08034EE4(Entity* this) {
UpdateSpriteForCollisionLayer(entity);
}
}
ExecuteScriptForEntity(this, NULL);
ExecuteScriptForEntity(super, NULL);
}
void sub_08034F58(Entity* this) {
void sub_08034F58(MazaalMacroEntity* this) {
DoExitTransition(&gUnk_0813ABA8);
DeleteEntity(this);
DeleteEntity(super);
}
void sub_08034F70(Entity* this) {
this->health = gRoomTransition.field_0x39;
void sub_08034F70(MazaalMacroEntity* this) {
super->health = gRoomTransition.field_0x39;
if (gRoomTransition.field_0x39 >= 0x3d) {
this->type2 = 0;
super->type2 = 0;
} else if (gRoomTransition.field_0x39 >= 0x1f) {
this->type2 = 1;
super->type2 = 1;
} else {
this->type2 = 2;
super->type2 = 2;
}
}
void sub_08034FA0(Entity* this) {
if (0 < this->iframes) {
this->child->iframes = this->iframes;
void sub_08034FA0(MazaalMacroEntity* this) {
if (0 < super->iframes) {
super->child->iframes = super->iframes;
InitScreenShake(12, 1);
}
switch (this->type2) {
switch (super->type2) {
case 0:
if (this->health < 0x3c) {
if (super->health < 0x3c) {
gRoomTransition.field_0x39 = 0x3c;
sub_08035050(this);
return;
}
break;
case 1:
if (this->health < 0x1e) {
if (super->health < 0x1e) {
gRoomTransition.field_0x39 = 0x1e;
sub_08035050(this);
return;
}
break;
default:
if (this->health == 0) {
RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer);
if (super->health == 0) {
RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer);
}
break;
}
gRoomTransition.field_0x39 = this->health;
gRoomTransition.field_0x39 = super->health;
}
void sub_08035050(Entity* this) {
void sub_08035050(MazaalMacroEntity* this) {
Entity* entity;
COLLISION_OFF(this);
this->health = 0;
COLLISION_OFF(super);
super->health = 0;
entity = CreateEnemy(VAATI_PROJECTILE, 0);
if (entity != NULL) {
entity->type2 = 1;
@@ -241,13 +251,13 @@ void sub_08035050(Entity* this) {
}
}
u32 sub_08035084(Entity* this) {
u32 sub_08035084(MazaalMacroEntity* this) {
u32 vulnPillar;
Entity* entity;
u32 i;
const u8* coords;
if (this->type == 0) {
if (super->type == 0) {
if (0x42 < gEntCount) {
return 0;
}
@@ -257,7 +267,7 @@ u32 sub_08035084(Entity* this) {
gRoomTransition.field_0x38 = (gRoomTransition.field_0x38 & 0xf) | (vulnPillar << 4);
for (i = 0, coords = gUnk_080CEECC; i < 6; i++, coords += 2) {
if (i == vulnPillar) {
entity = this;
entity = super;
} else {
entity = CreateEnemy(MAZAAL_MACRO, 1);
}
@@ -270,11 +280,11 @@ u32 sub_08035084(Entity* this) {
return 1;
}
void sub_08035120(Entity* this) {
void sub_08035120(MazaalMacroEntity* this) {
s32 tile;
u32 i;
tile = COORD_TO_TILE(this);
tile = COORD_TO_TILE(super);
for (i = 0; i < 0x18; i++) {
sub_0807B600(tile + gUnk_080CEED8[i]);
}
+50 -44
View File
@@ -4,79 +4,85 @@
*
* @brief Mini Fireball Guy enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
extern void sub_08045678(Entity*);
void MiniFireballGuy_OnTick(Entity*);
void MiniFireballGuy_OnCollision(Entity*);
void MiniFireballGuy_OnDeath(Entity*);
void MiniFireballGuy_OnGrabbed(Entity*);
void sub_08045618(Entity*);
void sub_08045654(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u8 unk_6c;
} MiniFireballGuyEntity;
static void (*const MiniFireballGuy_Functions[])(Entity*) = {
MiniFireballGuy_OnTick, MiniFireballGuy_OnCollision, GenericKnockback, MiniFireballGuy_OnDeath,
GenericConfused, MiniFireballGuy_OnGrabbed,
extern void sub_08045678(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnTick(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnCollision(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnDeath(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnGrabbed(MiniFireballGuyEntity* this);
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,
};
void MiniFireballGuy(Entity* this) {
EnemyFunctionHandler(this, MiniFireballGuy_Functions);
void MiniFireballGuy(MiniFireballGuyEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)MiniFireballGuy_Functions);
}
void MiniFireballGuy_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void MiniFireballGuy_OnTick(MiniFireballGuyEntity* this) {
static void (*const actionFuncs[])(MiniFireballGuyEntity*) = {
sub_08045618,
sub_08045654,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void MiniFireballGuy_OnCollision(Entity* this) {
EnemyFunctionHandlerAfterCollision(this, MiniFireballGuy_Functions);
void MiniFireballGuy_OnCollision(MiniFireballGuyEntity* this) {
EnemyFunctionHandlerAfterCollision(super, MiniFireballGuy_Functions);
}
void MiniFireballGuy_OnDeath(Entity* this) {
if ((this != this->parent) && (this->parent != NULL)) {
this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
void MiniFireballGuy_OnDeath(MiniFireballGuyEntity* this) {
if ((super != super->parent) && (super->parent != NULL)) {
this->unk_6c &= ~0x80;
super->parent->child = super->child;
super->child->parent = super->parent;
}
GenericDeath(this);
GenericDeath(super);
}
void MiniFireballGuy_OnGrabbed(Entity* this) {
void MiniFireballGuy_OnGrabbed(MiniFireballGuyEntity* this) {
}
void sub_08045618(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->speed = 0x80;
this->collisionFlags = this->collisionFlags | 0x10;
sub_0804A720(this);
InitializeAnimation(this, 1);
void sub_08045618(MiniFireballGuyEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->speed = 0x80;
super->collisionFlags = super->collisionFlags | 0x10;
sub_0804A720(super);
InitializeAnimation(super, 1);
sub_08045678(this);
}
void sub_08045654(Entity* this) {
ProcessMovement2(this);
GetNextFrame(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
void sub_08045654(MiniFireballGuyEntity* this) {
ProcessMovement2(super);
GetNextFrame(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
sub_08045678(this);
}
}
void sub_08045678(Entity* this) {
this->zVelocity = Q_16_16(1.75);
if (this->timer != 0) {
this->timer--;
void sub_08045678(MiniFireballGuyEntity* this) {
super->zVelocity = Q_16_16(1.75);
if (super->timer != 0) {
super->timer--;
} else {
this->timer = Random() & 3;
if ((sub_08049FA0(this) == 0) && (Random() & 3)) {
this->direction = DirectionRound(sub_08049EE4(this) - 4 + (Random() & 8));
super->timer = Random() & 3;
if ((sub_08049FA0(super) == 0) && (Random() & 3)) {
super->direction = DirectionRound(sub_08049EE4(super) - 4 + (Random() & 8));
} else {
this->direction = DirectionRound(Random());
super->direction = DirectionRound(Random());
}
}
}
+66 -61
View File
@@ -4,107 +4,112 @@
*
* @brief Mini Slime enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
void sub_08045374(Entity*);
void MiniSlime_OnTick(Entity*);
void MiniSlime_OnCollision(Entity*);
void MiniSlime_OnDeath(Entity*);
void MiniSlime_OnGrabbed(Entity*);
void sub_080452A4(Entity*);
void sub_080452E4(Entity*);
void sub_080452FC(Entity*);
void sub_08045374(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unk_6d;
} MiniSlimeEntity;
void sub_08045374(MiniSlimeEntity* this);
void MiniSlime_OnTick(MiniSlimeEntity* this);
void MiniSlime_OnCollision(MiniSlimeEntity* this);
void MiniSlime_OnDeath(MiniSlimeEntity* this);
void MiniSlime_OnGrabbed(MiniSlimeEntity* this);
void sub_080452A4(MiniSlimeEntity* this);
void sub_080452E4(MiniSlimeEntity* this);
void sub_080452FC(MiniSlimeEntity* this);
extern void sub_080452E4(Entity*);
extern void ReplaceMonitoredEntity(Entity*, Entity*);
static void (*const MiniSlime_Functions[])(Entity*) = {
MiniSlime_OnTick, MiniSlime_OnCollision, GenericKnockback, MiniSlime_OnDeath, GenericConfused, MiniSlime_OnGrabbed,
static void (*const MiniSlime_Functions[])(MiniSlimeEntity*) = {
MiniSlime_OnTick, MiniSlime_OnCollision, (void (*)(MiniSlimeEntity*))GenericKnockback, MiniSlime_OnDeath, (void (*)(MiniSlimeEntity*))GenericConfused, MiniSlime_OnGrabbed,
};
void MiniSlime(Entity* this) {
EnemyFunctionHandler(this, MiniSlime_Functions);
SetChildOffset(this, 0, 1, -8);
void MiniSlime(MiniSlimeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)MiniSlime_Functions);
SetChildOffset(super, 0, 1, -8);
}
void MiniSlime_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void MiniSlime_OnTick(MiniSlimeEntity* this) {
static void (*const actionFuncs[])(MiniSlimeEntity*) = {
sub_080452A4,
sub_080452E4,
sub_080452FC,
sub_08045374,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void MiniSlime_OnCollision(Entity* this) {
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
void MiniSlime_OnCollision(MiniSlimeEntity* this) {
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, MiniSlime_Functions);
EnemyFunctionHandlerAfterCollision(super, MiniSlime_Functions);
}
void MiniSlime_OnDeath(Entity* this) {
Entity* parent = this->parent;
if ((this != parent) && (parent != NULL)) {
this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
if (this->field_0x6c.HALF.HI & 0x40)
ReplaceMonitoredEntity(this, parent);
void MiniSlime_OnDeath(MiniSlimeEntity* this) {
Entity* parent = super->parent;
if ((super != parent) && (parent != NULL)) {
this->unk_6c &= ~0x80;
super->parent->child = super->child;
super->child->parent = super->parent;
if (this->unk_6d & 0x40)
ReplaceMonitoredEntity(super, parent);
}
GenericDeath(this);
GenericDeath(super);
}
void MiniSlime_OnGrabbed(Entity* this) {
void MiniSlime_OnGrabbed(MiniSlimeEntity* this) {
}
void sub_080452A4(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->speed = 0x100;
sub_0804A720(this);
InitializeAnimation(this, 6);
if (this->type2) {
this->action = 2;
this->timer = 1;
void sub_080452A4(MiniSlimeEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->speed = 0x100;
sub_0804A720(super);
InitializeAnimation(super, 6);
if (super->type2) {
super->action = 2;
super->timer = 1;
} else {
sub_080452E4(this);
}
}
void sub_080452E4(Entity* this) {
this->action = 2;
this->timer = (Random() & 0x1f) + 1;
void sub_080452E4(MiniSlimeEntity* this) {
super->action = 2;
super->timer = (Random() & 0x1f) + 1;
}
void sub_080452FC(Entity* this) {
void sub_080452FC(MiniSlimeEntity* this) {
u32 cVar2, bVar3;
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 3;
this->timer = 1;
if (0 < this->speed)
this->timer = FixedDiv(0x1000, this->speed) >> 8;
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 3;
super->timer = 1;
if (0 < super->speed)
super->timer = FixedDiv(0x1000, super->speed) >> 8;
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
cVar2 = sub_08049EE4(this);
if (sub_08049FA0(super) == 0 && (Random() & 3)) {
cVar2 = sub_08049EE4(super);
bVar3 = Random() & 8;
bVar3 += 0xfc;
this->direction = DirectionRound(cVar2 + bVar3);
super->direction = DirectionRound(cVar2 + bVar3);
} else {
this->direction = DirectionRound(Random());
super->direction = DirectionRound(Random());
sub_08045374(this);
}
}
}
void sub_08045374(Entity* this) {
ProcessMovement0(this);
GetNextFrame(this);
if (--this->timer == 0)
this->action = 1;
void sub_08045374(MiniSlimeEntity* this) {
ProcessMovement0(super);
GetNextFrame(super);
if (--super->timer == 0)
super->action = 1;
}
+2 -2
View File
@@ -4,9 +4,9 @@
*
* @brief Moldorm enemy
*/
#include "enemy.h"
//#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
void sub_08022EAC(Entity*);
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Moldworm enemy
*/
//#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
-2
View File
@@ -4,9 +4,7 @@
*
* @brief Mulldozer enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "collision.h"
#include "enemy.h"
+10 -10
View File
@@ -4,7 +4,7 @@
*
* @brief Octorok enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
@@ -128,14 +128,14 @@ void Octorok_Move(Entity* this) {
void Octorok_ShootNut(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
Entity* ent = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
if (ent != NULL) {
Entity* entity = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
if (entity != NULL) {
const s8* off;
ent->direction = this->direction;
entity->direction = this->direction;
off = &gOctorokNutOffset[this->direction / 4];
ent->x.HALF.HI += off[0];
ent->y.HALF.HI += off[1];
ent->z.HALF.HI = -3;
entity->x.HALF.HI += off[0];
entity->y.HALF.HI += off[1];
entity->z.HALF.HI = -3;
this->frame &= 0xfe;
EnqueueSFX(SFX_18D);
}
@@ -182,12 +182,12 @@ void Octorok_Turn(Entity* this) {
}
bool32 Octorok_FacesPlayer(Entity* this) {
Entity* ent = sub_08049DF4(1);
Entity* entity = sub_08049DF4(1);
if (ent == NULL)
if (entity == NULL)
return FALSE;
if (DirectionRoundUp(GetFacingDirection(this, ent)) != this->direction)
if (DirectionRoundUp(GetFacingDirection(this, entity)) != this->direction)
return FALSE;
return TRUE;
+8 -1
View File
@@ -1,6 +1,13 @@
/**
* @file octorokGolden.c
* @ingroup Enemies
*
* @brief Golden Octorock enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "map.h"
#include "enemy.h"
#include "map.h"
#include "player.h"
#include "item.h"
+237 -228
View File
@@ -4,21 +4,30 @@
*
* @brief Peahat enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "room.h"
#include "physics.h"
#include "room.h"
extern void (*const Peahat_Functions[])(Entity*);
extern void (*const gPeahatPropellerFunctions[])(Entity*);
extern void (*const gPeahatActions[])(Entity*);
extern void (*const gUnk_080CA5BC[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} PeahatEntity;
extern void (*const Peahat_Functions[])(PeahatEntity*);
extern void (*const gPeahatPropellerFunctions[])(PeahatEntity*);
extern void (*const gPeahatActions[])(PeahatEntity*);
extern void (*const gUnk_080CA5BC[])(PeahatEntity*);
extern const s8 gPeahatFlightHeights[];
extern const s8 gUnk_080CA5D4[];
void sub_080205F8(Entity*);
void sub_08020604(Entity*);
void sub_080205F8(PeahatEntity* this);
void sub_08020604(PeahatEntity* this);
extern Entity* gUnk_020000B0;
@@ -36,354 +45,354 @@ enum {
PeahatAnimation_RepairPropeller,
};
void Peahat(Entity* this) {
if (this->type == PeahatForm_Torso) {
EnemyFunctionHandler(this, Peahat_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Peahat(PeahatEntity* this) {
if (super->type == PeahatForm_Torso) {
EnemyFunctionHandler(super, (EntityActionArray)Peahat_Functions);
SetChildOffset(super, 0, 1, -0x10);
} else {
gPeahatPropellerFunctions[this->action](this);
gPeahatPropellerFunctions[super->action](this);
}
}
void Peahat_OnTick(Entity* this) {
gPeahatActions[this->action](this);
if (this->field_0x80.HALF.HI)
this->z.HALF.HI = gPeahatFlightHeights[(this->subtimer++ & 0x30) >> 4];
void Peahat_OnTick(PeahatEntity* this) {
gPeahatActions[super->action](this);
if (this->unk_81)
super->z.HALF.HI = gPeahatFlightHeights[(super->subtimer++ & 0x30) >> 4];
}
void Peahat_OnCollision(Entity* this) {
if (this->field_0x82.HALF.LO) {
if (this->contactFlags == 0x94) {
Entity* ent = CreateEnemy(PEAHAT, PeahatForm_Propeller);
if (ent != NULL) {
CopyPosition(this, ent);
ent->z.HALF.HI -= 8;
void Peahat_OnCollision(PeahatEntity* this) {
if (this->unk_82) {
if (super->contactFlags == 0x94) {
Entity* entity = CreateEnemy(PEAHAT, PeahatForm_Propeller);
if (entity != NULL) {
CopyPosition(super, entity);
entity->z.HALF.HI -= 8;
}
this->field_0x82.HALF.LO = 0;
this->animationState = PeahatAnimation_SlicedPropeller;
this->action = 5;
this->speed = 0x80;
this->iframes = -30;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
} else if (this->contactFlags == 0x9b) {
this->animationState = PeahatAnimation_BrokenPropeller;
this->action = 5;
this->speed = 0x80;
this->iframes = -30;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
} else if (this->contactFlags == 0x80) {
if (this->animationState == PeahatAnimation_Flying) {
this->action = 1;
this->timer = 30;
this->speed = 0x80;
this->direction = -1;
this->field_0x82.HALF.HI = 0x78;
GetNextFrame(this);
this->unk_82 = 0;
super->animationState = PeahatAnimation_SlicedPropeller;
super->action = 5;
super->speed = 0x80;
super->iframes = -30;
this->unk_81 = 0;
InitializeAnimation(super, super->animationState);
} else if (super->contactFlags == 0x9b) {
super->animationState = PeahatAnimation_BrokenPropeller;
super->action = 5;
super->speed = 0x80;
super->iframes = -30;
this->unk_81 = 0;
InitializeAnimation(super, super->animationState);
} else if (super->contactFlags == 0x80) {
if (super->animationState == PeahatAnimation_Flying) {
super->action = 1;
super->timer = 30;
super->speed = 0x80;
super->direction = -1;
this->unk_83 = 0x78;
GetNextFrame(super);
}
}
}
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, Peahat_Functions);
EnemyFunctionHandlerAfterCollision(super, Peahat_Functions);
}
void Peahat_OnGrabbed(Entity* this) {
if (2 >= this->subAction && !sub_0806F520(this))
void Peahat_OnGrabbed(PeahatEntity* this) {
if (2 >= super->subAction && !sub_0806F520(super))
return;
gUnk_080CA5BC[this->subAction](this);
gUnk_080CA5BC[super->subAction](this);
}
void sub_080200B4(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
if (this->animationState == PeahatAnimation_Flying) {
this->animationState = PeahatAnimation_BrokenPropeller;
this->action = 5;
this->hitType = 0x71;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
void sub_080200B4(PeahatEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
if (super->animationState == PeahatAnimation_Flying) {
super->animationState = PeahatAnimation_BrokenPropeller;
super->action = 5;
super->hitType = 0x71;
this->unk_81 = 0;
InitializeAnimation(super, super->animationState);
}
}
void sub_080200E4(Entity* this) {
sub_0806F4E8(this);
void sub_080200E4(PeahatEntity* this) {
sub_0806F4E8(super);
}
void sub_080200EC(Entity* this) {
sub_0806F3E4(this);
void sub_080200EC(PeahatEntity* this) {
sub_0806F3E4(super);
}
void sub_080200F4(Entity* this) {
COLLISION_OFF(this);
void sub_080200F4(PeahatEntity* this) {
COLLISION_OFF(super);
}
void nullsub_5(Entity* this) {
void nullsub_5(PeahatEntity* this) {
}
void sub_08020104(Entity* this) {
if (this->flags & ENT_COLLIDE) {
COLLISION_ON(this);
this->gustJarState &= 0xfb;
void sub_08020104(PeahatEntity* this) {
if (super->flags & ENT_COLLIDE) {
COLLISION_ON(super);
super->gustJarState &= 0xfb;
} else {
this->health = 0;
super->health = 0;
}
}
void Peahat_Initialize(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->timer = 16;
this->subtimer = Random();
this->direction = Random() & 0x1f;
this->gustJarFlags = 18;
this->field_0x80.HALF.LO = (Random() & 1) ? 2 : -2;
this->field_0x80.HALF.HI = 1;
this->field_0x82.HALF.LO = 1;
this->animationState = PeahatAnimation_Flying;
InitializeAnimation(this, this->animationState);
void Peahat_Initialize(PeahatEntity* this) {
sub_0804A720(super);
super->action = 1;
super->timer = 16;
super->subtimer = Random();
super->direction = Random() & 0x1f;
super->gustJarFlags = 18;
this->unk_80 = (Random() & 1) ? 2 : -2;
this->unk_81 = 1;
this->unk_82 = 1;
super->animationState = PeahatAnimation_Flying;
InitializeAnimation(super, super->animationState);
}
void Peahat_Fly(Entity* this) {
if (this->field_0x82.HALF.HI)
this->field_0x82.HALF.HI--;
void Peahat_Fly(PeahatEntity* this) {
if (this->unk_83)
this->unk_83--;
if (sub_08049FDC(this, 1)) {
if (this->field_0x82.HALF.HI == 0 && (this->subtimer & 0xf) == 0 && sub_08049F1C(this, gUnk_020000B0, 0x30)) {
this->action = 2;
this->subAction = Random() & 3;
this->timer = 60;
this->speed = 160;
if (sub_08049FDC(super, 1)) {
if (this->unk_83 == 0 && (super->subtimer & 0xf) == 0 && sub_08049F1C(super, gUnk_020000B0, 0x30)) {
super->action = 2;
super->subAction = Random() & 3;
super->timer = 60;
super->speed = 160;
}
}
if (--this->timer == 0) {
this->timer = 16;
if (--super->timer == 0) {
super->timer = 16;
sub_08020604(this);
if ((Random() & 3) == 0) {
this->field_0x80.HALF.LO = (Random() & 1) ? 2 : -2;
this->unk_80 = (Random() & 1) ? 2 : -2;
}
}
ProcessMovement2(this);
GetNextFrame(this);
ProcessMovement2(super);
GetNextFrame(super);
}
void Peahat_ChargeStart(Entity* this) {
if (sub_08049FDC(this, 1)) {
if (--this->timer) {
UpdateAnimationVariableFrames(this, 4 - ((this->timer >> 4) & 0x3));
void Peahat_ChargeStart(PeahatEntity* this) {
if (sub_08049FDC(super, 1)) {
if (--super->timer) {
UpdateAnimationVariableFrames(super, 4 - ((super->timer >> 4) & 0x3));
return;
} else {
this->action = 3;
this->timer = 120;
this->speed = 192;
this->direction = (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & 0x1f;
super->action = 3;
super->timer = 120;
super->speed = 192;
super->direction = (GetFacingDirection(super, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & 0x1f;
}
} else {
sub_080205F8(this);
}
UpdateAnimationVariableFrames(this, 4);
UpdateAnimationVariableFrames(super, 4);
}
void Peahat_ChargeTarget(Entity* this) {
if (sub_08049FDC(this, 1)) {
if (--this->timer == 0) {
void Peahat_ChargeTarget(PeahatEntity* this) {
if (sub_08049FDC(super, 1)) {
if (--super->timer == 0) {
sub_080205F8(this);
}
if (this->timer > 60) {
if (this->timer & 1)
this->speed += 4;
if (super->timer > 60) {
if (super->timer & 1)
super->speed += 4;
if ((gRoomTransition.frameCount & 3) == 0)
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
}
ProcessMovement2(this);
ProcessMovement2(super);
} else {
sub_080205F8(this);
}
UpdateAnimationVariableFrames(this, 4);
UpdateAnimationVariableFrames(super, 4);
}
void Peahat_ChargeEnd(Entity* this) {
if (--this->timer == 0) {
this->action = 1;
this->timer = 1;
this->speed = 128;
this->field_0x82.HALF.HI = 120;
GetNextFrame(this);
void Peahat_ChargeEnd(PeahatEntity* this) {
if (--super->timer == 0) {
super->action = 1;
super->timer = 1;
super->speed = 128;
this->unk_83 = 120;
GetNextFrame(super);
} else {
if (this->timer & 1)
this->speed -= 8;
if (super->timer & 1)
super->speed -= 8;
ProcessMovement2(this);
UpdateAnimationVariableFrames(this, 4);
ProcessMovement2(super);
UpdateAnimationVariableFrames(super, 4);
}
}
void Peahat_Stunned(Entity* this) {
switch (this->animationState) {
void Peahat_Stunned(PeahatEntity* this) {
switch (super->animationState) {
default:
if (sub_080044EC(this, 0x1800) == 0) {
this->action = 6;
this->timer = 240;
this->subtimer = 10;
this->hitType = 0x71;
if (sub_080044EC(super, 0x1800) == 0) {
super->action = 6;
super->timer = 240;
super->subtimer = 10;
super->hitType = 0x71;
}
if (this->direction == 0xff)
this->direction = this->knockbackDirection;
if (super->direction == 0xff)
super->direction = super->knockbackDirection;
ProcessMovement0(this);
GetNextFrame(this);
ProcessMovement0(super);
GetNextFrame(super);
break;
case PeahatAnimation_SlicedPropeller:
GravityUpdate(this, Q_8_8(28.0));
if (this->z.HALF.HI == 0) {
this->action = 7;
this->timer = 150;
this->subtimer = 10;
this->hitType = 0x71;
GravityUpdate(super, Q_8_8(28.0));
if (super->z.HALF.HI == 0) {
super->action = 7;
super->timer = 150;
super->subtimer = 10;
super->hitType = 0x71;
}
break;
};
}
void Peahat_RepairPropeller(Entity* this) {
if ((this->subtimer != 0) && (--this->subtimer == 0)) {
Create0x68FX(this, FX_STARS);
void Peahat_RepairPropeller(PeahatEntity* this) {
if ((super->subtimer != 0) && (--super->subtimer == 0)) {
Create0x68FX(super, FX_STARS);
}
if (sub_0800442E(this) || (--this->timer == 0)) {
this->action = 9;
this->zVelocity = Q_16_16(1.5);
this->direction = Random() & 0x1f;
sub_0804AA1C(this);
this->animationState = PeahatAnimation_RepairPropeller;
InitializeAnimation(this, this->animationState);
if (sub_0800442E(super) || (--super->timer == 0)) {
super->action = 9;
super->zVelocity = Q_16_16(1.5);
super->direction = Random() & 0x1f;
sub_0804AA1C(super);
super->animationState = PeahatAnimation_RepairPropeller;
InitializeAnimation(super, super->animationState);
}
}
void Peahat_Recover(Entity* this) {
if ((this->subtimer != 0) && (--this->subtimer == 0)) {
Create0x68FX(this, FX_STARS);
void Peahat_Recover(PeahatEntity* this) {
if ((super->subtimer != 0) && (--super->subtimer == 0)) {
Create0x68FX(super, FX_STARS);
}
if (sub_0800442E(this) || (--this->timer == 0)) {
this->action = 8;
this->timer = 240;
this->direction = Random() & 0x1f;
sub_0804AA1C(this);
if (sub_0800442E(super) || (--super->timer == 0)) {
super->action = 8;
super->timer = 240;
super->direction = Random() & 0x1f;
sub_0804AA1C(super);
}
}
void Peahat_Hop(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
if (this->frame & ANIM_DONE) {
this->action = 9;
this->zVelocity = Q_16_16(1.5);
this->animationState = PeahatAnimation_NewPropeller;
InitializeAnimation(this, this->animationState);
void Peahat_Hop(PeahatEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
if (super->frame & ANIM_DONE) {
super->action = 9;
super->zVelocity = Q_16_16(1.5);
super->animationState = PeahatAnimation_NewPropeller;
InitializeAnimation(super, super->animationState);
} else {
this->timer = 1;
super->timer = 1;
}
}
if (this->frame & 2) {
this->frame &= ~2;
this->direction = Random() & 0x1f;
if (super->frame & 2) {
super->frame &= ~2;
super->direction = Random() & 0x1f;
}
if (this->frame & 1) {
sub_0800442E(this);
if (super->frame & 1) {
sub_0800442E(super);
} else {
ProcessMovement0(this);
ProcessMovement0(super);
}
}
void Peahat_Takeoff(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->hitType = 0x70;
this->field_0x82.HALF.LO = 1;
this->field_0x80.HALF.HI = 1;
this->animationState = PeahatAnimation_Flying;
InitializeAnimation(this, this->animationState);
} else if (this->frame & 1) {
sub_0800442E(this);
void Peahat_Takeoff(PeahatEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->hitType = 0x70;
this->unk_82 = 1;
this->unk_81 = 1;
super->animationState = PeahatAnimation_Flying;
InitializeAnimation(super, super->animationState);
} else if (super->frame & 1) {
sub_0800442E(super);
} else {
GravityUpdate(this, Q_8_8(28.0));
ProcessMovement0(this);
GravityUpdate(super, Q_8_8(28.0));
ProcessMovement0(super);
}
}
void PeahatPropeller_Initialize(Entity* this) {
this->action = 1;
this->timer = 240;
this->subtimer = 40;
this->spriteSettings.draw = 1;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
this->spriteSettings.shadow = 0;
this->speed = 0x20;
this->direction = (Random() & 0x10) + 8;
InitializeAnimation(this, PeahatAnimation_Propeller);
void PeahatPropeller_Initialize(PeahatEntity* this) {
super->action = 1;
super->timer = 240;
super->subtimer = 40;
super->spriteSettings.draw = 1;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
super->spriteSettings.shadow = 0;
super->speed = 0x20;
super->direction = (Random() & 0x10) + 8;
InitializeAnimation(super, PeahatAnimation_Propeller);
}
void PeahatPropeller_Fly(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
DeleteEntity(this);
void PeahatPropeller_Fly(PeahatEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
DeleteEntity(super);
} else {
if (this->timer < 60)
this->spriteSettings.draw ^= 1;
if (super->timer < 60)
super->spriteSettings.draw ^= 1;
this->z.WORD -= Q_16_16(0.75);
LinearMoveUpdate(this);
if (--this->subtimer == 0) {
this->subtimer = 40;
this->direction = (Random() & 0x10) + 8;
super->z.WORD -= Q_16_16(0.75);
LinearMoveUpdate(super);
if (--super->subtimer == 0) {
super->subtimer = 40;
super->direction = (Random() & 0x10) + 8;
}
}
}
void sub_080205F8(Entity* this) {
this->action = 4;
this->timer = 60;
void sub_080205F8(PeahatEntity* this) {
super->action = 4;
super->timer = 60;
}
void sub_08020604(Entity* this) {
if (!sub_08049FA0(this) && (Random() & 3)) {
this->direction = sub_08049EE4(this);
void sub_08020604(PeahatEntity* this) {
if (!sub_08049FA0(super) && (Random() & 3)) {
super->direction = sub_08049EE4(super);
} else {
this->direction += this->field_0x80.HALF.LO;
this->direction &= 0x1f;
super->direction += this->unk_80;
super->direction &= 0x1f;
}
}
// clang-format off
void (*const Peahat_Functions[])(Entity*) = {
void (*const Peahat_Functions[])(PeahatEntity*) = {
Peahat_OnTick,
Peahat_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(PeahatEntity*))GenericKnockback,
(void (*)(PeahatEntity*))GenericDeath,
(void (*)(PeahatEntity*))GenericConfused,
Peahat_OnGrabbed,
};
void (*const gPeahatPropellerFunctions[])(Entity*) = {
void (*const gPeahatPropellerFunctions[])(PeahatEntity*) = {
PeahatPropeller_Initialize,
PeahatPropeller_Fly,
};
void (*const gPeahatActions[])(Entity*) = {
void (*const gPeahatActions[])(PeahatEntity*) = {
Peahat_Initialize,
Peahat_Fly,
Peahat_ChargeStart,
@@ -400,7 +409,7 @@ const s8 gPeahatFlightHeights[] = {
-5, -6, -7, -6,
};
void (*const gUnk_080CA5BC[])(Entity*) = {
void (*const gUnk_080CA5BC[])(PeahatEntity*) = {
sub_080200B4,
sub_080200E4,
sub_080200EC,
+38 -38
View File
@@ -4,13 +4,13 @@
*
* @brief Pesto enemy
*/
#include "enemy.h"
//#define NENT_DEPRECATED
#include "collision.h"
#include "object.h"
#include "enemy.h"
#include "game.h"
#include "save.h"
#include "object.h"
#include "playeritem.h"
#include "save.h"
void sub_080249F4(Entity*);
void sub_08024940(Entity*);
@@ -166,14 +166,14 @@ void sub_080240B8(Entity* this) {
sub_080249DC(this);
if (this->type == 1) {
Entity* ent;
Entity* entity;
this->field_0x82.HALF.HI = 0;
ent = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
if (ent != NULL) {
this->child = ent;
ent->parent = this;
ent->y.HALF.HI += 0x10;
entity = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
if (entity != NULL) {
this->child = entity;
entity->parent = this;
entity->y.HALF.HI += 0x10;
}
}
}
@@ -403,7 +403,7 @@ void sub_080244E8(Entity* this) {
break;
case 1:
if (EntityInRectRadius(this, this->child, 6, 6)) {
Entity* ent;
Entity* entity;
this->field_0x80.HALF.LO++;
this->timer = 12;
@@ -412,34 +412,34 @@ void sub_080244E8(Entity* this) {
this->z.HALF.HI -= 0xe;
this->field_0x78.HWORD -= 0xe;
ent = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
if (ent != NULL) {
ent->parent = this;
ent->z.HALF.HI += 0xe;
ent->child = this->child;
CopyPosition(ent, ent->child);
this->child = ent;
entity = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
if (entity != NULL) {
entity->parent = this;
entity->z.HALF.HI += 0xe;
entity->child = this->child;
CopyPosition(entity, entity->child);
this->child = entity;
}
}
break;
case 2:
if (EntityInRectRadius(this, this->child, 6, 6)) {
Entity* ent;
Entity* entity;
this->field_0x80.HALF.LO++;
this->timer = 12;
this->field_0x82.HALF.HI &= ~0x80;
ent = this->child;
SetTile((u16)ent->field_0x70.HALF.LO, COORD_TO_TILE(ent), ent->collisionLayer);
DeleteEntity(ent);
entity = this->child;
SetTile((u16)entity->field_0x70.HALF.LO, COORD_TO_TILE(entity), entity->collisionLayer);
DeleteEntity(entity);
this->z.HALF.HI -= 0xe;
this->field_0x78.HWORD -= 0xe;
ent = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
if (ent != NULL) {
ent->parent = this;
ent->z.HALF.HI += 0xe;
this->child = ent;
entity = CreateProjectileWithParent(this, DIRT_BALL_PROJECTILE, this->field_0x82.HALF.HI);
if (entity != NULL) {
entity->parent = this;
entity->z.HALF.HI += 0xe;
this->child = entity;
}
}
break;
@@ -635,7 +635,7 @@ bool32 sub_08024AD8(Entity* this) {
bool32 sub_08024B38(Entity* this) {
int iVar4 = 0;
Entity* ent;
Entity* entity;
if (gPlayerState.hurtBlinkSpeed != 0) {
if (gPlayerState.swim_state == 1) {
@@ -660,34 +660,34 @@ bool32 sub_08024B38(Entity* this) {
}
}
ent = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2);
if (ent != NULL) {
entity = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2);
if (entity != NULL) {
do {
if (ent->action != 2 && ent->z.HALF.HI == 0 && sub_08049F1C(this, ent, 0xa0)) {
if (entity->action != 2 && entity->z.HALF.HI == 0 && sub_08049F1C(this, entity, 0xa0)) {
iVar4 = 1;
this->child = ent;
this->child = entity;
this->field_0x82.HALF.HI |= 1;
this->field_0x82.HALF.HI &= ~0x40;
break;
}
} while (ent = FindNextDuplicateID(ent, 2), ent != NULL);
} while (entity = FindNextDuplicateID(entity, 2), entity != NULL);
}
if (iVar4 != 0) {
return iVar4;
}
ent = FindEntityByID(OBJECT, POT, 6);
if (ent != NULL) {
entity = FindEntityByID(OBJECT, POT, 6);
if (entity != NULL) {
do {
if (ent->action == 1 && sub_08049F1C(this, ent, 0xa0)) {
if (entity->action == 1 && sub_08049F1C(this, entity, 0xa0)) {
iVar4 = 1;
this->child = ent;
this->child = entity;
this->field_0x82.HALF.HI |= 2;
this->field_0x82.HALF.HI &= ~0x40;
break;
}
} while (ent = FindNextDuplicateID(ent, 6), ent != NULL);
} while (entity = FindNextDuplicateID(entity, 6), entity != NULL);
}
if (iVar4 == 0) {
+55 -35
View File
@@ -4,11 +4,31 @@
*
* @brief Puffstool enemy
*/
//#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*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;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unused2[1];
/*0x84*/ u16 unk_84;
/*0x86*/ u16 unk_86;
} PuffstoolEntity;
extern u8 gUnk_080B3E80[];
bool32 sub_080258C4(Entity*);
@@ -83,10 +103,10 @@ void Puffstool_OnCollide(Entity* this) {
break;
default:
if (this->hitType == 0x82 && this->iframes < 0) {
Entity* ent = CreateObject(DIRT_PARTICLE, 2, 0);
if (ent != NULL) {
ent->spritePriority.b0 = 3;
CopyPosition(this, ent);
Entity* entity = CreateObject(DIRT_PARTICLE, 2, 0);
if (entity != NULL) {
entity->spritePriority.b0 = 3;
CopyPosition(this, entity);
}
EnqueueSFX(SFX_186);
}
@@ -299,12 +319,12 @@ void sub_08025514(Entity* this) {
}
void sub_08025554(Entity* this) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
sub_080256B4(this);
} else {
if ((this->timer & 3) == 0) {
this->direction = GetFacingDirection(ent, this);
this->direction = GetFacingDirection(entity, this);
}
sub_08025C44(this);
GetNextFrame(this);
@@ -319,8 +339,8 @@ void sub_08025554(Entity* this) {
}
void sub_080255AC(Entity* this) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
sub_080256B4(this);
} else {
if (this->field_0x80.HALF.HI != 0) {
@@ -338,7 +358,7 @@ void sub_080255AC(Entity* this) {
}
tmp -= 7;
this->direction = (GetFacingDirection(ent, this) + tmp) & 0x1f;
this->direction = (GetFacingDirection(entity, this) + tmp) & 0x1f;
}
if (this->field_0x78.HWORD == 0) {
@@ -437,15 +457,15 @@ bool32 sub_080257EC(Entity* this, u32 x, u32 y) {
}
bool32 sub_080258C4(Entity* this) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
return FALSE;
} else {
s32 iVar4;
s32 iVar1;
iVar4 = ent->x.HALF.HI - this->x.HALF.HI;
iVar4 = entity->x.HALF.HI - this->x.HALF.HI;
iVar4 = iVar4 * iVar4;
iVar1 = ent->y.HALF.HI - this->y.HALF.HI;
iVar1 = entity->y.HALF.HI - this->y.HALF.HI;
iVar1 = iVar1 * iVar1;
iVar4 = iVar4 + iVar1;
if (this->cutsceneBeh.HWORD == 0 && this->field_0x80.HALF.HI == 0 && 0x400 >= iVar4) {
@@ -522,21 +542,21 @@ bool32 sub_08025AB8(u32 tile, u32 layer) {
}
void sub_08025AE8(Entity* this) {
Entity* ent;
Entity* entity;
ent = CreateFx(this, FX_BROWN_SMOKE, 0);
if (ent != NULL) {
ent->y.WORD--;
entity = CreateFx(this, FX_BROWN_SMOKE, 0);
if (entity != NULL) {
entity->y.WORD--;
}
ent = CreateFx(this, FX_BROWN_SMOKE_LARGE, 0);
if (ent != NULL) {
ent->y.WORD++;
entity = CreateFx(this, FX_BROWN_SMOKE_LARGE, 0);
if (entity != NULL) {
entity->y.WORD++;
}
}
void sub_08025B18(Entity* this) {
Entity* ent;
Entity* entity;
s32 x = this->x.HALF.HI - gRoomControls.origin_x;
s32 y = this->y.HALF.HI - gRoomControls.origin_y;
@@ -548,25 +568,25 @@ void sub_08025B18(Entity* this) {
for (; i < 9; i++, offset += 2) {
sub_08025AB8((((x + offset[0]) >> 4) & 0x3fU) | ((((y + offset[1]) >> 4) & 0x3fU) << 6), layer);
ent = CreateObject(DIRT_PARTICLE, 2, 0);
if (ent != NULL) {
PositionRelative(this, ent, Q_16_16(offset[0]), Q_16_16(offset[1]));
ent->x.HALF.HI &= -0x10;
ent->x.HALF.HI += 8;
ent->y.HALF.HI &= -0x10;
ent->y.HALF.HI += 8;
ent->z.HALF.HI = -1;
entity = CreateObject(DIRT_PARTICLE, 2, 0);
if (entity != NULL) {
PositionRelative(this, 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;
entity->y.HALF.HI += 8;
entity->z.HALF.HI = -1;
}
}
}
void sub_08025BD4(Entity* this) {
if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) {
Entity* ent = CreateObject(DIRT_PARTICLE, 0, 0);
if (ent != NULL) {
PositionRelative(this, ent, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 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]));
ent->z.HALF.HI = -10;
entity->z.HALF.HI = -10;
}
}
}
+15 -15
View File
@@ -4,7 +4,7 @@
*
* @brief Rock Chuchu enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "player.h"
@@ -20,7 +20,7 @@ void RockChuchu_OnTick(Entity* this) {
}
void RockChuchu_OnCollision(Entity* this) {
Entity* ent;
Entity* entity;
if (this->health) {
switch (this->contactFlags & 0x7f) {
@@ -44,18 +44,18 @@ void RockChuchu_OnCollision(Entity* this) {
case 0x16:
case 0x1c:
CreateFx(this, FX_ROCK, 0);
ent = CreateEnemy(CHUCHU, 1);
if (ent != NULL) {
ent->type2 = 1;
entity = CreateEnemy(CHUCHU, 1);
if (entity != NULL) {
entity->type2 = 1;
#ifndef EU
ent->iframes = -8;
entity->iframes = -8;
#endif
sub_0804A4E4(this, ent);
sub_0804A4E4(this, entity);
this->action = 2;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
this->direction = this->knockbackDirection;
this->child = ent;
this->child = entity;
}
}
} else {
@@ -97,15 +97,15 @@ void sub_08022390(Entity* this) {
}
void sub_080223E4(Entity* this) {
Entity* ent;
Entity* entity;
ent = this->child;
if (ent != NULL) {
ent->contactFlags = 0x94;
ent->iframes = 0x10;
entity = this->child;
if (entity != NULL) {
entity->contactFlags = 0x94;
entity->iframes = 0x10;
#ifndef EU
ent->knockbackDuration = 0xc;
ent->knockbackDirection = this->direction;
entity->knockbackDuration = 0xc;
entity->knockbackDirection = this->direction;
#endif
}
+171 -164
View File
@@ -4,281 +4,288 @@
*
* @brief Rollobite enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "physics.h"
#include "player.h"
#include "room.h"
#include "collision.h"
extern void (*const Rollobite_Functions[])(Entity*);
extern void (*const gRollobiteActions[])(Entity*);
extern void (*const gUnk_080CA6A4[])(Entity*);
extern void (*const gUnk_080CA6BC[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[28];
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unk_85;
} RollobiteEntity;
extern void (*const Rollobite_Functions[])(RollobiteEntity*);
extern void (*const gRollobiteActions[])(RollobiteEntity*);
extern void (*const gUnk_080CA6A4[])(RollobiteEntity*);
extern void (*const gUnk_080CA6BC[])(RollobiteEntity*);
extern const u8 gUnk_080CA6CC[];
extern const s8 gUnk_080CA6D4[];
void sub_08020A30(Entity*);
void sub_08020A7C(Entity*);
bool32 Rollobite_TryToHoleUp(Entity*);
bool32 Rollobite_IsRolledUp(Entity*);
void sub_08020A30(RollobiteEntity* this);
void sub_08020A7C(RollobiteEntity* this);
bool32 Rollobite_TryToHoleUp(RollobiteEntity* this);
bool32 Rollobite_IsRolledUp(RollobiteEntity* this);
extern void RegisterCarryEntity(Entity*);
void Rollobite(Entity* this) {
EnemyFunctionHandler(this, Rollobite_Functions);
void Rollobite(RollobiteEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Rollobite_Functions);
}
void Rollobite_OnTick(Entity* this) {
void Rollobite_OnTick(RollobiteEntity* this) {
Rollobite_TryToHoleUp(this);
gRollobiteActions[this->action](this);
gRollobiteActions[super->action](this);
}
void Rollobite_OnCollision(Entity* this) {
if (this->hitType == 34 && this->health != 0xff) {
this->action = 4;
this->zVelocity = Q_16_16(2.0);
this->direction = 0xff;
this->health = 0xff;
this->hitType = 35;
InitializeAnimation(this, this->animationState + 8);
void Rollobite_OnCollision(RollobiteEntity* this) {
if (super->hitType == 34 && super->health != 0xff) {
super->action = 4;
super->zVelocity = Q_16_16(2.0);
super->direction = 0xff;
super->health = 0xff;
super->hitType = 35;
InitializeAnimation(super, super->animationState + 8);
}
if (this->contactFlags != 0x80) {
if (this->action == 4 || this->action == 5) {
this->action = 4;
this->timer = 180;
this->direction = 0xff;
InitializeAnimation(this, this->animationState + 0x10);
if (super->contactFlags != 0x80) {
if (super->action == 4 || super->action == 5) {
super->action = 4;
super->timer = 180;
super->direction = 0xff;
InitializeAnimation(super, super->animationState + 0x10);
}
}
if (this->contactFlags == 0x93)
if (super->contactFlags == 0x93)
Rollobite_OnTick(this);
}
void Rollobite_OnKnockback(Entity* this) {
void Rollobite_OnKnockback(RollobiteEntity* this) {
if (Rollobite_TryToHoleUp(this)) {
this->knockbackDuration = 0;
super->knockbackDuration = 0;
} else if (Rollobite_IsRolledUp(this)) {
this->knockbackDuration--;
CalculateEntityTileCollisions(this, this->knockbackDirection, 10);
ProcessMovementInternal(this, this->knockbackSpeed, this->knockbackDirection, 10);
super->knockbackDuration--;
CalculateEntityTileCollisions(super, super->knockbackDirection, 10);
ProcessMovementInternal(super, super->knockbackSpeed, super->knockbackDirection, 10);
} else {
GenericKnockback(this);
GenericKnockback(super);
}
}
void Rollobite_OnGrabbed(Entity* this) {
if (this->subAction < 3 && !sub_0806F520(this)) {
this->action = 4;
COLLISION_ON(this);
this->direction = 0xff;
InitializeAnimation(this, this->animationState + 0x10);
void Rollobite_OnGrabbed(RollobiteEntity* this) {
if (super->subAction < 3 && !sub_0806F520(super)) {
super->action = 4;
COLLISION_ON(super);
super->direction = 0xff;
InitializeAnimation(super, super->animationState + 0x10);
} else {
gUnk_080CA6A4[this->subAction](this);
gUnk_080CA6A4[super->subAction](this);
}
}
void sub_0802077C(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
void sub_0802077C(RollobiteEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_08020788(Entity* this) {
sub_0806F4E8(this);
void sub_08020788(RollobiteEntity* this) {
sub_0806F4E8(super);
}
void sub_08020790(Entity* this) {
sub_0806F3E4(this);
void sub_08020790(RollobiteEntity* this) {
sub_0806F3E4(super);
}
void sub_08020798(Entity* this) {
COLLISION_OFF(this);
void sub_08020798(RollobiteEntity* this) {
COLLISION_OFF(super);
}
void nullsub_6(Entity* this) {
void nullsub_6(RollobiteEntity* this) {
/* ... */
}
void sub_080207A8(Entity* this) {
this->action = 4;
COLLISION_ON(this);
this->spritePriority.b0 = 4;
this->gustJarState &= 0xfb;
this->direction ^= 0x10;
this->zVelocity = Q_16_16(1.5);
this->speed = 0x80;
InitializeAnimation(this, this->animationState + 0x10);
void sub_080207A8(RollobiteEntity* this) {
super->action = 4;
COLLISION_ON(super);
super->spritePriority.b0 = 4;
super->gustJarState &= 0xfb;
super->direction ^= 0x10;
super->zVelocity = Q_16_16(1.5);
super->speed = 0x80;
InitializeAnimation(super, super->animationState + 0x10);
}
void Rollobite_Initialize(Entity* this) {
sub_0804A720(this);
this->carryFlags = 0x30;
this->gustJarFlags = 18;
this->cutsceneBeh.HALF.LO = 0;
this->direction = DirectionRound(Random());
void Rollobite_Initialize(RollobiteEntity* this) {
sub_0804A720(super);
super->carryFlags = 0x30;
super->gustJarFlags = 18;
this->unk_84 = 0;
super->direction = DirectionRound(Random());
sub_08020A30(this);
}
void Rollobite_Walk(Entity* this) {
GetNextFrame(this);
if (this->frame & 0x1) {
this->frame &= ~0x1;
if (!ProcessMovement0(this))
this->timer = 1;
void Rollobite_Walk(RollobiteEntity* this) {
GetNextFrame(super);
if (super->frame & 0x1) {
super->frame &= ~0x1;
if (!ProcessMovement0(super))
super->timer = 1;
}
if (this->frame & 0x10) {
this->frame &= ~0x10;
if (--this->timer == 0) {
this->action = 3;
this->timer = 60;
if (super->frame & 0x10) {
super->frame &= ~0x10;
if (--super->timer == 0) {
super->action = 3;
super->timer = 60;
}
}
}
void sub_08020874(Entity* this) {
gUnk_080CA6BC[this->subAction](this);
void sub_08020874(RollobiteEntity* this) {
gUnk_080CA6BC[super->subAction](this);
}
void sub_0802088C(Entity* this) {
this->subAction = 1;
COLLISION_OFF(this);
this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState;
this->spritePriority.b1 = 0;
void sub_0802088C(RollobiteEntity* this) {
super->subAction = 1;
COLLISION_OFF(super);
this->unk_85 = gPlayerEntity.animationState;
super->spritePriority.b1 = 0;
}
void sub_080208B4(Entity* this) {
s8 uVar1 = (this->cutsceneBeh.HALF.HI - gPlayerEntity.animationState) / 2;
void sub_080208B4(RollobiteEntity* this) {
s8 uVar1 = (this->unk_85 - gPlayerEntity.animationState) / 2;
if (uVar1) {
this->animationState = (this->animationState + uVar1) & 3;
InitializeAnimation(this, this->animationState + 0x10);
super->animationState = (super->animationState + uVar1) & 3;
InitializeAnimation(super, super->animationState + 0x10);
}
this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState;
this->unk_85 = gPlayerEntity.animationState;
}
void sub_080208F0(Entity* this) {
this->spritePriority.b1 = 3;
void sub_080208F0(RollobiteEntity* this) {
super->spritePriority.b1 = 3;
}
void sub_08020904(Entity* this) {
this->action = 4;
COLLISION_ON(this);
this->direction = -1;
InitializeAnimation(this, this->animationState + 0x10);
void sub_08020904(RollobiteEntity* this) {
super->action = 4;
COLLISION_ON(super);
super->direction = -1;
InitializeAnimation(super, super->animationState + 0x10);
}
void Rollobite_Turn(Entity* this) {
if (--this->timer == 0)
void Rollobite_Turn(RollobiteEntity* this) {
if (--super->timer == 0)
sub_08020A30(this);
}
void Rollobite_RolledUp(Entity* this) {
void Rollobite_RolledUp(RollobiteEntity* this) {
u32 unk;
if ((this->frame & ANIM_DONE) == 0)
GetNextFrame(this);
if ((super->frame & ANIM_DONE) == 0)
GetNextFrame(super);
unk = sub_080044EC(this, 0x2800);
unk = sub_080044EC(super, 0x2800);
if (unk == 0) {
if (--this->timer == 0) {
this->action = 5;
InitializeAnimation(this, this->animationState + 12);
if (--super->timer == 0) {
super->action = 5;
InitializeAnimation(super, super->animationState + 12);
}
RegisterCarryEntity(this);
RegisterCarryEntity(super);
} else {
if (unk == 1)
EnqueueSFX(SFX_PLACE_OBJ);
if ((this->direction & 0x80) == 0)
ProcessMovement2(this);
if ((super->direction & 0x80) == 0)
ProcessMovement2(super);
}
}
void Rollobite_Unroll(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
COLLISION_ON(this);
this->speed = 0x100;
this->hitType = 34;
void Rollobite_Unroll(RollobiteEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
COLLISION_ON(super);
super->speed = 0x100;
super->hitType = 34;
sub_08020A30(this);
this->direction = DirectionFromAnimationState(this->animationState);
InitializeAnimation(this, this->animationState);
super->direction = DirectionFromAnimationState(super->animationState);
InitializeAnimation(super, super->animationState);
} else {
if ((this->frame & 1) == 0)
RegisterCarryEntity(this);
if ((super->frame & 1) == 0)
RegisterCarryEntity(super);
}
}
void Rollobite_LinedUp(Entity* this) {
if (GravityUpdate(this, Q_8_8(28.0)) == 0) {
this->action = 7;
this->spritePriority.b0 = 7;
void Rollobite_LinedUp(RollobiteEntity* this) {
if (GravityUpdate(super, Q_8_8(28.0)) == 0) {
super->action = 7;
super->spritePriority.b0 = 7;
}
if (this->frame == 0)
GetNextFrame(this);
if (super->frame == 0)
GetNextFrame(super);
}
void Rollobite_Holed(Entity* this) {
GetNextFrame(this);
void Rollobite_Holed(RollobiteEntity* this) {
GetNextFrame(super);
}
void sub_08020A30(Entity* this) {
if (this->cutsceneBeh.HALF.LO < 2) {
this->timer = gUnk_080CA6CC[Random() & 7];
if (this->timer == 0) {
this->action = 3;
this->timer = 60;
this->cutsceneBeh.HALF.LO++;
void sub_08020A30(RollobiteEntity* this) {
if (this->unk_84 < 2) {
super->timer = gUnk_080CA6CC[Random() & 7];
if (super->timer == 0) {
super->action = 3;
super->timer = 60;
this->unk_84++;
return;
}
}
this->action = 1;
this->cutsceneBeh.HALF.LO = 0;
super->action = 1;
this->unk_84 = 0;
sub_08020A7C(this);
}
void sub_08020A7C(Entity* this) {
void sub_08020A7C(RollobiteEntity* this) {
int tmp = Random();
u32 state = DirectionRound(this->direction + gUnk_080CA6D4[tmp % 3]);
u32 state = DirectionRound(super->direction + gUnk_080CA6D4[tmp % 3]);
if (sub_08049FA0(this) == 0) {
int tmp = DirectionRoundUp(sub_08049EE4(this));
if (sub_08049FA0(super) == 0) {
int tmp = DirectionRoundUp(sub_08049EE4(super));
if ((state ^ 0x10) == tmp)
state ^= 0x10;
}
this->direction = state;
this->animationState = (u8)(state >> 3);
InitializeAnimation(this, this->animationState);
super->direction = state;
super->animationState = (u8)(state >> 3);
InitializeAnimation(super, super->animationState);
}
bool32 Rollobite_TryToHoleUp(Entity* this) {
if (Rollobite_IsRolledUp(this) && this->z.HALF.HI == 0) {
int tile = COORD_TO_TILE(this);
int iVar1 = GetTileType(tile, this->collisionLayer);
bool32 Rollobite_TryToHoleUp(RollobiteEntity* this) {
if (Rollobite_IsRolledUp(this) && super->z.HALF.HI == 0) {
int tile = COORD_TO_TILE(super);
int iVar1 = GetTileType(tile, super->collisionLayer);
if ((iVar1 * 0x10000 - 0x710000U) >> 0x10 < 2) {
this->action = 6;
COLLISION_OFF(this);
this->x.HALF.HI &= 0xfff0;
this->x.HALF.HI += 8;
this->y.HALF.HI &= 0xfff0;
this->y.HALF.HI += 13;
this->zVelocity = Q_16_16(2.0);
InitializeAnimation(this, this->animationState + 0x14);
SetTile(0x4034, tile, this->collisionLayer);
super->action = 6;
COLLISION_OFF(super);
super->x.HALF.HI &= 0xfff0;
super->x.HALF.HI += 8;
super->y.HALF.HI &= 0xfff0;
super->y.HALF.HI += 13;
super->zVelocity = Q_16_16(2.0);
InitializeAnimation(super, super->animationState + 0x14);
SetTile(0x4034, tile, super->collisionLayer);
return TRUE;
}
}
return FALSE;
}
bool32 Rollobite_IsRolledUp(Entity* this) {
u32 tmp = this->animIndex;
bool32 Rollobite_IsRolledUp(RollobiteEntity* this) {
u32 tmp = super->animIndex;
if (16 <= tmp && tmp <= 19) {
return TRUE;
} else {
@@ -287,16 +294,16 @@ bool32 Rollobite_IsRolledUp(Entity* this) {
}
// clang-format off
void (*const Rollobite_Functions[])(Entity*) = {
void (*const Rollobite_Functions[])(RollobiteEntity*) = {
Rollobite_OnTick,
Rollobite_OnCollision,
Rollobite_OnKnockback,
GenericDeath,
GenericConfused,
(void (*)(RollobiteEntity*))GenericDeath,
(void (*)(RollobiteEntity*))GenericConfused,
Rollobite_OnGrabbed,
};
void (*const gRollobiteActions[])(Entity*) = {
void (*const gRollobiteActions[])(RollobiteEntity*) = {
Rollobite_Initialize,
Rollobite_Walk,
sub_08020874,
@@ -307,7 +314,7 @@ void (*const gRollobiteActions[])(Entity*) = {
Rollobite_Holed,
};
void (*const gUnk_080CA6A4[])(Entity*) = {
void (*const gUnk_080CA6A4[])(RollobiteEntity*) = {
sub_0802077C,
sub_08020788,
sub_08020790,
@@ -316,7 +323,7 @@ void (*const gUnk_080CA6A4[])(Entity*) = {
sub_080207A8,
};
void (*const gUnk_080CA6BC[])(Entity*) = {
void (*const gUnk_080CA6BC[])(RollobiteEntity*) = {
sub_0802088C,
sub_080208B4,
sub_080208F0,
+117 -109
View File
@@ -4,203 +4,211 @@
*
* @brief Rope enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
void Rope_OnTick(Entity*);
void Rope_OnCollision(Entity*);
void Rope_OnGrabbed(Entity*);
void sub_08031434(Entity*);
void sub_08031480(Entity*);
void sub_080314FC(Entity*);
void sub_080315BC(Entity*);
void sub_0803140C(Entity*);
void sub_08031418(Entity*);
void sub_08031420(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unused2[1];
/*0x7a*/ u16 unk_7a;
} RopeEntity;
static void (*const Rope_Functions[6])(Entity*) = {
Rope_OnTick, Rope_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Rope_OnGrabbed,
void Rope_OnTick(RopeEntity* this);
void Rope_OnCollision(RopeEntity* this);
void Rope_OnGrabbed(RopeEntity* this);
void sub_08031434(RopeEntity* this);
void sub_08031480(RopeEntity* this);
void sub_080314FC(RopeEntity* this);
void sub_080315BC(RopeEntity* this);
void sub_0803140C(RopeEntity* this);
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,
};
extern Entity* gUnk_020000B0;
void sub_08031600(Entity*);
u32 sub_0803163C(Entity*);
void sub_08031600(RopeEntity* this);
u32 sub_0803163C(RopeEntity* this);
void Rope(Entity* this) {
EnemyFunctionHandler(this, Rope_Functions);
SetChildOffset(this, 0, 1, -16);
void Rope(RopeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Rope_Functions);
SetChildOffset(super, 0, 1, -16);
}
void Rope_OnTick(Entity* this) {
static void (*const actionFuncs[4])(Entity*) = {
void Rope_OnTick(RopeEntity* this) {
static void (*const actionFuncs[4])(RopeEntity*) = {
sub_08031434,
sub_08031480,
sub_080314FC,
sub_080315BC,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void Rope_OnCollision(Entity* this) {
if (this->action == 3) {
this->subtimer = 30;
this->field_0x78.HALF.LO = 0x3c;
void Rope_OnCollision(RopeEntity* this) {
if (super->action == 3) {
super->subtimer = 30;
this->unk_78 = 0x3c;
sub_08031600(this);
}
if (this->confusedTime) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Rope_Functions);
EnemyFunctionHandlerAfterCollision(super, Rope_Functions);
}
void Rope_OnGrabbed(Entity* this) {
static void (*const subActionFuncs[3])(Entity*) = {
void Rope_OnGrabbed(RopeEntity* this) {
static void (*const subActionFuncs[3])(RopeEntity*) = {
sub_0803140C,
sub_08031418,
sub_08031420,
};
if (sub_0806F520(this)) {
subActionFuncs[this->subAction](this);
if (sub_0806F520(super)) {
subActionFuncs[super->subAction](this);
}
}
void sub_0803140C(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_0803140C(RopeEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_08031418(Entity* this) {
sub_0806F4E8(this);
void sub_08031418(RopeEntity* this) {
sub_0806F4E8(super);
}
void sub_08031420(Entity* this) {
if (sub_0806F3E4(this)) {
GenericDeath(this);
void sub_08031420(RopeEntity* this) {
if (sub_0806F3E4(super)) {
GenericDeath(super);
}
}
void sub_08031434(Entity* this) {
void sub_08031434(RopeEntity* this) {
sub_0804A720(this);
this->animationState = 0xff;
this->gustJarFlags = 1;
this->field_0x7a.HWORD = this->speed;
if (!(this->type)) {
sub_0804A720(super);
super->animationState = 0xff;
super->gustJarFlags = 1;
this->unk_7a = super->speed;
if (!(super->type)) {
sub_08031600(this);
} else {
this->action = 1;
this->subAction = 0;
this->spriteSettings.draw = (this->spriteSettings.draw & 0xfc);
this->z.HALF.HI = -0x80;
this->frameIndex = 0xff;
super->action = 1;
super->subAction = 0;
super->spriteSettings.draw = (super->spriteSettings.draw & 0xfc);
super->z.HALF.HI = -0x80;
super->frameIndex = 0xff;
}
}
void sub_08031480(Entity* this) {
if (this->subAction == 0) {
if (this->timer != 0) {
this->timer--;
void sub_08031480(RopeEntity* this) {
if (super->subAction == 0) {
if (super->timer != 0) {
super->timer--;
} else {
sub_08031600(this);
this->action = 1;
this->subAction = 1;
this->spriteSettings.draw = 3;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
super->action = 1;
super->subAction = 1;
super->spriteSettings.draw = 3;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
SoundReq(SFX_12D);
}
} else {
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 2;
this->subtimer = 15;
this->spriteSettings.draw = 1;
UpdateSpriteForCollisionLayer(this);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
super->action = 2;
super->subtimer = 15;
super->spriteSettings.draw = 1;
UpdateSpriteForCollisionLayer(super);
EnqueueSFX(SFX_WATER_SPLASH);
}
}
}
void sub_080314FC(Entity* this) {
void sub_080314FC(RopeEntity* this) {
u32 u;
GetNextFrame(this);
if (this->subtimer) {
this->subtimer--;
GetNextFrame(super);
if (super->subtimer) {
super->subtimer--;
} else {
if (this->field_0x78.HALF.LO) {
this->field_0x78.HALF.LO--;
if (this->unk_78) {
this->unk_78--;
}
if (sub_08049FA0(this)) {
if (!(this->field_0x78.HALF.LO)) {
if (sub_08049FDC(this, 1)) {
u = sub_0804A044(this, gUnk_020000B0, 0xc);
if (sub_08049FA0(super)) {
if (!(this->unk_78)) {
if (sub_08049FDC(super, 1)) {
u = sub_0804A044(super, gUnk_020000B0, 0xc);
if (u != 0xff) {
this->action = 3;
this->timer = 30;
this->field_0x7a.HWORD = this->speed = 0x1a0;
this->direction = u;
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
super->action = 3;
super->timer = 30;
this->unk_7a = super->speed = 0x1a0;
super->direction = u;
super->animationState = super->direction >> 3;
InitializeAnimation(super, super->animationState + 4);
return;
}
}
}
} else {
if ((Random() & 1)) {
this->direction = DirectionRoundUp(sub_08049EE4(this));
u = this->direction >> 3;
if (u != this->animationState) {
this->animationState = u;
InitializeAnimation(this, u);
super->direction = DirectionRoundUp(sub_08049EE4(super));
u = super->direction >> 3;
if (u != super->animationState) {
super->animationState = u;
InitializeAnimation(super, u);
}
}
}
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_08031600(this);
}
sub_0803163C(this);
}
}
void sub_080315BC(Entity* this) {
if (this->timer != 0) {
this->timer--;
UpdateAnimationVariableFrames(this, 2);
void sub_080315BC(RopeEntity* this) {
if (super->timer != 0) {
super->timer--;
UpdateAnimationVariableFrames(super, 2);
} else {
if (sub_08049FA0(this)) {
GetNextFrame(this);
if (sub_08049FA0(super)) {
GetNextFrame(super);
if (sub_0803163C(this)) {
return;
}
}
this->field_0x78.HALF.LO = 0x1e;
this->unk_78 = 0x1e;
sub_08031600(this);
}
}
void sub_08031600(Entity* this) {
void sub_08031600(RopeEntity* this) {
u32 r;
this->action = 2;
this->timer = (Random() & 0x30) + 60;
this->speed = 0x80;
this->field_0x7a.HWORD = 0x80;
super->action = 2;
super->timer = (Random() & 0x30) + 60;
super->speed = 0x80;
this->unk_7a = 0x80;
r = Random() & 0x18;
this->direction = r;
super->direction = r;
r = r / 8;
if (r != this->animationState) {
this->animationState = r;
InitializeAnimation(this, r);
if (r != super->animationState) {
super->animationState = r;
InitializeAnimation(super, r);
}
}
u32 sub_0803163C(Entity* this) {
u32 sub_0803163C(RopeEntity* this) {
u32 h;
if (GetTileUnderEntity(this) == 0x13) {
h = this->field_0x7a.HWORD / 2;
if (GetTileUnderEntity(super) == 0x13) {
h = this->unk_7a / 2;
} else {
h = this->field_0x7a.HWORD;
h = this->unk_7a;
}
this->speed = h;
return ProcessMovement0(this);
super->speed = h;
return ProcessMovement0(super);
}
+90 -83
View File
@@ -4,166 +4,173 @@
*
* @brief Golden Rope enemy
*/
#include "global.h"
#include "entity.h"
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "physics.h"
#include "player.h"
#include "item.h"
void RopeGolden_OnTick(Entity*);
void RopeGolden_OnCollision(Entity*);
void RopeGolden_OnDeath(Entity*);
void sub_08038258(Entity*);
void sub_0803827C(Entity*);
void sub_080382EC(Entity*);
void sub_08038304(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
} RopeGoldenEntity;
static void (*const RopeGolden_Functions[6])(Entity*) = {
RopeGolden_OnTick, RopeGolden_OnCollision, GenericKnockback, RopeGolden_OnDeath, GenericConfused, RopeGolden_OnTick,
void RopeGolden_OnTick(RopeGoldenEntity* this);
void RopeGolden_OnCollision(RopeGoldenEntity* this);
void RopeGolden_OnDeath(RopeGoldenEntity* this);
void sub_08038258(RopeGoldenEntity* this);
void sub_0803827C(RopeGoldenEntity* this);
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,
};
void sub_080383AC(Entity*);
void sub_080383E4(Entity*);
void sub_080383AC(RopeGoldenEntity* this);
void sub_080383E4(RopeGoldenEntity* this);
void RopeGolden(Entity* this) {
void RopeGolden(RopeGoldenEntity* this) {
u32 x;
x = sub_080012DC(this);
x = sub_080012DC(super);
if (x != 0) {
gUnk_080012C8[x](this);
gUnk_080012C8[x](super);
} else {
RopeGolden_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
RopeGolden_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
}
void RopeGolden_OnTick(Entity* this) {
static void (*const actionFuncs[4])(Entity*) = {
void RopeGolden_OnTick(RopeGoldenEntity* this) {
static void (*const actionFuncs[4])(RopeGoldenEntity*) = {
sub_08038258,
sub_0803827C,
sub_080382EC,
sub_08038304,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void RopeGolden_OnCollision(Entity* this) {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
void RopeGolden_OnCollision(RopeGoldenEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, RopeGolden_Functions);
EnemyFunctionHandlerAfterCollision(super, RopeGolden_Functions);
}
void RopeGolden_OnDeath(Entity* this) {
if ((this->gustJarState & 2) == 0) {
SetGlobalFlag(this->type2);
void RopeGolden_OnDeath(RopeGoldenEntity* this) {
if ((super->gustJarState & 2) == 0) {
SetGlobalFlag(super->type2);
}
CreateDeathFx(this, 0xff, ITEM_RUPEE100);
CreateDeathFx(super, 0xff, ITEM_RUPEE100);
}
void sub_08038258(Entity* this) {
if (CheckGlobalFlag(this->type2) != 0) {
void sub_08038258(RopeGoldenEntity* this) {
if (CheckGlobalFlag(super->type2) != 0) {
DeleteThisEntity();
}
sub_0804A720(this);
this->animationState = 0xff;
sub_0804A720(super);
super->animationState = 0xff;
sub_080383AC(this);
}
void sub_0803827C(Entity* this) {
if (this->subtimer != 0) {
this->subtimer--;
void sub_0803827C(RopeGoldenEntity* this) {
if (super->subtimer != 0) {
super->subtimer--;
} else {
if ((sub_0804A044(this, &gPlayerEntity, 0x8) != 0xff) ||
(EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x24) != 0)) {
if ((sub_0804A044(super, &gPlayerEntity, 0x8) != 0xff) ||
(EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x24) != 0)) {
sub_080383E4(this);
return;
}
}
UpdateAnimationVariableFrames(this, 0x2);
if (!ProcessMovement0(this)) {
UpdateAnimationVariableFrames(super, 0x2);
if (!ProcessMovement0(super)) {
sub_080383AC(this);
} else {
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_080383AC(this);
}
}
}
void sub_080382EC(Entity* this) {
if (--this->timer == 0) {
this->action = 3;
void sub_080382EC(RopeGoldenEntity* this) {
if (--super->timer == 0) {
super->action = 3;
}
}
void sub_08038304(Entity* this) {
void sub_08038304(RopeGoldenEntity* this) {
u32 cVar2;
s32 tmp;
u32 tmp3;
u32 h;
UpdateAnimationVariableFrames(this, 2);
if (!ProcessMovement0(this)) {
if (this->field_0x78.HALF.LO == this->direction) {
UpdateAnimationVariableFrames(super, 2);
if (!ProcessMovement0(super)) {
if (this->unk_78 == super->direction) {
#ifdef EU
this->subtimer = 30;
super->subtimer = 30;
#else
this->subtimer = 90;
super->subtimer = 90;
#endif
sub_080383AC(this);
} else {
this->direction = this->field_0x78.HALF.LO;
super->direction = this->unk_78;
}
} else {
tmp = 10;
if ((u8)((++this->timer) % tmp) == 0) {
this->timer = 0;
if (this->field_0x78.HALF.LO == this->direction) {
if ((u8)((++super->timer) % tmp) == 0) {
super->timer = 0;
if (this->unk_78 == super->direction) {
cVar2 = ((Random() & 2) - 1) << 27;
cVar2 = cVar2 >> 24;
h = this->field_0x78.HALF.HI;
h = this->unk_79;
tmp3 = (u8)cVar2 << 24;
if (tmp3 >> 24 == h) {
if (h == this->field_0x7a.HALF.LO) {
if (h == this->unk_7a) {
cVar2 = -tmp3 >> 24;
}
}
this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI;
this->field_0x78.HALF.HI = cVar2;
this->direction = (this->direction + cVar2) & 0x18;
this->unk_7a = this->unk_79;
this->unk_79 = cVar2;
super->direction = (super->direction + cVar2) & 0x18;
} else {
this->direction = this->field_0x78.HALF.LO;
super->direction = this->unk_78;
}
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
super->animationState = super->direction >> 3;
InitializeAnimation(super, super->animationState + 4);
}
}
}
void sub_080383AC(Entity* this) {
void sub_080383AC(RopeGoldenEntity* this) {
u32 v;
this->action = 1;
this->timer = 8;
this->speed = 0x100;
this->direction = DirectionRoundUp(GetFacingDirection(this, &gPlayerEntity));
v = this->direction >> 3;
if (v != this->animationState) {
this->animationState = v;
InitializeAnimation(this, v);
super->action = 1;
super->timer = 8;
super->speed = 0x100;
super->direction = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity));
v = super->direction >> 3;
if (v != super->animationState) {
super->animationState = v;
InitializeAnimation(super, v);
}
}
void sub_080383E4(Entity* this) {
void sub_080383E4(RopeGoldenEntity* this) {
u32 v;
this->action = 2;
this->timer = 8;
this->speed = 0x280;
v = DirectionRoundUp(GetFacingDirection(this, &gPlayerEntity));
this->direction = v;
this->field_0x78.HALF.LO = v;
this->animationState = this->direction >> 3;
this->field_0x78.HALF.HI = 0xff;
this->field_0x7a.HALF.LO = -1;
InitializeAnimation(this, this->animationState + 4);
super->action = 2;
super->timer = 8;
super->speed = 0x280;
v = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity));
super->direction = v;
this->unk_78 = v;
super->animationState = super->direction >> 3;
this->unk_79 = 0xff;
this->unk_7a = -1;
InitializeAnimation(super, super->animationState + 4);
}
+167 -158
View File
@@ -4,237 +4,246 @@
*
* @brief Rupee Like enemy
*/
#include "global.h"
#include "entity.h"
#define NENT_DEPRECATED
#include "enemy.h"
#include "object.h"
#include "save.h"
#include "entity.h"
#include "hitbox.h"
#include "object.h"
#include "room.h"
#include "save.h"
extern void sub_080293DC(Entity*);
extern void sub_080296D8(Entity*);
extern void sub_08029770(Entity*);
extern void sub_080297F0(Entity*);
extern void sub_080296C8(Entity*);
extern void sub_0802969C(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84;
} RupeeLikeEntity;
extern void (*const RupeeLike_Functions[])(Entity*);
extern void (*const gUnk_080CCC18[])(Entity*);
extern void (*const gUnk_080CCC3C[])(Entity*);
extern void sub_080293DC(RupeeLikeEntity* this);
extern void sub_080296D8(RupeeLikeEntity* this);
extern void sub_08029770(RupeeLikeEntity* this);
extern void sub_080297F0(RupeeLikeEntity* this);
extern void sub_080296C8(RupeeLikeEntity* this);
extern void sub_0802969C(RupeeLikeEntity* this);
extern void (*const RupeeLike_Functions[])(RupeeLikeEntity*);
extern void (*const gUnk_080CCC18[])(RupeeLikeEntity*);
extern void (*const gUnk_080CCC3C[])(RupeeLikeEntity*);
extern const u8 gUnk_080CCC34[];
extern const s8 gUnk_080CCC44[];
extern const u8 gUnk_080CCC47[];
void RupeeLike(Entity* this) {
void RupeeLike(RupeeLikeEntity* this) {
u32 uVar1;
if (this->type2 == 0) {
uVar1 = (u8)sub_080043E8(this);
if (super->type2 == 0) {
uVar1 = (u8)sub_080043E8(super);
if (uVar1 != 0) {
if (this->action == 4) {
if (super->action == 4) {
sub_080296D8(this);
}
sub_08001290(this, uVar1);
sub_08001290(super, uVar1);
} else {
RupeeLike_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
RupeeLike_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
} else {
sub_080293DC(this);
}
}
void RupeeLike_OnTick(Entity* this) {
gUnk_080CCC18[this->action](this);
void RupeeLike_OnTick(RupeeLikeEntity* this) {
gUnk_080CCC18[super->action](this);
}
void RupeeLike_OnCollision(Entity* this) {
if (this->hitType == 0x8e) {
void RupeeLike_OnCollision(RupeeLikeEntity* this) {
if (super->hitType == 0x8e) {
sub_08029770(this);
} else {
if (this->action == 4) {
if (super->action == 4) {
sub_080296D8(this);
}
if (*(u8*)(*(u32*)&this->contactedEntity + 8) == 1) {
if (this->action == 2) {
InitializeAnimation(this, 0);
InitializeAnimation(this->child, 4);
if (*(u8*)(*(u32*)&super->contactedEntity + 8) == 1) {
if (super->action == 2) {
InitializeAnimation(super, 0);
InitializeAnimation(super->child, 4);
}
this->action = 4;
this->timer = 60;
this->subtimer = 0;
this->field_0x82.HALF.HI = 0x41;
this->flags2 &= 0xfc;
this->field_0x80.HALF.LO = gPlayerEntity.spritePriority.b1;
super->action = 4;
super->timer = 60;
super->subtimer = 0;
this->unk_83 = 0x41;
super->flags2 &= 0xfc;
this->unk_80 = gPlayerEntity.spritePriority.b1;
EnqueueSFX(SFX_PLACE_OBJ);
} else {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
}
}
EnemyFunctionHandlerAfterCollision(this, RupeeLike_Functions);
EnemyFunctionHandlerAfterCollision(super, RupeeLike_Functions);
}
void RupeeLike_OnDeath(Entity* this) {
CreateDeathFx(this, 0xff, gUnk_080CCC34[this->cutsceneBeh.HALF.LO * 3 + this->type]);
void RupeeLike_OnDeath(RupeeLikeEntity* this) {
CreateDeathFx(super, 0xff, gUnk_080CCC34[this->unk_84 * 3 + super->type]);
}
void RupeeLike_OnGrabbed(Entity* this) {
void RupeeLike_OnGrabbed(RupeeLikeEntity* this) {
}
void sub_080293DC(Entity* this) {
CopyPositionAndSpriteOffset(this->parent, this);
this->y.HALF.HI++;
this->z.HALF.HI--;
gUnk_080CCC3C[this->action](this);
void sub_080293DC(RupeeLikeEntity* this) {
CopyPositionAndSpriteOffset(super->parent, super);
super->y.HALF.HI++;
super->z.HALF.HI--;
gUnk_080CCC3C[super->action](this);
}
void sub_0802940C(Entity* this) {
Entity* ent;
void sub_0802940C(RupeeLikeEntity* this) {
Entity* entity;
ent = CreateEnemy(RUPEE_LIKE, this->type);
if (ent != NULL) {
sub_0804A720(this);
ent->parent = this;
ent->type2 = 1;
this->child = ent;
this->field_0x80.HALF.HI = 0;
this->cutsceneBeh.HALF.LO = 0;
this->field_0x82.HALF.LO = this->palette.b.b0;
entity = CreateEnemy(RUPEE_LIKE, super->type);
if (entity != NULL) {
sub_0804A720(super);
entity->parent = super;
entity->type2 = 1;
super->child = entity;
this->unk_81 = 0;
this->unk_84 = 0;
this->unk_82 = super->palette.b.b0;
sub_080297F0(this);
}
}
void sub_0802944C(Entity* this) {
void sub_0802944C(RupeeLikeEntity* this) {
sub_080296C8(this);
if ((this->field_0x80.HALF.HI != 0) && sub_08049FDC(this, 1)) {
if ((this->unk_81 != 0) && sub_08049FDC(super, 1)) {
sub_08029770(this);
}
}
void sub_08029474(Entity* this) {
void sub_08029474(RupeeLikeEntity* this) {
u32 bVar1;
sub_080296C8(this);
if (this->frame & ANIM_DONE) {
this->action = 3;
this->timer = 8;
bVar1 = GetFacingDirection(this, &gPlayerEntity);
this->direction = bVar1;
this->animationState = (bVar1 << 0x18) >> 0x1c;
InitializeAnimation(this, this->animationState);
InitializeAnimation(this->child, this->animationState + 4);
if (super->frame & ANIM_DONE) {
super->action = 3;
super->timer = 8;
bVar1 = GetFacingDirection(super, &gPlayerEntity);
super->direction = bVar1;
super->animationState = (bVar1 << 0x18) >> 0x1c;
InitializeAnimation(super, super->animationState);
InitializeAnimation(super->child, super->animationState + 4);
} else {
if (this->frame == 1) {
this->frame = 0;
COLLISION_ON(this);
if (super->frame == 1) {
super->frame = 0;
COLLISION_ON(super);
}
}
}
void sub_080294D4(Entity* this) {
if (sub_08049FDC(this, 1) != 0) {
if (--this->timer == 0) {
this->timer = 8;
sub_08004596(this, GetFacingDirection(this, &gPlayerEntity));
void sub_080294D4(RupeeLikeEntity* this) {
if (sub_08049FDC(super, 1) != 0) {
if (--super->timer == 0) {
super->timer = 8;
sub_08004596(super, GetFacingDirection(super, &gPlayerEntity));
sub_0802969C(this);
}
ProcessMovement0(this);
ProcessMovement0(super);
sub_080296C8(this);
} else {
this->action = 6;
COLLISION_OFF(this);
InitializeAnimation(this, 3);
InitializeAnimation(this->child, 7);
super->action = 6;
COLLISION_OFF(super);
InitializeAnimation(super, 3);
InitializeAnimation(super->child, 7);
}
}
void sub_0802953C(Entity* this) {
void sub_0802953C(RupeeLikeEntity* this) {
u8* pbVar3;
sub_080296C8(this);
sub_080296C8(this);
if (sub_0807953C() != 0) {
this->subtimer++;
super->subtimer++;
}
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
}
if (((this->subtimer > 0x2d) || (gSave.stats.rupees == 0)) && (this->timer == 0)) {
if (((super->subtimer > 0x2d) || (gSave.stats.rupees == 0)) && (super->timer == 0)) {
sub_080296D8(this);
} else {
ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
PositionRelative(super, &gPlayerEntity, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex);
gPlayerEntity.spriteOffsetX = pbVar3[0];
gPlayerEntity.spriteOffsetY = pbVar3[1] - 1;
gPlayerEntity.spritePriority.b1 = 0;
if (--this->field_0x82.HALF.HI == 0) {
this->field_0x82.HALF.HI = 0x41;
if (--this->unk_83 == 0) {
this->unk_83 = 0x41;
if (gSave.stats.rupees != 0) {
ModRupees(gUnk_080CCC44[this->type]);
this->cutsceneBeh.HALF.LO = 1;
ModRupees(gUnk_080CCC44[super->type]);
this->unk_84 = 1;
}
}
}
}
void sub_08029610(Entity* this) {
if (--this->subtimer == 0) {
this->action = 3;
this->timer = 1;
void sub_08029610(RupeeLikeEntity* this) {
if (--super->subtimer == 0) {
super->action = 3;
super->timer = 1;
}
sub_080296C8(this);
}
void sub_08029630(Entity* this) {
void sub_08029630(RupeeLikeEntity* this) {
sub_080296C8(this);
if (this->frame & ANIM_DONE) {
this->field_0x80.HALF.HI = 1;
this->child->spriteSettings.draw = FALSE;
if (super->frame & ANIM_DONE) {
this->unk_81 = 1;
super->child->spriteSettings.draw = FALSE;
sub_080297F0(this);
}
}
void sub_08029660(Entity* this) {
void sub_08029660(RupeeLikeEntity* this) {
u32 temp;
this->action = 1;
this->spriteIndex = 0xd1;
temp = gUnk_080CCC47[this->type];
this->palette.b.b0 = temp;
super->action = 1;
super->spriteIndex = 0xd1;
temp = gUnk_080CCC47[super->type];
super->palette.b.b0 = temp;
}
void sub_08029688(Entity* this) {
if (this->parent->next == NULL) {
DeleteEntity(this);
void sub_08029688(RupeeLikeEntity* this) {
if (super->parent->next == NULL) {
DeleteEntity(super);
}
}
void sub_0802969C(Entity* this) {
void sub_0802969C(RupeeLikeEntity* this) {
u32 bVar1;
if ((this->direction & 0xf) != 0) {
if ((super->direction & 0xf) != 0) {
bVar1 = this->direction >> 4;
if (bVar1 != this->animationState) {
this->animationState = bVar1;
InitializeAnimation(this, bVar1);
InitializeAnimation(this->child, bVar1 + 4);
bVar1 = super->direction >> 4;
if (bVar1 != super->animationState) {
super->animationState = bVar1;
InitializeAnimation(super, bVar1);
InitializeAnimation(super->child, bVar1 + 4);
}
}
}
void sub_080296C8(Entity* this) {
GetNextFrame(this);
GetNextFrame(this->child);
void sub_080296C8(RupeeLikeEntity* this) {
GetNextFrame(super);
GetNextFrame(super->child);
}
void sub_080296D8(Entity* this) {
void sub_080296D8(RupeeLikeEntity* this) {
gPlayerState.jump_status = 0x41;
gPlayerState.flags &= ~PL_CAPTURED;
gPlayerEntity.flags |= ENT_COLLIDE;
@@ -242,65 +251,65 @@ void sub_080296D8(Entity* this) {
gPlayerEntity.iframes = 0xa6;
gPlayerEntity.z.HALF.HI = -2;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.spritePriority.b1 = this->field_0x80.HALF.LO;
gPlayerEntity.spritePriority.b1 = this->unk_80;
gPlayerEntity.spriteOffsetY = 0;
gPlayerEntity.speed = 0x140;
this->action = 5;
this->subtimer = 60;
this->flags2 |= 3;
if ((s8)this->iframes == 0) {
this->iframes = 0xf4;
super->action = 5;
super->subtimer = 60;
super->flags2 |= 3;
if ((s8)super->iframes == 0) {
super->iframes = 0xf4;
}
}
void sub_08029770(Entity* this) {
void sub_08029770(RupeeLikeEntity* this) {
u32 temp;
if (LoadFixedGFX(this, 0x73) != 0) {
this->action = 2;
COLLISION_OFF(this);
this->spriteIndex = 0xd1;
this->spritePriority.b1 = 3;
temp = this->field_0x82.HALF.LO;
this->palette.b.b0 = temp;
this->hitType = 0x8d;
this->hitbox = (Hitbox*)&gUnk_080FD260;
InitializeAnimation(this, 2);
this->child->spriteSettings.draw = TRUE;
InitializeAnimation(this->child, 6);
CreateDust(this);
if (LoadFixedGFX(super, 0x73) != 0) {
super->action = 2;
COLLISION_OFF(super);
super->spriteIndex = 0xd1;
super->spritePriority.b1 = 3;
temp = this->unk_82;
super->palette.b.b0 = temp;
super->hitType = 0x8d;
super->hitbox = (Hitbox*)&gUnk_080FD260;
InitializeAnimation(super, 2);
super->child->spriteSettings.draw = TRUE;
InitializeAnimation(super->child, 6);
CreateDust(super);
}
}
void sub_080297F0(Entity* this) {
void sub_080297F0(RupeeLikeEntity* this) {
u32 temp;
this->action = 1;
this->timer = 120;
COLLISION_ON(this);
this->spriteSettings.draw = TRUE;
this->hitType = 0x8e;
UnloadGFXSlots(this);
super->action = 1;
super->timer = 120;
COLLISION_ON(super);
super->spriteSettings.draw = TRUE;
super->hitType = 0x8e;
UnloadGFXSlots(super);
#ifdef EU
this->spriteIndex = 0x142;
super->spriteIndex = 0x142;
#else
this->spriteIndex = 0x143;
super->spriteIndex = 0x143;
#endif
temp = gUnk_080CCC47[this->type];
this->palette.b.b0 = temp;
this->spriteVramOffset = 9;
InitializeAnimation(this, 0x54);
temp = gUnk_080CCC47[super->type];
super->palette.b.b0 = temp;
super->spriteVramOffset = 9;
InitializeAnimation(super, 0x54);
}
// clang-format off
void (*const RupeeLike_Functions[])(Entity*) = {
void (*const RupeeLike_Functions[])(RupeeLikeEntity*) = {
RupeeLike_OnTick,
RupeeLike_OnCollision,
GenericKnockback,
(void (*)(RupeeLikeEntity*))GenericKnockback,
RupeeLike_OnDeath,
GenericConfused,
(void (*)(RupeeLikeEntity*))GenericConfused,
RupeeLike_OnGrabbed,
};
void (*const gUnk_080CCC18[])(Entity*) = {
void (*const gUnk_080CCC18[])(RupeeLikeEntity*) = {
sub_0802940C,
sub_0802944C,
sub_08029474,
@@ -316,7 +325,7 @@ const u8 gUnk_080CCC34[] = {
0x56, 0x57,
};
void (*const gUnk_080CCC3C[])(Entity*) = {
void (*const gUnk_080CCC3C[])(RupeeLikeEntity*) = {
sub_08029660,
sub_08029688,
};
+14 -8
View File
@@ -1,7 +1,13 @@
/**
* @file scissorsBeetle.c
* @ingroup Enemies
*
* @brief Scissors Beetle enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
typedef struct {
Entity base;
@@ -62,22 +68,22 @@ void ScissorsBeetle_OnGrabbed(ScissorsBeetleEntity* this) {
}
void ScissorsBeetle_Init(ScissorsBeetleEntity* this) {
Entity* ent = CreateProjectile(MANDIBLES_PROJECTILE);
if (ent == NULL)
Entity* entity = CreateProjectile(MANDIBLES_PROJECTILE);
if (entity == NULL)
return;
sub_0804A720(super);
super->action = 1;
super->spriteSettings.draw = 1;
COLLISION_ON(super);
super->child = ent;
super->child = entity;
super->animationState = Random() & 6;
this->unk_80 = 0;
this->unk_7a = 0;
ent->parent = super;
ent->type = 0;
ent->animationState = 0xff;
ent->collisionLayer = super->collisionLayer;
entity->parent = super;
entity->type = 0;
entity->animationState = 0xff;
entity->collisionLayer = super->collisionLayer;
sub_08038BA8(this);
}
+50 -37
View File
@@ -4,105 +4,118 @@
*
* @brief Sensor Blade Trap enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "map.h"
#include "physics.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unused2[4];
/*0x84*/ u16 unk_84;
/*0x86*/ u16 unk_86;
} SensorBladeTrapEntity;
extern u32 sub_0804A024(Entity*, u32, u32);
void sub_0802BB10(Entity*);
bool32 sub_0802BB2C(Entity*, u32);
void sub_0802BB10(SensorBladeTrapEntity* this);
bool32 sub_0802BB2C(SensorBladeTrapEntity* this, u32);
extern void (*const gUnk_080CD3C4[])(Entity*);
extern void (*const gUnk_080CD3C4[])(SensorBladeTrapEntity*);
extern const u16 gUnk_080CD3D4[];
extern const s8 gUnk_080CD3DC[];
void SensorBladeTrap(Entity* this) {
gUnk_080CD3C4[this->action](this);
void SensorBladeTrap(SensorBladeTrapEntity* this) {
gUnk_080CD3C4[super->action](this);
}
void sub_0802B9EC(Entity* this) {
this->action = 1;
this->field_0x78.HWORD = gUnk_080CD3D4[this->type];
this->field_0x7c.HALF.LO = this->cutsceneBeh.HWORD;
this->field_0x7c.HALF.HI = this->field_0x86.HWORD;
void sub_0802B9EC(SensorBladeTrapEntity* this) {
super->action = 1;
this->unk_78 = gUnk_080CD3D4[super->type];
this->unk_7c = this->unk_84;
this->unk_7e = this->unk_86;
}
void sub_0802BA18(Entity* this) {
u32 direction = sub_0804A024(this, 1, 0xe);
void sub_0802BA18(SensorBladeTrapEntity* this) {
u32 direction = sub_0804A024(super, 1, 0xe);
if (direction == 0xff)
return;
if (sub_0802BB2C(this, direction))
return;
this->action = 2;
this->speed = this->field_0x78.HWORD;
this->direction = direction;
super->action = 2;
super->speed = this->unk_78;
super->direction = direction;
switch (direction >> 3) {
case 0:
this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI;
this->unk_7a = super->y.HALF.HI - this->unk_7e;
break;
case 1:
this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO;
this->unk_7a = super->x.HALF.HI + this->unk_7c;
break;
case 2:
this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI;
this->unk_7a = super->y.HALF.HI + this->unk_7e;
break;
case 3:
this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO;
this->unk_7a = super->x.HALF.HI - this->unk_7c;
break;
}
}
void sub_0802BA8C(Entity* this) {
if (!ProcessMovement12(this)) {
void sub_0802BA8C(SensorBladeTrapEntity* this) {
if (!ProcessMovement12(super)) {
sub_0802BB10(this);
} else {
switch (this->direction >> 3) {
switch (super->direction >> 3) {
case 0:
if (this->field_0x7a.HWORD >= this->y.HALF.HI)
if (this->unk_7a >= super->y.HALF.HI)
sub_0802BB10(this);
break;
case 1:
if (this->field_0x7a.HWORD <= this->x.HALF.HI)
if (this->unk_7a <= super->x.HALF.HI)
sub_0802BB10(this);
break;
case 2:
if (this->field_0x7a.HWORD <= this->y.HALF.HI)
if (this->unk_7a <= super->y.HALF.HI)
sub_0802BB10(this);
break;
case 3:
if (this->field_0x7a.HWORD >= this->x.HALF.HI)
if (this->unk_7a >= super->x.HALF.HI)
sub_0802BB10(this);
break;
}
}
}
void sub_0802BAFC(Entity* this) {
if (!ProcessMovement12(this)) {
this->action = 1;
void sub_0802BAFC(SensorBladeTrapEntity* this) {
if (!ProcessMovement12(super)) {
super->action = 1;
}
}
void sub_0802BB10(Entity* this) {
this->action = 3;
this->speed = 0xc0;
this->direction = this->direction ^ 0x10;
void sub_0802BB10(SensorBladeTrapEntity* this) {
super->action = 3;
super->speed = 0xc0;
super->direction = super->direction ^ 0x10;
EnqueueSFX(SFX_METAL_CLINK);
}
bool32 sub_0802BB2C(Entity* this, u32 param_2) {
u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
bool32 sub_0802BB2C(SensorBladeTrapEntity* this, u32 param_2) {
u8* layer = super->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
const s8* ptr = &gUnk_080CD3DC[param_2 >> 2];
return IsTileCollision(layer, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1], 0);
return IsTileCollision(layer, super->x.HALF.HI + ptr[0], super->y.HALF.HI + ptr[1], 0);
}
// clang-format off
void (*const gUnk_080CD3C4[])(Entity*) = {
void (*const gUnk_080CD3C4[])(SensorBladeTrapEntity*) = {
sub_0802B9EC,
sub_0802BA18,
sub_0802BA8C,
+74 -68
View File
@@ -4,142 +4,148 @@
*
* @brief Slime enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
#include "room.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[28];
/*0x84*/ u8 unk_84;
} SlimeEntity;
typedef struct {
s8 h, v;
} PACKED PosOffset;
void sub_08044FF8(Entity*);
void Slime_OnTick(Entity*);
void Slime_OnCollision(Entity*);
void Slime_OnGrabbed(Entity*);
void sub_08044FC8(Entity*);
void sub_08044FF8(Entity*);
void sub_08045018(Entity*);
void sub_08045088(Entity*);
void sub_080450A8(Entity*);
void sub_08045178(Entity*, Entity*, int, int);
void sub_08044FF8(SlimeEntity* this);
void Slime_OnTick(SlimeEntity* this);
void Slime_OnCollision(SlimeEntity* this);
void Slime_OnGrabbed(SlimeEntity* this);
void sub_08044FC8(SlimeEntity* this);
void sub_08044FF8(SlimeEntity* this);
void sub_08045018(SlimeEntity* this);
void sub_08045088(SlimeEntity* this);
void sub_080450A8(SlimeEntity* this);
void sub_08045178(SlimeEntity* this, Entity*, int, int);
static void (*const Slime_Functions[])(Entity*) = {
Slime_OnTick, Slime_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Slime_OnGrabbed,
static void (*const Slime_Functions[])(SlimeEntity*) = {
Slime_OnTick, Slime_OnCollision, (void (*)(SlimeEntity*))GenericKnockback, (void (*)(SlimeEntity*))GenericDeath, (void (*)(SlimeEntity*))GenericConfused, Slime_OnGrabbed,
};
void Slime(Entity* this) {
EnemyFunctionHandler(this, Slime_Functions);
SetChildOffset(this, 0, 1, -12);
void Slime(SlimeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Slime_Functions);
SetChildOffset(super, 0, 1, -12);
}
void Slime_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void Slime_OnTick(SlimeEntity* this) {
static void (*const actionFuncs[])(SlimeEntity*) = {
sub_08044FC8, sub_08044FF8, sub_08045018, sub_08045088, sub_080450A8,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void Slime_OnCollision(Entity* this) {
if ((this->health != 0) && (this->cutsceneBeh.HALF.LO != this->health)) {
this->action = 4;
void Slime_OnCollision(SlimeEntity* this) {
if ((super->health != 0) && (this->unk_84 != super->health)) {
super->action = 4;
} else {
EnemyFunctionHandlerAfterCollision(this, Slime_Functions);
EnemyFunctionHandlerAfterCollision(super, Slime_Functions);
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
}
void Slime_OnGrabbed(Entity* this) {
void Slime_OnGrabbed(SlimeEntity* this) {
}
void sub_08044FC8(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->speed = 128;
sub_0804A720(this);
InitializeAnimation(this, 0);
void sub_08044FC8(SlimeEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->speed = 128;
sub_0804A720(super);
InitializeAnimation(super, 0);
sub_08044FF8(this);
}
void sub_08044FF8(Entity* this) {
this->action = 2;
this->timer = (Random() & 0x1F) + 30;
this->cutsceneBeh.HALF.LO = this->health;
void sub_08044FF8(SlimeEntity* this) {
super->action = 2;
super->timer = (Random() & 0x1F) + 30;
this->unk_84 = super->health;
}
void sub_08045018(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 3;
this->timer = 1;
if (0 < this->speed) {
this->timer = FixedDiv(0x1000, this->speed) >> 8;
void sub_08045018(SlimeEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 3;
super->timer = 1;
if (0 < super->speed) {
super->timer = FixedDiv(0x1000, super->speed) >> 8;
}
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
this->direction = (sub_08049EE4(this) + 0xfc + (Random() & 8)) & 24;
if (sub_08049FA0(super) == 0 && (Random() & 3)) {
super->direction = (sub_08049EE4(super) + 0xfc + (Random() & 8)) & 24;
return;
}
this->direction = Random() & 24;
super->direction = Random() & 24;
}
}
void sub_08045088(Entity* this) {
ProcessMovement0(this);
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 1;
void sub_08045088(SlimeEntity* this) {
ProcessMovement0(super);
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 1;
}
}
/* Split slime into new ones */
void sub_080450A8(Entity* this) {
void sub_080450A8(SlimeEntity* this) {
Entity* entities[4];
Entity* ent;
Entity* entity;
s32 count, i;
const PosOffset* off;
static const u8 typeEntityCount[4] = { 2, 2, 4, 2 };
static const PosOffset gUnk_080D16D4[4] = { { 6, 0 }, { -6, 0 }, { 0, 6 }, { 0, -6 } };
/* Can we create enough new entities? */
count = typeEntityCount[this->type];
count = typeEntityCount[super->type];
if (MAX_ENTITIES + 1 - count <= gEntCount)
return;
/* Create 2-4 new MiniSlime */
for (i = 0; i < count; i++)
entities[i] = CreateEnemy(MINI_SLIME, this->type);
entities[i] = CreateEnemy(MINI_SLIME, super->type);
off = gUnk_080D16D4;
for (i = 0; i < count; i++) {
ent = entities[i];
ent->child = entities[(i + 1) % count];
ent->parent = entities[(i + count - 1) % count];
ent->type2 = 1;
ent->z.HALF.HI = 0;
ent->iframes = -0x10;
entity = entities[i];
entity->child = entities[(i + 1) % count];
entity->parent = entities[(i + count - 1) % count];
entity->type2 = 1;
entity->z.HALF.HI = 0;
entity->iframes = -0x10;
/* Set MiniSlime offset relative to killed slime. */
sub_08045178(this, ent, off->h, off->v);
sub_08045178(this, entity, off->h, off->v);
off++;
}
ent = CreateFx(this, FX_DEATH, 0);
if (ent != NULL)
CopyPosition(this, ent);
entity = CreateFx(super, FX_DEATH, 0);
if (entity != NULL)
CopyPosition(super, entity);
DeleteEntity(this);
DeleteEntity(super);
}
void sub_08045178(Entity* this, Entity* child, int h, int v) {
void sub_08045178(SlimeEntity* this, Entity* child, int h, int v) {
int x, y;
if (child == NULL)
return;
sub_0804A4E4(this, child);
sub_0804A4E4(super, child);
if (sub_080B1AF0(child, h, v))
return;
+8 -8
View File
@@ -4,7 +4,7 @@
*
* @brief Sluggula enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
@@ -129,9 +129,9 @@ void sub_08023CE0(Entity* this) {
GetNextFrame(this);
if (this->frame) {
if (this->frame & ANIM_DONE) {
Entity* ent = CreateEnemy(SLUGGULA, 1);
if (ent != NULL) {
sub_0804A4E4(this, ent);
Entity* entity = CreateEnemy(SLUGGULA, 1);
if (entity != NULL) {
sub_0804A4E4(this, entity);
DeleteThisEntity();
}
} else {
@@ -156,14 +156,14 @@ void sub_08023E10(Entity* this) {
}
void sub_08023E54(Entity* this) {
Entity* ent;
Entity* entity;
if (this->subtimer++ > 27) {
this->subtimer = 0;
ent = CreateEnemy(SLUGGULA, 2);
if (ent != NULL) {
entity = CreateEnemy(SLUGGULA, 2);
if (entity != NULL) {
const s8* ptr = &gUnk_080CBDF7[this->animationState * 2];
PositionRelative(this, ent, Q_16_16(ptr[0]), Q_16_16(ptr[1]));
PositionRelative(this, entity, Q_16_16(ptr[0]), Q_16_16(ptr[1]));
}
}
}
+84 -78
View File
@@ -4,146 +4,152 @@
*
* @brief Small Pesto enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
void sub_080317F8(Entity*);
void SmallPesto_OnTick(Entity*);
void SmallPesto_OnCollision(Entity*);
void SmallPesto_OnGrabbed(Entity*);
void sub_08031704(Entity*);
void sub_08031714(Entity*);
void sub_08031770(Entity*);
void sub_080316DC(Entity*);
void sub_080316E8(Entity*);
void sub_080316F0(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u16 unk_80;
} SmallPestoEntity;
static void (*const SmallPesto_Functions[])(Entity*) = {
SmallPesto_OnTick, SmallPesto_OnCollision, GenericKnockback, GenericDeath, GenericConfused, SmallPesto_OnGrabbed,
void sub_080317F8(SmallPestoEntity* this);
void SmallPesto_OnTick(SmallPestoEntity* this);
void SmallPesto_OnCollision(SmallPestoEntity* this);
void SmallPesto_OnGrabbed(SmallPestoEntity* this);
void sub_08031704(SmallPestoEntity* this);
void sub_08031714(SmallPestoEntity* this);
void sub_08031770(SmallPestoEntity* this);
void sub_080316DC(SmallPestoEntity* this);
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,
};
void sub_080317B4(Entity*);
void sub_080317E0(Entity*);
void sub_08031840(Entity*);
void sub_080317B4(SmallPestoEntity* this);
void sub_080317E0(SmallPestoEntity* this);
void sub_08031840(SmallPestoEntity* this);
void SmallPesto(Entity* this) {
SmallPesto_Functions[GetNextFunction(this)](this);
void SmallPesto(SmallPestoEntity* this) {
SmallPesto_Functions[GetNextFunction(super)](this);
}
void SmallPesto_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void SmallPesto_OnTick(SmallPestoEntity* this) {
static void (*const actionFuncs[])(SmallPestoEntity*) = {
sub_08031704,
sub_08031714,
sub_08031770,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void SmallPesto_OnCollision(Entity* this) {
void SmallPesto_OnCollision(SmallPestoEntity* this) {
}
void SmallPesto_OnGrabbed(Entity* this) {
void SmallPesto_OnGrabbed(SmallPestoEntity* this) {
s32 iVar1;
static void (*const subActionFuncs[])(Entity*) = {
static void (*const subActionFuncs[])(SmallPestoEntity*) = {
sub_080316DC,
sub_080316E8,
sub_080316F0,
};
GetNextFrame(this);
iVar1 = sub_0806F520(this);
GetNextFrame(super);
iVar1 = sub_0806F520(super);
if (iVar1 == 0) {
this->action = 1;
this->subAction = 0;
COLLISION_ON(this);
this->speed = 0x40;
this->subtimer = 1;
super->action = 1;
super->subAction = 0;
COLLISION_ON(super);
super->speed = 0x40;
super->subtimer = 1;
} else {
subActionFuncs[this->subAction](this);
subActionFuncs[super->subAction](this);
}
}
void sub_080316DC(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_080316DC(SmallPestoEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_080316E8(Entity* this) {
sub_0806F4E8(this);
void sub_080316E8(SmallPestoEntity* this) {
sub_0806F4E8(super);
}
void sub_080316F0(Entity* this) {
if (sub_0806F3E4(this)) {
GenericDeath(this);
void sub_080316F0(SmallPestoEntity* this) {
if (sub_0806F3E4(super)) {
GenericDeath(super);
}
}
void sub_08031704(Entity* this) {
sub_0804A720(this);
void sub_08031704(SmallPestoEntity* this) {
sub_0804A720(super);
sub_080317F8(this);
}
void sub_08031714(Entity* this) {
void sub_08031714(SmallPestoEntity* this) {
sub_080317B4(this);
if (--this->subtimer == 0) {
this->subtimer = (Random() & 0xf) + 16;
if (sub_08049FA0(this) == 0 && (this->subtimer & 1) != 0) {
this->direction = sub_08049EE4(this);
if (--super->subtimer == 0) {
super->subtimer = (Random() & 0xf) + 16;
if (sub_08049FA0(super) == 0 && (super->subtimer & 1) != 0) {
super->direction = sub_08049EE4(super);
} else {
this->direction += 0x18;
this->direction = ((Random() & 0xe) + this->direction) & 0x1f;
super->direction += 0x18;
super->direction = ((Random() & 0xe) + super->direction) & 0x1f;
}
sub_080317E0(this);
}
}
void sub_08031770(Entity* this) {
if (this->field_0x80.HWORD != 0) {
if (--this->field_0x80.HWORD == 0) {
void sub_08031770(SmallPestoEntity* this) {
if (this->unk_80 != 0) {
if (--this->unk_80 == 0) {
sub_08031840(this);
}
} else if (this->child == NULL) {
this->field_0x80.HWORD = (Random() & 0x7f) | (0x80 << 2);
} else if (super->child == NULL) {
this->unk_80 = (Random() & 0x7f) | (0x80 << 2);
} else {
if (this->child->next == NULL) {
this->child = NULL;
if (super->child->next == NULL) {
super->child = NULL;
}
}
}
void sub_080317B4(Entity* this) {
this->z.HALF.HI = ((Random() & 0x30) != 0) ? -0xc : -0xd;
LinearMoveUpdate(this);
GetNextFrame(this);
void sub_080317B4(SmallPestoEntity* this) {
super->z.HALF.HI = ((Random() & 0x30) != 0) ? -0xc : -0xd;
LinearMoveUpdate(super);
GetNextFrame(super);
}
void sub_080317E0(Entity* this) {
this->animationState = ((u8)(this->direction + 2) & 0x1c) >> 2;
InitializeAnimation(this, this->animationState);
void sub_080317E0(SmallPestoEntity* this) {
super->animationState = ((u8)(super->direction + 2) & 0x1c) >> 2;
InitializeAnimation(super, super->animationState);
}
void sub_080317F8(Entity* this) {
void sub_080317F8(SmallPestoEntity* this) {
static const Hitbox3D gUnk_080CE560 = { 0, -3, { 3, 2, 2, 3 }, 2, 2, 12, { 0, 0, 0 } };
u8 newDirection = Random() & 0x18;
this->action = 1;
this->z.HALF.HI = 0x0000FFF4;
this->collisionLayer = 1;
this->collisionFlags |= 0x10;
this->gustJarFlags = 1;
this->direction = newDirection;
this->hitbox = (Hitbox*)&gUnk_080CE560;
super->action = 1;
super->z.HALF.HI = 0x0000FFF4;
super->collisionLayer = 1;
super->collisionFlags |= 0x10;
super->gustJarFlags = 1;
super->direction = newDirection;
super->hitbox = (Hitbox*)&gUnk_080CE560;
sub_080317E0(this);
this->timer = 0;
this->subtimer = 32;
super->timer = 0;
super->subtimer = 32;
}
void sub_08031840(Entity* this) {
Entity* enemy = CreateEnemy(SMALL_PESTO, this->type);
void sub_08031840(SmallPestoEntity* this) {
Entity* enemy = CreateEnemy(SMALL_PESTO, super->type);
if (enemy != NULL) {
CopyPosition(this, enemy);
enemy->parent = this;
this->child = enemy;
CopyPosition(super, enemy);
enemy->parent = super;
super->child = enemy;
enemy->type2 = 1;
}
}
+9 -9
View File
@@ -4,7 +4,7 @@
*
* @brief Spark enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "object.h"
@@ -21,7 +21,7 @@ void Spark_OnTick(Entity* this) {
}
void Spark_OnCollision(Entity* this) {
Entity* ent;
Entity* entity;
if (this->contactFlags & 0x80) {
if ((this->contactFlags & 0x7f) == 0x14) {
@@ -29,11 +29,11 @@ void Spark_OnCollision(Entity* this) {
this->iframes = 0;
this->spriteSettings.draw = 0;
this->action = 2;
ent = CreateFx(this, FX_DEATH, 0);
if (ent != NULL) {
this->child = ent;
entity = CreateFx(this, FX_DEATH, 0);
if (entity != NULL) {
this->child = entity;
this->timer = 14;
CopyPosition(this, ent);
CopyPosition(this, entity);
}
}
}
@@ -120,9 +120,9 @@ void sub_0802B35C(Entity* this) {
void sub_0802B4A8(Entity* this) {
if (--this->timer == 0) {
Entity* ent = CreateObjectWithParent(this, GROUND_ITEM, 0x60, 0);
if (ent != NULL) {
ent->y.HALF.HI -= 4;
Entity* entity = CreateObjectWithParent(this, GROUND_ITEM, 0x60, 0);
if (entity != NULL) {
entity->y.HALF.HI -= 4;
}
DeleteEntity(this);
}
+16 -16
View File
@@ -4,7 +4,7 @@
*
* @brief Spear Moblin enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
@@ -196,10 +196,10 @@ void sub_08028488(Entity* this) {
}
void sub_08028528(Entity* this) {
Entity* ent = sub_08049DF4(1);
Entity* entity = sub_08049DF4(1);
const Hitbox* box;
if (ent == NULL) {
if (entity == NULL) {
this->subtimer = 0;
sub_08028728(this);
} else {
@@ -218,7 +218,7 @@ void sub_08028528(Entity* this) {
if (++this->timer == 0x20) {
u32 direction;
this->timer = 0;
direction = GetFacingDirection(this, ent);
direction = GetFacingDirection(this, entity);
if (sub_08028828(this->direction, direction)) {
this->direction = direction;
}
@@ -282,13 +282,13 @@ void sub_08028604(Entity* this) {
bool32 sub_080286CC(Entity* this) {
if (this->field_0x80.HALF.HI == 0) {
Entity* ent = sub_08049DF4(1);
if (ent != NULL) {
if (this->field_0x82.HALF.LO == 2 && sub_0806FC80(this, ent, 0x30))
Entity* entity = sub_08049DF4(1);
if (entity != NULL) {
if (this->field_0x82.HALF.LO == 2 && sub_0806FC80(this, entity, 0x30))
return TRUE;
if (sub_0806FC80(this, ent, 0x40) &&
DirectionRoundUp(GetFacingDirection(this, ent)) >> 2 == this->animationState)
if (sub_0806FC80(this, entity, 0x40) &&
DirectionRoundUp(GetFacingDirection(this, entity)) >> 2 == this->animationState)
return TRUE;
}
}
@@ -386,13 +386,13 @@ bool32 sub_080288A4(Entity* this) {
}
void sub_080288C0(Entity* this) {
Entity* ent = this->child;
if ((ent != NULL) && (ent->contactFlags & 0x80)) {
this->knockbackDirection = ent->knockbackDirection;
this->iframes = -ent->iframes;
this->knockbackSpeed = ent->knockbackSpeed;
this->knockbackDuration = ent->knockbackDuration;
ent->knockbackDuration = 0;
Entity* entity = this->child;
if ((entity != NULL) && (entity->contactFlags & 0x80)) {
this->knockbackDirection = entity->knockbackDirection;
this->iframes = -entity->iframes;
this->knockbackSpeed = entity->knockbackSpeed;
this->knockbackDuration = entity->knockbackDuration;
entity->knockbackDuration = 0;
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Spiked Beetle enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
+7 -1
View File
@@ -1,6 +1,12 @@
/**
* @file spinyBeetle.c
* @ingroup Enemies
*
* @brief Spiny Beetle enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "object.h"
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Spiny Chuchu enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "hitbox.h"
-2
View File
@@ -4,9 +4,7 @@
*
* @brief Stalfos enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "collision.h"
#include "enemy.h"
#include "functions.h"
+16 -10
View File
@@ -1,10 +1,16 @@
/**
* @file takkuri.c
* @ingroup Enemies
*
* @brief Takkuri enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "enemy.h"
#include "save.h"
#include "object.h"
#include "item.h"
#include "object.h"
#include "save.h"
typedef struct {
Entity base;
@@ -118,7 +124,7 @@ void sub_0803BCA4(TakkuriEntity* this) {
}
void sub_0803BD08(TakkuriEntity* this) {
Entity* ent;
Entity* entity;
if (super->subtimer) {
if (CheckOnScreen(super) == 0) {
@@ -131,8 +137,8 @@ void sub_0803BD08(TakkuriEntity* this) {
sub_0803BEE8(this);
GetNextFrame(super);
ent = sub_08049DF4(1);
if (ent != NULL) {
entity = sub_08049DF4(1);
if (entity != NULL) {
if (EntityInRectRadius(super, gUnk_020000B0, 0x88, 0x50)) {
if (gUnk_020000B0->y.HALF.HI > super->y.HALF.HI + 8) {
super->action = 2;
@@ -304,9 +310,9 @@ void sub_0803BF70(TakkuriEntity* this) {
void sub_0803C0AC(Entity* this) {
u32 index, rupeeType, rupees;
Entity* ent;
ent = sub_08049DF4(1);
if (ent == NULL)
Entity* entity;
entity = sub_08049DF4(1);
if (entity == NULL)
return;
rupees = gSave.stats.rupees;
@@ -331,7 +337,7 @@ void sub_0803C0AC(Entity* this) {
Entity* obj = CreateObject(RUPEE_OBJECT, rupeeType, 0);
if (obj) {
CopyPosition(ent, obj);
CopyPosition(entity, obj);
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Tektite enemy
*/
//#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Golden Tektite enemy
*/
//#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "item.h"
+8 -2
View File
@@ -1,9 +1,15 @@
/**
* @file torchTrap.c
* @ingroup Enemies
*
* @brief Torch Trap enemy
*/
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "room.h"
#include "entity.h"
#include "physics.h"
#include "player.h"
#include "room.h"
typedef struct {
Entity base;
+2 -3
View File
@@ -4,11 +4,10 @@
*
* @brief Tree Item enemy
*/
#include "global.h"
//#define NENT_DEPRECATED
#include "enemy.h"
#include "object.h"
#include "item.h"
#include "object.h"
static bool32 ShouldSpawnTreeItem(Entity*);
+10 -10
View File
@@ -4,7 +4,7 @@
*
* @brief Vaati Arm enemy
*/
//#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
@@ -866,7 +866,7 @@ void sub_080432A8(Entity* this) {
s32 iVar3;
s32 i;
VaatiArm_HeapStruct1* hs;
Entity* ent;
Entity* entity;
i = 3;
iVar3 = 0;
@@ -884,10 +884,10 @@ void sub_080432A8(Entity* this) {
hs->unk04.HALF.HI -= 2;
for (i = 0; i < 4; i++) {
ent = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
if (ent->z.HALF.HI < 4) {
COLLISION_ON(ent);
ent->spriteSettings.draw = 1;
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[i];
if (entity->z.HALF.HI < 4) {
COLLISION_ON(entity);
entity->spriteSettings.draw = 1;
}
}
@@ -1205,11 +1205,11 @@ void sub_0804393C(Entity* this) {
s32 uVar6;
s32 iVar7;
VaatiArm_HeapStruct1* hs;
Entity* ent;
Entity* entity;
ent = ((VaatiArm_HeapStruct*)this->myHeap)->entities[0];
if (ent->field_0x7c.BYTES.byte0 != 0 && ent->field_0x7c.BYTES.byte1 <= this->type) {
uVar2 = gUnk_080D1362[this->type * 16 + ((ent->field_0x7c.BYTES.byte0 >> 3) & 0xf)];
entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[0];
if (entity->field_0x7c.BYTES.byte0 != 0 && entity->field_0x7c.BYTES.byte1 <= this->type) {
uVar2 = gUnk_080D1362[this->type * 16 + ((entity->field_0x7c.BYTES.byte0 >> 3) & 0xf)];
} else {
uVar2 = 0;
}
+4 -4
View File
@@ -4,12 +4,12 @@
*
* @brief Vaati Ball enemy
*/
#include "entity.h"
//#define NENT_DEPRECATED
#include "enemy.h"
#include "player.h"
#include "object.h"
#include "entity.h"
#include "functions.h"
#include "object.h"
#include "player.h"
typedef struct {
s8 h, v;
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Vaati Eyes Macro enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Vaati Projectile enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "screenTransitions.h"
+2 -2
View File
@@ -4,9 +4,9 @@
*
* @brief Vaati Reborn enemy
*/
#include "enemy.h"
//#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
void VaatiRebornEnemyType0PreAction(Entity*);
+2 -2
View File
@@ -4,10 +4,10 @@
*
* @brief Vaati Transfigured enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
void sub_080409B0(Entity*);
void sub_080408EC(Entity*);
+3 -3
View File
@@ -4,12 +4,12 @@
*
* @brief Vaati Transfigured Eye enemy
*/
#include "entity.h"
//#define NENT_DEPRECATED
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "message.h"
#include "physics.h"
#include "functions.h"
void sub_08045A00(Entity*);
void sub_08045A28(Entity*);
+3 -3
View File
@@ -4,11 +4,11 @@
*
* @brief Vaati Wrath enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "object.h"
#include "message.h"
#include "functions.h"
#include "message.h"
#include "object.h"
#include "save.h"
#include "screen.h"
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Vaati Wrath Eye enemy
*/
//#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
+5 -5
View File
@@ -4,7 +4,7 @@
*
* @brief Wall Master enemy
*/
//#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
@@ -70,14 +70,14 @@ void sub_0802A534(Entity* this) {
if (this->field_0x78.HWORD) {
this->field_0x78.HWORD--;
} else if (this->field_0x7a.HWORD == 0) {
Entity* ent = sub_08049DF4(1);
if (ent != NULL) {
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 = ent->x.HALF.HI;
this->y.HALF.HI = ent->y.HALF.HI;
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;
+1 -1
View File
@@ -4,7 +4,7 @@
*
* @brief Wall Master 2 enemy
*/
//#define NENT_DEPRECATED
#include "area.h"
#include "enemy.h"
#include "functions.h"
+6 -6
View File
@@ -4,10 +4,10 @@
*
* @brief Water Drop enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "screen.h"
#include "object.h"
#include "screen.h"
#include "structures.h"
void sub_0802A39C(Entity*);
@@ -22,7 +22,7 @@ void WaterDrop(Entity* this) {
}
void sub_0802A250(Entity* this) {
Entity* ent;
Entity* entity;
this->action = 1;
this->timer = 0;
@@ -33,9 +33,9 @@ void sub_0802A250(Entity* this) {
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
ent = CreateObject(WATER_DROP_OBJECT, 0, 0);
if (ent != NULL) {
ent->parent = this;
entity = CreateObject(WATER_DROP_OBJECT, 0, 0);
if (entity != NULL) {
entity->parent = this;
}
}
+8 -8
View File
@@ -4,12 +4,12 @@
*
* @brief Wisp enemy
*/
//#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "save.h"
#include "object.h"
#include "functions.h"
#include "object.h"
#include "save.h"
static void sub_08033744(Entity* this);
void Wisp_OnTick(Entity* this);
@@ -41,7 +41,7 @@ void Wisp_OnTick(Entity* this) {
void Wisp_OnCollision(Entity* this) {
u32 bits;
Entity* ent;
Entity* entity;
bits = this->contactFlags;
if ((bits & 0x80) == 0) {
@@ -70,11 +70,11 @@ void Wisp_OnCollision(Entity* this) {
COLLISION_OFF(this);
this->iframes = 0;
this->spriteSettings.draw = FALSE;
ent = CreateFx(this, FX_DEATH, 0);
if (ent != NULL) {
this->child = ent;
entity = CreateFx(this, FX_DEATH, 0);
if (entity != NULL) {
this->child = entity;
this->timer = 14;
CopyPosition(this, ent);
CopyPosition(this, entity);
}
DeleteThisEntity();
break;
+1 -3
View File
@@ -4,11 +4,9 @@
*
* @brief Wizzrobe Fire enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "enemy/wizzrobe.h"
#include "enemy.h"
#include "functions.h"
extern void (*const WizzrobeFire_Functions[])(WizzrobeEntity*);

Some files were not shown because too many files have changed in this diff Show More