mirror of
https://github.com/zeldaret/tmc
synced 2026-07-10 07:06:52 -04:00
Decompile remainder of Enemy4D
This commit is contained in:
+1
-1
@@ -446,7 +446,7 @@ u32 sub_0806FCAC(Entity* this, Entity* other) {
|
||||
return sub_0806F5B0(GetFacingDirection(this, other));
|
||||
}
|
||||
|
||||
u32 EntityWithinDistance(Entity* ent, s32 x, s32 y, s32 distance) {
|
||||
bool32 EntityWithinDistance(Entity* ent, s32 x, s32 y, s32 distance) {
|
||||
return PointInsideRadius(ent->x.HALF.HI - x, ent->y.HALF.HI - y, distance);
|
||||
}
|
||||
|
||||
|
||||
+306
-32
@@ -4,59 +4,333 @@
|
||||
*
|
||||
* @brief enemy 4D
|
||||
*/
|
||||
|
||||
#define NENT_DEPRECATED
|
||||
#include "global.h"
|
||||
#include "entity.h"
|
||||
#include "enemy.h"
|
||||
#include "functions.h"
|
||||
|
||||
extern void sub_0803EE8C(Entity*);
|
||||
typedef struct {
|
||||
/*0x00*/ Entity base;
|
||||
/*0x68*/ u8 unk_68[0x5];
|
||||
/*0x6d*/ u8 unk_6d;
|
||||
/*0x6e*/ u8 unk_6e;
|
||||
/*0x6f*/ u8 unk_6f;
|
||||
/*0x70*/ u16 unk_70;
|
||||
/*0x72*/ u16 unk_72;
|
||||
/*0x74*/ u8 unk_74[0x4];
|
||||
/*0x78*/ u16 unk_78;
|
||||
/*0x7a*/ u8 unk_7a;
|
||||
/*0x7b*/ u8 unk_7b;
|
||||
/*0x7c*/ u8 unk_7c;
|
||||
/*0x7d*/ u8 unk_7d;
|
||||
/*0x7e*/ u8 unk_7e;
|
||||
/*0x7f*/ u8 unk_7f;
|
||||
/*0x80*/ u16 unk_80;
|
||||
/*0x82*/ u16 unk_82;
|
||||
/*0x84*/ u16 unk_84;
|
||||
/*0x86*/ u16 unk_86;
|
||||
} Enemy4DEntity;
|
||||
|
||||
extern void (*const Enemy4D_Functions[])(Entity*);
|
||||
extern void (*const gUnk_080D0898[])(Entity*);
|
||||
extern void sub_0803E9A4(Entity*); // ballChainSoldier
|
||||
extern void sub_0803E94C(Entity*, u32); // ballChainSoldier
|
||||
|
||||
void Enemy4D(Entity* this) {
|
||||
EnemyFunctionHandler(this, Enemy4D_Functions);
|
||||
extern Entity* gUnk_020000B0;
|
||||
|
||||
void sub_0803EE8C(Enemy4DEntity*);
|
||||
bool32 sub_0803EF20(Enemy4DEntity*);
|
||||
bool32 sub_0803EEA4(Enemy4DEntity*);
|
||||
bool32 sub_0803EF04(Enemy4DEntity*, u32);
|
||||
void Enemy4D_OnTick(Enemy4DEntity*);
|
||||
void Enemy4D_OnCollision(Enemy4DEntity*);
|
||||
void Enemy4D_OnKnockback(Enemy4DEntity*);
|
||||
void Enemy4D_OnDeath(Enemy4DEntity*);
|
||||
void Enemy4D_OnGrabbed(Enemy4DEntity*);
|
||||
void Enemy4D_Init(Enemy4DEntity*);
|
||||
void Enemy4D_Action1(Enemy4DEntity*);
|
||||
void Enemy4D_Action2(Enemy4DEntity*);
|
||||
void Enemy4D_Action3(Enemy4DEntity*);
|
||||
void Enemy4D_Action4(Enemy4DEntity*);
|
||||
void Enemy4D_Action5(Enemy4DEntity*);
|
||||
void Enemy4D_Action6(Enemy4DEntity*);
|
||||
void Enemy4D_Action7(Enemy4DEntity*);
|
||||
void Enemy4D_Action8(Enemy4DEntity*);
|
||||
void Enemy4D_Action9(Enemy4DEntity*);
|
||||
void Enemy4D_Action10(Enemy4DEntity*);
|
||||
bool32 sub_0803EF70(Entity*, Entity*);
|
||||
bool32 sub_0803EF74(Entity*, Entity*);
|
||||
bool32 sub_0803EFAC(Entity*, Entity*);
|
||||
|
||||
void (*const Enemy4D_Functions[])(Enemy4DEntity*) = {
|
||||
Enemy4D_OnTick,
|
||||
Enemy4D_OnCollision,
|
||||
Enemy4D_OnKnockback,
|
||||
Enemy4D_OnDeath,
|
||||
(void (*)(Enemy4DEntity*))GenericConfused,
|
||||
Enemy4D_OnGrabbed,
|
||||
};
|
||||
|
||||
void Enemy4D(Enemy4DEntity* this) {
|
||||
EnemyFunctionHandler(super, (EntityActionArray)Enemy4D_Functions);
|
||||
}
|
||||
|
||||
void Enemy4D_OnTick(Entity* this) {
|
||||
gUnk_080D0898[this->action](this);
|
||||
void Enemy4D_OnTick(Enemy4DEntity* this) {
|
||||
static void (*const Enemy4D_Actions[])(Enemy4DEntity*) = {
|
||||
Enemy4D_Init, Enemy4D_Action1, Enemy4D_Action2, Enemy4D_Action3, Enemy4D_Action4, Enemy4D_Action5,
|
||||
Enemy4D_Action6, Enemy4D_Action7, Enemy4D_Action8, Enemy4D_Action9, Enemy4D_Action10,
|
||||
};
|
||||
Enemy4D_Actions[super->action](this);
|
||||
}
|
||||
|
||||
void Enemy4D_OnCollision(Entity* this) {
|
||||
EnemyFunctionHandlerAfterCollision(this, Enemy4D_Functions);
|
||||
void Enemy4D_OnCollision(Enemy4DEntity* this) {
|
||||
EnemyFunctionHandlerAfterCollision(super, Enemy4D_Functions);
|
||||
}
|
||||
|
||||
void Enemy4D_OnKnockback(Entity* this) {
|
||||
GenericKnockback(this);
|
||||
void Enemy4D_OnKnockback(Enemy4DEntity* this) {
|
||||
GenericKnockback(super);
|
||||
Enemy4D_OnTick(this);
|
||||
}
|
||||
|
||||
void Enemy4D_OnDeath(Entity* this) {
|
||||
CreateDeathFx(this, 0xff, 0x57);
|
||||
void Enemy4D_OnDeath(Enemy4DEntity* this) {
|
||||
CreateDeathFx(super, 0xff, 0x57);
|
||||
}
|
||||
|
||||
void Enemy4D_OnGrabbed(Entity* this) {
|
||||
void Enemy4D_OnGrabbed(Enemy4DEntity* this) {
|
||||
}
|
||||
|
||||
void sub_0803EB44(Entity* this) {
|
||||
Entity* pEVar1;
|
||||
void Enemy4D_Init(Enemy4DEntity* this) {
|
||||
Entity* projectile;
|
||||
|
||||
sub_0804A720(this);
|
||||
pEVar1 = CreateProjectileWithParent(this, BALL_AND_CHAIN, 0);
|
||||
if (pEVar1 != NULL) {
|
||||
pEVar1->parent = this;
|
||||
this->child = pEVar1;
|
||||
COLLISION_ON(this);
|
||||
this->spriteSettings.draw = TRUE;
|
||||
this->animationState = 2;
|
||||
*((u8*)&this->field_0x7a + 1) = 0;
|
||||
*(u8*)&this->field_0x7c = 0;
|
||||
*((u8*)&this->field_0x7c + 2) = 0x28;
|
||||
*((u8*)&this->field_0x7c + 3) = 0xfe;
|
||||
this->field_0x80.HWORD = this->x.HALF.HI;
|
||||
this->field_0x82.HWORD = this->y.HALF.HI;
|
||||
InitAnimationForceUpdate(this, this->animationState << 2);
|
||||
sub_0804A720(super);
|
||||
projectile = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
|
||||
if (projectile != NULL) {
|
||||
projectile->parent = super;
|
||||
super->child = projectile;
|
||||
COLLISION_ON(super);
|
||||
super->spriteSettings.draw = TRUE;
|
||||
super->animationState = 2;
|
||||
this->unk_7b = 0;
|
||||
this->unk_7c = 0;
|
||||
this->unk_7e = 0x28;
|
||||
this->unk_7f = 0xfe;
|
||||
this->unk_80 = super->x.HALF.HI;
|
||||
this->unk_82 = super->y.HALF.HI;
|
||||
InitAnimationForceUpdate(super, super->animationState << 2);
|
||||
sub_0803EE8C(this);
|
||||
}
|
||||
}
|
||||
void Enemy4D_Action1(Enemy4DEntity* this) {
|
||||
this->unk_7c -= 0xa;
|
||||
if (sub_08049DF4(1)) {
|
||||
super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
|
||||
sub_0803E94C(super, 0);
|
||||
}
|
||||
sub_0803E9A4(super);
|
||||
if (EntityWithinDistance(super, this->unk_80, this->unk_82, 2) == FALSE) {
|
||||
super->action = 4;
|
||||
sub_0803E94C(super, 0x10);
|
||||
} else {
|
||||
if (sub_0803EF20(this) == FALSE) {
|
||||
sub_0803EEA4(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action2(Enemy4DEntity* this) {
|
||||
this->unk_7c -= 0x10;
|
||||
sub_0803E9A4(super);
|
||||
if (this->unk_7e > 0x1c) {
|
||||
this->unk_7e--;
|
||||
}
|
||||
if (--this->unk_78 == 0) {
|
||||
super->action = 3;
|
||||
this->unk_7b = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action3(Enemy4DEntity* this) {
|
||||
this->unk_7c -= 0xa;
|
||||
sub_0803E9A4(super);
|
||||
if (this->unk_7e < 0x28) {
|
||||
this->unk_7e++;
|
||||
} else {
|
||||
sub_0803EE8C(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action4(Enemy4DEntity* this) {
|
||||
this->unk_7c -= 0xa;
|
||||
sub_0803E9A4(super);
|
||||
if (EntityWithinDistance(super, this->unk_80, this->unk_82, 1)) {
|
||||
super->x.HALF.HI = this->unk_80;
|
||||
super->y.HALF.HI = this->unk_82;
|
||||
sub_0803EE8C(this);
|
||||
sub_0803E94C(super, 0);
|
||||
} else {
|
||||
if (super->knockbackDuration == 0) {
|
||||
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_80, this->unk_82);
|
||||
sub_0803E94C(super, 0x10);
|
||||
ProcessMovement0(super);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action5(Enemy4DEntity* this) {
|
||||
s32 tmp;
|
||||
this->unk_7c -= 0xc;
|
||||
sub_0803E9A4(super);
|
||||
tmp = this->unk_7e - 4;
|
||||
this->unk_7e = tmp;
|
||||
if ((tmp * 0x1000000) < 1) {
|
||||
this->unk_7e = 0;
|
||||
super->action = 6;
|
||||
super->actionDelay = 0x0f;
|
||||
InitAnimationForceUpdate(super, super->animationState + 0x20);
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action6(Enemy4DEntity* this) {
|
||||
|
||||
static const u8 gUnk_080D08C4[] = {
|
||||
0,
|
||||
68,
|
||||
128,
|
||||
188,
|
||||
};
|
||||
if (--super->actionDelay == 0) {
|
||||
super->action = 7;
|
||||
super->actionDelay = 1;
|
||||
this->unk_7c = gUnk_080D08C4[super->animationState];
|
||||
this->unk_7f = 0xf6;
|
||||
EnqueueSFX(SFX_15B);
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action7(Enemy4DEntity* this) {
|
||||
if ((super->frame & 0x80) == 0) {
|
||||
UpdateAnimationSingleFrame(super);
|
||||
} else {
|
||||
if (--super->actionDelay == 0) {
|
||||
super->actionDelay = 2;
|
||||
this->unk_7f++;
|
||||
}
|
||||
if (this->unk_7f != 0) {
|
||||
this->unk_7e += 5;
|
||||
} else {
|
||||
super->action = 8;
|
||||
super->actionDelay = 0x1e;
|
||||
InitScreenShake(8, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action8(Enemy4DEntity* this) {
|
||||
if (--super->actionDelay == 0) {
|
||||
super->action = 9;
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action9(Enemy4DEntity* this) {
|
||||
u8 tmp;
|
||||
tmp = this->unk_7e = this->unk_7e - 2;
|
||||
if (tmp < 0xb) {
|
||||
super->action = 0xa;
|
||||
super->actionDelay = 0x3c;
|
||||
super->direction = super->animationState << 3;
|
||||
this->unk_7c = 0;
|
||||
this->unk_7f = 0xfe;
|
||||
sub_0803E94C(super, 0x10);
|
||||
} else if (tmp < 0x13) {
|
||||
super->child->flags &= ~ENT_COLLIDE;
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy4D_Action10(Enemy4DEntity* this) {
|
||||
if (super->actionDelay != 0) {
|
||||
if (--super->actionDelay == 0) {
|
||||
super->child->flags |= ENT_COLLIDE;
|
||||
sub_0803E94C(super, 0);
|
||||
}
|
||||
} else {
|
||||
this->unk_7c -= 0xa;
|
||||
sub_0803E9A4(super);
|
||||
if (++this->unk_7e > 0x27) {
|
||||
sub_0803EE8C(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0803EE8C(Enemy4DEntity* this) {
|
||||
super->action = 1;
|
||||
this->unk_7a = 0x1e;
|
||||
sub_0803E94C(super, 0);
|
||||
}
|
||||
|
||||
bool32 sub_0803EEA4(Enemy4DEntity* this) {
|
||||
s32 tmp;
|
||||
if (sub_08049FDC(super, 1)) {
|
||||
if (sub_0803EF04(this, 0x4e) != 0) {
|
||||
tmp = sub_0804A044(super, gUnk_020000B0, 0x12);
|
||||
if (tmp != 0xff) {
|
||||
if (--this->unk_7a == 0) {
|
||||
super->action = 5;
|
||||
super->direction = tmp;
|
||||
sub_0803E94C(super, 0);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
this->unk_7a = 0x1e;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_0803EF04(Enemy4DEntity* this, u32 distance) {
|
||||
return EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI - 4, distance);
|
||||
}
|
||||
|
||||
bool32 sub_0803EF20(Enemy4DEntity* this) {
|
||||
static bool32 (*const gUnk_080D08C8[])(Entity*, Entity*) = {
|
||||
sub_0803EF70, sub_0803EF70, sub_0803EF70, sub_0803EF74, sub_0803EFAC, sub_0803EF70, sub_0803EF70, sub_0803EF70,
|
||||
sub_0803EF70, sub_0803EF70, sub_0803EF70, sub_0803EF70, sub_0803EF70, sub_0803EF70, sub_0803EF70, sub_0803EFAC,
|
||||
sub_0803EF70, sub_0803EFAC, sub_0803EFAC, sub_0803EFAC, sub_0803EF70, sub_0803EF70, sub_0803EFAC,
|
||||
};
|
||||
Entity* it;
|
||||
LinkedList* list = ((LinkedList*)&gEntityLists + 2);
|
||||
|
||||
for (it = list->first; it != (Entity*)list; it = it->next) {
|
||||
if ((it->kind == 8) && gUnk_080D08C8[it->id](super, it)) {
|
||||
super->action = 2;
|
||||
this->unk_78 = 0xb4;
|
||||
this->unk_7b = 1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_0803EF70(Entity* param_1, Entity* param_2) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_0803EF74(Entity* param_1, Entity* param_2) {
|
||||
if (EntityWithinDistance(param_1, param_2->x.HALF.HI, param_2->y.HALF.HI, 0x50)) {
|
||||
if (4 >= (((param_2->direction - GetFacingDirection(param_2, param_1)) + 2) & 0x1f)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_0803EFAC(Entity* param_1, Entity* param_2) {
|
||||
if (EntityInRectRadius(param_1, param_2, 0x50, 0x50)) {
|
||||
u32 tmp = sub_0804A044(param_2, param_1, 0x1c);
|
||||
if (tmp != 0xff) {
|
||||
if (tmp == param_2->direction) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user