diff --git a/include/player.h b/include/player.h index 74a129a254..10fcd490b7 100644 --- a/include/player.h +++ b/include/player.h @@ -694,10 +694,13 @@ typedef struct PlayerAgeProperties { /* 0xCC */ LinkAnimationHeader* unk_CC[2]; } PlayerAgeProperties; // size = 0xD4 +#define MELEE_WEAPON_INFO_TIP(weaponInfo) (&(weaponInfo)->posA) +#define MELEE_WEAPON_INFO_BASE(weaponInfo) (&(weaponInfo)->posB) + typedef struct WeaponInfo { /* 0x00 */ s32 active; - /* 0x04 */ Vec3f tip; - /* 0x10 */ Vec3f base; + /* 0x04 */ Vec3f posA; // For melee weapons, this is the tip (furthest from the player hand) + /* 0x10 */ Vec3f posB; // For melee weapons, this is the base (near the player hand) } WeaponInfo; // size = 0x1C #define LEDGE_DIST_MAX 399.96002f @@ -1033,7 +1036,7 @@ s32 Player_OverrideLimbDrawGameplayFirstPerson(struct PlayState* play, s32 limbI Vec3s* rot, void* thisx); s32 Player_OverrideLimbDrawGameplayCrawling(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); -u8 func_80090480(struct PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase); +u8 Player_UpdateWeaponInfo(struct PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newPosA, Vec3f* newPosB); void Player_DrawGetItem(struct PlayState* play, Player* this); void Player_PostLimbDrawGameplay(struct PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); u32 Player_InitPauseDrawData(struct PlayState* play, u8* segment, SkelAnime* skelAnime); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 7358db96d5..d56eb84102 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -803,7 +803,7 @@ int Player_IsBurningStickInRange(PlayState* play, Vec3f* pos, f32 xzRange, f32 y s32 pad; if ((this->heldItemAction == PLAYER_IA_DEKU_STICK) && (this->unk_860 != 0)) { - Math_Vec3f_Diff(&this->meleeWeaponInfo[0].tip, pos, &diff); + Math_Vec3f_Diff(MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0]), pos, &diff); return ((SQ(diff.x) + SQ(diff.z)) <= SQ(xzRange)) && (0.0f <= diff.y) && (diff.y <= yRange); } else { return false; @@ -1444,30 +1444,42 @@ s32 Player_OverrideLimbDrawGameplayCrawling(PlayState* play, s32 limbIndex, Gfx* return false; } -u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase) { - if (weaponInfo->active == 0) { +/** + * Handles colliders for player weapons, by creating a quad collider each frame between the weapon's previous position + * and its new position. + * This position is given as a pair, `newPosA` and `newPosB`, representing two ends of a line that can be thought of as + * the active part of the weapon. Note that this line is not necessarily following the weapon's shape: for example + * arrows use a line perpendicular to the shaft. + * @param collider The quad collider to use for the weapon. + * @param newPosA One end of the line. For melee weapons, this is the tip. + * @param newPosB One end of the line. For melee weapons, this is the base. + * @return true if the weapon is active at a new position. + */ +u8 Player_UpdateWeaponInfo(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newPosA, + Vec3f* newPosB) { + if (!weaponInfo->active) { if (collider != NULL) { Collider_ResetQuadAT(play, &collider->base); } - Math_Vec3f_Copy(&weaponInfo->tip, newTip); - Math_Vec3f_Copy(&weaponInfo->base, newBase); - weaponInfo->active = 1; + Math_Vec3f_Copy(&weaponInfo->posA, newPosA); + Math_Vec3f_Copy(&weaponInfo->posB, newPosB); + weaponInfo->active = true; return true; - } else if ((weaponInfo->tip.x == newTip->x) && (weaponInfo->tip.y == newTip->y) && - (weaponInfo->tip.z == newTip->z) && (weaponInfo->base.x == newBase->x) && - (weaponInfo->base.y == newBase->y) && (weaponInfo->base.z == newBase->z)) { + } else if ((weaponInfo->posA.x == newPosA->x) && (weaponInfo->posA.y == newPosA->y) && + (weaponInfo->posA.z == newPosA->z) && (weaponInfo->posB.x == newPosB->x) && + (weaponInfo->posB.y == newPosB->y) && (weaponInfo->posB.z == newPosB->z)) { if (collider != NULL) { Collider_ResetQuadAT(play, &collider->base); } return false; } else { if (collider != NULL) { - Collider_SetQuadVertices(collider, newBase, newTip, &weaponInfo->base, &weaponInfo->tip); + Collider_SetQuadVertices(collider, newPosB, newPosA, &weaponInfo->posB, &weaponInfo->posA); CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); } - Math_Vec3f_Copy(&weaponInfo->base, newBase); - Math_Vec3f_Copy(&weaponInfo->tip, newTip); - weaponInfo->active = 1; + Math_Vec3f_Copy(&weaponInfo->posB, newPosB); + Math_Vec3f_Copy(&weaponInfo->posA, newPosA); + weaponInfo->active = true; return true; } } @@ -1496,33 +1508,35 @@ void Player_UpdateShieldCollider(PlayState* play, Player* this, ColliderQuad* co } } -Vec3f D_80126080 = { 5000.0f, 400.0f, 0.0f }; -Vec3f D_8012608C = { 5000.0f, -400.0f, 1000.0f }; -Vec3f D_80126098 = { 5000.0f, 1400.0f, -1000.0f }; +// Positions for the tip of melee weapons, in the left hand limb's own model space. +Vec3f sMeleeWeaponTipOffsetFromLeftHand0 = { 5000.0f, 400.0f, 0.0f }; +Vec3f sMeleeWeaponTipOffsetFromLeftHand1 = { 5000.0f, -400.0f, 1000.0f }; +Vec3f sMeleeWeaponTipOffsetFromLeftHand2 = { 5000.0f, 1400.0f, -1000.0f }; -Vec3f D_801260A4[3] = { - { 0.0f, 400.0f, 0.0f }, - { 0.0f, 1400.0f, -1000.0f }, - { 0.0f, -400.0f, 1000.0f }, -}; +// Positions for the base of melee weapons, in the left hand limb's own model space. +Vec3f sMeleeWeaponBaseOffsetFromLeftHand0 = { 0.0f, 400.0f, 0.0f }; +Vec3f sMeleeWeaponBaseOffsetFromLeftHand1 = { 0.0f, 1400.0f, -1000.0f }; +Vec3f sMeleeWeaponBaseOffsetFromLeftHand2 = { 0.0f, -400.0f, 1000.0f }; -void func_800906D4(PlayState* play, Player* this, Vec3f* newTipPos) { - Vec3f newBasePos[3]; +void Player_UpdateMeleeWeaponInfo(PlayState* play, Player* this, Vec3f* newTipPositions) { + Vec3f newBasePositions[3]; - Matrix_MultVec3f(&D_801260A4[0], &newBasePos[0]); - Matrix_MultVec3f(&D_801260A4[1], &newBasePos[1]); - Matrix_MultVec3f(&D_801260A4[2], &newBasePos[2]); + Matrix_MultVec3f(&sMeleeWeaponBaseOffsetFromLeftHand0, &newBasePositions[0]); + Matrix_MultVec3f(&sMeleeWeaponBaseOffsetFromLeftHand1, &newBasePositions[1]); + Matrix_MultVec3f(&sMeleeWeaponBaseOffsetFromLeftHand2, &newBasePositions[2]); - if (func_80090480(play, NULL, &this->meleeWeaponInfo[0], &newTipPos[0], &newBasePos[0]) && + if (Player_UpdateWeaponInfo(play, NULL, &this->meleeWeaponInfo[0], &newTipPositions[0], &newBasePositions[0]) && !(this->stateFlags1 & PLAYER_STATE1_SHIELDING)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->meleeWeaponEffectIndex), &this->meleeWeaponInfo[0].tip, - &this->meleeWeaponInfo[0].base); + EffectBlure_AddVertex(Effect_GetByIndex(this->meleeWeaponEffectIndex), &this->meleeWeaponInfo[0].posA, + &this->meleeWeaponInfo[0].posB); } if ((this->meleeWeaponState > 0) && ((this->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) || (this->stateFlags2 & PLAYER_STATE2_17))) { - func_80090480(play, &this->meleeWeaponQuads[0], &this->meleeWeaponInfo[1], &newTipPos[1], &newBasePos[1]); - func_80090480(play, &this->meleeWeaponQuads[1], &this->meleeWeaponInfo[2], &newTipPos[2], &newBasePos[2]); + Player_UpdateWeaponInfo(play, &this->meleeWeaponQuads[0], &this->meleeWeaponInfo[1], &newTipPositions[1], + &newBasePositions[1]); + Player_UpdateWeaponInfo(play, &this->meleeWeaponQuads[1], &this->meleeWeaponInfo[2], &newTipPositions[2], + &newBasePositions[2]); } } @@ -1553,20 +1567,20 @@ void Player_DrawGetItem(PlayState* play, Player* this) { } } -void func_80090A28(Player* this, Vec3f* vecs) { - D_8012608C.x = D_80126080.x; +void Player_CalcMeleeWeaponTipPositions(Player* this, Vec3f* tipPositions) { + sMeleeWeaponTipOffsetFromLeftHand1.x = sMeleeWeaponTipOffsetFromLeftHand0.x; if (this->unk_845 >= 3) { this->unk_845++; - D_8012608C.x *= 1.0f + ((9 - this->unk_845) * 0.1f); + sMeleeWeaponTipOffsetFromLeftHand1.x *= 1.0f + ((9 - this->unk_845) * 0.1f); } - D_8012608C.x += 1200.0f; - D_80126098.x = D_8012608C.x; + sMeleeWeaponTipOffsetFromLeftHand1.x += 1200.0f; + sMeleeWeaponTipOffsetFromLeftHand2.x = sMeleeWeaponTipOffsetFromLeftHand1.x; - Matrix_MultVec3f(&D_80126080, &vecs[0]); - Matrix_MultVec3f(&D_8012608C, &vecs[1]); - Matrix_MultVec3f(&D_80126098, &vecs[2]); + Matrix_MultVec3f(&sMeleeWeaponTipOffsetFromLeftHand0, &tipPositions[0]); + Matrix_MultVec3f(&sMeleeWeaponTipOffsetFromLeftHand1, &tipPositions[1]); + Matrix_MultVec3f(&sMeleeWeaponTipOffsetFromLeftHand2, &tipPositions[2]); } void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) { @@ -1608,7 +1622,7 @@ void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) { } // Coordinates of the player focus position, in the head limb's own model space. -Vec3f sPlayerFocusHeadLimbModelPos = { 1100.0f, -700.0f, 0.0f }; +Vec3f sPlayerFocusOffsetFromHead = { 1100.0f, -700.0f, 0.0f }; f32 sMeleeWeaponLengths[] = { 0.0f, // not a melee weapon @@ -1651,17 +1665,17 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve Math_Vec3f_Copy(&this->leftHandPos, sCurBodyPartPos); if (this->itemAction == PLAYER_IA_DEKU_STICK) { - Vec3f sp124[3]; + Vec3f tipPositions[3]; OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2633); if (this->actor.scale.y >= 0.0f) { - D_80126080.x = this->unk_85C * 5000.0f; - func_80090A28(this, sp124); + sMeleeWeaponTipOffsetFromLeftHand0.x = this->unk_85C * 5000.0f; + Player_CalcMeleeWeaponTipPositions(this, tipPositions); if (this->meleeWeaponState != 0) { - func_800906D4(play, this, sp124); + Player_UpdateMeleeWeaponInfo(play, this, tipPositions); } else { - Math_Vec3f_Copy(&this->meleeWeaponInfo[0].tip, &sp124[0]); + Math_Vec3f_Copy(MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0]), &tipPositions[0]); } } @@ -1674,16 +1688,16 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2656); } else if ((this->actor.scale.y >= 0.0f) && (this->meleeWeaponState != 0)) { - Vec3f spE4[3]; + Vec3f tipPositions[3]; if (Player_HoldsBrokenKnife(this)) { - D_80126080.x = 1500.0f; + sMeleeWeaponTipOffsetFromLeftHand0.x = 1500.0f; } else { - D_80126080.x = sMeleeWeaponLengths[Player_GetMeleeWeaponHeld(this)]; + sMeleeWeaponTipOffsetFromLeftHand0.x = sMeleeWeaponLengths[Player_GetMeleeWeaponHeld(this)]; } - func_80090A28(this, spE4); - func_800906D4(play, this, spE4); + Player_CalcMeleeWeaponTipPositions(this, tipPositions); + Player_UpdateMeleeWeaponInfo(play, this, tipPositions); } else if ((*dList != NULL) && (this->leftHandType == PLAYER_MODELTYPE_LH_BOTTLE)) { //! @bug When Player is actively using shield, the `itemAction` value will be set to -1. //! If shield is used at the same time a bottle is in hand, `Player_ActionToBottle` will @@ -1854,7 +1868,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve Matrix_Get(&this->shieldMf); } } else if (limbIndex == PLAYER_LIMB_HEAD) { - Matrix_MultVec3f(&sPlayerFocusHeadLimbModelPos, &this->actor.focus.pos); + Matrix_MultVec3f(&sPlayerFocusOffsetFromHead, &this->actor.focus.pos); } else { // Position of Link's foot, in the foot limb's own model space. static Vec3f sLeftRightFootLimbModelFootPos[] = { diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 62594850af..3e8127024b 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -337,8 +337,8 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { ArmsHook* this = (ArmsHook*)thisx; Player* player = GET_PLAYER(play); Vec3f sp78; - Vec3f hookNewTip; - Vec3f hookNewBase; + Vec3f posA; + Vec3f posB; f32 sp5C; f32 sp58; @@ -349,16 +349,16 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { Matrix_MultVec3f(&D_80865B70, &this->unk_1E8); - Matrix_MultVec3f(&D_80865B88, &hookNewTip); - Matrix_MultVec3f(&D_80865B94, &hookNewBase); - this->hookInfo.active = 0; + Matrix_MultVec3f(&D_80865B88, &posA); + Matrix_MultVec3f(&D_80865B94, &posB); + this->weaponInfo.active = false; } else { Matrix_MultVec3f(&D_80865B7C, &this->unk_1E8); - Matrix_MultVec3f(&D_80865BA0, &hookNewTip); - Matrix_MultVec3f(&D_80865BAC, &hookNewBase); + Matrix_MultVec3f(&D_80865BA0, &posA); + Matrix_MultVec3f(&D_80865BAC, &posB); } - func_80090480(play, &this->collider, &this->hookInfo, &hookNewTip, &hookNewBase); + Player_UpdateWeaponInfo(play, &this->collider, &this->weaponInfo, &posA, &posB); Gfx_SetupDL_25Opa(play->state.gfxCtx); MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx, "../z_arms_hook.c", 895); gSPDisplayList(POLY_OPA_DISP++, gLinkAdultHookshotTipDL); diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h index d06019f040..fe85e5693a 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -12,7 +12,7 @@ typedef void (*ArmsHookActionFunc)(struct ArmsHook*, struct PlayState*); typedef struct ArmsHook { /* 0x0000 */ Actor actor; /* 0x014C */ ColliderQuad collider; - /* 0x01CC */ WeaponInfo hookInfo; + /* 0x01CC */ WeaponInfo weaponInfo; /* 0x01E8 */ Vec3f unk_1E8; /* 0x01F4 */ Vec3f unk_1F4; /* 0x0200 */ Actor* attachedActor; diff --git a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c index 9e6fca4b52..723852f33b 100644 --- a/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c +++ b/src/overlays/actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c @@ -294,9 +294,9 @@ void BgYdanSp_FloorWebIdle(BgYdanSp* this, PlayState* play) { webPos.x = this->dyna.actor.world.pos.x; webPos.y = this->dyna.actor.world.pos.y - 50.0f; webPos.z = this->dyna.actor.world.pos.z; - if (Player_IsBurningStickInRange(play, &webPos, 70.0f, 50.0f) != 0) { - this->dyna.actor.home.pos.x = player->meleeWeaponInfo[0].tip.x; - this->dyna.actor.home.pos.z = player->meleeWeaponInfo[0].tip.z; + if (Player_IsBurningStickInRange(play, &webPos, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->x; + this->dyna.actor.home.pos.z = MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->z; BgYdanSp_BurnWeb(this, play); return; } @@ -412,10 +412,10 @@ void BgYdanSp_WallWebIdle(BgYdanSp* this, PlayState* play) { this->dyna.actor.home.pos.y = this->dyna.actor.world.pos.y + 80.0f; BgYdanSp_BurnWeb(this, play); } else if (player->heldItemAction == PLAYER_IA_DEKU_STICK && player->unk_860 != 0) { - Actor_WorldToActorCoords(&this->dyna.actor, &sp30, &player->meleeWeaponInfo[0].tip); + Actor_WorldToActorCoords(&this->dyna.actor, &sp30, MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])); if (fabsf(sp30.x) < 100.0f && sp30.z < 1.0f && sp30.y < 200.0f) { OnePointCutscene_Init(play, 3020, 40, &this->dyna.actor, CAM_ID_MAIN); - Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->meleeWeaponInfo[0].tip); + Math_Vec3f_Copy(&this->dyna.actor.home.pos, MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])); BgYdanSp_BurnWeb(this, play); } } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index c4a90bec05..48517bfe41 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -429,36 +429,36 @@ void EnArrow_Update(Actor* thisx, PlayState* play) { } void func_809B4800(EnArrow* this, PlayState* play) { - static Vec3f D_809B4E88 = { 0.0f, 400.0f, 1500.0f }; - static Vec3f D_809B4E94 = { 0.0f, -400.0f, 1500.0f }; + static Vec3f sPosAOffset = { 0.0f, 400.0f, 1500.0f }; + static Vec3f sPosBOffset = { 0.0f, -400.0f, 1500.0f }; static Vec3f D_809B4EA0 = { 0.0f, 0.0f, -300.0f }; - Vec3f sp44; - Vec3f sp38; + Vec3f posA; + Vec3f posB; s32 addBlureVertex; Matrix_MultVec3f(&D_809B4EA0, &this->unk_21C); if (EnArrow_Fly == this->actionFunc) { - Matrix_MultVec3f(&D_809B4E88, &sp44); - Matrix_MultVec3f(&D_809B4E94, &sp38); + Matrix_MultVec3f(&sPosAOffset, &posA); + Matrix_MultVec3f(&sPosBOffset, &posB); if (this->actor.params <= ARROW_SEED) { addBlureVertex = this->actor.params <= ARROW_LIGHT; if (this->hitActor == NULL) { - addBlureVertex &= func_80090480(play, &this->collider, &this->weaponInfo, &sp44, &sp38); + addBlureVertex &= Player_UpdateWeaponInfo(play, &this->collider, &this->weaponInfo, &posA, &posB); } else { if (addBlureVertex) { - if ((sp44.x == this->weaponInfo.tip.x) && (sp44.y == this->weaponInfo.tip.y) && - (sp44.z == this->weaponInfo.tip.z) && (sp38.x == this->weaponInfo.base.x) && - (sp38.y == this->weaponInfo.base.y) && (sp38.z == this->weaponInfo.base.z)) { + if ((posA.x == this->weaponInfo.posA.x) && (posA.y == this->weaponInfo.posA.y) && + (posA.z == this->weaponInfo.posA.z) && (posB.x == this->weaponInfo.posB.x) && + (posB.y == this->weaponInfo.posB.y) && (posB.z == this->weaponInfo.posB.z)) { addBlureVertex = false; } } } if (addBlureVertex) { - EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp44, &sp38); + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &posA, &posB); } } } diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index d70422b1d0..f679755105 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -257,22 +257,22 @@ void EnBoom_Update(Actor* thisx, PlayState* play) { } void EnBoom_Draw(Actor* thisx, PlayState* play) { - static Vec3f sMultVec1 = { -960.0f, 0.0f, 0.0f }; - static Vec3f sMultVec2 = { 960.0f, 0.0f, 0.0f }; + static Vec3f sPosAOffset = { -960.0f, 0.0f, 0.0f }; + static Vec3f sPosBOffset = { 960.0f, 0.0f, 0.0f }; EnBoom* this = (EnBoom*)thisx; - Vec3f vec1; - Vec3f vec2; + Vec3f posA; + Vec3f posB; OPEN_DISPS(play->state.gfxCtx, "../z_en_boom.c", 567); Matrix_RotateY(BINANG_TO_RAD(this->actor.world.rot.y), MTXMODE_APPLY); Matrix_RotateZ(BINANG_TO_RAD(0x1F40), MTXMODE_APPLY); Matrix_RotateX(BINANG_TO_RAD(this->actor.world.rot.x), MTXMODE_APPLY); - Matrix_MultVec3f(&sMultVec1, &vec1); - Matrix_MultVec3f(&sMultVec2, &vec2); + Matrix_MultVec3f(&sPosAOffset, &posA); + Matrix_MultVec3f(&sPosBOffset, &posB); - if (func_80090480(play, &this->collider, &this->boomerangInfo, &vec1, &vec2)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &vec1, &vec2); + if (Player_UpdateWeaponInfo(play, &this->collider, &this->weaponInfo, &posA, &posB)) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &posA, &posB); } Gfx_SetupDL_25Opa(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.h b/src/overlays/actors/ovl_En_Boom/z_en_boom.h index f62edc7654..83b960bc66 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -17,7 +17,7 @@ typedef struct EnBoom { /* 0x01D4 */ u8 returnTimer; // returns to Link when 0 /* 0x01D5 */ u8 activeTimer; // increments once every update /* 0x01D8 */ s32 effectIndex; - /* 0x01DC */ WeaponInfo boomerangInfo; + /* 0x01DC */ WeaponInfo weaponInfo; /* 0x01F8 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x01FC diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index 58a5392306..888ef865e1 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -318,9 +318,11 @@ void EnButte_FollowLink(EnButte* this, PlayState* play) { minAnimSpeed = 0.0f; if ((this->flightParamsIdx != 0) && (this->timer < 12)) { - swordTip.x = player->meleeWeaponInfo[0].tip.x + Math_SinS(player->actor.shape.rot.y) * 10.0f; - swordTip.y = player->meleeWeaponInfo[0].tip.y; - swordTip.z = player->meleeWeaponInfo[0].tip.z + Math_CosS(player->actor.shape.rot.y) * 10.0f; + swordTip.x = + MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->x + Math_SinS(player->actor.shape.rot.y) * 10.0f; + swordTip.y = MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->y; + swordTip.z = + MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->z + Math_CosS(player->actor.shape.rot.y) * 10.0f; yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &swordTip) + (s16)(Rand_ZeroOne() * D_809CE410); if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 2000) != 0) { @@ -332,7 +334,7 @@ void EnButte_FollowLink(EnButte* this, PlayState* play) { } } - this->posYTarget = MAX(player->actor.world.pos.y + 30.0f, player->meleeWeaponInfo[0].tip.y); + this->posYTarget = MAX(player->actor.world.pos.y + 30.0f, MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->y); EnButte_Turn(this); @@ -352,7 +354,8 @@ void EnButte_FollowLink(EnButte* this, PlayState* play) { (this->swordDownTimer <= 0) && (distSqFromHome < SQ(320.0f)))) { EnButte_SetupFlyAround(this); } else if (distSqFromHome > SQ(240.0f)) { - distSqFromSword = Math3D_Dist2DSq(player->meleeWeaponInfo[0].tip.x, player->meleeWeaponInfo[0].tip.z, + distSqFromSword = Math3D_Dist2DSq(MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->x, + MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->z, this->actor.world.pos.x, this->actor.world.pos.z); if (distSqFromSword < SQ(60.0f)) { EnButte_SetupTransformIntoFairy(this); diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/src/overlays/actors/ovl_En_Mb/z_en_mb.c index 8c1413bc0f..56e96bf293 100644 --- a/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ b/src/overlays/actors/ovl_En_Mb/z_en_mb.c @@ -1514,7 +1514,7 @@ void EnMb_Update(Actor* thisx, PlayState* play) { void EnMb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f unused = { 1100.0f, -700.0f, 0.0f }; static Vec3f feetPos = { 0.0f, 0.0f, 0.0f }; - static Vec3f effSpawnModelPos = { 0.0f, -8000.0f, 0.0f }; + static Vec3f effSpawnOffsetFromLeftHand = { 0.0f, -8000.0f, 0.0f }; static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s32 bodyPart = -1; EnMb* this = (EnMb*)thisx; @@ -1522,7 +1522,7 @@ void EnMb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, if (this->actor.params == ENMB_TYPE_CLUB) { if (limbIndex == ENMB_LIMB_LHAND) { - Matrix_MultVec3f(&effSpawnModelPos, &this->effSpawnPos); + Matrix_MultVec3f(&effSpawnOffsetFromLeftHand, &this->effSpawnPos); if (this->attack > ENMB_ATTACK_NONE) { EnMb_ClubUpdateAttackCollider(&this->actor, play); } diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 9409ee0a52..ccebc0615e 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -188,7 +188,7 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { interactionType = 1; } } else if (player->heldItemAction == PLAYER_IA_DEKU_STICK) { - Math_Vec3f_Diff(&player->meleeWeaponInfo[0].tip, &this->actor.world.pos, &tipToFlame); + Math_Vec3f_Diff(MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0]), &this->actor.world.pos, &tipToFlame); tipToFlame.y -= 67.0f; if ((SQ(tipToFlame.x) + SQ(tipToFlame.y) + SQ(tipToFlame.z)) < SQ(20.0f)) { interactionType = -1; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e6e017490a..68a2683ca9 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -1766,7 +1766,7 @@ void Player_ApplyYawFromAnim(Player* this) { void func_80832318(Player* this) { this->stateFlags2 &= ~PLAYER_STATE2_17; this->meleeWeaponState = 0; - this->meleeWeaponInfo[0].active = this->meleeWeaponInfo[1].active = this->meleeWeaponInfo[2].active = 0; + this->meleeWeaponInfo[0].active = this->meleeWeaponInfo[1].active = this->meleeWeaponInfo[2].active = false; } void func_80832340(PlayState* play, Player* this) { @@ -9070,7 +9070,7 @@ s32 func_80842DF4(PlayState* play, Player* this) { s32 bgId; Vec3f sp68; Vec3f sp5C; - Vec3f sp50; + Vec3f baseToTip; s32 temp1; s32 surfaceMaterial; @@ -9080,18 +9080,19 @@ s32 func_80842DF4(PlayState* play, Player* this) { !(this->meleeWeaponQuads[1].base.atFlags & AT_BOUNCED)) { if (this->skelAnime.curFrame >= 2.0f) { - phi_f2 = Math_Vec3f_DistXYZAndStoreDiff(&this->meleeWeaponInfo[0].tip, - &this->meleeWeaponInfo[0].base, &sp50); + phi_f2 = + Math_Vec3f_DistXYZAndStoreDiff(MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0]), + MELEE_WEAPON_INFO_BASE(&this->meleeWeaponInfo[0]), &baseToTip); if (phi_f2 != 0.0f) { phi_f2 = (phi_f2 + 10.0f) / phi_f2; } - sp68.x = this->meleeWeaponInfo[0].tip.x + (sp50.x * phi_f2); - sp68.y = this->meleeWeaponInfo[0].tip.y + (sp50.y * phi_f2); - sp68.z = this->meleeWeaponInfo[0].tip.z + (sp50.z * phi_f2); + sp68.x = MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0])->x + (baseToTip.x * phi_f2); + sp68.y = MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0])->y + (baseToTip.y * phi_f2); + sp68.z = MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0])->z + (baseToTip.z * phi_f2); - if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, &this->meleeWeaponInfo[0].tip, &sp5C, &groundPoly, - true, false, false, true, &bgId) && + if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0]), + &sp5C, &groundPoly, true, false, false, true, &bgId) && !SurfaceType_IsIgnoredByEntities(&play->colCtx, groundPoly, bgId) && (SurfaceType_GetFloorType(&play->colCtx, groundPoly, bgId) != FLOOR_TYPE_6) && (func_8002F9EC(play, &this->actor, groundPoly, bgId, &sp5C) == 0)) { @@ -11474,8 +11475,8 @@ void Player_UpdateBurningDekuStick(PlayState* play, Player* this) { this->unk_85C = temp; } - func_8002836C(play, &this->meleeWeaponInfo[0].tip, &D_808547A4, &D_808547B0, &D_808547BC, &D_808547C0, - temp * 200.0f, 0, 8); + func_8002836C(play, MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0]), &D_808547A4, &D_808547B0, &D_808547BC, + &D_808547C0, temp * 200.0f, 0, 8); } void Player_UpdateBodyShock(PlayState* play, Player* this) {