Merge pull request #618 from octorock/playerItems

Create new entity structs for Player Items
This commit is contained in:
notyourav 2023-07-31 19:20:00 -07:00 committed by GitHub
commit 064bc43e78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 895 additions and 741 deletions

View File

@ -20,7 +20,7 @@ typedef struct {
static_assert(sizeof(OctorokBossHeap) == 0x30); static_assert(sizeof(OctorokBossHeap) == 0x30);
struct OctorokBossEntity { struct OctorokBossEntity {
Entity base; /*0x00*/ Entity base;
/*0x68*/ union SplitHWord field_0x68; /*0x68*/ union SplitHWord field_0x68;
/*0x6a*/ union SplitHWord field_0x6a; /*0x6a*/ union SplitHWord field_0x6a;
/*0x6c*/ union SplitHWord field_0x6c; /*0x6c*/ union SplitHWord field_0x6c;

View File

@ -1,49 +1,56 @@
/**
* @file playerItemBomb.c
* @ingroup Items
*
* @brief Bomb Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "asm.h" #include "asm.h"
#include "entity.h"
#include "functions.h"
#include "item.h" #include "item.h"
#include "object.h" #include "object.h"
#include "player.h"
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u32 unk_68; /*0x68*/ u32 unk_68;
} PlayerItemBombEntity; } PlayerItemBombEntity;
void sub_0801B418(Entity*); void sub_0801B418(Entity* this);
void sub_0801B3A4(PlayerItemBombEntity*); void sub_0801B3A4(PlayerItemBombEntity* this);
void sub_0801B250(PlayerItemBombEntity*); void PlayerItemBomb_Init(PlayerItemBombEntity* this);
void sub_0801B2CC(PlayerItemBombEntity*); void PlayerItemBomb_Action1(PlayerItemBombEntity* this);
void sub_0801B318(PlayerItemBombEntity*); void PlayerItemBomb_Action2(PlayerItemBombEntity* this);
void sub_0801B38C(PlayerItemBombEntity*); void PlayerItemBomb_Action3(PlayerItemBombEntity* this);
void sub_0801B330(PlayerItemBombEntity*); void PlayerItemBomb_SubAction0(PlayerItemBombEntity* this);
void sub_0801B340(PlayerItemBombEntity*); void PlayerItemBomb_SubAction1(PlayerItemBombEntity* this);
void sub_0801B354(PlayerItemBombEntity*); void PlayerItemBomb_SubAction2(PlayerItemBombEntity* this);
void sub_0801B368(PlayerItemBombEntity*); void PlayerItemBomb_SubAction3(PlayerItemBombEntity* this);
void sub_0801B384(PlayerItemBombEntity*); void PlayerItemBomb_SubAction4(PlayerItemBombEntity* this);
static void (*const actionFuncs[])(PlayerItemBombEntity*) = { static void (*const PlayerItemBomb_Actions[])(PlayerItemBombEntity*) = {
sub_0801B250, PlayerItemBomb_Init,
sub_0801B2CC, PlayerItemBomb_Action1,
sub_0801B318, PlayerItemBomb_Action2,
sub_0801B38C, PlayerItemBomb_Action3,
}; };
static void (*const subActionFuncs[])(PlayerItemBombEntity*) = { static void (*const PlayerItemBomb_SubActions[])(PlayerItemBombEntity*) = {
sub_0801B330, sub_0801B340, sub_0801B354, sub_0801B368, sub_0801B384, PlayerItemBomb_SubAction0, PlayerItemBomb_SubAction1, PlayerItemBomb_SubAction2,
PlayerItemBomb_SubAction3, PlayerItemBomb_SubAction4,
}; };
static const Hitbox unusedHitbox = { 0, 0, { 4, 0, 0, 4 }, 22, 22 }; static const Hitbox unusedHitbox = { 0, 0, { 4, 0, 0, 4 }, 22, 22 };
static const Hitbox gUnk_080B77F4 = { 0, 0, 6, 0, 0, 6, 4, 4 }; static const Hitbox gUnk_080B77F4 = { 0, 0, 6, 0, 0, 6, 4, 4 };
void PlayerItemBomb(PlayerItemBombEntity* this) { void PlayerItemBomb(PlayerItemBombEntity* this) {
u8 uVar1, uVar2; u8 action, uVar2;
actionFuncs[super->action](this); PlayerItemBomb_Actions[super->action](this);
GetNextFrame(super); GetNextFrame(super);
uVar2 = uVar1 = super->action; uVar2 = action = super->action;
if (uVar1 != 0x03) { if (action != 3) {
if (super->timer != 0) { if (super->timer != 0) {
if (*(u8*)&this->unk_68 == 7) { if (*(u8*)&this->unk_68 == 7) {
super->timer--; super->timer--;
@ -56,11 +63,11 @@ void PlayerItemBomb(PlayerItemBombEntity* this) {
} }
} else { } else {
if (super->subtimer != 0) { if (super->subtimer != 0) {
if (super->subtimer-- == 0x01) { if (super->subtimer-- == 1) {
if ((uVar1 == 0x02) && (super->subAction == 1)) { if ((action == 2) && (super->subAction == 1)) {
gPlayerState.heldObject = 0; gPlayerState.heldObject = 0;
} }
super->action = 0x03; super->action = 3;
super->spritePriority.b1 = 2; super->spritePriority.b1 = 2;
super->timer = 15; super->timer = 15;
super->spriteSettings.draw = 0; super->spriteSettings.draw = 0;
@ -76,7 +83,7 @@ void PlayerItemBomb(PlayerItemBombEntity* this) {
} }
} }
void sub_0801B250(PlayerItemBombEntity* this) { void PlayerItemBomb_Init(PlayerItemBombEntity* this) {
super->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
super->action = 1; super->action = 1;
super->spritePriority.b1 = 3; super->spritePriority.b1 = 3;
@ -98,59 +105,59 @@ void sub_0801B250(PlayerItemBombEntity* this) {
} }
} }
void sub_0801B2CC(PlayerItemBombEntity* this) { void PlayerItemBomb_Action1(PlayerItemBombEntity* this) {
u16 unaff_r5; u16 input;
if (!sub_0800442E(super)) { if (!sub_0800442E(super)) {
RegisterCarryEntity(super); RegisterCarryEntity(super);
} }
switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) { switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) {
case EQUIP_SLOT_A: case EQUIP_SLOT_A:
unaff_r5 = PLAYER_INPUT_1; input = PLAYER_INPUT_1;
break; break;
case EQUIP_SLOT_B: case EQUIP_SLOT_B:
unaff_r5 = PLAYER_INPUT_2; input = PLAYER_INPUT_2;
break; break;
case EQUIP_SLOT_NONE: case EQUIP_SLOT_NONE:
unaff_r5 = 0; input = 0;
break; break;
} }
if ((gPlayerState.playerInput.newInput & unaff_r5) != 0) { if ((gPlayerState.playerInput.newInput & input) != 0) {
super->timer = 0; super->timer = 0;
super->subtimer = 1; super->subtimer = 1;
} }
} }
void sub_0801B318(PlayerItemBombEntity* this) { void PlayerItemBomb_Action2(PlayerItemBombEntity* this) {
subActionFuncs[super->subAction](this); PlayerItemBomb_SubActions[super->subAction](this);
} }
void sub_0801B330(PlayerItemBombEntity* this) { void PlayerItemBomb_SubAction0(PlayerItemBombEntity* this) {
super->subAction++; super->subAction++;
sub_08079BD8(super); sub_08079BD8(super);
} }
void sub_0801B340(PlayerItemBombEntity* this) { void PlayerItemBomb_SubAction1(PlayerItemBombEntity* this) {
super->spritePriority.b1 = 2; super->spritePriority.b1 = 2;
} }
void sub_0801B354(PlayerItemBombEntity* this) { void PlayerItemBomb_SubAction2(PlayerItemBombEntity* this) {
super->spritePriority.b1 = 3; super->spritePriority.b1 = 3;
} }
void sub_0801B368(PlayerItemBombEntity* this) { void PlayerItemBomb_SubAction3(PlayerItemBombEntity* this) {
super->action--; super->action--;
super->subAction = 0; super->subAction = 0;
if (0x3c < super->timer) { if (super->timer > 60) {
super->timer = 60; super->timer = 60;
} }
} }
void sub_0801B384(PlayerItemBombEntity* this) { void PlayerItemBomb_SubAction4(PlayerItemBombEntity* this) {
DeleteThisEntity(); DeleteThisEntity();
} }
void sub_0801B38C(PlayerItemBombEntity* this) { void PlayerItemBomb_Action3(PlayerItemBombEntity* this) {
if (super->timer-- == 0) { if (super->timer-- == 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
@ -158,7 +165,7 @@ void sub_0801B38C(PlayerItemBombEntity* this) {
void sub_0801B3A4(PlayerItemBombEntity* this) { void sub_0801B3A4(PlayerItemBombEntity* this) {
u32 tmp; u32 tmp;
if (super->subtimer >= 0x29) { if (super->subtimer > 40) {
tmp = 8; tmp = 8;
} else { } else {
tmp = 4; tmp = 4;

View File

@ -1,213 +1,228 @@
#include "entity.h" /**
#include "sound.h" * @file playerItemBoomerang.c
#include "functions.h" * @ingroup Items
*
* @brief Boomerang Player Item
*/
#define NENT_DEPRECATED
#include "asm.h" #include "asm.h"
#include "entity.h"
#include "functions.h"
#include "item.h" #include "item.h"
#include "sound.h"
void sub_0801B804(Entity*); typedef struct {
Entity* sub_0801B864(Entity*); /*0x00*/ Entity base;
void sub_0801B584(Entity*); /*0x68*/ u8 unk_68;
void PlayerItemBoomerang_Init(Entity*); /*0x69*/ u8 unused1[23];
void sub_0801B680(Entity*); /*0x80*/ u8 unk_80;
void sub_0801B7A8(Entity*); /*0x81*/ u8 unused2[1];
/*0x83*/ union SplitHWord unk_82;
/*0x84*/ u8 unused3[2];
/*0x86*/ u16 unk_86;
} PlayerItemBoomerangEntity;
void sub_0801B804(PlayerItemBoomerangEntity* this);
Entity* sub_0801B864(Entity* this);
void PlayerItemBoomerang_Action1(PlayerItemBoomerangEntity* this);
void PlayerItemBoomerang_Init(PlayerItemBoomerangEntity* this);
void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this);
void PlayerItemBoomerang_Action3(PlayerItemBoomerangEntity* this);
extern Entity* sub_08008782(Entity*, u32, s32, s32); extern Entity* sub_08008782(Entity*, u32, s32, s32);
extern bool32 sub_080040E2(Entity*, u8*); extern bool32 sub_080040E2(Entity*, u8*);
extern Hitbox gUnk_081271CC; extern Hitbox gUnk_081271CC;
extern u8 gUnk_08003E44; extern u8 gUnk_08003E44;
void PlayerItemBoomerang(Entity* this) { void PlayerItemBoomerang(PlayerItemBoomerangEntity* this) {
static void (*const PlayerItemBoomerang_Actions[])(Entity*) = { static void (*const PlayerItemBoomerang_Actions[])(PlayerItemBoomerangEntity*) = {
PlayerItemBoomerang_Init, PlayerItemBoomerang_Init,
sub_0801B584, PlayerItemBoomerang_Action1,
sub_0801B680, PlayerItemBoomerang_Action2,
sub_0801B7A8, PlayerItemBoomerang_Action3,
}; };
// Unused // Unused
static const u16 gUnk_080B780C[] = { 0x75, 0x1, 0x76, 0x1, 0x3ac, 0x1, 0x4050, 0x1, 0x377, 0x1, 0x378, 0x1, 0x0 }; static const u16 gUnk_080B780C[] = { 0x75, 0x1, 0x76, 0x1, 0x3ac, 0x1, 0x4050, 0x1, 0x377, 0x1, 0x378, 0x1, 0x0 };
PlayerItemBoomerang_Actions[this->action](this); PlayerItemBoomerang_Actions[super->action](this);
if (this->animIndex != 0xb) { if (super->animIndex != 0xb) {
if (this->animationState == 6) { if (super->animationState == 6) {
this->field_0x86.HWORD += 0x2000; this->unk_86 += 0x2000;
} else { } else {
this->field_0x86.HWORD -= 0x2000; this->unk_86 -= 0x2000;
} }
SetAffineInfo(this, 0x100, 0x100, this->field_0x86.HWORD); SetAffineInfo(super, 0x100, 0x100, this->unk_86);
} }
this->subtimer--; super->subtimer--;
if ((this->subtimer & 0xf) == 0) { if ((super->subtimer & 0xf) == 0) {
EnqueueSFX(SFX_FB); EnqueueSFX(SFX_FB);
} }
} }
void PlayerItemBoomerang_Init(Entity* this) { void PlayerItemBoomerang_Init(PlayerItemBoomerangEntity* this) {
u32 uVar1; gPlayerState.item = super;
super->action = 1;
gPlayerState.item = this; super->hitbox = &gUnk_081271CC;
this->action = 1; super->frameIndex = 0xff;
this->hitbox = &gUnk_081271CC; this->unk_80 = 0;
this->frameIndex = 0xff;
this->field_0x80.HALF.LO = 0;
#ifdef EU #ifdef EU
this->spriteVramOffset = gPlayerEntity.spriteVramOffset; super->spriteVramOffset = gPlayerEntity.spriteVramOffset;
#endif #endif
this->animIndex = 11; super->animIndex = 11;
this->parent = &gPlayerEntity; super->parent = &gPlayerEntity;
this->field_0x86.HWORD = 0; this->unk_86 = 0;
if ((this->animationState & 2) != 0) { if ((super->animationState & 2) != 0) {
this->spriteSettings.flipX = ~gPlayerEntity.spriteSettings.flipX; super->spriteSettings.flipX = ~gPlayerEntity.spriteSettings.flipX;
} }
if (this->field_0x68.HALF.LO == 12) { if (this->unk_68 == 12) {
this->speed = 0x280; super->speed = 0x280;
uVar1 = 60; super->timer = 60;
} else { } else {
this->speed = 0x200; super->speed = 0x200;
uVar1 = 30; super->timer = 30;
} }
this->timer = uVar1;
if (((s8)gPlayerState.direction) >= 0) { if (((s8)gPlayerState.direction) >= 0) {
this->direction = gPlayerState.direction; super->direction = gPlayerState.direction;
} else { } else {
this->direction = this->animationState << 2; super->direction = super->animationState << 2;
} }
this->field_0x82.HALF.HI = this->direction; this->unk_82.HALF.HI = super->direction;
if (this->collisionLayer == 2) { if (super->collisionLayer == 2) {
this->type2 = 1; super->type2 = 1;
} }
LoadSwapGFX(this, 1, 3); LoadSwapGFX(super, 1, 3);
sub_0801766C(this); sub_0801766C(super);
sub_0801B584(this); PlayerItemBoomerang_Action1(this);
} }
void sub_0801B584(Entity* this) { void PlayerItemBoomerang_Action1(PlayerItemBoomerangEntity* this) {
static const s8 gUnk_080B7826[] = { 0, -8, 8, -4, 0, 8, -8, -4 }; static const s8 gUnk_080B7826[] = { 0, -8, 8, -4, 0, 8, -8, -4 };
u32 frameIndex; u32 frameIndex;
int iVar2; int iVar2;
u32 cVar3; u32 cVar3;
sub_0801B804(this); sub_0801B804(this);
if ((gPlayerState.attack_status == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != this || if ((gPlayerState.attack_status == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != super ||
(gPlayerState.item == this && gPlayerEntity.action != PLAYER_NORMAL)) { (gPlayerState.item == super && gPlayerEntity.action != PLAYER_NORMAL)) {
if (gPlayerState.item == this) { if (gPlayerState.item == super) {
gPlayerState.item = NULL; gPlayerState.item = NULL;
} }
DeleteThisEntity(); DeleteThisEntity();
} }
if ((gPlayerEntity.frame & 1) == 0) { if ((gPlayerEntity.frame & 1) == 0) {
if (this->field_0x68.HALF.LO == 12) { if (this->unk_68 == 12) {
cVar3 = 6; cVar3 = 6;
} else { } else {
cVar3 = 0; cVar3 = 0;
} }
frameIndex = (gPlayerEntity.frame >> 4) + cVar3; frameIndex = (gPlayerEntity.frame >> 4) + cVar3;
if (this->frameIndex != frameIndex) { if (super->frameIndex != frameIndex) {
this->frameIndex = frameIndex; super->frameIndex = frameIndex;
sub_080042D0(this, this->frameIndex, this->spriteIndex); sub_080042D0(super, super->frameIndex, super->spriteIndex);
} }
sub_08078E84(this, &gPlayerEntity); sub_08078E84(super, &gPlayerEntity);
} else { } else {
this->action = 2; super->action = 2;
this->spriteVramOffset = 0xd5; super->spriteVramOffset = 0xd5;
COLLISION_ON(this); COLLISION_ON(super);
this->collisionFlags |= 1; super->collisionFlags |= 1;
this->flags2 = gPlayerEntity.flags2; super->flags2 = gPlayerEntity.flags2;
this->spriteIndex = 0xa6; super->spriteIndex = 0xa6;
this->spriteSettings.flipX = 0; super->spriteSettings.flipX = 0;
this->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
iVar2 = (this->animationState >> 1) * 2; iVar2 = (super->animationState >> 1) * 2;
this->x.HALF.HI += gUnk_080B7826[iVar2]; super->x.HALF.HI += gUnk_080B7826[iVar2];
this->y.HALF.HI += gUnk_080B7826[iVar2 + 1]; super->y.HALF.HI += gUnk_080B7826[iVar2 + 1];
InitializeAnimation(this, 0); InitializeAnimation(super, 0);
gPlayerState.item = NULL; gPlayerState.item = NULL;
gPlayerState.attack_status |= 0x80; gPlayerState.attack_status |= 0x80;
} }
} }
void sub_0801B680(Entity* this) { void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this) {
u32 uvar1; u32 uVar1;
u32 uVar6; bool32 uVar6;
sub_0801B804(this); sub_0801B804(this);
if ((this->field_0x68.HALF.LO == 12) && (this->field_0x80.HALF.LO == 0) && ((gPlayerState.direction & 0x80) == 0)) { if ((this->unk_68 == 12) && (this->unk_80 == 0) && ((gPlayerState.direction & 0x80) == 0)) {
if (((this->field_0x82.HALF.HI - gPlayerState.direction) & 0x1f) > 0x10) { if (((this->unk_82.HALF.HI - gPlayerState.direction) & 0x1f) > 0x10) {
this->field_0x82.HWORD += 0x40; this->unk_82.HWORD += 0x40;
this->field_0x82.HALF.HI &= 0x1f; this->unk_82.HALF.HI &= 0x1f;
this->direction = this->field_0x82.HALF.HI; super->direction = this->unk_82.HALF.HI;
} else { } else {
this->field_0x82.HWORD -= 0x40; this->unk_82.HWORD -= 0x40;
this->field_0x82.HALF.HI &= 0x1f; this->unk_82.HALF.HI &= 0x1f;
this->direction = this->field_0x82.HALF.HI; super->direction = this->unk_82.HALF.HI;
} }
} }
LinearMoveUpdate(this); LinearMoveUpdate(super);
uVar6 = 0; uVar6 = FALSE;
if (sub_0801B864(this)) { if (sub_0801B864(super)) {
uvar1 = this->field_0x68.HALF.LO; uVar1 = this->unk_68;
uvar1 ^= 0xc; uVar1 ^= 0xc;
if (uvar1) { if (uVar1) {
uVar6 = TRUE; uVar6 = TRUE;
} else { } else {
uVar6 = FALSE; uVar6 = FALSE;
} }
} }
if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) {
if (uVar6 == 0) { if (!uVar6) {
uVar6 = sub_080040E2(this, &gUnk_08003E44); uVar6 = sub_080040E2(super, &gUnk_08003E44);
} }
} }
if (uVar6 == 0) { if (!uVar6) {
if (--this->timer < 0xc) { if (--super->timer < 0xc) {
this->speed = this->speed + -0x10; super->speed = super->speed + -0x10;
} }
if (this->timer == 0) { if (super->timer == 0) {
uVar6 = 1; uVar6 = TRUE;
} }
if (this->contactFlags & 0x80) { if (super->contactFlags & 0x80) {
uVar6 = 1; uVar6 = TRUE;
} }
if (uVar6 == 0) { if (!uVar6) {
return; return;
} }
if (this->field_0x68.HALF.LO == 12) { if (this->unk_68 == 12) {
this->timer = 30; super->timer = 30;
} else { } else {
this->timer = 12; super->timer = 12;
} }
} else { } else {
this->timer = 1; super->timer = 1;
} }
if (uVar6) { if (uVar6) {
this->action++; super->action++;
this->speed = 0x1c0; super->speed = 0x1c0;
} }
} }
void sub_0801B7A8(Entity* this) { void PlayerItemBoomerang_Action3(PlayerItemBoomerangEntity* this) {
sub_0801B804(this); sub_0801B804(this);
if (this->timer != 0) { if (super->timer != 0) {
this->timer--; super->timer--;
} else { } else {
sub_0801B864(this); sub_0801B864(super);
if (this->speed < 0x280) { if (super->speed < 0x280) {
this->speed += 8; super->speed += 8;
} }
this->direction = GetFacingDirection(this, &gPlayerEntity); super->direction = GetFacingDirection(super, &gPlayerEntity);
LinearMoveUpdate(this); LinearMoveUpdate(super);
if (sub_0800419C(this, &gPlayerEntity, 2, 2) != 0) { if (sub_0800419C(super, &gPlayerEntity, 2, 2) != 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
} }
} }
void sub_0801B804(Entity* this) { void sub_0801B804(PlayerItemBoomerangEntity* this) {
EquipSlot equipSlot; EquipSlot equipSlot;
u32 uVar1; u32 uVar1;
@ -225,7 +240,7 @@ void sub_0801B804(Entity* this) {
} }
if ((uVar1 & gPlayerState.playerInput.heldInput) == 0) { if ((uVar1 & gPlayerState.playerInput.heldInput) == 0) {
this->field_0x80.HALF.LO = 1; this->unk_80 = 1;
gPlayerState.field_0xa &= ~0x80; gPlayerState.field_0xa &= ~0x80;
gPlayerState.keepFacing &= ~0x80; gPlayerState.keepFacing &= ~0x80;
} else { } else {

View File

@ -1,53 +1,67 @@
/**
* @file playerItemBottle.c
* @ingroup Items
*
* @brief Bottle Player Item
*/
#define NENT_DEPRECATED
#include "entity.h" #include "entity.h"
#include "functions.h"
#include "item.h"
#include "object.h"
#include "save.h" #include "save.h"
#include "sound.h" #include "sound.h"
#include "functions.h"
#include "object.h" typedef struct {
#include "item.h" /*0x00*/ Entity base;
/*0x68*/ u8 bottleIndex; /**< @see Item */
/*0x69*/ u8 unused[6];
/*0x6f*/ u8 bottleContent; /**< @see Item */
} PlayerItemBottleEntity;
void PlayerItemBottle_UseEmptyBottle(Entity*); void PlayerItemBottle_UseEmptyBottle(Entity*);
void PlayerItemBottle_Action1(Entity*); void PlayerItemBottle_Action1(PlayerItemBottleEntity*);
void sub_0801BDE8(Entity*, Entity*); void sub_0801BDE8(Entity*, Entity*);
void PlayerItemBottle_UseEmptyBottle2(Entity*); void PlayerItemBottle_UseEmptyBottle2(Entity*);
void PlayerItemBottle_UsePotionOrPicolyte(Entity*); void PlayerItemBottle_UsePotionOrPicolyte(PlayerItemBottleEntity*);
void PlayerItemBottle_UseOther(Entity*); void PlayerItemBottle_UseOther(PlayerItemBottleEntity*);
void PlayerItemBottle_Init(Entity*); void PlayerItemBottle_Init(PlayerItemBottleEntity*);
extern u32 SetBottleContents(u32 itemID, u32 bottleIndex); extern u32 SetBottleContents(u32 itemID, u32 bottleIndex);
extern void sub_0801B9F0(Entity* this); extern void sub_0801B9F0(Entity* this);
void PlayerItemBottle(Entity* this) { void PlayerItemBottle(PlayerItemBottleEntity* this) {
static void (*const PlayerItemBottle_Actions[])(Entity*) = { static void (*const PlayerItemBottle_Actions[])(PlayerItemBottleEntity*) = {
PlayerItemBottle_Init, PlayerItemBottle_Init,
PlayerItemBottle_Action1, PlayerItemBottle_Action1,
}; };
PlayerItemBottle_Actions[this->action](this); PlayerItemBottle_Actions[super->action](this);
} }
void PlayerItemBottle_Init(Entity* this) { void PlayerItemBottle_Init(PlayerItemBottleEntity* this) {
u32 bottleType; u32 bottleContent;
if (this->field_0x68.HALF.LO == ITEM_QST_DOGFOOD) { if (this->bottleIndex == ITEM_QST_DOGFOOD) {
bottleType = ITEM_QST_DOGFOOD; bottleContent = ITEM_QST_DOGFOOD;
} else { } else {
u32 tmp = this->field_0x68.HALF.LO; u32 tmp = this->bottleIndex;
bottleType = gSave.saved_status.field_0x24[tmp - 6]; bottleContent = gSave.stats.bottles[tmp - ITEM_BOTTLE1];
} }
this->field_0x6e.HALF.HI = bottleType; this->bottleContent = bottleContent;
switch (bottleType) { switch (bottleContent) {
case ITEM_BOTTLE_EMPTY: case ITEM_BOTTLE_EMPTY:
if (AllocMutableHitbox(this) == NULL) { if (AllocMutableHitbox(super) == NULL) {
return; return;
} }
COLLISION_ON(this); COLLISION_ON(super);
this->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20; super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20;
this->flags2 = gPlayerEntity.flags2; super->flags2 = gPlayerEntity.flags2;
this->hurtType = 0x1f; super->hurtType = 0x1f;
this->type = 1; super->type = 1;
this->type2 = ITEM_BOTTLE_EMPTY; super->type2 = ITEM_BOTTLE_EMPTY;
this->timer = 82; super->timer = 82;
this->subtimer = 27; super->subtimer = 27;
sub_0801766C(this); sub_0801766C(super);
SoundReq(SFX_1DC); SoundReq(SFX_1DC);
break; break;
case ITEM_BOTTLE_BUTTER: case ITEM_BOTTLE_BUTTER:
@ -61,43 +75,43 @@ void PlayerItemBottle_Init(Entity* this) {
case ITEM_BOTTLE_PICOLYTE_GREEN: case ITEM_BOTTLE_PICOLYTE_GREEN:
case ITEM_BOTTLE_PICOLYTE_BLUE: case ITEM_BOTTLE_PICOLYTE_BLUE:
case ITEM_BOTTLE_PICOLYTE_WHITE: case ITEM_BOTTLE_PICOLYTE_WHITE:
this->timer = 213; super->timer = 213;
this->subtimer = 60; super->subtimer = 60;
break; break;
case BOTTLE_CHARM_NAYRU: case BOTTLE_CHARM_NAYRU:
case BOTTLE_CHARM_FARORE: case BOTTLE_CHARM_FARORE:
case BOTTLE_CHARM_DIN: case BOTTLE_CHARM_DIN:
default: default:
this->timer = 55; super->timer = 55;
this->subtimer = 0; super->subtimer = 0;
} }
this->action = 1; super->action = 1;
this->frameIndex = 0xff; super->frameIndex = 0xff;
gPlayerState.item = this; gPlayerState.item = super;
LoadSwapGFX(this, 1, 3); LoadSwapGFX(super, 1, 3);
PlayerItemBottle_Action1(this); PlayerItemBottle_Action1(this);
} }
void PlayerItemBottle_Action1(Entity* this) { void PlayerItemBottle_Action1(PlayerItemBottleEntity* this) {
int iVar1; u32 bottleIndex;
if (gPlayerState.item != this) { if (gPlayerState.item != super) {
if ((this->type == 1) && (this->type2 != ITEM_BOTTLE_EMPTY)) { if ((super->type == 1) && (super->type2 != ITEM_BOTTLE_EMPTY)) {
iVar1 = this->field_0x68.HALF.LO - 0x1c; bottleIndex = this->bottleIndex - ITEM_BOTTLE1;
SetBottleContents(this->type2, iVar1); SetBottleContents(super->type2, bottleIndex);
#if defined(EU) || defined(JP) || defined(DEMO_JP) #if defined(EU) || defined(JP) || defined(DEMO_JP)
CreateItemEntity(this->type2, iVar1, 5); CreateItemEntity(super->type2, bottleIndex, 5);
#else #else
InitItemGetSequence(this->type2, iVar1, 5); InitItemGetSequence(super->type2, bottleIndex, 5);
#endif #endif
SoundReq(SFX_ITEM_GET); SoundReq(SFX_ITEM_GET);
} }
DeleteThisEntity(); DeleteThisEntity();
} }
sub_0801BDE8(this, &gPlayerEntity); sub_0801BDE8(super, &gPlayerEntity);
switch (this->field_0x6e.HALF.HI) { switch (this->bottleContent) {
case ITEM_BOTTLE_EMPTY: case ITEM_BOTTLE_EMPTY:
PlayerItemBottle_UseEmptyBottle2(this); PlayerItemBottle_UseEmptyBottle2(super);
break; break;
case ITEM_BOTTLE_BUTTER: case ITEM_BOTTLE_BUTTER:
case ITEM_BOTTLE_MILK: case ITEM_BOTTLE_MILK:
@ -127,15 +141,15 @@ void PlayerItemBottle_UseEmptyBottle2(Entity* this) {
PlayerItemBottle_UseEmptyBottle(this); PlayerItemBottle_UseEmptyBottle(this);
} }
void PlayerItemBottle_UsePotionOrPicolyte(Entity* this) { void PlayerItemBottle_UsePotionOrPicolyte(PlayerItemBottleEntity* this) {
u32 health; u32 health;
u32 bottleType; u32 bottleContent;
bottleType = ITEM_BOTTLE_EMPTY; bottleContent = ITEM_BOTTLE_EMPTY;
health = 0; health = 0;
switch (this->field_0x6e.HALF.HI) { switch (this->bottleContent) {
case ITEM_BOTTLE_MILK: case ITEM_BOTTLE_MILK:
bottleType = ITEM_BOTTLE_HALF_MILK; bottleContent = ITEM_BOTTLE_HALF_MILK;
case ITEM_BOTTLE_HALF_MILK: case ITEM_BOTTLE_HALF_MILK:
health = 40; health = 40;
break; break;
@ -152,69 +166,69 @@ void PlayerItemBottle_UsePotionOrPicolyte(Entity* this) {
case ITEM_BOTTLE_PICOLYTE_GREEN: case ITEM_BOTTLE_PICOLYTE_GREEN:
case ITEM_BOTTLE_PICOLYTE_BLUE: case ITEM_BOTTLE_PICOLYTE_BLUE:
case ITEM_BOTTLE_PICOLYTE_WHITE: case ITEM_BOTTLE_PICOLYTE_WHITE:
gSave.stats.picolyteType = this->field_0x6e.HALF.HI; gSave.stats.picolyteType = this->bottleContent;
gSave.stats.picolyteTimer = 900; gSave.stats.picolyteTimer = 900;
SoundReq(SFX_PICOLYTE); SoundReq(SFX_PICOLYTE);
break; break;
} }
ModHealth(health); ModHealth(health);
SetBottleContents(bottleType, this->field_0x68.HALF.LO - 0x1c); SetBottleContents(bottleContent, this->bottleIndex - 0x1c);
} }
void PlayerItemBottle_UseOther(Entity* this) { void PlayerItemBottle_UseOther(PlayerItemBottleEntity* this) {
if (gPlayerEntity.frame == 1) { if (gPlayerEntity.frame == 1) {
if (this->field_0x6e.HALF.HI != 0x36) { if (this->bottleContent != ITEM_QST_DOGFOOD) {
SetBottleContents(ITEM_BOTTLE_EMPTY, this->field_0x68.HALF.LO - 0x1c); SetBottleContents(ITEM_BOTTLE_EMPTY, this->bottleIndex - 0x1c);
} }
switch (this->field_0x6e.HALF.HI) { switch (this->bottleContent) {
case ITEM_BOTTLE_WATER: case ITEM_BOTTLE_WATER:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 0, 0); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 0, 0);
break; break;
case ITEM_BOTTLE_MINERAL_WATER: case ITEM_BOTTLE_MINERAL_WATER:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 1, 1); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 1, 1);
break; break;
case ITEM_BOTTLE_FAIRY: case ITEM_BOTTLE_FAIRY:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 2, 2); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 2, 2);
ModHealth(0x20); ModHealth(0x20);
break; break;
case BOTTLE_CHARM_NAYRU: case BOTTLE_CHARM_NAYRU:
case BOTTLE_CHARM_FARORE: case BOTTLE_CHARM_FARORE:
case BOTTLE_CHARM_DIN: case BOTTLE_CHARM_DIN:
gSave.stats.charm = this->field_0x6e.HALF.HI; gSave.stats.charm = this->bottleContent;
gSave.stats.charmTimer = 3600; gSave.stats.charmTimer = 3600;
SoundReq(SFX_ELEMENT_CHARGE); SoundReq(SFX_ELEMENT_CHARGE);
} }
} }
if (gPlayerEntity.frame == 2) { if (gPlayerEntity.frame == 2) {
switch (this->field_0x6e.HALF.HI) { switch (this->bottleContent) {
case ITEM_BOTTLE_WATER: case ITEM_BOTTLE_WATER:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 0, 0); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 0, 0);
break; break;
case ITEM_BOTTLE_MINERAL_WATER: case ITEM_BOTTLE_MINERAL_WATER:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 1, 1); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 1, 1);
break; break;
} }
} }
if (gPlayerEntity.frame == 3) { if (gPlayerEntity.frame == 3) {
switch (this->field_0x6e.HALF.HI) { switch (this->bottleContent) {
case ITEM_BOTTLE_WATER: case ITEM_BOTTLE_WATER:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 0, 0); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 0, 0);
break; break;
case ITEM_BOTTLE_MINERAL_WATER: case ITEM_BOTTLE_MINERAL_WATER:
CreateObjectWithParent(this, LINK_EMPTYING_BOTTLE, 1, 0); CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 1, 0);
break; break;
} }
} }
} }
void sub_0801BDE8(Entity* this, Entity* ent2) { void sub_0801BDE8(Entity* this, Entity* ent2) {
u32 uVar1; u32 frameIndex;
u32 flipX; u32 flipX;
u32 animationState; u32 animationState;
uVar1 = (ent2->frameIndex - this->timer) + this->subtimer; frameIndex = (ent2->frameIndex - this->timer) + this->subtimer;
if (uVar1 != this->frameIndex) { if (frameIndex != this->frameIndex) {
this->frameIndex = uVar1; this->frameIndex = frameIndex;
sub_080042D0(this, this->frameIndex, (u16)this->spriteIndex); sub_080042D0(this, this->frameIndex, (u16)this->spriteIndex);
} }
flipX = ent2->spriteSettings.flipX; flipX = ent2->spriteSettings.flipX;
@ -235,8 +249,8 @@ void PlayerItemBottle_UseEmptyBottle(Entity* this) {
16, -12, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, -12, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
int iVar2; s32 iVar2;
Hitbox* pHVar5; Hitbox* hitbox;
const u8* ptr; const u8* ptr;
const s8* ptr2; const s8* ptr2;
@ -256,11 +270,11 @@ void PlayerItemBottle_UseEmptyBottle(Entity* this) {
ptr = &bottleHitboxParameters[(this->frameIndex - 0x1b) * 4]; ptr = &bottleHitboxParameters[(this->frameIndex - 0x1b) * 4];
if (this->spriteSettings.flipX != 0) { if (this->spriteSettings.flipX != 0) {
pHVar5 = this->hitbox; hitbox = this->hitbox;
pHVar5->offset_x = -ptr[0]; hitbox->offset_x = -ptr[0];
} else { } else {
pHVar5 = this->hitbox; hitbox = this->hitbox;
pHVar5->offset_x = ptr[0]; hitbox->offset_x = ptr[0];
} }
this->hitbox->offset_y = ptr[1]; this->hitbox->offset_y = ptr[1];
this->hitbox->width = ptr[2]; this->hitbox->width = ptr[2];

View File

@ -1,22 +1,27 @@
/**
* @file playerItemBow.c
* @ingroup Items
*
* @brief Bow Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "global.h"
#include "asm.h" #include "asm.h"
#include "effects.h"
#include "entity.h" #include "entity.h"
#include "functions.h" #include "functions.h"
#include "effects.h"
#include "object.h" #include "object.h"
#include "playeritem.h" #include "playeritem.h"
#include "sound.h"
#include "save.h" #include "save.h"
#include "sound.h"
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u8 unk_68; /*0x68*/ u8 unk_68;
u8 unk_69[3]; /*0x69*/ u8 unk_69[3];
u32 unk_6c; /*0x6c*/ u32 unk_6c;
u32 unk_70; /*0x70*/ u32 unk_70;
u32 unk_74; /*0x74*/ u32 unk_74;
u32 unk_78; /*0x78*/ u32 unk_78;
} PlayerItemBowEntity; } PlayerItemBowEntity;
typedef struct { typedef struct {
@ -37,20 +42,20 @@ extern Entity* sub_08008782(Entity*, u32, s32, s32);
extern void sub_08017744(Entity*); extern void sub_08017744(Entity*);
extern void ModArrows(s32); extern void ModArrows(s32);
void sub_08019468(PlayerItemBowEntity*); void sub_08019468(PlayerItemBowEntity* this);
void sub_08018FE4(PlayerItemBowEntity*); void PlayerItemBow_Init(PlayerItemBowEntity* this);
void sub_0801917C(PlayerItemBowEntity*); void PlayerItemBow_Action1(PlayerItemBowEntity* this);
void sub_08019410(PlayerItemBowEntity*); void PlayerItemBow_Action2(PlayerItemBowEntity* this);
void sub_08019444(PlayerItemBowEntity*); void PlayerItemBow_Action3(PlayerItemBowEntity* this);
void PlayerItemBow(Entity* this) { void PlayerItemBow(Entity* this) {
static void (*const gUnk_080B3E30[])(PlayerItemBowEntity*) = { static void (*const PlayerItemBow_Actions[])(PlayerItemBowEntity*) = {
sub_08018FE4, PlayerItemBow_Init,
sub_0801917C, PlayerItemBow_Action1,
sub_08019410, PlayerItemBow_Action2,
sub_08019444, PlayerItemBow_Action3,
}; };
gUnk_080B3E30[this->action]((PlayerItemBowEntity*)this); PlayerItemBow_Actions[this->action]((PlayerItemBowEntity*)this);
} }
static const Hitbox gUnk_080B3E70; static const Hitbox gUnk_080B3E70;
@ -66,14 +71,14 @@ static const struct_080B3E40 gUnk_080B3E40[] = {
static const Hitbox gUnk_080B3E70 = { 0, 0, { 4, 0, 0, 0 }, 6, 4 }; static const Hitbox gUnk_080B3E70 = { 0, 0, { 4, 0, 0, 0 }, 6, 4 };
static const Hitbox gUnk_080B3E78 = { 0, 0, { 0, 0, 0, 4 }, 4, 6 }; static const Hitbox gUnk_080B3E78 = { 0, 0, { 0, 0, 0, 4 }, 4, 6 };
void sub_08018FE4(PlayerItemBowEntity* this) { void PlayerItemBow_Init(PlayerItemBowEntity* this) {
Entity* object; Entity* object;
const struct_080B3E40* ptr; const struct_080B3E40* ptr;
super->action = 1; super->action = 1;
if (super->type != 0) { if (super->type != 0) {
super->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
super->flags |= 0x80; super->flags |= 0x80;
this->unk_74 = 0x6a; this->unk_74 = 106;
super->hurtType = super->type2; super->hurtType = super->type2;
super->spriteIndex = 0xa6; super->spriteIndex = 0xa6;
if (super->hurtType == 0x0e) { if (super->hurtType == 0x0e) {
@ -114,7 +119,7 @@ void sub_08018FE4(PlayerItemBowEntity* this) {
LoadSwapGFX(super, 1, 3); LoadSwapGFX(super, 1, 3);
sub_08079BD8(super); sub_08079BD8(super);
if (this->unk_68 == 0xa) { if (this->unk_68 == 0xa) {
this->unk_78 = 0x3c; this->unk_78 = 60;
object = CreateObject(SWORD_PARTICLE, super->type, 1); object = CreateObject(SWORD_PARTICLE, super->type, 1);
if (object != NULL) { if (object != NULL) {
CopyPosition(super, object); CopyPosition(super, object);
@ -122,11 +127,11 @@ void sub_08018FE4(PlayerItemBowEntity* this) {
} else { } else {
this->unk_78 = 0; this->unk_78 = 0;
} }
sub_0801917C(this); PlayerItemBow_Action1(this);
} }
} }
void sub_0801917C(PlayerItemBowEntity* this) { void PlayerItemBow_Action1(PlayerItemBowEntity* this) {
u8 arrowCount; u8 arrowCount;
bool32 tmp2; bool32 tmp2;
s32 tmp3; s32 tmp3;
@ -138,7 +143,7 @@ void sub_0801917C(PlayerItemBowEntity* this) {
DeleteThisEntity(); DeleteThisEntity();
} }
GetNextFrame(super); GetNextFrame(super);
if (this->unk_74 < 0x18) { if (this->unk_74 < 24) {
super->spriteSettings.draw ^= 1; super->spriteSettings.draw ^= 1;
} }
LinearMoveUpdate(super); LinearMoveUpdate(super);
@ -238,7 +243,7 @@ void sub_0801917C(PlayerItemBowEntity* this) {
} }
} }
void sub_08019410(PlayerItemBowEntity* this) { void PlayerItemBow_Action2(PlayerItemBowEntity* this) {
if (super->timer < 0xf) { if (super->timer < 0xf) {
InitializeAnimation(super, super->animIndex); InitializeAnimation(super, super->animIndex);
} else { } else {
@ -249,7 +254,7 @@ void sub_08019410(PlayerItemBowEntity* this) {
} }
} }
void sub_08019444(PlayerItemBowEntity* this) { void PlayerItemBow_Action3(PlayerItemBowEntity* this) {
GetNextFrame(super); GetNextFrame(super);
LinearMoveUpdate(super); LinearMoveUpdate(super);
if (GravityUpdate(super, Q_8_8(32.0)) == 0) { if (GravityUpdate(super, Q_8_8(32.0)) == 0) {
@ -258,7 +263,7 @@ void sub_08019444(PlayerItemBowEntity* this) {
} }
void sub_08019468(PlayerItemBowEntity* this) { void sub_08019468(PlayerItemBowEntity* this) {
if (super->hurtType == 0x0e) { if (super->hurtType == 0xe) {
CreateFx(super, FX_REFLECT5, 0); CreateFx(super, FX_REFLECT5, 0);
} }
} }

View File

@ -1,77 +1,84 @@
/**
* @file playerItemCellOverwriteSet.c
* @ingroup Items
*
* @brief Cell Overwrite Set Player Item
*/
#define NENT_DEPRECATED
#include "asm.h"
#include "common.h"
#include "entity.h" #include "entity.h"
#include "player.h" #include "player.h"
#include "room.h" #include "room.h"
#include "common.h"
#include "asm.h" typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused[4];
/*0x6c*/ u16 tileType;
} PlayerItemCellOverwriteSetEntity;
extern const u8 gUnk_080B7910[]; extern const u8 gUnk_080B7910[];
extern const u8 gUnk_080B79A7[]; extern const u8 gUnk_080B79A7[];
extern const u8 gUnk_080B7A3E[]; // TODO figure out type from arm_sub_080B1B84 and arm_sub_080B1BA4 extern const u8 gUnk_080B7A3E[]; // TODO figure out type from arm_sub_080B1B84 and arm_sub_080B1BA4
void PlayerItemCellOverwriteSet(Entity* this) { void PlayerItemCellOverwriteSet(PlayerItemCellOverwriteSetEntity* this) {
static const s8 gUnk_080B7B6C[] = { 0x0, -0x10, 0x10, 0x0, 0x0, 0x10, -0x10, 0x0 }; static const s8 gUnk_080B7B6C[] = { 0x0, -0x10, 0x10, 0x0, 0x0, 0x10, -0x10, 0x0 };
u32 tmp; u32 tmp;
Entity* player = &gPlayerEntity; Entity* player = &gPlayerEntity;
if (this->action == 0) { if (super->action == 0) {
this->field_0x6c.HWORD = this->tileType = GetTileType(TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe],
GetTileType(TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe], player->y.HALF.HI + gUnk_080B7B6C[(player->animationState & 0xe) + 1]),
player->y.HALF.HI + gUnk_080B7B6C[(player->animationState & 0xe) + 1]), super->collisionLayer);
this->collisionLayer); super->action++;
this->action++;
} }
gPlayerState.mobility |= 0x80; gPlayerState.mobility |= 0x80;
tmp = gInput.heldKeys & R_BUTTON; tmp = gInput.heldKeys & R_BUTTON;
if ((gInput.heldKeys & A_BUTTON) != 0) { if ((gInput.heldKeys & A_BUTTON) != 0) {
if ((R_BUTTON & gInput.newKeys) != 0) { if ((R_BUTTON & gInput.newKeys) != 0) {
this->field_0x6c.HWORD = this->tileType = GetTileType(TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe],
GetTileType(TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe], player->y.HALF.HI + gUnk_080B7B6C[(player->animationState & 0xe) + 1]),
player->y.HALF.HI + gUnk_080B7B6C[(player->animationState & 0xe) + 1]), super->collisionLayer);
this->collisionLayer);
} }
if ((gInput.heldKeys & R_BUTTON) != 0) { if ((gInput.heldKeys & R_BUTTON) != 0) {
player->iframes = 2; player->iframes = 2;
} else { } else {
if ((gInput.newKeys & DPAD_RIGHT) != 0) { if ((gInput.newKeys & DPAD_RIGHT) != 0) {
this->field_0x6c.HWORD--; this->tileType--;
} }
if ((gInput.newKeys & DPAD_LEFT) != 0) { if ((gInput.newKeys & DPAD_LEFT) != 0) {
this->field_0x6c.HWORD++; this->tileType++;
} }
if ((gInput.heldKeys & (DPAD_LEFT | DPAD_RIGHT)) != 0) { if ((gInput.heldKeys & (DPAD_LEFT | DPAD_RIGHT)) != 0) {
if (++this->subtimer > 0x1e) { if (++super->subtimer > 0x1e) {
this->subtimer = 30; super->subtimer = 30;
if ((gInput.heldKeys & DPAD_RIGHT) != 0) { if ((gInput.heldKeys & DPAD_RIGHT) != 0) {
this->field_0x6c.HWORD--; this->tileType--;
} }
if ((gInput.heldKeys & DPAD_LEFT) != 0) { if ((gInput.heldKeys & DPAD_LEFT) != 0) {
this->field_0x6c.HWORD++; this->tileType++;
} }
} }
} else { } else {
this->subtimer = 0; super->subtimer = 0;
} }
} }
} else { } else {
sub_0807B7D8(this->field_0x6c.HWORD, sub_0807B7D8(this->tileType,
TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe], TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe],
player->y.HALF.HI + gUnk_080B7B6C[(player->animationState & 0xe) + 1]), player->y.HALF.HI + gUnk_080B7B6C[(player->animationState & 0xe) + 1]),
this->collisionLayer); super->collisionLayer);
gPlayerState.mobility &= ~0x80; gPlayerState.mobility &= ~0x80;
DeleteThisEntity(); DeleteThisEntity();
} }
if ((gInput.heldKeys & B_BUTTON) != 0) { if ((gInput.heldKeys & B_BUTTON) != 0) {
sub_0807B7D8(this->field_0x6c.HWORD, sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + gUnk_080B7B6C[0], player->y.HALF.HI + gUnk_080B7B6C[1]),
TILE(player->x.HALF.HI + gUnk_080B7B6C[0], player->y.HALF.HI + gUnk_080B7B6C[1]), super->collisionLayer);
this->collisionLayer); sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + gUnk_080B7B6C[2], player->y.HALF.HI + gUnk_080B7B6C[3]),
sub_0807B7D8(this->field_0x6c.HWORD, super->collisionLayer);
TILE(player->x.HALF.HI + gUnk_080B7B6C[2], player->y.HALF.HI + gUnk_080B7B6C[3]), sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + gUnk_080B7B6C[4], player->y.HALF.HI + gUnk_080B7B6C[5]),
this->collisionLayer); super->collisionLayer);
sub_0807B7D8(this->field_0x6c.HWORD, sub_0807B7D8(this->tileType, TILE(player->x.HALF.HI + gUnk_080B7B6C[6], player->y.HALF.HI + gUnk_080B7B6C[7]),
TILE(player->x.HALF.HI + gUnk_080B7B6C[4], player->y.HALF.HI + gUnk_080B7B6C[5]), super->collisionLayer);
this->collisionLayer);
sub_0807B7D8(this->field_0x6c.HWORD,
TILE(player->x.HALF.HI + gUnk_080B7B6C[6], player->y.HALF.HI + gUnk_080B7B6C[7]),
this->collisionLayer);
} }
} }

View File

@ -1,52 +1,56 @@
/**
* @file playerItemDashSword.c
* @ingroup Items
*
* @brief Dash Sword Player Item
*/
#define NENT_DEPRECATED
#include "entity.h" #include "entity.h"
#include "player.h"
#include "functions.h" #include "functions.h"
#include "player.h"
extern Entity* sub_08008782(Entity*, u32, s32, s32); extern Entity* sub_08008782(Entity*, u32, s32, s32);
void sub_0801B8FC(Entity*); void PlayerItemDashSword_Action1(Entity* this);
void sub_0801B8B0(Entity*); void PlayerItemDashSword_Init(Entity* this);
void sub_0801B938(Entity*); void sub_0801B938(Entity* this);
extern void sub_08017744(Entity*); extern void sub_08017744(Entity*);
void PlayerItemDashSword(Entity* this) { void PlayerItemDashSword(Entity* this) {
static void (*const PlayerItemC_Actions[])(Entity*) = { static void (*const PlayerItemDashSword_Actions[])(Entity*) = {
sub_0801B8B0, PlayerItemDashSword_Init,
sub_0801B8FC, PlayerItemDashSword_Action1,
}; };
PlayerItemC_Actions[this->action](this); PlayerItemDashSword_Actions[this->action](this);
} }
void sub_0801B8B0(Entity* this) { void PlayerItemDashSword_Init(Entity* this) {
if (gPlayerState.dash_state != 0) { if (gPlayerState.dash_state != 0) {
gPlayerState.item = this; gPlayerState.item = this;
this->flags |= ENT_PERSIST; this->flags |= ENT_PERSIST;
this->action = 0x01; this->action = 1;
this->flags2 = 8; this->flags2 = 8;
LoadSwapGFX(this, 1, 3); LoadSwapGFX(this, 1, 3);
sub_08079BD8(this); sub_08079BD8(this);
sub_0801766C(this); sub_0801766C(this);
sub_0801B8FC(this); PlayerItemDashSword_Action1(this);
} else { } else {
DeleteThisEntity(); DeleteThisEntity();
} }
} }
void sub_0801B8FC(Entity* this) { void PlayerItemDashSword_Action1(Entity* this) {
Entity* pbVar1; if (gPlayerState.item != this) {
pbVar1 = (Entity*)gPlayerState.item;
if ((Entity*)gPlayerState.item != this) {
DeleteThisEntity(); DeleteThisEntity();
} else { } else {
if (gPlayerState.dash_state == 0) { if (gPlayerState.dash_state == 0) {
gPlayerState.item = NULL; gPlayerState.item = NULL;
DeleteThisEntity(); DeleteThisEntity();
} else { } else {
pbVar1->flags |= ENT_COLLIDE; this->flags |= ENT_COLLIDE;
pbVar1->collisionFlags = 0x21; this->collisionFlags = 0x21;
sub_0801B938(pbVar1); sub_0801B938(this);
} }
} }
} }

View File

@ -1,46 +1,52 @@
/**
* @file playerItemFireRodProjectile.c
* @ingroup Items
*
* @brief Fire Rod Projectile Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "asm.h" #include "asm.h"
#include "entity.h"
#include "sound.h"
#include "physics.h"
#include "functions.h"
#include "effects.h" #include "effects.h"
#include "entity.h"
#include "functions.h"
#include "physics.h"
#include "playeritem.h" #include "playeritem.h"
#include "sound.h"
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u8 unk68; /*0x68*/ u8 unk_68;
u16 unk6a; /*0x6a*/ u8 unused[2];
u32 unk6c; /*0x6c*/ u32 unk_6c;
} FireRodProjectileEntity; } PlayerItemFireRodProjectileEntity;
extern u8 gUnk_08003E44; extern u8 gUnk_08003E44;
void sub_080A3084(FireRodProjectileEntity*); void PlayerItemFireRodProjectile_Init(PlayerItemFireRodProjectileEntity* this);
void sub_080A310C(FireRodProjectileEntity*); void PlayerItemFireRodProjectile_Action1(PlayerItemFireRodProjectileEntity* this);
void PlayerItemFireRodProjectile(Entity* this) { void PlayerItemFireRodProjectile(Entity* this) {
static void (*const actionFuncs[])(FireRodProjectileEntity*) = { static void (*const PlayerItemFireRodProjectile_Actions[])(PlayerItemFireRodProjectileEntity*) = {
sub_080A3084, PlayerItemFireRodProjectile_Init,
sub_080A310C, PlayerItemFireRodProjectile_Action1,
}; };
actionFuncs[this->action]((FireRodProjectileEntity*)this); PlayerItemFireRodProjectile_Actions[this->action]((PlayerItemFireRodProjectileEntity*)this);
} }
void sub_080A3084(FireRodProjectileEntity* this) { void PlayerItemFireRodProjectile_Init(PlayerItemFireRodProjectileEntity* this) {
static const Hitbox gUnk_08127278 = { 0, 0, { 4, 2, 2, 4 }, 6, 6 }; static const Hitbox gUnk_08127278 = { 0, 0, { 4, 2, 2, 4 }, 6, 6 };
super->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
super->action = 0x01; super->action = 1;
CopyPosition(super->parent, super); CopyPosition(super->parent, super);
if (super->type == 0) { if (super->type == 0) {
super->collisionFlags = gPlayerEntity.collisionFlags + 1; super->collisionFlags = gPlayerEntity.collisionFlags + 1;
super->hitbox = (Hitbox*)&gUnk_08127278; super->hitbox = (Hitbox*)&gUnk_08127278;
super->speed = 0x400; super->speed = 0x400;
if (super->collisionLayer == 0x02) { if (super->collisionLayer == 2) {
super->type2 = 0x01; super->type2 = 1;
} }
super->direction = Direction8FromAnimationState(super->animationState); super->direction = Direction8FromAnimationState(super->animationState);
this->unk6c = 60; this->unk_6c = 60;
sub_0801766C(super); sub_0801766C(super);
LinearMoveUpdate(super); LinearMoveUpdate(super);
SoundReq(SFX_ITEM_SWORD_BEAM); SoundReq(SFX_ITEM_SWORD_BEAM);
@ -48,17 +54,17 @@ void sub_080A3084(FireRodProjectileEntity* this) {
super->timer = 6; super->timer = 6;
} }
InitializeAnimation(super, 0x18); InitializeAnimation(super, 0x18);
sub_080A310C(this); PlayerItemFireRodProjectile_Action1(this);
} }
void sub_080A310C(FireRodProjectileEntity* this) { void PlayerItemFireRodProjectile_Action1(PlayerItemFireRodProjectileEntity* this) {
if (super->type != 0) { if (super->type != 0) {
if (super->timer-- == 0) { if (super->timer-- == 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
} else { } else {
GetNextFrame(super); GetNextFrame(super);
if (this->unk6c-- != 0) { if (this->unk_6c-- != 0) {
GetNextFrame(super); GetNextFrame(super);
LinearMoveUpdate(super); LinearMoveUpdate(super);
super->timer++; super->timer++;
@ -77,7 +83,7 @@ void sub_080A310C(FireRodProjectileEntity* this) {
if (sub_08008790(super, 0xc)) { if (sub_08008790(super, 0xc)) {
DeleteThisEntity(); DeleteThisEntity();
} }
super->child = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 1, 0, this->unk68); super->child = CreatePlayerItem(PLAYER_ITEM_FIRE_ROD_PROJECTILE, 1, 0, this->unk_68);
if (super->child != NULL) { if (super->child != NULL) {
super->child->parent = super; super->child->parent = super;
} }

View File

@ -1,9 +1,15 @@
/**
* @file playerItemGust.c
* @ingroup Items
*
* @brief Gust Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "asm.h" #include "asm.h"
#include "entity.h"
#include "functions.h"
#include "object.h" #include "object.h"
#include "player.h"
#include "playeritem.h" #include "playeritem.h"
enum { enum {
@ -12,20 +18,21 @@ enum {
}; };
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u32 filler68[2]; /*0x68*/ u32 filler68[2];
u32 timer; /*0x70*/ u32 timer;
u32 offset_iter; /*0x74*/ u32 offset_iter;
u32 unk78; /*0x78*/ u32 unk78;
} GustEntity; } PlayerItemGustEntity;
typedef void(GustActionFunc)(GustEntity*);
typedef void(GustActionFunc)(PlayerItemGustEntity*);
static GustActionFunc PlayerItemGust_Init; static GustActionFunc PlayerItemGust_Init;
static GustActionFunc PlayerItemGust_Update; static GustActionFunc PlayerItemGust_Update;
static void sub_080ACC78(GustEntity*); static void sub_080ACC78(PlayerItemGustEntity*);
/*static*/ bool32 sub_080ACDB0(GustEntity*); /*static*/ bool32 sub_080ACDB0(PlayerItemGustEntity*);
static void sub_080ACECC(GustEntity*); static void sub_080ACECC(PlayerItemGustEntity*);
typedef struct { typedef struct {
u16 bits; u16 bits;
@ -50,7 +57,7 @@ extern const s8 gUnk_08126EE4[];
// type 2: same as 1? // type 2: same as 1?
// type 3: horizontal spread // type 3: horizontal spread
void PlayerItemGust(Entity* this) { void PlayerItemGust(Entity* this) {
static GustActionFunc* const sActions[] = { static GustActionFunc* const PlayerItemGust_Actions[] = {
PlayerItemGust_Init, PlayerItemGust_Init,
PlayerItemGust_Update, PlayerItemGust_Update,
}; };
@ -58,11 +65,11 @@ void PlayerItemGust(Entity* this) {
if ((gPlayerState.field_0x1c & 0x7f) != 1) { if ((gPlayerState.field_0x1c & 0x7f) != 1) {
DeleteThisEntity(); DeleteThisEntity();
} }
sActions[this->action]((GustEntity*)this); PlayerItemGust_Actions[this->action]((PlayerItemGustEntity*)this);
this->iframes = 0; this->iframes = 0;
} }
static void PlayerItemGust_Init(GustEntity* this) { static void PlayerItemGust_Init(PlayerItemGustEntity* this) {
super->action = GUST_UPDATE; super->action = GUST_UPDATE;
super->flags2 = gPlayerEntity.flags2; super->flags2 = gPlayerEntity.flags2;
super->direction = super->animationState << 2; super->direction = super->animationState << 2;
@ -75,14 +82,14 @@ static void PlayerItemGust_Init(GustEntity* this) {
sub_0801766C(super); sub_0801766C(super);
} }
static void PlayerItemGust_Update(GustEntity* this) { static void PlayerItemGust_Update(PlayerItemGustEntity* this) {
if (sub_080ACDB0(this) == FALSE) { if (sub_080ACDB0(this) == FALSE) {
sub_080ACC78(this); sub_080ACC78(this);
sub_080ACECC(this); sub_080ACECC(this);
} }
} }
static void sub_080ACC78(GustEntity* this) { static void sub_080ACC78(PlayerItemGustEntity* this) {
s32 width; s32 width;
Obj11* o; Obj11* o;
Entity* child; Entity* child;
@ -151,7 +158,7 @@ static void sub_080ACC78(GustEntity* this) {
} }
} }
bool32 sub_080ACDB0(GustEntity* this) { bool32 sub_080ACDB0(PlayerItemGustEntity* this) {
s32 sVar2; s32 sVar2;
s32 sVar3; s32 sVar3;
Entity* pEVar4; Entity* pEVar4;
@ -217,7 +224,7 @@ bool32 sub_080ACDB0(GustEntity* this) {
return 0; return 0;
} }
static void sub_080ACECC(GustEntity* this) { static void sub_080ACECC(PlayerItemGustEntity* this) {
Entity* entity; Entity* entity;
if (super->type < 3 && super->child == NULL && (s32)this->unk78 >= 0 && gUnk_0812AAE8[super->type] <= this->unk78) { if (super->type < 3 && super->child == NULL && (s32)this->unk78 >= 0 && gUnk_0812AAE8[super->type] <= this->unk78) {

View File

@ -1,31 +1,46 @@
#include "global.h" /**
#include "entity.h" * @file playerItemGustBig.c
#include "player.h" * @ingroup Items
#include "functions.h" *
#include "sound.h" * @brief Gust Big Player Item
*/
#define NENT_DEPRECATED
#include "asm.h" #include "asm.h"
#include "entity.h"
#include "functions.h"
#include "global.h"
#include "new_player.h"
#include "player.h"
#include "sound.h"
extern void sub_08078CD0(Entity*); typedef struct {
extern void sub_08018FA0(Entity*); /*0x00*/ Entity base;
extern void sub_08018CBC(Entity*); /*0x68*/ u8 unused[24];
extern void sub_08018DE8(Entity*); /*0x80*/ u32 unk_80;
extern void sub_08018E68(Entity*); /*0x84*/ u32 unk_84;
extern void sub_08018F6C(Entity*); } PlayerItemGustBigEntity;
extern void sub_08078CD0(Entity* this);
extern void sub_08018FA0(Entity* this);
extern void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this);
extern void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this);
extern void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this);
extern void PlayerItemGustBig_Action3(PlayerItemGustBigEntity* this);
extern u32 sub_08007DD6(u32, const u16*); extern u32 sub_08007DD6(u32, const u16*);
extern const u8 gUnk_08003E44[]; extern const u8 gUnk_08003E44[];
void PlayerItemGustBig(Entity* this) { void PlayerItemGustBig(PlayerItemGustBigEntity* this) {
static void (*const gUnk_080B3DD0[])(Entity*) = { static void (*const PlayerItemGustBig_Actions[])(PlayerItemGustBigEntity*) = {
sub_08018CBC, PlayerItemGustBig_Init,
sub_08018DE8, PlayerItemGustBig_Action1,
sub_08018E68, PlayerItemGustBig_Action2,
sub_08018F6C, PlayerItemGustBig_Action3,
}; };
if (this->health) { if (super->health) {
this->iframes = 0; super->iframes = 0;
gUnk_080B3DD0[this->action](this); PlayerItemGustBig_Actions[super->action](this);
} else { } else {
DeleteThisEntity(); DeleteThisEntity();
} }
@ -48,95 +63,95 @@ static const Hitbox gUnk_080B3E18 = { 0, 0, { 6, 3, 3, 6 }, 6, 6 };
static const Hitbox gUnk_080B3E20 = { 0, 0, { 6, 3, 3, 6 }, 8, 8 }; static const Hitbox gUnk_080B3E20 = { 0, 0, { 6, 3, 3, 6 }, 8, 8 };
static const Hitbox gUnk_080B3E28 = { 0, 0, { 6, 3, 3, 6 }, 12, 12 }; static const Hitbox gUnk_080B3E28 = { 0, 0, { 6, 3, 3, 6 }, 12, 12 };
void sub_08018CBC(Entity* this) { void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) {
u32 PVar1; u32 PVar1;
u8 uVar2; u8 uVar2;
Entity* pEVar3; Entity* pEVar3;
*(u32*)&this->cutsceneBeh = this->x.WORD = gPlayerEntity.x.WORD; this->unk_84 = super->x.WORD = gPlayerEntity.x.WORD;
*(u32*)&this->field_0x80 = this->y.WORD = gPlayerEntity.y.WORD; this->unk_80 = super->y.WORD = gPlayerEntity.y.WORD;
uVar2 = this->animationState = gPlayerEntity.animationState & 0xe; uVar2 = super->animationState = gPlayerEntity.animationState & 0xe;
this->direction = (u8)(uVar2 << 2); super->direction = (u8)(uVar2 << 2);
this->speed = 0x400; super->speed = 0x400;
this->hitType = 0x96; super->hitType = 0x96;
this->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x80; super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x80;
this->flags2 = gPlayerEntity.flags2; super->flags2 = gPlayerEntity.flags2;
pEVar3 = this->child; pEVar3 = super->child;
if (pEVar3 != NULL) { if (pEVar3 != NULL) {
this->action = 1; super->action = 1;
COLLISION_OFF(this); COLLISION_OFF(super);
this->timer = 86; super->timer = 86;
this->hurtType = 0x1c; super->hurtType = 0x1c;
this->damage = 6; super->damage = 6;
this->hitbox = (Hitbox*)&gUnk_080B3E18; super->hitbox = (Hitbox*)&gUnk_080B3E18;
this->child->spriteOffsetX = 0; super->child->spriteOffsetX = 0;
this->child->spriteSettings.draw = 0; super->child->spriteSettings.draw = 0;
} else { } else {
if (gPlayerState.field_0x1c == 0) { if (gPlayerState.field_0x1c == 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
this->action = 2; super->action = 2;
this->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
this->spriteIndex = 0xa6; super->spriteIndex = 0xa6;
this->palette.raw = 0x33; super->palette.raw = 0x33;
this->spriteVramOffset = 0; super->spriteVramOffset = 0;
this->type = gPlayerState.gustJarSpeed - 1; super->type = gPlayerState.gustJarSpeed - 1;
this->timer = gUnk_080B3DE0[this->type * 2]; super->timer = gUnk_080B3DE0[super->type * 2];
this->damage = gUnk_080B3DE0[this->type * 2 + 1]; super->damage = gUnk_080B3DE0[super->type * 2 + 1];
this->hurtType = 0x1b; super->hurtType = 0x1b;
this->hitbox = (Hitbox*)gUnk_080B3DE8[this->type]; super->hitbox = (Hitbox*)gUnk_080B3DE8[super->type];
(u32*)gPlayerEntity.field_0x70.WORD = this; gNewPlayerEntity.unk_70 = super;
sub_08078CD0(&gPlayerEntity); sub_08078CD0(&gPlayerEntity);
(u32*)gPlayerEntity.field_0x70.WORD = pEVar3; gNewPlayerEntity.unk_70 = pEVar3;
InitializeAnimation(this, this->type + 10); InitializeAnimation(super, super->type + 10);
sub_08018FA0(this); sub_08018FA0(super);
} }
sub_0801766C(this); sub_0801766C(super);
} }
void sub_08018DE8(Entity* this) { void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this) {
u8 bVar1; u8 bVar1;
bVar1 = this->child->gustJarState & 4; bVar1 = super->child->gustJarState & 4;
if (bVar1 == 0) { if (bVar1 == 0) {
gPlayerState.field_0x1c = bVar1; gPlayerState.field_0x1c = bVar1;
DeleteThisEntity(); DeleteThisEntity();
} }
switch (gPlayerState.field_0x1c) { switch (gPlayerState.field_0x1c) {
case 0: case 0:
sub_08018F6C(this); PlayerItemGustBig_Action3(this);
break; break;
case 5: case 5:
this->child->subAction = 4; super->child->subAction = 4;
COLLISION_ON(this); COLLISION_ON(super);
this->action = 2; super->action = 2;
this->spritePriority.b0 = 2; super->spritePriority.b0 = 2;
this->child->spriteSettings.draw = 1; super->child->spriteSettings.draw = 1;
sub_08018FA0(this); sub_08018FA0(super);
break; break;
} }
sub_08078CD0(&gPlayerEntity); sub_08078CD0(&gPlayerEntity);
} }
void sub_08018E68(Entity* this) { void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) {
s32 y; s32 y;
s32 x; s32 x;
if (this->child == NULL) { if (super->child == NULL) {
GetNextFrame(this); GetNextFrame(super);
sub_08008790(this, 5); sub_08008790(super, 5);
} else { } else {
if ((this->child->gustJarState & 4) == 0) { if ((super->child->gustJarState & 4) == 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
if ((this->contactFlags & 0x80) != 0) { if ((super->contactFlags & 0x80) != 0) {
sub_08018F6C(this); PlayerItemGustBig_Action3(this);
return; return;
} }
} }
if (this->timer-- != 0) { if (super->timer-- != 0) {
LinearMoveUpdate(this); LinearMoveUpdate(super);
switch (this->direction) { switch (super->direction) {
case DirectionNorth: case DirectionNorth:
x = 0; x = 0;
y = -4; y = -4;
@ -154,38 +169,38 @@ void sub_08018E68(Entity* this) {
y = 0; y = 0;
break; break;
} }
if (this->child != NULL) { if (super->child != NULL) {
this->child->direction = this->direction; super->child->direction = super->direction;
CopyPosition(this, this->child); CopyPosition(super, super->child);
} }
if (this->type2 == 0) { if (super->type2 == 0) {
sub_0800451C(this); sub_0800451C(super);
} }
if (sub_08007DD6(sub_080B1A0C(this, x, y), gUnk_080B3DF4) != 0) { if (sub_08007DD6(sub_080B1A0C(super, x, y), gUnk_080B3DF4) != 0) {
return; return;
} }
if (GetRelativeCollisionTile(this, x, y) == 0x74) { if (GetRelativeCollisionTile(super, x, y) == 0x74) {
return; return;
} }
if (sub_080040D8(this, (u8*)gUnk_08003E44, this->x.HALF.HI + x, this->y.HALF.HI + y) == 0) { if (sub_080040D8(super, (u8*)gUnk_08003E44, super->x.HALF.HI + x, super->y.HALF.HI + y) == 0) {
return; return;
} }
} }
if (this->child == NULL) { if (super->child == NULL) {
InitializeAnimation(this, this->type + 0xd); InitializeAnimation(super, super->type + 0xd);
} }
this->action++; super->action++;
sub_08018F6C(this); PlayerItemGustBig_Action3(this);
} }
void sub_08018F6C(Entity* this) { void PlayerItemGustBig_Action3(PlayerItemGustBigEntity* this) {
if (this->child != NULL) { if (super->child != NULL) {
this->child->subAction = 5; super->child->subAction = 5;
this->child->spriteSettings.draw = 1; super->child->spriteSettings.draw = 1;
} else { } else {
GetNextFrame(this); GetNextFrame(super);
if (this->frame == 0) { if (super->frame == 0) {
return; return;
} }
} }
@ -194,8 +209,8 @@ void sub_08018F6C(Entity* this) {
void sub_08018FA0(Entity* this) { void sub_08018FA0(Entity* this) {
this->collisionLayer = gPlayerEntity.collisionLayer; this->collisionLayer = gPlayerEntity.collisionLayer;
if (this->collisionLayer == 0x02) { if (this->collisionLayer == 2) {
this->type2 = 0x01; this->type2 = 1;
} }
SoundReq(this->type + SFX_EA); SoundReq(this->type + SFX_EA);
} }

View File

@ -1,6 +1,13 @@
/**
* @file playerItemGustJar.c
* @ingroup Items
*
* @brief Gust Jar Player Item
*/
#define NENT_DEPRECATED
#include "entity.h" #include "entity.h"
#include "player.h"
#include "functions.h" #include "functions.h"
#include "player.h"
#include "sound.h" #include "sound.h"
extern const u8* gUnk_08132714[]; // Anim index lists? extern const u8* gUnk_08132714[]; // Anim index lists?
@ -18,7 +25,7 @@ void sub_080ADCDC(Entity*, u32);
void sub_080ADCA0(Entity*, u32); void sub_080ADCA0(Entity*, u32);
void PlayerItemGustJar(Entity* this) { void PlayerItemGustJar(Entity* this) {
static void (*const actionFuncs[])(Entity*) = { static void (*const PlayerItemGustJar_Actions[])(Entity*) = {
PlayerItemGustJar_Init, PlayerItemGustJar_Action1, PlayerItemGustJar_Action2, PlayerItemGustJar_Init, PlayerItemGustJar_Action1, PlayerItemGustJar_Action2,
PlayerItemGustJar_Action3, PlayerItemGustJar_Action4, PlayerItemGustJar_Action3, PlayerItemGustJar_Action4,
}; };
@ -26,7 +33,7 @@ void PlayerItemGustJar(Entity* this) {
if (((Entity*)gPlayerState.item != this) || (gPlayerState.field_0x1c == 0)) { if (((Entity*)gPlayerState.item != this) || (gPlayerState.field_0x1c == 0)) {
DeleteThisEntity(); DeleteThisEntity();
} }
actionFuncs[this->action](this); PlayerItemGustJar_Actions[this->action](this);
sub_08078E84(this, &gPlayerEntity); sub_08078E84(this, &gPlayerEntity);
} }

View File

@ -1,24 +1,25 @@
/**
* @file playerItemHeldObject.c
* @ingroup Items
*
* @brief Held Object Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "player.h"
#include "new_player.h"
#include "asm.h" #include "asm.h"
#include "effects.h" #include "effects.h"
#include "entity.h"
#include "functions.h" #include "functions.h"
#include "player.h"
#include "new_player.h" #include "new_player.h"
#include "player.h"
#include "sound.h" #include "sound.h"
#include "functions.h"
#include "new_player.h"
#include "player.h"
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u8 unk_68[4]; /*0x68*/ u8 unk_68[4];
u16 unk_6c; /*0x6c*/ u16 unk_6c;
u16 unk_6e; /*0x6e*/ u16 unk_6e;
} PlayerItemHeldObjectEntity; } PlayerItemHeldObjectEntity;
extern bool32 ProcessMovement10(Entity*); extern bool32 ProcessMovement10(Entity*);
typedef struct { typedef struct {
@ -28,26 +29,26 @@ typedef struct {
u8 unk3; u8 unk3;
} struct_gUnk_081320B8; } struct_gUnk_081320B8;
bool32 sub_080AD32C(PlayerItemHeldObjectEntity*); bool32 sub_080AD32C(PlayerItemHeldObjectEntity* this);
void sub_080AD27C(PlayerItemHeldObjectEntity*); void sub_080AD27C(PlayerItemHeldObjectEntity* this);
void sub_080ACF2C(PlayerItemHeldObjectEntity*); void PlayerItemHeldObject_SubAction0(PlayerItemHeldObjectEntity* this);
void sub_080ACFCC(PlayerItemHeldObjectEntity*); void PlayerItemHeldObject_SubAction1(PlayerItemHeldObjectEntity* this);
void sub_080AD040(PlayerItemHeldObjectEntity*); void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this);
void sub_080AD274(PlayerItemHeldObjectEntity*); void PlayerItemHeldObject_SubAction3(PlayerItemHeldObjectEntity* this);
void PlayerItemHeldObject(Entity* this) { void PlayerItemHeldObject(Entity* this) {
static void (*const subActionFuncs[])(PlayerItemHeldObjectEntity*) = { static void (*const PlayerItemHeldObject_SubActions[])(PlayerItemHeldObjectEntity*) = {
sub_080ACF2C, PlayerItemHeldObject_SubAction0,
sub_080ACFCC, PlayerItemHeldObject_SubAction1,
sub_080AD040, PlayerItemHeldObject_SubAction2,
sub_080AD274, PlayerItemHeldObject_SubAction3,
}; };
subActionFuncs[this->subAction]((PlayerItemHeldObjectEntity*)this); PlayerItemHeldObject_SubActions[this->subAction]((PlayerItemHeldObjectEntity*)this);
} }
static const Hitbox3D gUnk_081320E4; static const Hitbox3D gUnk_081320E4;
void sub_080ACF2C(PlayerItemHeldObjectEntity* this) { void PlayerItemHeldObject_SubAction0(PlayerItemHeldObjectEntity* this) {
static const struct_gUnk_081320B8 gUnk_081320B8[] = { { 0, 2, 0xe8, 0 }, { 0, 5, 0xe0, 0 }, { 0, 5, 0xf2, 0 } }; static const struct_gUnk_081320B8 gUnk_081320B8[] = { { 0, 2, 0xe8, 0 }, { 0, 5, 0xe0, 0 }, { 0, 5, 0xf2, 0 } };
PlayerItemHeldObjectEntity* child; PlayerItemHeldObjectEntity* child;
PlayerItemHeldObjectEntity* child2; PlayerItemHeldObjectEntity* child2;
@ -80,7 +81,7 @@ void sub_080ACF2C(PlayerItemHeldObjectEntity* this) {
this->unk_6e = (child->base).id; this->unk_6e = (child->base).id;
} }
void sub_080ACFCC(PlayerItemHeldObjectEntity* this) { void PlayerItemHeldObject_SubAction1(PlayerItemHeldObjectEntity* this) {
Entity* child = super->child; Entity* child = super->child;
if ((this->unk_6c == child->kind) || (this->unk_6e == child->id)) { if ((this->unk_6c == child->kind) || (this->unk_6e == child->id)) {
if (child->action != 2) { if (child->action != 2) {
@ -101,7 +102,7 @@ void sub_080ACFCC(PlayerItemHeldObjectEntity* this) {
} }
} }
void sub_080AD040(PlayerItemHeldObjectEntity* this) { void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this) {
static const s8 gUnk_081320C4[] = { static const s8 gUnk_081320C4[] = {
0, -6, 6, 0, 0, 6, -6, 0, 0, -6, 6, 0, 0, 6, -6, 0,
}; };
@ -222,7 +223,7 @@ void sub_080AD040(PlayerItemHeldObjectEntity* this) {
} }
} }
void sub_080AD274(PlayerItemHeldObjectEntity* this) { void PlayerItemHeldObject_SubAction3(PlayerItemHeldObjectEntity* this) {
DeleteThisEntity(); DeleteThisEntity();
} }

View File

@ -1,27 +1,33 @@
/**
* @file playerItemLantern.c
* @ingroup Items
*
* @brief Lantern Player Item
*/
#define NENT_DEPRECATED
#include "entity.h" #include "entity.h"
#include "player.h"
#include "functions.h" #include "functions.h"
#include "item.h" #include "item.h"
#include "object.h" #include "object.h"
#include "player.h"
void sub_08054AC8(Entity*); void PlayerItemLantern_Init(Entity* this);
void sub_08054A60(Entity*); void PlayerItemLantern_Action1(Entity* this);
void PlayerItemLantern(Entity* this) { void PlayerItemLantern(Entity* this) {
static void (*const gUnk_080FEEA8[])(Entity*) = { static void (*const PlayerItemLantern_Actions[])(Entity*) = {
sub_08054A60, PlayerItemLantern_Init,
sub_08054AC8, PlayerItemLantern_Action1,
}; };
gUnk_080FEEA8[this->action](this); PlayerItemLantern_Actions[this->action](this);
this->contactFlags = 0; this->contactFlags = 0;
} }
void sub_08054A60(Entity* this) { void PlayerItemLantern_Init(Entity* this) {
this->flags |= (ENT_PERSIST | ENT_COLLIDE); this->flags |= (ENT_PERSIST | ENT_COLLIDE);
this->action = 1; this->action = 1;
this->timer = 4; this->timer = 4;
this->frameIndex = -1; this->frameIndex = -1;
// TODO regalloc and mov 6 too early
this->updatePriority = 6; this->updatePriority = 6;
this->collisionFlags = 7; this->collisionFlags = 7;
this->flags2 = -0x80; this->flags2 = -0x80;
@ -31,10 +37,10 @@ void sub_08054A60(Entity* this) {
} }
sub_0801766C(this); sub_0801766C(this);
LoadSwapGFX(this, 1, 3); LoadSwapGFX(this, 1, 3);
sub_08054AC8(this); PlayerItemLantern_Action1(this);
} }
void sub_08054AC8(Entity* this) { void PlayerItemLantern_Action1(Entity* this) {
Entity* object; Entity* object;
static const s8 offsets[] = { 6, -6, 7, -3, -5, 2, -7, -3 }; static const s8 offsets[] = { 6, -6, 7, -3, -5, 2, -7, -3 };
this->animationState = gPlayerEntity.animationState & 0xe; this->animationState = gPlayerEntity.animationState & 0xe;

View File

@ -1,9 +1,16 @@
#include "entity.h" /**
#include "sound.h" * @file playerItemPacciCane.c
#include "functions.h" * @ingroup Items
*
* @brief Pacci Cane Player Item
*/
#define NENT_DEPRECATED
#include "common.h" #include "common.h"
#include "entity.h"
#include "functions.h"
#include "message.h" #include "message.h"
#include "save.h" #include "save.h"
#include "sound.h"
#include "structures.h" #include "structures.h"
void PlayerItemPacciCane_Action1(Entity*); void PlayerItemPacciCane_Action1(Entity*);

View File

@ -1,26 +1,45 @@
/**
* @file playerItemPacciCaneProjectile.c
* @ingroup Items
*
* @brief Pacci Cane Projectile Player Item
*/
#define NENT_DEPRECATED
#include "asm.h" #include "asm.h"
#include "entity.h" #include "entity.h"
#include "functions.h" #include "functions.h"
#include "sound.h"
#include "object.h" #include "object.h"
#include "sound.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused[4];
/*0x6c*/ u32 unk_6c;
/*0x70*/ u32 unk_70;
/*0x74*/ s32 unk_74;
/*0x78*/ s32 unk_78;
/*0x7c*/ u32 unk_7c;
} PlayerItemPacciCaneProjectileEntity;
static const Hitbox gUnk_0811B9D0; static const Hitbox gUnk_0811B9D0;
void PlayerItemPacciCaneProjectile_Init(Entity* this); void PlayerItemPacciCaneProjectile_Init(PlayerItemPacciCaneProjectileEntity* this);
void sub_080701F8(Entity* this); void PlayerItemPacciCaneProjectile_Action1(PlayerItemPacciCaneProjectileEntity* this);
void sub_0807037C(Entity* this); void PlayerItemPacciCaneProjectile_Action2(PlayerItemPacciCaneProjectileEntity* this);
void sub_08070398(Entity* this); void PlayerItemPacciCaneProjectile_Action3(PlayerItemPacciCaneProjectileEntity* this);
void sub_080703BC(Entity* this); void PlayerItemPacciCaneProjectile_Action4(PlayerItemPacciCaneProjectileEntity* this);
void sub_08070458(Entity* this); void sub_08070458(PlayerItemPacciCaneProjectileEntity* this);
extern void sub_08017744(Entity*); extern void sub_08017744(Entity*);
extern u8* sub_08008782(Entity*, u32, u32, u32); extern u8* sub_08008782(Entity*, u32, u32, u32);
void PlayerItemPacciCaneProjectile(Entity* this) { void PlayerItemPacciCaneProjectile(PlayerItemPacciCaneProjectileEntity* this) {
static void (*const PlayerItemPacciCaneProjectile_Actions[])(Entity*) = { static void (*const PlayerItemPacciCaneProjectile_Actions[])(PlayerItemPacciCaneProjectileEntity*) = {
PlayerItemPacciCaneProjectile_Init, sub_080701F8, sub_0807037C, sub_08070398, sub_080703BC, PlayerItemPacciCaneProjectile_Init, PlayerItemPacciCaneProjectile_Action1,
PlayerItemPacciCaneProjectile_Action2, PlayerItemPacciCaneProjectile_Action3,
PlayerItemPacciCaneProjectile_Action4,
}; };
PlayerItemPacciCaneProjectile_Actions[this->action](this); PlayerItemPacciCaneProjectile_Actions[super->action](this);
} }
extern u8 gUnk_08003E44; extern u8 gUnk_08003E44;
@ -34,7 +53,7 @@ typedef struct {
u8 filler[3]; u8 filler[3];
} gUnk_0811B9A8_struct; } gUnk_0811B9A8_struct;
void PlayerItemPacciCaneProjectile_Init(Entity* this) { void PlayerItemPacciCaneProjectile_Init(PlayerItemPacciCaneProjectileEntity* this) {
static const s8 gUnk_0811B9A0[] = { static const s8 gUnk_0811B9A0[] = {
0, -18, 14, 0, 0, 14, -14, 0, 0, -18, 14, 0, 0, 14, -14, 0,
}; };
@ -46,36 +65,36 @@ void PlayerItemPacciCaneProjectile_Init(Entity* this) {
}; };
const gUnk_0811B9A8_struct* ptr; const gUnk_0811B9A8_struct* ptr;
this->action = 1; super->action = 1;
this->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
COLLISION_ON(this); COLLISION_ON(super);
this->direction = this->animationState << 2; super->direction = super->animationState << 2;
this->speed = 0x200; super->speed = 0x200;
*(u32*)&this->field_0x74 = 0x40; this->unk_74 = 0x40;
*(u32*)&this->field_0x78 = 0x1e0; this->unk_78 = 0x1e0;
this->x.HALF.HI = gPlayerEntity.x.HALF.HI + gUnk_0811B9A0[this->animationState]; super->x.HALF.HI = gPlayerEntity.x.HALF.HI + gUnk_0811B9A0[super->animationState];
this->y.HALF.HI = gPlayerEntity.y.HALF.HI + gUnk_0811B9A0[this->animationState + 1]; super->y.HALF.HI = gPlayerEntity.y.HALF.HI + gUnk_0811B9A0[super->animationState + 1];
this->collisionFlags = 7; super->collisionFlags = 7;
this->flags2 = 0x8a; super->flags2 = 0x8a;
this->hitbox = (Hitbox*)&gUnk_0811B9D0; super->hitbox = (Hitbox*)&gUnk_0811B9D0;
if (this->collisionLayer == 2) { if (super->collisionLayer == 2) {
this->type = 1; super->type = 1;
} else { } else {
this->type = 0; super->type = 0;
} }
this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY;
ptr = &gUnk_0811B9A8[(this->animationState >> 1)]; ptr = &gUnk_0811B9A8[(super->animationState >> 1)];
this->spriteSettings.flipX = ptr->flipX; super->spriteSettings.flipX = ptr->flipX;
this->spriteSettings.flipY = ptr->flipY; super->spriteSettings.flipY = ptr->flipY;
this->animIndex = ptr->animIndex; super->animIndex = ptr->animIndex;
*(int*)&this->field_0x6c = ptr->unk2; this->unk_6c = ptr->unk2;
this->field_0x70.WORD = ptr->unk3; this->unk_70 = ptr->unk3;
sub_0801766C(this); sub_0801766C(super);
InitializeAnimation(this, this->animIndex); InitializeAnimation(super, super->animIndex);
SoundReq(SFX_1DD); SoundReq(SFX_1DD);
} }
void sub_080701F8(Entity* this) { void PlayerItemPacciCaneProjectile_Action1(PlayerItemPacciCaneProjectileEntity* this) {
static const s8 gUnk_0811B9C8[] = { static const s8 gUnk_0811B9C8[] = {
0, -4, 4, 0, 0, 4, -4, 0, 0, -4, 4, 0, 0, 4, -4, 0,
}; };
@ -84,87 +103,87 @@ void sub_080701F8(Entity* this) {
u8* iVar3; u8* iVar3;
Entity* pEVar4; Entity* pEVar4;
cVar1 = gUnk_0811B9C8[this->animationState]; cVar1 = gUnk_0811B9C8[super->animationState];
cVar2 = gUnk_0811B9C8[this->animationState + 1]; cVar2 = gUnk_0811B9C8[super->animationState + 1];
iVar3 = sub_08008782(this, 10, cVar1, cVar2); iVar3 = sub_08008782(super, 10, cVar1, cVar2);
if (iVar3) { if (iVar3) {
pEVar4 = CreateObject(OBJECT_53, iVar3[5], iVar3[2]); pEVar4 = CreateObject(OBJECT_53, iVar3[5], iVar3[2]);
if (pEVar4) { if (pEVar4) {
pEVar4->timer = iVar3[3]; pEVar4->timer = iVar3[3];
pEVar4->x.HALF.HI = this->x.HALF.HI + cVar1; pEVar4->x.HALF.HI = super->x.HALF.HI + cVar1;
pEVar4->y.HALF.HI = this->y.HALF.HI + cVar2; pEVar4->y.HALF.HI = super->y.HALF.HI + cVar2;
} }
sub_08070458(this); sub_08070458(this);
return; return;
} }
if ((--(*(int*)&this->field_0x74) == -1) || (--(*(int*)&this->field_0x78) == -1)) { if ((--(this->unk_74) == -1) || (--(this->unk_78) == -1)) {
sub_08070458(this); sub_08070458(this);
} else { } else {
GetNextFrame(this); GetNextFrame(super);
LinearMoveUpdate(this); LinearMoveUpdate(super);
if (this->type == 0) { if (super->type == 0) {
sub_0800451C(this); sub_0800451C(super);
} }
if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) {
if (sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) == 0) { if (sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI) == 0) {
if (GetTileUnderEntity(this) == 0x19) { if (GetTileUnderEntity(super) == 0x19) {
this->action = 4; super->action = 4;
COLLISION_OFF(this); COLLISION_OFF(super);
this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8; super->x.HALF.HI = (super->x.HALF.HI & 0xfff0) | 8;
this->y.HALF.HI = (this->y.HALF.HI & 0xfff0) | 8; super->y.HALF.HI = (super->y.HALF.HI & 0xfff0) | 8;
this->spritePriority.b0 = 7; super->spritePriority.b0 = 7;
this->field_0x7c.WORD = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); this->unk_7c = GetTileIndex(COORD_TO_TILE(super), super->collisionLayer);
InitializeAnimation(this, 0x14); InitializeAnimation(super, 0x14);
SetTile(0x4020, COORD_TO_TILE(this), this->collisionLayer); SetTile(0x4020, COORD_TO_TILE(super), super->collisionLayer);
return; return;
} }
} else { } else {
sub_08070458(this); sub_08070458(this);
} }
} }
if (this->contactFlags != 0) { if (super->contactFlags != 0) {
sub_08070458(this); sub_08070458(this);
} }
} }
} }
void sub_0807037C(Entity* this) { void PlayerItemPacciCaneProjectile_Action2(PlayerItemPacciCaneProjectileEntity* this) {
GetNextFrame(this); GetNextFrame(super);
if ((this->frame & ANIM_DONE) != 0) { if ((super->frame & ANIM_DONE) != 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
} }
void sub_08070398(Entity* this) { void PlayerItemPacciCaneProjectile_Action3(PlayerItemPacciCaneProjectileEntity* this) {
GetNextFrame(this); GetNextFrame(super);
LinearMoveUpdate(this); LinearMoveUpdate(super);
if (GravityUpdate(this, Q_8_8(32.0)) == 0) { if (GravityUpdate(super, Q_8_8(32.0)) == 0) {
DeleteThisEntity(); DeleteThisEntity();
} }
} }
void sub_080703BC(Entity* this) { void PlayerItemPacciCaneProjectile_Action4(PlayerItemPacciCaneProjectileEntity* this) {
GetNextFrame(this); GetNextFrame(super);
switch (GetTileIndex(COORD_TO_TILE(this), this->collisionLayer)) { switch (GetTileIndex(COORD_TO_TILE(super), super->collisionLayer)) {
default: default:
this->field_0x7c.WORD = 0; this->unk_7c = 0;
sub_08070458(this); sub_08070458(this);
break; break;
case 0x4021: case 0x4021:
sub_08070458(this); sub_08070458(this);
break; break;
case 0x4070: case 0x4070:
*(int*)&this->field_0x78 = 0xff; this->unk_78 = 0xff;
case 0x4020: case 0x4020:
if (--(*(int*)&this->field_0x78) == -1) { if (--(this->unk_78) == -1) {
sub_08070458(this); sub_08070458(this);
} else { } else {
if (this->contactFlags == 0) { if (super->contactFlags == 0) {
return; return;
} }
if (((this->contactFlags & 0x7f) == 0) && (this->action != 0x1a)) { if (((super->contactFlags & 0x7f) == 0) && (super->action != 0x1a)) {
return; return;
} }
sub_08070458(this); sub_08070458(this);
@ -174,15 +193,15 @@ void sub_080703BC(Entity* this) {
} }
} }
void sub_08070458(Entity* this) { void sub_08070458(PlayerItemPacciCaneProjectileEntity* this) {
this->action = 2; super->action = 2;
COLLISION_OFF(this); COLLISION_OFF(super);
this->speed = 0; super->speed = 0;
if (this->field_0x7c.WORD != 0) { if (this->unk_7c != 0) {
SetTile(this->field_0x7c.WORD, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); SetTile(this->unk_7c, TILE(super->x.HALF.HI, super->y.HALF.HI), super->collisionLayer);
} }
InitializeAnimation(this, 0x13); InitializeAnimation(super, 0x13);
sub_08017744(this); sub_08017744(super);
SoundReq(SFX_199); SoundReq(SFX_199);
} }

View File

@ -1,29 +1,35 @@
/**
* @file playerItemShield.c
* @ingroup Items
*
* @brief Shield Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "entity.h"
#include "player.h"
#include "functions.h"
#include "sound.h"
#include "collision.h" #include "collision.h"
#include "entity.h"
#include "functions.h"
#include "player.h"
#include "playeritem.h" #include "playeritem.h"
#include "sound.h"
const Hitbox gUnk_081271CC = { 0, 0, { 1, 0, 0, 1 }, 8, 8 }; const Hitbox gUnk_081271CC = { 0, 0, { 1, 0, 0, 1 }, 8, 8 };
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u8 unk_68; /*0x68*/ u8 unk_68;
u8 unk_69[3]; /*0x69*/ u8 unk_69[3];
u32 bounceTimer; /*0x6c*/ u32 bounceTimer;
u32 unk_70; /*0x70*/ u32 unk_70;
u32 unk_74; /*0x74*/ u32 unk_74;
u32 unk_78; /*0x78*/ u32 unk_78;
u8* unk_7c; /*0x7c*/ u8* unk_7c;
} PlayerItemShieldEntity; } PlayerItemShieldEntity;
void sub_080A2D98(PlayerItemShieldEntity*);
void sub_080A2E00(PlayerItemShieldEntity*); void PlayerItemShield_Init(PlayerItemShieldEntity* this);
void (*const gUnk_081271D4[])(PlayerItemShieldEntity*) = { void PlayerItemShield_Action1(PlayerItemShieldEntity* this);
sub_080A2D98, void (*const PlayerItemShield_Actions[])(PlayerItemShieldEntity*) = {
sub_080A2E00, PlayerItemShield_Init,
PlayerItemShield_Action1,
}; };
const u8 gUnk_081271DC[] = { const u8 gUnk_081271DC[] = {
7, 60, 0, 0, 0, 2, 0, 0, 1, 2, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 4, 2, 0, 0, 5, 2, 0, 0, 6, 2, 0, 0, 7, 20, 7, 60, 0, 0, 0, 2, 0, 0, 1, 2, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 4, 2, 0, 0, 5, 2, 0, 0, 6, 2, 0, 0, 7, 20,
@ -48,16 +54,16 @@ const Hitbox gUnk_08127258 = { 5, -4, { 0, 0, 0, 0 }, 5, 7 };
const Hitbox gUnk_08127260 = { 0, 0, { 0, 0, 0, 0 }, 6, 7 }; const Hitbox gUnk_08127260 = { 0, 0, { 0, 0, 0, 0 }, 6, 7 };
const Hitbox gUnk_08127268 = { -5, -4, { 0, 0, 0, 0 }, 5, 7 }; const Hitbox gUnk_08127268 = { -5, -4, { 0, 0, 0, 0 }, 5, 7 };
void sub_080A2E00(PlayerItemShieldEntity* this); void PlayerItemShield_Action1(PlayerItemShieldEntity* this);
void PlayerItemShield(PlayerItemShieldEntity* this) { void PlayerItemShield(PlayerItemShieldEntity* this) {
if (this->bounceTimer != 0) { if (this->bounceTimer != 0) {
this->bounceTimer--; this->bounceTimer--;
} }
gUnk_081271D4[super->action](this); PlayerItemShield_Actions[super->action](this);
} }
void sub_080A2D98(PlayerItemShieldEntity* this) { void PlayerItemShield_Init(PlayerItemShieldEntity* this) {
gPlayerState.item = super; gPlayerState.item = super;
super->action = 1; super->action = 1;
super->updatePriority = 6; super->updatePriority = 6;
@ -73,10 +79,10 @@ void sub_080A2D98(PlayerItemShieldEntity* this) {
super->animationState = gPlayerEntity.animationState & 0xe; super->animationState = gPlayerEntity.animationState & 0xe;
sub_08079BD8(super); sub_08079BD8(super);
LoadSwapGFX(super, 1, 3); LoadSwapGFX(super, 1, 3);
sub_080A2E00(this); PlayerItemShield_Action1(this);
} }
void sub_080A2E00(PlayerItemShieldEntity* this) { void PlayerItemShield_Action1(PlayerItemShieldEntity* this) {
Entity* playerItem; Entity* playerItem;
u8* pbVar3; u8* pbVar3;
u32 tmp2; u32 tmp2;

View File

@ -1,60 +1,71 @@
#include "entity.h" /**
#include "sound.h" * @file playerItemSpiral Beam.c
#include "functions.h" * @ingroup Items
#include "effects.h" *
* @brief Spiral Beam Player Item
*/
#define NENT_DEPRECATED
#include "asm.h" #include "asm.h"
#include "effects.h"
#include "entity.h"
#include "functions.h"
#include "sound.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u32 unk_6c;
} PlayerItemSpiralBeamEntity;
extern u8 gUnk_08003E44; extern u8 gUnk_08003E44;
void sub_0805FBE8(Entity*); void PlayerItemSpiralBeam_Init(PlayerItemSpiralBeamEntity*);
void sub_0805FC74(Entity*); void PlayerItemSpiralBeam_Action1(PlayerItemSpiralBeamEntity*);
void PlayerItemSpiralBeam(Entity* this) { void PlayerItemSpiralBeam(PlayerItemSpiralBeamEntity* this) {
static void (*const actionFuncs[])(Entity*) = { static void (*const PlayerItemSpiralBeam_Actions[])(PlayerItemSpiralBeamEntity*) = {
sub_0805FBE8, PlayerItemSpiralBeam_Init,
sub_0805FC74, PlayerItemSpiralBeam_Action1,
}; };
actionFuncs[this->action](this); PlayerItemSpiralBeam_Actions[super->action](this);
} }
void sub_0805FBE8(Entity* this) { void PlayerItemSpiralBeam_Init(PlayerItemSpiralBeamEntity* this) {
static const Hitbox gUnk_08109AD0 = { 0, 0, { 4, 0, 0, 0 }, 6, 6 }; static const Hitbox gUnk_08109AD0 = { 0, 0, { 4, 0, 0, 0 }, 6, 6 };
CopyPosition(&gPlayerEntity, this); CopyPosition(&gPlayerEntity, super);
this->action++; super->action++;
this->spriteSettings.draw = TRUE; super->spriteSettings.draw = TRUE;
this->collisionFlags = gPlayerEntity.collisionFlags + 1; super->collisionFlags = gPlayerEntity.collisionFlags + 1;
this->hitbox = (Hitbox*)&gUnk_08109AD0; super->hitbox = (Hitbox*)&gUnk_08109AD0;
this->speed = 0x380; super->speed = 0x380;
this->animationState = this->animationState & 0x7f; super->animationState = super->animationState & 0x7f;
if (this->collisionLayer == 2) { if (super->collisionLayer == 2) {
this->type2 = 1; super->type2 = 1;
} }
this->direction = this->animationState << 2; super->direction = super->animationState << 2;
*(u32*)&this->field_0x6c = 0x3c; this->unk_6c = 60;
InitializeAnimation(this, (this->animationState >> 1) + 0xc); InitializeAnimation(super, (super->animationState >> 1) + 0xc);
sub_0801766C(this); sub_0801766C(super);
LinearMoveUpdate(this); LinearMoveUpdate(super);
sub_0805FC74(this); PlayerItemSpiralBeam_Action1(this);
SoundReq(SFX_ITEM_SWORD_BEAM); SoundReq(SFX_ITEM_SWORD_BEAM);
} }
void sub_0805FC74(Entity* this) { void PlayerItemSpiralBeam_Action1(PlayerItemSpiralBeamEntity* this) {
int iVar1; if (this->unk_6c-- != 0) {
GetNextFrame(super);
if (--*(int*)&this->field_0x6c != -1) { LinearMoveUpdate(super);
GetNextFrame(this); super->timer++;
LinearMoveUpdate(this); if (super->type2 == 0) {
this->timer++; sub_0800451C(super);
if (this->type2 == 0) {
sub_0800451C(this);
} }
if (!sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) && if (!sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) &&
sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI)) { sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI)) {
CreateFx(this, FX_SWORD_MAGIC, 0); CreateFx(super, FX_SWORD_MAGIC, 0);
DeleteThisEntity(); DeleteThisEntity();
} }
if (this->contactFlags != 0) { if (super->contactFlags != 0) {
CreateFx(this, FX_SWORD_MAGIC, 0); CreateFx(super, FX_SWORD_MAGIC, 0);
DeleteThisEntity(); DeleteThisEntity();
} }
} else { } else {

View File

@ -1,32 +1,38 @@
/**
* @file playerItemSword.c
* @ingroup Items
*
* @brief Sword Player Item
*/
#define NENT_DEPRECATED #define NENT_DEPRECATED
#include "entity.h"
#include "functions.h"
#include "sound.h"
#include "asm.h" #include "asm.h"
#include "effects.h" #include "effects.h"
#include "entity.h"
#include "functions.h"
#include "object.h" #include "object.h"
#include "sound.h"
typedef struct { typedef struct {
Entity base; /*0x00*/ Entity base;
u8 unk_68; /*0x68*/ u8 unk_68;
} PlayerItemSwordEntity; } PlayerItemSwordEntity;
void sub_080A78B8(PlayerItemSwordEntity*, Entity*); void sub_080A78B8(PlayerItemSwordEntity*, Entity*);
void sub_080A7B98(PlayerItemSwordEntity*); void sub_080A7B98(PlayerItemSwordEntity*);
void sub_080A7A54(PlayerItemSwordEntity*); void sub_080A7A54(PlayerItemSwordEntity*);
void sub_080A7824(PlayerItemSwordEntity*); void PlayerItemSword_Action2(PlayerItemSwordEntity*);
void sub_080A76CC(PlayerItemSwordEntity*); void PlayerItemSword_Action1(PlayerItemSwordEntity*);
void sub_080A758C(PlayerItemSwordEntity*); void PlayerItemSword_Init(PlayerItemSwordEntity*);
void sub_080A7A84(PlayerItemSwordEntity*); void sub_080A7A84(PlayerItemSwordEntity*);
void PlayerItemSword(Entity* this) { void PlayerItemSword(Entity* this) {
static void (*const gUnk_0812905C[])(PlayerItemSwordEntity*) = { static void (*const PlayerItemSword_Actions[])(PlayerItemSwordEntity*) = {
sub_080A758C, PlayerItemSword_Init,
sub_080A76CC, PlayerItemSword_Action1,
sub_080A7824, PlayerItemSword_Action2,
}; };
gUnk_0812905C[this->action]((PlayerItemSwordEntity*)this); PlayerItemSword_Actions[this->action]((PlayerItemSwordEntity*)this);
if (this->type == 0) { if (this->type == 0) {
sub_08078E84(this, &gPlayerEntity); sub_08078E84(this, &gPlayerEntity);
this->hitbox->offset_x += this->spriteOffsetX; this->hitbox->offset_x += this->spriteOffsetX;
@ -34,7 +40,7 @@ void PlayerItemSword(Entity* this) {
} }
} }
void sub_080A758C(PlayerItemSwordEntity* this) { void PlayerItemSword_Init(PlayerItemSwordEntity* this) {
static const u8 gUnk_08129068[] = { static const u8 gUnk_08129068[] = {
0x56, 0x56,
0x55, 0x55,
@ -79,16 +85,16 @@ void sub_080A758C(PlayerItemSwordEntity* this) {
break; break;
} }
super->action++; super->action++;
sub_080A7824(this); PlayerItemSword_Action2(this);
} else { } else {
super->damage = gPlayerState.swordDamage * 2 + 4; super->damage = gPlayerState.swordDamage * 2 + 4;
sub_080A76CC(this); PlayerItemSword_Action1(this);
} }
gPlayerState.item = super; gPlayerState.item = super;
sub_08079BD8(super); sub_08079BD8(super);
SoundReq(gUnk_0812906C[GetRandomByWeight(gUnk_08129068)]); SoundReq(gUnk_0812906C[GetRandomByWeight(gUnk_08129068)]);
} else { } else {
sub_080A76CC(this); PlayerItemSword_Action1(this);
} }
SoundReq(SFX_10E); SoundReq(SFX_10E);
} }
@ -147,7 +153,7 @@ static const s8 gUnk_081292E2[] = { 0x0, 0x2, -0x8, 0xa, -0x8, 0xa, 0x0
0x0, -0x2, 0x10, -0x12, 0x10, -0x12, 0x0, -0x16, 0x0, -0x16, -0xc, 0x0, -0x2, 0x10, -0x12, 0x10, -0x12, 0x0, -0x16, 0x0, -0x16, -0xc,
-0x14, -0xc, -0x10, -0xc, -0xc, 0x0, -0x2 }; -0x14, -0xc, -0x10, -0xc, -0xc, 0x0, -0x2 };
void sub_080A76CC(PlayerItemSwordEntity* this) { void PlayerItemSword_Action1(PlayerItemSwordEntity* this) {
Entity* effect; Entity* effect;
Effect type; Effect type;
const s8* ptr; const s8* ptr;
@ -221,7 +227,7 @@ void sub_080A76CC(PlayerItemSwordEntity* this) {
} }
} }
void sub_080A7824(PlayerItemSwordEntity* this) { void PlayerItemSword_Action2(PlayerItemSwordEntity* this) {
if (gPlayerState.item != super) { if (gPlayerState.item != super) {
DeleteThisEntity(); DeleteThisEntity();
} }

View File

@ -1,109 +1,120 @@
#include "entity.h" /**
#include "player.h" * @file playerItemSwordBeam.c
#include "physics.h" * @ingroup Items
#include "functions.h" *
#include "sound.h" * @brief Sword Beam Player Item
#include "effects.h" */
#include "common.h" #define NENT_DEPRECATED
#include "asm.h" #include "asm.h"
#include "common.h"
#include "effects.h"
#include "entity.h"
#include "functions.h"
#include "physics.h"
#include "player.h"
#include "sound.h"
void sub_08019498(Entity*); typedef struct {
void sub_08019580(Entity*); /*0x00*/ Entity base;
void sub_08019644(Entity*); /*0x68*/ u8 unused[4];
/*0x6c*/ u32 unk_6c;
/*0x70*/ u32 unk_70;
/*0x74*/ u32 unk_74;
} PlayerItemSwordBeamEntity;
void PlayerItemSwordBeam_Init(PlayerItemSwordBeamEntity* this);
void PlayerItemSwordBeam_Action1(PlayerItemSwordBeamEntity* this);
void PlayerItemSwordBeam_CyclePalettes(PlayerItemSwordBeamEntity* this);
extern u8 gUnk_08003E44; extern u8 gUnk_08003E44;
void PlayerItemSwordBeam(Entity* this) { void PlayerItemSwordBeam(PlayerItemSwordBeamEntity* this) {
static void (*const actionFuncs[])(Entity*) = { static void (*const PlayerItemSwordBeam_Actions[])(PlayerItemSwordBeamEntity*) = {
sub_08019498, PlayerItemSwordBeam_Init,
sub_08019580, PlayerItemSwordBeam_Action1,
}; };
actionFuncs[this->action](this); PlayerItemSwordBeam_Actions[super->action](this);
} }
static const u8 gUnk_080B43FC[] = { 30, 29, 30, 29 }; static const u8 PlayerItemSwordBeam_AnimIndices[] = { 30, 29, 30, 29 };
static const u8 gUnk_080B4400[] = { 0, 4, 1, 2, -1, 0, 0, 0 }; static const u8 PlayerItemSwordBeam_Palettes[] = { 0, 4, 1, 2, 0xff };
void sub_08019498(Entity* this) { void PlayerItemSwordBeam_Init(PlayerItemSwordBeamEntity* this) {
static const Hitbox gUnk_080B4408 = { 0, 0, { 4, 0, 0, 0 }, 6, 6 }; static const Hitbox hitbox = { 0, 0, { 4, 0, 0, 0 }, 6, 6 };
CopyPosition(&gPlayerEntity, this); CopyPosition(&gPlayerEntity, super);
this->action += 0x01; super->action++;
this->spriteSettings.draw = 1; super->spriteSettings.draw = 1;
this->collisionFlags = gPlayerEntity.collisionFlags + 1; super->collisionFlags = gPlayerEntity.collisionFlags + 1;
this->hitbox = (Hitbox*)&gUnk_080B4408; super->hitbox = (Hitbox*)&hitbox;
this->speed = 0x380; super->speed = 0x380;
*(u32*)&this->field_0x74 = 2; this->unk_74 = 2;
this->field_0x70.WORD = 0; this->unk_70 = 0;
if (this->collisionLayer == 0x02) { if (super->collisionLayer == 2) {
this->type2 = 0x01; super->type2 = 1;
} }
this->direction = this->animationState << 2; super->direction = super->animationState << 2;
*(u32*)&this->field_0x6c = 0x3c; this->unk_6c = 60;
switch (this->animationState) { switch (super->animationState) {
case 0: case 0:
this->x.HALF.HI += -3; super->x.HALF.HI -= 3;
this->y.HALF.HI += -8; super->y.HALF.HI -= 8;
this->spriteSettings.flipY = 1; super->spriteSettings.flipY = 1;
break; break;
case 4: case 4:
this->x.HALF.HI += 2; super->x.HALF.HI += 2;
break; break;
case 2: case 2:
this->spriteSettings.flipX = 1; super->spriteSettings.flipX = 1;
this->x.HALF.HI++; super->x.HALF.HI++;
this->y.HALF.HI += -4; super->y.HALF.HI -= 4;
break; break;
case 6: case 6:
this->x.HALF.HI--; super->x.HALF.HI--;
this->y.HALF.HI += -4; super->y.HALF.HI -= 4;
break; break;
} }
InitializeAnimation(this, gUnk_080B43FC[this->animationState >> 1]); InitializeAnimation(super, PlayerItemSwordBeam_AnimIndices[super->animationState >> 1]);
sub_0801766C(this); sub_0801766C(super);
LinearMoveUpdate(this); LinearMoveUpdate(super);
sub_08019580(this); PlayerItemSwordBeam_Action1(this);
SoundReq(SFX_ITEM_SWORD_BEAM); SoundReq(SFX_ITEM_SWORD_BEAM);
} }
void sub_08019580(Entity* this) { void PlayerItemSwordBeam_Action1(PlayerItemSwordBeamEntity* this) {
if (--*(int*)&this->field_0x6c != -1) { if (this->unk_6c-- != 0) {
GetNextFrame(this); GetNextFrame(super);
LinearMoveUpdate(this); LinearMoveUpdate(super);
this->timer++; super->timer++;
if (this->type2 == 0) { if (super->type2 == 0) {
sub_0800451C(this); sub_0800451C(super);
} }
if ((sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) && if ((sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) &&
(sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) != 0)) { (sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI) != 0)) {
CreateFx(this, FX_SWORD_MAGIC, 0); CreateFx(super, FX_SWORD_MAGIC, 0);
DeleteThisEntity(); DeleteThisEntity();
} }
if (this->contactFlags != 0) { if (super->contactFlags != 0) {
CreateFx(this, FX_SWORD_MAGIC, 0); CreateFx(super, FX_SWORD_MAGIC, 0);
DeleteThisEntity(); DeleteThisEntity();
} }
if (sub_08008790(this, 0xc) != NULL) { if (sub_08008790(super, 0xc) != NULL) {
DeleteThisEntity(); DeleteThisEntity();
} }
} else { } else {
DeleteThisEntity(); DeleteThisEntity();
} }
sub_08019644(this); PlayerItemSwordBeam_CyclePalettes(this);
} }
void sub_08019644(Entity* this) { void PlayerItemSwordBeam_CyclePalettes(PlayerItemSwordBeamEntity* this) {
s32 iVar1; if (--this->unk_74 == 0) {
this->unk_74 = 2;
iVar1 = *(int*)&this->field_0x74 + -1; this->unk_70++;
*(int*)&this->field_0x74 = iVar1; if (PlayerItemSwordBeam_Palettes[this->unk_70] == 0xff) {
if (iVar1 == 0) { this->unk_70 = 0;
*(int*)&this->field_0x74 = 2;
this->field_0x70.WORD++;
if (gUnk_080B4400[this->field_0x70.WORD] == 0xff) {
this->field_0x70.WORD = iVar1;
} }
ChangeObjPalette(this, (u32)gUnk_080B4400[this->field_0x70.WORD]); ChangeObjPalette(super, PlayerItemSwordBeam_Palettes[this->unk_70]);
} }
} }