From c4132fe352dba533880c53e57c4867e22c4b3b7c Mon Sep 17 00:00:00 2001 From: Jonathan Hohle Date: Wed, 7 Aug 2024 10:05:56 -0700 Subject: [PATCH] Decompile `EntityWeaponAttack` for `w_033` --- src/weapon/w_033.c | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/weapon/w_033.c b/src/weapon/w_033.c index 4293220f87..d876789723 100644 --- a/src/weapon/w_033.c +++ b/src/weapon/w_033.c @@ -3,7 +3,61 @@ #include "weapon_private.h" #include "shared.h" -INCLUDE_ASM("weapon/nonmatchings/w_033", EntityWeaponAttack); +extern WeaponAnimation D_EB000_8017AC3C[2]; + +void EntityWeaponAttack(Entity* self) { + WeaponAnimation* anim; + s8 animIndex; + + self->posX.val = g_Entities->posX.val; + self->posY.val = PLAYER.posY.val; + self->facingLeft = PLAYER.facingLeft; + animIndex = (self->params & 0x7fff) >> 8; + anim = &D_EB000_8017AC3C[animIndex]; + + if (PLAYER.ext.player.anim >= anim->frameStart && + PLAYER.ext.player.anim < (anim->frameStart + 7) && g_Player.unk46) { + + 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 = FALL_TERMINAL_VELOCITY; + self->zPriority = PLAYER.zPriority - 2; + 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); + } + + if (PLAYER.animFrameIdx == 12 && PLAYER.animFrameDuration == 1) { + g_api.PlaySfx(anim->soundId); + g_api.PlaySfx(SFX_WEAPON_SWISH_B); + } + if (g_api.UpdateUnarmedAnim(anim->frameProps, anim->frames) < 0) { + DestroyEntity(self); + return; + } + } else { + DestroyEntity(self); + return; + } + + self->drawFlags = PLAYER.drawFlags; + self->rotY = PLAYER.rotY; + self->rotPivotY = PLAYER.rotPivotY; +} s32 func_ptr_80170004(Entity* self) {}