Decompile func_ptr_8017000C_w_030 (#1545)

https://decomp.me/scratch/uusD5
This commit is contained in:
Josh Lory 2024-08-20 14:56:39 -07:00 committed by GitHub
parent bac0e55cd2
commit c22cd8f9c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 144 additions and 2 deletions

View File

@ -191,7 +191,8 @@ typedef struct PACKED {
/* 0x8C */ struct Entity* parent;
/* 0x90 */ s32 unk90;
/* 0x94 */ s32 unk94;
/* 0x98 */ s32 unk98;
/* 0x98 */ s16 unk98;
/* 0x9A */ s16 unk9A;
/* 0x9C */ s32 accelerationX;
/* 0xA0 */ s32 accelerationY;
/* 0xA4 */ s16 unkA4;
@ -202,6 +203,28 @@ typedef struct PACKED {
/* 0xAE */ s16 equipId;
} ET_Weapon;
typedef struct PACKED {
/* 0x7C */ s16 lifetime;
/* 0x7E */ s16 unk7E;
/* 0x80 */ s16 unk80;
/* 0x82 */ s16 unk82;
/* 0x84 */ s32 unk84;
/* 0x88 */ s16 childPalette;
/* 0x8A */ s16 unk8A;
/* 0x8C */ struct Entity* parent;
/* 0x90 */ s32 unk90;
/* 0x94 */ struct Entity* other;
/* 0x98 */ s16 unk98;
/* 0x9A */ s16 unk9A;
/* 0x9C */ s32 accelerationX;
/* 0xA0 */ s32 accelerationY;
/* 0xA4 */ s32 unkA4;
/* 0xA8 */ s32 unkA8;
/* 0xAC */ u8 anim;
/* 0xAD */ u8 unkAD;
/* 0xAE */ s16 equipId;
} ET_WeaponUnk030;
typedef struct PACKED {
s32 unk7C;
s32 unk80;
@ -1524,6 +1547,7 @@ typedef union { // offset=0x7C
ET_MessageBox messageBox;
ET_Weapon weapon;
ET_WeaponUnk012 weapon_012;
ET_WeaponUnk030 weapon_030;
ET_WeaponUnk046 weapon_046;
ET_Shield shield;
ET_DarkShield darkShield;

View File

@ -210,6 +210,7 @@ enum SfxModes {
#define SFX_UNK_6AD 0x6AD
#define SFX_UNK_6B0 0x6B0 // Used for Shaman Shield, could be same as petal
#define SFX_UNK_6B1 0x6B1
#define SFX_UNK_6BA 0x6BA
#define NA_SE_EN_SLOGRA_SPEAR_SLASH 0x6C6
#define NA_SE_EN_SLOGRA_BEAK_ATTACK 0x6C8
#define NA_SE_EN_SKELETON_THROW_BONE 0x6C8

View File

@ -12,6 +12,8 @@ extern s32 g_HandId;
extern AnimationFrame D_D6000_8017A514[];
extern AnimationFrame D_D6000_8017A548[];
extern WeaponAnimation D_D6000_8017A5E4[];
extern s16 D_D6000_8017A66C[16];
extern s32 D_D6000_8017CC44;
static void EntityWeaponAttack(Entity* self) {
WeaponAnimation* anim;
@ -68,7 +70,122 @@ INCLUDE_ASM("weapon/nonmatchings/w_030", func_ptr_80170004);
INCLUDE_ASM("weapon/nonmatchings/w_030", func_ptr_80170008);
INCLUDE_ASM("weapon/nonmatchings/w_030", func_ptr_8017000C);
void func_ptr_8017000C(Entity* self) {
s16 result;
s16 angleDiff;
s16 maskedParams;
s32 temp_a2;
s16 angle;
s32 temp_lo;
maskedParams = (self->params >> 8) & 0x7F;
switch (self->step) {
case 0:
self->palette = 0x110;
self->unk5A = 0x64;
if (g_HandId != 0) {
self->palette += 0x18;
self->unk5A += 2;
}
self->flags = FLAG_UNK_08000000;
self->animSet = 0xA;
self->animCurFrame = 0x64;
self->zPriority = PLAYER.zPriority + 2;
self->facingLeft = self->ext.weapon.parent->facingLeft;
if (maskedParams == 1) {
self->posY.i.hi -= 4;
}
if (maskedParams == 0) {
self->posY.i.hi -= 0x10;
}
if (maskedParams == 2) {
self->posY.i.hi -= 28 + (rand() & 15);
self->posX.i.hi += D_D6000_8017A66C[D_D6000_8017CC44 % 3];
self->posX.i.hi += -4 + (rand() & 7);
self->ext.weapon.unk82 = (self->facingLeft + 1) & 1;
self->facingLeft = 0;
self->drawFlags = DRAW_COLORS;
self->step = 2;
g_api.PlaySfx(SFX_UNK_6BA);
self->ext.weapon.unk80 = rand();
self->ext.weapon.lifetime = ((u8)self->params * 4) + 0x30;
D_D6000_8017CC44++;
} else {
SetSpeedX(FIX(-5.5));
self->posX.val += self->velocityX * 5;
}
self->attack = 4;
self->attackElement = ELEMENT_HIT;
self->hitboxState = 2;
self->nFramesInvincibility = 4;
self->stunFrames = 4;
self->hitEffect = 1;
self->entityRoomIndex = 0;
g_api.func_80118894(self);
self->hitboxWidth = 8;
self->hitboxHeight = 4;
self->step++;
break;
case 1:
if (maskedParams == 2) {
result = g_api.func_80118B18(
self, self->ext.weapon_030.other, self->ext.weapon.unk82);
if (result >= 0) {
temp_a2 = self->ext.weapon.unk80 & 0xFFF;
angle = temp_a2;
angleDiff = abs(angle - result);
if (self->ext.weapon.unk98 > angleDiff) {
self->ext.weapon.unk98 = angleDiff;
}
if (angle < result) {
if (angleDiff < 0x800) {
angle += self->ext.weapon.unk98;
} else {
angle -= self->ext.weapon.unk98;
}
} else {
if (angleDiff < 0x800) {
angle -= self->ext.weapon.unk98;
} else {
angle += self->ext.weapon.unk98;
}
}
self->ext.weapon.unk80 = angle & 0xFFF;
}
self->velocityX =
(rcos(self->ext.weapon.unk80) * self->ext.weapon.unk9A) >> 5;
temp_lo = rsin(self->ext.weapon.unk80) * self->ext.weapon.unk9A;
self->ext.weapon.unk98 += 0x18;
self->rotZ = -self->ext.weapon.unk80 + 0x800;
self->velocityY = -(temp_lo >> 5);
}
if (self->hitFlags != 0) {
self->ext.weapon.lifetime = 10;
self->step++;
}
self->posX.val += self->velocityX;
self->posY.val += self->velocityY;
return;
case 2:
self->drawFlags |= FLAG_DRAW_UNK80;
if (--self->ext.weapon.lifetime == 0) {
DestroyEntity(self);
return;
}
return;
case 3:
self->ext.weapon.unk80 += 0x100;
self->rotZ = -self->ext.weapon.unk80 + 0x800;
if (--self->ext.weapon.lifetime == 0) {
self->ext.weapon_030.other = g_api.func_80118970();
self->ext.weapon.unk98 = 0x20;
self->ext.weapon.unk9A = 0x600;
g_api.PlaySfx(SFX_ARROW_SHOT_C);
self->step = 1;
}
break;
}
}
s32 func_ptr_80170010(Entity* self) {
s32 hitboxSize;