Skip to content

Commit

Permalink
Add fox item attr and some small fixes (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronB-Hub authored Sep 23, 2024
1 parent 0443d45 commit 8b105fc
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 83 deletions.
45 changes: 38 additions & 7 deletions src/melee/it/itCharItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,50 @@ typedef struct {
/* x108 */ HSD_GObj* owner; // xE7C
} FoxBlasterVars;

typedef struct FoxBlasterAttr {
/* +0 */ float x0;
/* +4 */ float x4;
/* +8 */ float x8;
/* +C */ float xC;
/* +10 */ float x10;
/* +14 */ float x14;
/* +18 */ float x18; // [1]
/* +1C */ float x1C;
/* +20 */ float x20; // [2]
/* +24 */ float x24;
} FoxBlasterAttr;

typedef struct {
float xDD4;
float xDD8;
float xDDC;
Vec3 xDE0;
/* +0 ip+DD4 */ float scale;
/* +4 ip+DD8 */ float angle;
/* +8 ip+DDC */ float speed;
/* +C ip+DE0 */ Vec3 pos;
} FoxLaserVars;

typedef struct FoxLaserAttr {
/* +0 */ float lifetime; // [35]
/* +4 */ float scale; // [3]
/* +8 */ float x8;
/* +C */ float xC;
/* +10 */ float x10;
/* +14 */ float x14;
/* +18 */ float x18;
/* +1C */ float x1C;
/* +20 */ float x20;
/* +24 */ float x24; // [1]
} FoxLaserAttr;

typedef struct {
HSD_Joint* xDD4;
float xDD8;
HSD_JObj* xDDC;
/* +0 ip+DD4 */ HSD_Joint* xDD4;
/* +4 ip+DD8 */ float xDD8;
/* +8 ip+DDC */ HSD_JObj* xDDC;
} FoxIllusionVars;

typedef struct FoxIllusionAttr {
float x0; // [5]
float x4; // [2]
} FoxIllusionAttr;

typedef struct {
u32 x0;
} itKirbyHammerVars;
Expand Down
86 changes: 61 additions & 25 deletions src/melee/it/itCommonItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
typedef struct {
bool x0;
bool x4;
} ItCapsuleAttrs;
} ItCapsuleVars;

typedef struct {
bool x0; // [1 or true]
s32 x4; // [8]
} ItCapsuleAttr;

typedef struct {
/* ip+DD4 */ float dir;
Expand Down Expand Up @@ -88,6 +93,28 @@ typedef struct HeartContainerVars {
f32 xDEC;
} HeartContainerVars;

typedef struct HeartContainerAttr {
s32 x0_heal; // [100]
union {
struct {
u8 b0 : 1;
u8 b1 : 1;
u8 b2 : 1;
u8 b3 : 1;
u8 b4 : 1;
u8 b5 : 1;
u8 b6 : 1;
u8 b7 : 1;
} bits;
u32 flags;
} x4; // [999]
s32 x8; // [1200]
s32 xC; // [1140]
s32 x10; // [120]
f32 x14; // y velocity? [1.5]
f32 x18; // y rotation? [0.0349066]
} HeartContainerAttr;

typedef struct MaximTomatoVars {
s32 heal_amount;
union {
Expand Down Expand Up @@ -120,22 +147,27 @@ typedef struct FoodVars {
s32 xDD8_heal;
} FoodVars;

typedef struct ItLGunVars {
/* +0 ip+DD4 */ int timer;
} ItLGunVars;

typedef struct ItLGunAttr {
int x0;
Vec3 pos;
int x0; // [16]
Vec3 pos; // [0, 2.128, 6.668]
} ItLGunAttr;

typedef struct ItLGunVars {
int timer;
} ItLGunVars;
typedef struct ItLGunRayVars {
/* +0 ip+DD4 */ float scale;
/* +4 ip+DD8 */ float angle;
/* +8 ip+DDC */ float speed;
/* +C ip+DE0 */ Vec3 pos;
} ItLGunRayVars;

typedef struct ItLGunBeamAttr {
float x0; // lifetime
float x4; // related to position calcs for var xDFC
float x8; // related to position calcs for var xDFC
float xC; // related to position calcs for var xDF8
float x10; // related to position calcs for var xDF8
} ItLGunBeamAttr;
typedef struct ItLGunRayAttr {
/* +0 */ float speed; // [5]
/* +4 */ float lifetime; // [80]
/* +8 */ float max_scale; // [3]
} ItLGunRayAttr;

typedef struct ItLGunBeamVars {
/* +0 ip+DD4 */ Vec3 position0;
Expand All @@ -147,18 +179,13 @@ typedef struct ItLGunBeamVars {
/* +30 ip+E04 */ int xE04;
} ItLGunBeamVars;

typedef struct ItLGunRayAttr {
/* +0 */ float speed;
/* +4 */ float lifetime;
/* +8 */ float max_scale;
} ItLGunRayAttr;

typedef struct ItLGunRayVars {
/* ip+DD4 */ float scale;
/* ip+DD8 */ float angle;
/* ip+DDC */ float speed;
/* ip+DE0 */ Vec3 pos;
} ItLGunRayVars;
typedef struct ItLGunBeamAttr {
float lifetime; // lifetime - [18]
float x4; // related to position calcs for var angle1 - [1]
float x8; // related to position calcs for var angle1 - [2]
float xC; // related to position calcs for var angle0 - [1.22173]
float x10; // related to position calcs for var angle0 - [2/3 * pi]
} ItLGunBeamAttr;

/// Eggs spawned on Yoshi stages / by Chansey
typedef struct EggVars {
Expand Down Expand Up @@ -308,6 +335,15 @@ typedef struct FFlowerVars {
uint x4;
} FFlowerVars;

typedef struct FFlowerAttr {
int x0; // [120]
int x4; // [1200]
int x8; // [1140]
int xC; // [120]
float x10; // [1.5]
float x14;
} FFlowerAttr;

typedef struct FFlowerFlameVars {
/* +0 */ Vec3 pos;
/* +C */ f32 unk;
Expand Down
6 changes: 3 additions & 3 deletions src/melee/it/items/itcapsule.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ void it_8027CF30(Item_GObj* gobj)
u8 _[8] = { 0 };

Item* it = GET_ITEM(gobj);
ItCapsuleAttrs* capsule = it->xC4_article_data->x4_specialAttributes;
ItCapsuleAttr* attr = it->xC4_article_data->x4_specialAttributes;

sp18.x = sp18.y = sp18.z = 0.0F;
if (!it_8026F8B4(gobj, &it->pos, &sp18, 0)) {
if (!HSD_Randi(capsule->x4)) {
if (!HSD_Randi(attr->x4)) {
it_8027D2DC(gobj);
it->xDD4_itemVar.capsule.x0 = false;
} else {
it_8026F3D4(gobj, 0, capsule->x0, 0);
it_8026F3D4(gobj, 0, attr->x0, 0);
it->xDD4_itemVar.capsule.x0 = true;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/melee/it/items/itegg.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Item_GObj* it_80288C88(Item_GObj* gobj, Vec3* pos, Vec3* vel, float dir)

void it_80288D98(Item_GObj* gobj)
{
GET_ITEM(gobj)->xDD4_itemVar.capsule.x0 = false;
GET_ITEM(gobj)->xDD4_itemVar.egg.x0 = false;
it_80288EFC(gobj);
}

Expand Down Expand Up @@ -259,7 +259,7 @@ bool it_80289218(Item_GObj* gobj)
{
Item* ip = gobj->user_data;

if (ip->xDD4_itemVar.capsule.x0) {
if (ip->xDD4_itemVar.egg.x0) {
return false;
}
if (it_80288DC4(gobj)) {
Expand Down
6 changes: 3 additions & 3 deletions src/melee/it/items/itfflower.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ void it_80292E04(Item_GObj* gobj)
{
Item* ip = GET_ITEM(gobj);

FFlowerVars* attr = ip->xC4_article_data->x4_specialAttributes;
FFlowerAttr* attr = ip->xC4_article_data->x4_specialAttributes;

ip->xD4C = attr->x0;
ip->xAC4_ignoreItemID = Item_8026AE60();
ip->xDD4_itemVar.capsule.x0 = 0;
ip->xDD4_itemVar.capsule.x4 = 0;
ip->xDD4_itemVar.fflower.x0 = 0;
ip->xDD4_itemVar.fflower.x4 = 0;
it_8029313C(gobj);
}

Expand Down
56 changes: 28 additions & 28 deletions src/melee/it/items/itfoxlaser.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ inline void* getFoxLaser(Item* item)
bool it_8029C4D4(Item_GObj* item_gobj, CollData* arg1)
{
Item* item = GET_ITEM(item_gobj);
return it_8026E9A4(item_gobj, &item->xDD4_itemVar.foxlaser.xDE0,
&item->pos, 0);
return it_8026E9A4(item_gobj, &item->xDD4_itemVar.foxlaser.pos, &item->pos,
0);
}

static inline void normalizeAngle(f32* angle)
Expand All @@ -46,7 +46,7 @@ static inline void normalizeAngle(f32* angle)
}

void it_8029C504(HSD_GObj* parent, Vec3* pos, enum_t msid, int kind, f32 angle,
f32 arg9)
f32 speed)
{
SpawnItem spawn;
Item_GObj* item_gobj;
Expand All @@ -71,13 +71,13 @@ void it_8029C504(HSD_GObj* parent, Vec3* pos, enum_t msid, int kind, f32 angle,
item_gobj = Item_80268B18(&spawn);
if (item_gobj != NULL) {
Item* item = GET_ITEM(item_gobj);
FoxLaserVars* attr = item->xC4_article_data->x4_specialAttributes;
FoxLaserAttr* attr = item->xC4_article_data->x4_specialAttributes;
Item_80268E5C(item_gobj, msid, ITEM_ANIM_UPDATE);
it_80275158(item_gobj, attr->xDD4);
item->xDD4_itemVar.foxlaser.xDD4 = 0.0F;
item->xDD4_itemVar.foxlaser.xDD8 = angle;
item->xDD4_itemVar.foxlaser.xDDC = arg9;
item->xDD4_itemVar.foxlaser.xDE0 = spawn.pos;
it_80275158(item_gobj, attr->lifetime);
item->xDD4_itemVar.foxlaser.scale = 0.0F;
item->xDD4_itemVar.foxlaser.angle = angle;
item->xDD4_itemVar.foxlaser.speed = speed;
item->xDD4_itemVar.foxlaser.pos = spawn.pos;
db_80225DD8(item_gobj, parent);
}
}
Expand Down Expand Up @@ -105,7 +105,7 @@ bool it_8029C6F4(Item_GObj* item_gobj)
{
Article* article;
Item* item;
FoxLaserVars* attr;
FoxLaserAttr* attr;
HSD_JObj* jobj;
f32 dir;
f32 vel_x;
Expand All @@ -114,10 +114,10 @@ bool it_8029C6F4(Item_GObj* item_gobj)
jobj = GET_JOBJ(item_gobj);
article = item->xC4_article_data;
attr = article->x4_specialAttributes;
item->x40_vel.x = item->xDD4_itemVar.foxlaser.xDDC *
cosf(item->xDD4_itemVar.foxlaser.xDD8);
item->x40_vel.y = item->xDD4_itemVar.foxlaser.xDDC *
sinf(item->xDD4_itemVar.foxlaser.xDD8);
item->x40_vel.x = item->xDD4_itemVar.foxlaser.speed *
cosf(item->xDD4_itemVar.foxlaser.angle);
item->x40_vel.y = item->xDD4_itemVar.foxlaser.speed *
sinf(item->xDD4_itemVar.foxlaser.angle);
item->x40_vel.z = 0.0F;
if (item->x40_vel.x > 0.0F) {
dir = +1.0F;
Expand All @@ -132,22 +132,22 @@ bool it_8029C6F4(Item_GObj* item_gobj)
vel_x = +item->x40_vel.x;
}
HSD_JObjSetRotationX(jobj, M_PI + atan2f(item->x40_vel.y, vel_x));
item->xDD4_itemVar.foxlaser.xDD4 +=
fabsf(item->xDD4_itemVar.foxlaser.xDDC) / 11.25F;
if (item->xDD4_itemVar.foxlaser.xDD4 > attr->xDD8) {
item->xDD4_itemVar.foxlaser.xDD4 = attr->xDD8;
item->xDD4_itemVar.foxlaser.scale +=
fabsf(item->xDD4_itemVar.foxlaser.speed) / 11.25F;
if (item->xDD4_itemVar.foxlaser.scale > attr->scale) {
item->xDD4_itemVar.foxlaser.scale = attr->scale;
}
if (item->xDD4_itemVar.foxlaser.xDD4 < 1e-5F) {
item->xDD4_itemVar.foxlaser.xDD4 = 1e-3;
if (item->xDD4_itemVar.foxlaser.scale < 1e-5F) {
item->xDD4_itemVar.foxlaser.scale = 1e-3;
}
HSD_JObjSetScaleZ(jobj, item->xDD4_itemVar.foxlaser.xDD4);
HSD_JObjSetScaleZ(jobj, item->xDD4_itemVar.foxlaser.scale);
return it_80273130(item_gobj);
}

void it_8029C9CC(Item_GObj* item_gobj)
{
Item* item = GET_ITEM(item_gobj);
item->xDD4_itemVar.foxlaser.xDE0 = item->pos;
item->xDD4_itemVar.foxlaser.pos = item->pos;
}

bool it_8029C9EC(Item_GObj* item_gobj)
Expand Down Expand Up @@ -175,9 +175,9 @@ bool it_8029CA80(Item_GObj* item_gobj)
item->facing_dir = item->xC68;
HSD_JObjSetRotationY(jobj, (M_PI / 2) * item->facing_dir);
}
HSD_JObjSetScaleZ(jobj, item->xDD4_itemVar.foxlaser.xDD4 = 1e-3);
item->xDD4_itemVar.foxlaser.xDD8 += M_PI;
normalizeAngle(&item->xDD4_itemVar.foxlaser.xDD8);
HSD_JObjSetScaleZ(jobj, item->xDD4_itemVar.foxlaser.scale = 1e-3);
item->xDD4_itemVar.foxlaser.angle += M_PI;
normalizeAngle(&item->xDD4_itemVar.foxlaser.angle);
return false;
}

Expand All @@ -191,10 +191,10 @@ bool it_8029CC54(Item_GObj* item_gobj)
Item* item = GET_ITEM(item_gobj);
u8 _[4] = { 0 };
lbVector_Mirror(&item->x40_vel, &item->xC58);
item->xDD4_itemVar.foxlaser.xDD4 = 1e-3;
item->xDD4_itemVar.foxlaser.xDD8 =
item->xDD4_itemVar.foxlaser.scale = 1e-3;
item->xDD4_itemVar.foxlaser.angle =
atan2f(item->x40_vel.y, item->x40_vel.x);
normalizeAngle(&item->xDD4_itemVar.foxlaser.xDD8);
normalizeAngle(&item->xDD4_itemVar.foxlaser.angle);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/melee/it/items/itfoxlaser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* 29C4D4 */ bool it_8029C4D4(Item_GObj*, CollData*);
/* 29C504 */ void it_8029C504(HSD_GObj* parent, Vec3* pos, enum_t msid,
int kind, f32 angle, f32 arg9);
int kind, f32 angle, f32 speed);
/* 29C6A4 */ void it_8029C6A4(f32 angle, f32 vel, HSD_GObj* parent, Vec3* vec,
int kind);
/* 29C6CC */ void it_8029C6CC(f32 angle, f32 vel, HSD_GObj* parent, Vec3* vec,
Expand All @@ -24,7 +24,7 @@
/* 29CC4C */ bool it_8029CC4C(Item_GObj*);
/* 29CC54 */ bool it_8029CC54(Item_GObj*);
/* 29CCF0 */ bool it_8029CCF0(Item_GObj*);
/* 29CCF8 */ void it_8029CCF8(Item_GObj*, HSD_GObj* ref);
/* 29CCF8 */ void it_8029CCF8(Item_GObj*, HSD_GObj*);
/* 3F67D0 */ extern ItemStateTable it_803F67D0[];

#endif
Loading

0 comments on commit 8b105fc

Please sign in to comment.