Merge pull request #275 from hatal175/takkuri

This commit is contained in:
notyourav
2022-01-11 19:34:08 -08:00
committed by GitHub
9 changed files with 391 additions and 862 deletions
+364
View File
@@ -0,0 +1,364 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "enemy.h"
#include "save.h"
#include "object.h"
#include "item.h"
typedef struct {
Entity base;
u8 filler[0x10];
u16 x_0x78;
u16 y_0x7a;
u8 filler2[0x4];
u8 unk_0x80;
u8 unk_0x81;
u16 unk_0x82;
u8 unk_0x84;
} TakkuriEntity;
static_assert(sizeof(TakkuriEntity) == 0x88);
extern void sub_0803C0AC(Entity*);
extern Entity* sub_08049DF4(u32);
extern Entity* gUnk_020000B0;
void (*const gUnk_080CFF3C[])(Entity*);
void (*const gUnk_080CFF54[])(TakkuriEntity*);
void (*const gUnk_080CFF6C[])(TakkuriEntity*);
void sub_0803BF2C(TakkuriEntity*);
void sub_0803BEE8(TakkuriEntity* this);
void sub_0803BF70(TakkuriEntity* this);
void sub_0803BF48(TakkuriEntity* this);
void sub_0803C120(TakkuriEntity* this);
void Takkuri(Entity* this) {
gUnk_080CFF3C[GetNextFunction(this)](this);
}
void sub_0803BB98(TakkuriEntity* this) {
gUnk_080CFF54[super->action](this);
}
void sub_0803BBB0(TakkuriEntity* this) {
if (super->bitfield & 0x80) {
if ((super->bitfield & 0x7f) == 0) {
u32 direction;
sub_0803C0AC(super);
COLLISION_OFF(super);
direction = super->direction;
if (!DirectionIsHorizontal(DirectionRoundUp(direction))) {
if (DirectionIsVertical(direction)) {
super->direction += 2;
} else {
super->direction -= 2;
}
}
super->direction = 0x20 - super->direction;
sub_0803BF2C(this);
} else {
if (((u8)super->iframes & 0x80) == 0) {
super->health = 0;
}
}
if (this->unk_0x82 >= 0x11) {
this->unk_0x82 -= 0xc;
}
}
GetNextFrame(super);
}
void sub_0803BC34(TakkuriEntity* this) {
gUnk_080CFF6C[super->subAction](this);
GetNextFrame(super);
if (sub_0806F520(super) == 0) {
super->action = 2;
super->subAction = 0;
this->unk_0x84 = 2;
super->actionDelay = 8;
super->speed = 0x1c0;
sub_0803BF2C(this);
}
}
void sub_0803BC7C(TakkuriEntity* this) {
super->subAction = 1;
super->field_0x1d = 0x3c;
}
void sub_0803BC88(TakkuriEntity* this) {
sub_0806F4E8(super);
}
void sub_0803BC90(TakkuriEntity* this) {
if (sub_0806F3E4(super)) {
sub_0804A7D4(super);
}
}
void sub_0803BCA4(TakkuriEntity* this) {
sub_0804A720(super);
super->action = 1;
super->field_0xf = 0;
super->direction = sub_08049F84(super, 1);
this->unk_0x80 = 0;
this->unk_0x81 = 0;
super->field_0x1c = 1;
super->field_0x3c |= 0x10;
super->collisionLayer = 3;
super->spriteOrientation.flipY = 1;
this->x_0x78 = super->x.HALF.HI;
this->y_0x7a = super->y.HALF.HI;
UpdateSpriteForCollisionLayer(super);
sub_0803BF2C(this);
}
void sub_0803BD08(TakkuriEntity* this) {
Entity* ent;
if (super->field_0xf) {
if (CheckOnScreen(super) == 0) {
super->field_0xf = 0;
super->spriteSettings.draw = 1;
} else {
return;
}
}
sub_0803BEE8(this);
GetNextFrame(super);
ent = sub_08049DF4(1);
if (ent) {
if (EntityInRectRadius(super, gUnk_020000B0, 0x88, 0x50)) {
if (gUnk_020000B0->y.HALF.HI > super->y.HALF.HI + 8) {
super->action = 2;
this->unk_0x84 = 0;
super->actionDelay = 0x10;
this->unk_0x81 = 2;
sub_0803BF2C(this);
}
}
}
}
void sub_0803BD88(TakkuriEntity* this) {
sub_0803BF70(this);
}
void sub_0803BD90(TakkuriEntity* this) {
if (CheckOnScreen(super) == 0) {
super->action = 4;
super->spriteSettings.draw = 4;
COLLISION_OFF(super);
super->spritePriority.b1 = 1;
super->actionDelay = 8;
} else {
sub_0803BF48(this);
GetNextFrame(super);
}
}
void sub_0803BDD8(TakkuriEntity* this) {
if (--super->actionDelay) {
return;
}
if (sub_08049FDC(super, 1) == 0 || sub_08049FA0(super) == 0) {
sub_0803C120(this);
} else {
if (super->direction & 0x10) {
super->direction = 0x8;
super->x.HALF.HI = gRoomControls.scroll_x - 0x20;
} else {
super->direction = 0x18;
super->x.HALF.HI = gRoomControls.scroll_x + 0x110;
}
super->y.HALF.HI = gRoomControls.scroll_y + 8;
super->spriteSettings.draw = 1;
COLLISION_ON(super);
super->action = 2;
this->unk_0x84 = 1;
super->actionDelay = 0x18;
this->unk_0x82 = 0x12c;
super->speed = 0x12c + 0x94;
this->unk_0x81 = 4;
}
sub_0803BF2C(this);
}
void sub_0803BE7C(TakkuriEntity* this) {
if (CheckOnScreen(super))
return;
super->action = 1;
super->spriteSettings.draw = 1;
COLLISION_OFF(super);
super->actionDelay = 0x8;
super->field_0xf = 1;
super->direction = sub_08049F84(super, 1);
this->unk_0x80 = 0;
super->spritePriority.b1 = 3;
this->unk_0x81 = 0;
super->collisionLayer = 3;
UpdateSpriteForCollisionLayer(super);
sub_0803BF2C(this);
}
void sub_0803BEE8(TakkuriEntity* this) {
if (--super->actionDelay == 0) {
u32 direction;
this->unk_0x80 = super->direction;
direction = sub_08049F84(super, 1);
if (direction != 0xff) {
super->direction = direction;
}
super->actionDelay = 8;
if (DirectionIsVertical(this->unk_0x80) != DirectionIsVertical(super->direction)) {
sub_0803BF2C(this);
}
}
}
void sub_0803BF2C(TakkuriEntity* this) {
InitializeAnimation(super, ((super->direction & 0x10) >> 4) + this->unk_0x81);
}
void sub_0803BF48(TakkuriEntity* this) {
LinearMoveUpdate(super);
super->collisionLayer = 3;
super->spriteOrientation.flipY = 1;
super->spriteRendering.b3 = 1;
}
void sub_0803BF70(TakkuriEntity* this) {
u32 tmp1, tmp2, tmp3;
switch (this->unk_0x84) {
case 0:
if (super->actionDelay & 0x1) {
super->z.HALF.HI--;
}
if (--super->actionDelay == 0) {
this->unk_0x84 = 1;
super->actionDelay = 0x18;
COLLISION_ON(super);
this->unk_0x81 = 2;
sub_0803BF2C(this);
}
break;
case 1:
if (--super->actionDelay == 0) {
this->unk_0x84 = 2;
super->actionDelay = 8;
super->speed = 0x1c0;
this->unk_0x81 = 4;
sub_0803BF2C(this);
}
break;
case 2:
if (--this->unk_0x82 == 0) {
super->action = 3;
this->unk_0x84 = 0;
super->actionDelay = 0;
super->speed = 0x180;
if ((super->direction + 0x18) & 0x10) {
super->direction = (0x10 - super->direction) & 0x1f;
}
sub_0803BF2C(this);
} else {
if (--super->actionDelay == 0) {
super->actionDelay = 8;
this->unk_0x80 = super->direction;
sub_08004596(super, sub_08049F84(super, 1));
if ((super->direction + 0x18) & 0x10) {
if (this->unk_0x80 == 0x10) {
if (this->unk_0x80 & super->direction) {
this->unk_0x80 = 0x12;
} else {
this->unk_0x80 = 0xe;
}
}
super->direction = this->unk_0x80;
this->unk_0x82 = 1;
}
if ((((u32)this->unk_0x80 & 0x10)) >> 4 != ((((u32)super->direction) & 0x10)) >> 4) {
InitializeAnimation(super, (((u32)super->direction & 0x10) >> 4) + 4);
}
}
}
sub_0803BF48(this);
break;
}
GetNextFrame(super);
}
void sub_0803C0AC(Entity* this) {
u32 index, rupeeType, rupees;
Entity* ent;
ent = sub_08049DF4(1);
if (!ent)
return;
rupees = gSave.stats.rupees;
if (rupees >= 500) {
rupeeType = ITEM_RUPEE20;
index = 5;
ModRupees(-100);
} else if (rupees >= 100) {
rupeeType = ITEM_RUPEE5;
index = 5;
ModRupees(-25);
} else {
rupeeType = ITEM_RUPEE1;
index = rupees;
if (rupees >= 0x5) {
index = 5;
}
ModRupees(-index);
}
for (; index != 0; index--) {
Entity* obj = CreateObject(RUPEE_OBJECT, rupeeType, 0);
if (obj) {
CopyPosition(ent, obj);
}
}
}
void sub_0803C120(TakkuriEntity* this) {
super->action = 5;
super->spriteSettings.draw = 0;
super->flags &= 0x7f;
super->x.HALF.HI = this->x_0x78;
super->y.HALF.HI = this->y_0x7a;
super->z.HALF.HI += 8;
super->spritePriority.b1 = 3;
}
void (*const gUnk_080CFF3C[])(Entity*) = {
(EntityActionPtr)sub_0803BB98, (EntityActionPtr)sub_0803BBB0, sub_08001324, sub_0804A7D4, sub_08001242,
(EntityActionPtr)sub_0803BC34,
};
void (*const gUnk_080CFF54[])(TakkuriEntity*) = {
sub_0803BCA4, sub_0803BD08, sub_0803BD88, sub_0803BD90, sub_0803BDD8, sub_0803BE7C,
};
void (*const gUnk_080CFF6C[])(TakkuriEntity*) = {
sub_0803BC7C,
sub_0803BC88,
sub_0803BC90,
};
+1 -1
View File
@@ -28,7 +28,7 @@ void (*const gObjectFunctions[])(Entity*) = {
[OBJECT_17] = Object17,
[EVIL_SPIRIT] = EvilSpirit,
[HOUSE_DOOR_EXT] = HouseDoorExterior,
[OBJECT_1A] = Object1A,
[RUPEE_OBJECT] = Rupee,
[GREAT_FAIRY] = GreatFairy,
[OBJECT_1C] = Object1C,
[OBJECT_1D] = Object1D,
+9 -3
View File
@@ -1,14 +1,14 @@
#include "object.h"
#include "functions.h"
extern void sub_08086A6C(Entity*);
void sub_08086A6C(Entity*);
extern void (*gUnk_081206C4[99])(Entity*);
void (*const gUnk_081206C4[])(Entity*);
extern Hitbox gUnk_080FD1A8;
// Main
void Object1A(Entity* ent) {
void Rupee(Entity* ent) {
gUnk_081206C4[ent->action](ent);
}
@@ -55,3 +55,9 @@ void sub_08086A6C(Entity* ent) {
ent->direction = DirectionNormalize(uVar1 >> 16);
ent->speed = uVar1 & 480;
}
void (*const gUnk_081206C4[])(Entity*) = {
sub_080869DC,
sub_08086A28,
sub_08086A5C,
};