identify all player items

This commit is contained in:
theo3
2022-03-28 15:08:37 -07:00
parent 270476488f
commit 7c16e8d50a
46 changed files with 531 additions and 515 deletions
-187
View File
@@ -1,187 +0,0 @@
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "asm.h"
#include "object.h"
extern void (*const gUnk_0812AA80[])(Entity*);
bool32 sub_080ACDB0(Entity*);
void sub_080ACC78(Entity*);
void sub_080ACECC(Entity*);
typedef struct {
u16 bits;
u8 type2;
u8 actionDelay;
u8 _4;
u8 type;
u16 tileID;
} Obj11;
Obj11* sub_08008782(Entity*, u32, u32, u32);
const s8 gUnk_0812AA88[] = {
-4, -4, 4, -4, -4, 4, 4, 4, 0,
};
const s8 gUnk_0812AA91[] = {
-5, -5, 5, -5, -5, 5, 5, 5, 0,
};
const s8 gUnk_0812AA9A[] = {
-9, -9, 1, -9, 9, -9, -9, 1, 9, 1, -9, 9, 1, 9, 9, 9, 0, 0,
};
const s8* const gUnk_0812AAAC[] = {
gUnk_0812AA88,
gUnk_0812AA91,
gUnk_0812AA91,
gUnk_0812AA9A,
};
const s8 gUnk_0812AABC[] = {
0x78,
0x50,
0x28,
0x4,
};
const Hitbox gUnk_0812AAC0 = {
0, 0, 4, 2, 2, 4, 4, 4,
};
const Hitbox gUnk_0812AAC8 = {
0, 0, 4, 3, 3, 4, 9, 9,
};
const Hitbox gUnk_0812AAD0 = {
0, 0, 8, 7, 7, 8, 14, 14,
};
const Hitbox* const gUnk_0812AAD8[] = {
&gUnk_0812AAC0,
&gUnk_0812AAC8,
&gUnk_0812AAC8,
&gUnk_0812AAD0,
};
const u8 gUnk_0812AAE8[] = {
0,
12,
16,
16,
};
void PlayerItem10(Entity* this) {
if ((gPlayerState.field_0x1c & 0x7f) != 1) {
DeleteThisEntity();
}
gUnk_0812AA80[this->action](this);
this->iframes = 0;
}
void sub_080ACC04(Entity* this) {
this->action = 1;
this->flags2 = gPlayerEntity.flags2;
this->direction = this->animationState << 2;
this->speed = 0x200;
this->flags |= ENT_COLLIDE | ENT_PERSIST;
this->field_0x3c = 2;
this->hitbox = (Hitbox*)gUnk_0812AAD8[this->type];
this->field_0x70.WORD = 0x10;
sub_080ACDB0(this);
sub_0801766C(this);
}
void sub_080ACC5C(Entity* this) {
if (sub_080ACDB0(this) == FALSE) {
sub_080ACC78(this);
sub_080ACECC(this);
}
}
void sub_080ACC78(Entity* this) {
s32 width;
Obj11* o;
Entity* child;
s32 offset;
const s8* puVar8;
if ((this->type + gRoomTransition.frameCount) & 1) {
puVar8 = gUnk_0812AAAC[this->type];
if (puVar8[*(u32*)&this->field_0x74] == 0) {
*(u32*)&this->field_0x74 = 0;
}
o = sub_08008782(this, 0xe, puVar8[*(u32*)&this->field_0x74], puVar8[*(u32*)&this->field_0x74 + 1]);
if (o != NULL) {
child = CreateObject(OBJECT_11, o->type, o->type2);
if (child != NULL) {
child->actionDelay = o->actionDelay;
child->x.HALF.HI = puVar8[*(u32*)&this->field_0x74] + this->x.HALF.HI;
child->y.HALF.HI = puVar8[*(u32*)&this->field_0x74 + 1] + this->y.HALF.HI;
}
}
*(u32*)&this->field_0x74 += 2;
}
if (this->child == NULL && (u32)this->field_0x70.WORD > 2) {
this->field_0x70.WORD = 1;
}
if (--this->field_0x70.WORD != -1) {
return;
}
if (this->child == NULL) {
this->field_0x70.WORD = 2;
} else {
this->field_0x70.WORD = gUnk_0812AABC[this->type];
}
child = CreateObject(OBJECT_17, 0, 0);
if (child == NULL) {
return;
}
offset = Random() % 16;
width = this->hitbox->width;
if (width < offset) {
offset = width;
}
if (offset & 1) {
offset = -offset;
}
switch (this->animationState >> 1) {
case 0:
child->y.HALF.HI = this->y.HALF.HI - this->hitbox->height;
child->x.HALF.HI = this->x.HALF.HI + offset;
break;
case 2:
child->y.HALF.HI = this->y.HALF.HI + this->hitbox->height;
child->x.HALF.HI = this->x.HALF.HI + offset;
break;
case 1:
child->x.HALF.HI = this->x.HALF.HI + this->hitbox->width;
child->y.HALF.HI = this->y.HALF.HI + offset;
break;
case 3:
child->x.HALF.HI = this->x.HALF.HI - this->hitbox->width;
child->y.HALF.HI = this->y.HALF.HI + offset;
break;
}
}
ASM_FUNC("asm/non_matching/playerItem10/sub_080ACDB0.inc", bool32 sub_080ACDB0(Entity* this))
void sub_080ACECC(Entity* this) {
Entity* entity;
if (this->type < 3 && this->child == NULL && (s32) * (u32*)&this->field_0x78 >= 0 &&
gUnk_0812AAE8[this->type] <= *(u32*)&this->field_0x78) {
entity = CreatePlayerItem(0x10, this->type + 1, 0, 0);
if (entity != NULL) {
entity->parent = this;
this->child = entity;
entity->x.HALF.HI = this->x.HALF.HI;
entity->y.HALF.HI = this->y.HALF.HI;
}
}
}
@@ -7,7 +7,7 @@
void sub_0801B804(Entity*);
Entity* sub_0801B864(Entity*);
void sub_0801B584(Entity*);
void PlayerItem3_Init(Entity*);
void PlayerItemBoomerang_Init(Entity*);
void sub_0801B680(Entity*);
void sub_0801B7A8(Entity*);
@@ -16,9 +16,9 @@ extern bool32 sub_080040E2(Entity*, u8*);
extern Hitbox gUnk_081271CC;
extern u8 gUnk_08003E44;
void PlayerItem3(Entity* this) {
static void (*const PlayerItem3_Actions[])(Entity*) = {
PlayerItem3_Init,
void PlayerItemBoomerang(Entity* this) {
static void (*const PlayerItemBoomerang_Actions[])(Entity*) = {
PlayerItemBoomerang_Init,
sub_0801B584,
sub_0801B680,
sub_0801B7A8,
@@ -27,7 +27,7 @@ void PlayerItem3(Entity* this) {
// Unused
static const u16 gUnk_080B780C[] = { 0x75, 0x1, 0x76, 0x1, 0x3ac, 0x1, 0x4050, 0x1, 0x377, 0x1, 0x378, 0x1, 0x0 };
PlayerItem3_Actions[this->action](this);
PlayerItemBoomerang_Actions[this->action](this);
if (this->animIndex != 0xb) {
if (this->animationState == 6) {
this->field_0x86.HWORD += 0x2000;
@@ -43,7 +43,7 @@ void PlayerItem3(Entity* this) {
}
}
void PlayerItem3_Init(Entity* this) {
void PlayerItemBoomerang_Init(Entity* this) {
u32 uVar1;
gPlayerState.item = this;
@@ -11,7 +11,7 @@ void sub_0801B938(Entity*);
extern void sub_08017744(Entity*);
void PlayerItemC(Entity* this) {
void PlayerItemDashSword(Entity* this) {
static void (*const PlayerItemC_Actions[])(Entity*) = {
sub_0801B8B0,
sub_0801B8FC,
@@ -8,7 +8,7 @@ extern void (*const gUnk_08127270[])(Entity*);
extern Hitbox gUnk_08127278;
void sub_080A310C(Entity*);
void PlayerItem15(Entity* this) {
void PlayerItemFireRodProjectile(Entity* this) {
gUnk_08127270[this->action](this);
}
+218
View File
@@ -0,0 +1,218 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "asm.h"
#include "object.h"
enum {
GUST_INIT,
GUST_UPDATE,
};
typedef struct {
Entity base;
u32 filler68[2];
u32 timer;
u32 offset_iter;
u32 unk78;
} GustEntity;
typedef void(GustActionFunc)(GustEntity*);
static GustActionFunc PlayerItemGust_Init;
static GustActionFunc PlayerItemGust_Update;
static void sub_080ACC78(GustEntity*);
/*static*/ bool32 sub_080ACDB0(GustEntity*);
static void sub_080ACECC(GustEntity*);
typedef struct {
u16 bits;
u8 type2;
u8 actionDelay;
u8 _4;
u8 type;
u16 tileID;
} Obj11;
Obj11* sub_08008782(Entity*, u32, u32, u32);
extern const s8* const sOffsets[];
extern const s8 gUnk_0812AABC[];
extern const Hitbox* const sHitboxes[];
extern const u8 gUnk_0812AAE8[];
// specifically, the little gusts that come out while the item is active
// type 0: stays close to jar?
// type 1: causes the particles to move away from the jar
// type 2: same as 1?
// type 3: horizontal spread
void PlayerItemGust(Entity* this) {
static GustActionFunc* const sActions[] = {
PlayerItemGust_Init,
PlayerItemGust_Update,
};
if ((gPlayerState.field_0x1c & 0x7f) != 1) {
DeleteThisEntity();
}
sActions[this->action]((GustEntity*)this);
this->iframes = 0;
}
static void PlayerItemGust_Init(GustEntity* this) {
super->action = GUST_UPDATE;
super->flags2 = gPlayerEntity.flags2;
super->direction = super->animationState << 2;
super->speed = 0x200;
super->flags |= ENT_COLLIDE | ENT_PERSIST;
super->field_0x3c = 2;
super->hitbox = (Hitbox*)sHitboxes[super->type];
this->timer = 16;
sub_080ACDB0(this);
sub_0801766C(super);
}
static void PlayerItemGust_Update(GustEntity* this) {
if (sub_080ACDB0(this) == FALSE) {
sub_080ACC78(this);
sub_080ACECC(this);
}
}
static void sub_080ACC78(GustEntity* this) {
s32 width;
Obj11* o;
Entity* child;
s32 offset;
const s8* child_offsets;
// this is what makes types 1 and 2 different?
if ((super->type + gRoomTransition.frameCount) & 1) {
child_offsets = sOffsets[super->type];
if (child_offsets[this->offset_iter] == 0) {
this->offset_iter = 0;
}
o = sub_08008782(super, 0xe, child_offsets[this->offset_iter], child_offsets[this->offset_iter + 1]);
if (o != NULL) {
child = CreateObject(OBJECT_11, o->type, o->type2);
if (child != NULL) {
child->actionDelay = o->actionDelay;
child->x.HALF.HI = child_offsets[this->offset_iter] + super->x.HALF.HI;
child->y.HALF.HI = child_offsets[this->offset_iter + 1] + super->y.HALF.HI;
}
}
this->offset_iter += 2;
}
if (super->child == NULL && (u32)this->timer > 2) {
this->timer = 1;
}
if (this->timer-- != 0) {
return;
}
if (super->child == NULL) {
this->timer = 2;
} else {
this->timer = gUnk_0812AABC[super->type];
}
child = CreateObject(OBJECT_17, 0, 0);
if (child == NULL) {
return;
}
offset = Random() % 16;
width = super->hitbox->width;
if (width < offset) {
offset = width;
}
if (offset & 1) {
offset = -offset;
}
switch (super->animationState >> 1) {
case 0:
child->y.HALF.HI = super->y.HALF.HI - super->hitbox->height;
child->x.HALF.HI = super->x.HALF.HI + offset;
break;
case 2:
child->y.HALF.HI = super->y.HALF.HI + super->hitbox->height;
child->x.HALF.HI = super->x.HALF.HI + offset;
break;
case 1:
child->x.HALF.HI = super->x.HALF.HI + super->hitbox->width;
child->y.HALF.HI = super->y.HALF.HI + offset;
break;
case 3:
child->x.HALF.HI = super->x.HALF.HI - super->hitbox->width;
child->y.HALF.HI = super->y.HALF.HI + offset;
break;
}
}
/*static*/ ASM_FUNC("asm/non_matching/playerItem10/sub_080ACDB0.inc", bool32 sub_080ACDB0(GustEntity* this))
static void sub_080ACECC(GustEntity* this) {
Entity* entity;
if (super->type < 3 && super->child == NULL && (s32)this->unk78 >= 0 && gUnk_0812AAE8[super->type] <= this->unk78) {
entity = CreatePlayerItem(0x10, super->type + 1, 0, 0);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
entity->x.HALF.HI = super->x.HALF.HI;
entity->y.HALF.HI = super->y.HALF.HI;
}
}
}
static const s8 sOffsets0[] = {
-4, -4, 4, -4, -4, 4, 4, 4, 0,
};
static const s8 sOffsets1And2[] = {
-5, -5, 5, -5, -5, 5, 5, 5, 0,
};
static const s8 sOffsets3[] = {
-9, -9, 1, -9, 9, -9, -9, 1, 9, 1, -9, 9, 1, 9, 9, 9, 0, 0,
};
static const s8* const sOffsets[] = {
sOffsets0,
sOffsets1And2,
sOffsets1And2,
sOffsets3,
};
static const s8 gUnk_0812AABC[] = {
120,
80,
40,
4,
};
static const Hitbox sHitbox0 = {
0, 0, 4, 2, 2, 4, 4, 4,
};
static const Hitbox sHitbox1And2 = {
0, 0, 4, 3, 3, 4, 9, 9,
};
static const Hitbox sHitbox3 = {
0, 0, 8, 7, 7, 8, 14, 14,
};
static const Hitbox* const sHitboxes[] = {
&sHitbox0,
&sHitbox1And2,
&sHitbox1And2,
&sHitbox3,
};
static const u8 gUnk_0812AAE8[] = {
0,
12,
16,
16,
};
@@ -19,7 +19,7 @@ extern u32 sub_08007DD6(u32, const u16*);
extern const u16 gUnk_080B3DF4[];
extern const u8 gUnk_08003E44[];
void PlayerItem11(Entity* this) {
void PlayerItemGustBig(Entity* this) {
if (this->health) {
this->iframes = 0;
gUnk_080B3DD0[this->action](this);
@@ -20,25 +20,25 @@ typedef struct {
u8 unk_68[4];
u16 unk_6c;
u16 unk_6e;
} PlayerItem13Entity;
} PlayerItemHeldObjectEntity;
extern bool32 ProcessMovement10(Entity*);
extern const s8 gUnk_081320C4[];
bool32 sub_080AD32C(PlayerItem13Entity*);
void sub_080AD27C(PlayerItem13Entity*);
bool32 sub_080AD32C(PlayerItemHeldObjectEntity*);
void sub_080AD27C(PlayerItemHeldObjectEntity*);
u32 sub_0806F8DC(Entity*);
extern const u16 gUnk_081320CC[];
extern const u32 gUnk_081320D4[];
void PlayerItem13(Entity* this) {
void PlayerItemHeldObject(Entity* this) {
gUnk_081320A8[this->subAction](this);
}
ASM_FUNC("asm/non_matching/playerItem13/sub_080ACF2C.inc", void sub_080ACF2C(Entity* this))
void sub_080ACFCC(PlayerItem13Entity* this) {
void sub_080ACFCC(PlayerItemHeldObjectEntity* this) {
Entity* child = super->child;
if ((this->unk_6c == child->kind) || (this->unk_6e == child->id)) {
if (child->action != 2) {
@@ -59,12 +59,12 @@ void sub_080ACFCC(PlayerItem13Entity* this) {
}
}
void sub_080AD040(PlayerItem13Entity* this) {
PlayerItem13Entity* child;
void sub_080AD040(PlayerItemHeldObjectEntity* this) {
PlayerItemHeldObjectEntity* child;
u32 tile;
u32 tmp;
child = (PlayerItem13Entity*)super->child;
child = (PlayerItemHeldObjectEntity*)super->child;
if ((child->base).action != 2) {
DeleteThisEntity();
}
@@ -134,7 +134,7 @@ void sub_080AD040(PlayerItem13Entity* this) {
} else {
if (super->actionDelay != 0 || sub_080AD32C(child)) {
if (super->actionDelay == 1) {
SoundReq(SFX_104);
SoundReq(SFX_PLACE_OBJ);
}
UpdateSpriteForCollisionLayer(super);
child->base.subAction = 3;
@@ -143,7 +143,7 @@ void sub_080AD040(PlayerItem13Entity* this) {
child->base.spritePriority.b0 = super->spritePriority.b0;
DeleteThisEntity();
} else {
SoundReq(SFX_104);
SoundReq(SFX_PLACE_OBJ);
super->actionDelay++;
super->zVelocity = 0x10000;
super->speed /= 2;
@@ -181,9 +181,9 @@ void sub_080AD274(Entity* this) {
DeleteThisEntity();
}
void sub_080AD27C(PlayerItem13Entity* this) {
void sub_080AD27C(PlayerItemHeldObjectEntity* this) {
u32 tmp;
PlayerItem13Entity* child = (PlayerItem13Entity*)super->child;
PlayerItemHeldObjectEntity* child = (PlayerItemHeldObjectEntity*)super->child;
gNewPlayerEntity.unk_74 = NULL;
if ((this->unk_6c == (u16)(child->base).kind) && (this->unk_6e == (u16)(child->base).id)) {
if (child != this) {
@@ -209,7 +209,7 @@ void sub_080AD27C(PlayerItem13Entity* this) {
}
}
bool32 sub_080AD32C(PlayerItem13Entity* this) {
bool32 sub_080AD32C(PlayerItemHeldObjectEntity* this) {
bool32 result = FALSE;
if (((super->field_0x16 & 0xf0) == 0x10) ||
((super->kind == OBJECT && ((super->id == 5 || (super->id == 0x7d)))))) {
@@ -6,7 +6,7 @@
static const Hitbox gUnk_0811B9D0;
void PlayerItem12_Init(Entity* this);
void PlayerItemPacciCaneProjectile_Init(Entity* this);
void sub_080701F8(Entity* this);
void sub_0807037C(Entity* this);
void sub_08070398(Entity* this);
@@ -16,11 +16,11 @@ void sub_08070458(Entity* this);
extern void sub_08017744(Entity*);
extern u8* sub_08008782(Entity*, u32, u32, u32);
void PlayerItem12(Entity* this) {
static void (*const PlayerItem12_Actions[])(Entity*) = {
PlayerItem12_Init, sub_080701F8, sub_0807037C, sub_08070398, sub_080703BC,
void PlayerItemPacciCaneProjectile(Entity* this) {
static void (*const PlayerItemPacciCaneProjectile_Actions[])(Entity*) = {
PlayerItemPacciCaneProjectile_Init, sub_080701F8, sub_0807037C, sub_08070398, sub_080703BC,
};
PlayerItem12_Actions[this->action](this);
PlayerItemPacciCaneProjectile_Actions[this->action](this);
}
extern u8 gUnk_08003E44;
@@ -34,7 +34,7 @@ typedef struct {
u8 filler[3];
} gUnk_0811B9A8_struct;
void PlayerItem12_Init(Entity* this) {
void PlayerItemPacciCaneProjectile_Init(Entity* this) {
static const s8 gUnk_0811B9A0[] = {
0, -18, 14, 0, 0, 14, -14, 0,
};
@@ -10,7 +10,7 @@ extern u8 gUnk_08003E44;
void sub_0805FC74(Entity*);
void PlayerItem14(Entity* this) {
void PlayerItemSpiralBeam(Entity* this) {
gUnk_08109AC8[this->action](this);
}