Skip to content

Commit

Permalink
Decompile w_005 EntityWeaponAttack (Xeeynamo#1501)
Browse files Browse the repository at this point in the history
Decompiles `EntityWeaponAttack` of `w_005`.

Fixes `g_Entities` use in `w_033` to properly use the `PLAYER` macro.
  • Loading branch information
hohle authored Aug 12, 2024
1 parent 570147f commit cc278d8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
56 changes: 55 additions & 1 deletion src/weapon/w_005.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,61 @@ extern s32 g_HandId;
#define g_Animset w_005_1
#define g_Animset2 w_005_2

INCLUDE_ASM("weapon/nonmatchings/w_005", EntityWeaponAttack);
extern WeaponAnimation D_27000_8017B2F4[];

void EntityWeaponAttack(Entity* self) {
WeaponAnimation* anim;
s8 animIndex;

self->posX.val = PLAYER.posX.val;
self->posY.val = PLAYER.posY.val;
self->facingLeft = PLAYER.facingLeft;
animIndex = (self->params & 0x7fff) >> 8;
anim = &D_27000_8017B2F4[animIndex];

if (PLAYER.ext.player.anim >= anim->frameStart &&
PLAYER.ext.player.anim < (anim->frameStart + 7) &&
g_Player.unk46 != 0) {
if (self->step == 0) {
SetSpriteBank1(g_Animset);
self->animSet = ANIMSET_OVL(0x10);
self->palette = PAL_DRA(0x110);
self->unk5A = 0x64;
if (g_HandId != 0) {
self->animSet += 2;
self->palette += 0x18;
self->unk5A += 2;
}
self->palette += anim->palette;
self->flags = FLAG_UNK_20000 | FLAG_UNK_40000;
self->zPriority = PLAYER.zPriority - 2;
self->drawMode = DRAW_TPAGE2 | DRAW_TPAGE;
SetWeaponProperties(self, 0);
self->step++;
}
self->ext.weapon.anim = PLAYER.ext.player.anim - anim->frameStart;
if ((PLAYER.animFrameDuration == 1) &&
(PLAYER.animFrameIdx == anim->soundFrame)) {
g_api.PlaySfx(anim->soundId);
g_api.PlaySfx(SFX_ANIME_SWORD_B);
}
if (g_api.UpdateUnarmedAnim(anim->frameProps, anim->frames) < 0) {
DestroyEntity(self);
return;
}
} else {
DestroyEntity(self);
return;
}

if (PLAYER.animFrameIdx >= 6 && PLAYER.animFrameIdx < 8) {
self->hitboxOffX = self->hitboxOffX + 7;
self->hitboxWidth += 7;
}
self->drawFlags = PLAYER.drawFlags;
self->rotY = PLAYER.rotY;
self->rotPivotY = PLAYER.rotPivotY;
}

s32 func_ptr_80170004(Entity* self) {}

Expand Down
2 changes: 1 addition & 1 deletion src/weapon/w_033.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void EntityWeaponAttack(Entity* self) {
WeaponAnimation* anim;
s8 animIndex;

self->posX.val = g_Entities->posX.val;
self->posX.val = PLAYER.posX.val;
self->posY.val = PLAYER.posY.val;
self->facingLeft = PLAYER.facingLeft;
animIndex = (self->params & 0x7fff) >> 8;
Expand Down

0 comments on commit cc278d8

Please sign in to comment.