From 658c0b8ed69e9ca0510690b5682150f09aac9c28 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Mon, 11 Dec 2023 15:59:39 +0100 Subject: [PATCH 1/3] WeaponInfo docs --- include/functions.h | 2 +- include/z64player.h | 4 +- src/code/z_player_lib.c | 112 ++++++++++-------- .../actors/ovl_Arms_Hook/z_arms_hook.c | 16 +-- .../actors/ovl_Arms_Hook/z_arms_hook.h | 2 +- .../actors/ovl_Bg_Ydan_Sp/z_bg_ydan_sp.c | 10 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 22 ++-- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 16 +-- src/overlays/actors/ovl_En_Boom/z_en_boom.h | 2 +- src/overlays/actors/ovl_En_Butte/z_en_butte.c | 10 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 2 +- .../actors/ovl_player_actor/z_player.c | 18 +-- 12 files changed, 115 insertions(+), 101 deletions(-) diff --git a/include/functions.h b/include/functions.h index 62ca9d50034..f4af4e8462a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1026,7 +1026,7 @@ s32 Player_OverrideLimbDrawGameplayFirstPerson(PlayState* play, s32 limbIndex, G void* thisx); s32 Player_OverrideLimbDrawGameplayCrawling(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx); -u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase); +u8 Player_UpdateWeaponInfo(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newPosA, Vec3f* newPosB); void Player_DrawGetItem(PlayState* play, Player* this); void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx); u32 Player_InitPauseDrawData(PlayState* play, u8* segment, SkelAnime* skelAnime); diff --git a/include/z64player.h b/include/z64player.h index 861f90081ff..7e67de2b14b 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -587,8 +587,8 @@ typedef struct { typedef struct { /* 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 diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index feee098caa8..a6a63b32800 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -646,7 +646,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(&this->meleeWeaponInfo[0].posA, pos, &diff); return ((SQ(diff.x) + SQ(diff.z)) <= SQ(xzRange)) && (0.0f <= diff.y) && (diff.y <= yRange); } else { return false; @@ -1213,30 +1213,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; } } @@ -1265,33 +1277,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 sMeleeWeaponTipLeftHandLimbModelPos0 = { 5000.0f, 400.0f, 0.0f }; +Vec3f sMeleeWeaponTipLeftHandLimbModelPos1 = { 5000.0f, -400.0f, 1000.0f }; +Vec3f sMeleeWeaponTipLeftHandLimbModelPos2 = { 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 sMeleeWeaponBaseLeftHandLimbModelPos0 = { 0.0f, 400.0f, 0.0f }; +Vec3f sMeleeWeaponBaseLeftHandLimbModelPos1 = { 0.0f, 1400.0f, -1000.0f }; +Vec3f sMeleeWeaponBaseLeftHandLimbModelPos2 = { 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(&sMeleeWeaponBaseLeftHandLimbModelPos0, &newBasePositions[0]); + Matrix_MultVec3f(&sMeleeWeaponBaseLeftHandLimbModelPos1, &newBasePositions[1]); + Matrix_MultVec3f(&sMeleeWeaponBaseLeftHandLimbModelPos2, &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_22)) { - 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]); } } @@ -1322,20 +1336,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) { + sMeleeWeaponTipLeftHandLimbModelPos1.x = sMeleeWeaponTipLeftHandLimbModelPos0.x; if (this->unk_845 >= 3) { this->unk_845++; - D_8012608C.x *= 1.0f + ((9 - this->unk_845) * 0.1f); + sMeleeWeaponTipLeftHandLimbModelPos1.x *= 1.0f + ((9 - this->unk_845) * 0.1f); } - D_8012608C.x += 1200.0f; - D_80126098.x = D_8012608C.x; + sMeleeWeaponTipLeftHandLimbModelPos1.x += 1200.0f; + sMeleeWeaponTipLeftHandLimbModelPos2.x = sMeleeWeaponTipLeftHandLimbModelPos1.x; - Matrix_MultVec3f(&D_80126080, &vecs[0]); - Matrix_MultVec3f(&D_8012608C, &vecs[1]); - Matrix_MultVec3f(&D_80126098, &vecs[2]); + Matrix_MultVec3f(&sMeleeWeaponTipLeftHandLimbModelPos0, &tipPositions[0]); + Matrix_MultVec3f(&sMeleeWeaponTipLeftHandLimbModelPos1, &tipPositions[1]); + Matrix_MultVec3f(&sMeleeWeaponTipLeftHandLimbModelPos2, &tipPositions[2]); } void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) { @@ -1457,17 +1471,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); + sMeleeWeaponTipLeftHandLimbModelPos0.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(&this->meleeWeaponInfo[0].posA, &tipPositions[0]); } } @@ -1481,16 +1495,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; + sMeleeWeaponTipLeftHandLimbModelPos0.x = 1500.0f; } else { - D_80126080.x = sMeleeWeaponLengths[Player_GetMeleeWeaponHeld(this)]; + sMeleeWeaponTipLeftHandLimbModelPos0.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)) { Color_RGB8* bottleColor = &sBottleColors[Player_ActionToBottle(this, this->itemAction)]; 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 d78418fa562..3fb3c66549b 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -300,8 +300,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; @@ -310,16 +310,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); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_arms_hook.c", 895), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 b624599a53d..53fd8ea9df8 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -11,7 +11,7 @@ typedef void (*ArmsHookActionFunc)(struct ArmsHook*, 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* grabbed; 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 2047230a58d..d604952447d 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 @@ -277,9 +277,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 = player->meleeWeaponInfo[0].posA.x; + this->dyna.actor.home.pos.z = player->meleeWeaponInfo[0].posA.z; BgYdanSp_BurnWeb(this, play); return; } @@ -395,10 +395,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) { - func_8002DBD0(&this->dyna.actor, &sp30, &player->meleeWeaponInfo[0].tip); + func_8002DBD0(&this->dyna.actor, &sp30, &player->meleeWeaponInfo[0].posA); 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, &player->meleeWeaponInfo[0].posA); 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 fafaaa5aaa3..3c5493fd270 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -413,36 +413,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 sPosAModel = { 0.0f, 400.0f, 1500.0f }; + static Vec3f sPosBModel = { 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(&sPosAModel, &posA); + Matrix_MultVec3f(&sPosBModel, &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 6103793a3f9..607b1436e79 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -247,22 +247,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 sPosAModel = { -960.0f, 0.0f, 0.0f }; + static Vec3f sPosBModel = { 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(&sPosAModel, &posA); + Matrix_MultVec3f(&sPosBModel, &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 4284063726d..f795a49fda9 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -16,7 +16,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 32087b23d30..2845eaadea6 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -304,9 +304,9 @@ 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 = player->meleeWeaponInfo[0].posA.x + Math_SinS(player->actor.shape.rot.y) * 10.0f; + swordTip.y = player->meleeWeaponInfo[0].posA.y; + swordTip.z = player->meleeWeaponInfo[0].posA.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) { @@ -318,7 +318,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, player->meleeWeaponInfo[0].posA.y); EnButte_Turn(this); @@ -338,7 +338,7 @@ 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(player->meleeWeaponInfo[0].posA.x, player->meleeWeaponInfo[0].posA.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_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 9f3e4302404..3c470309e84 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -176,7 +176,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(&player->meleeWeaponInfo[0].posA, &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 68b57faca3b..b1abb4a49be 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -1647,7 +1647,7 @@ void func_808322FC(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) { @@ -8385,7 +8385,7 @@ s32 func_80842DF4(PlayState* play, Player* this) { s32 bgId; Vec3f sp68; Vec3f sp5C; - Vec3f sp50; + Vec3f baseToTip; s32 temp1; s32 surfaceMaterial; @@ -8395,17 +8395,17 @@ 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(&this->meleeWeaponInfo[0].posA, + &this->meleeWeaponInfo[0].posB, &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 = this->meleeWeaponInfo[0].posA.x + (baseToTip.x * phi_f2); + sp68.y = this->meleeWeaponInfo[0].posA.y + (baseToTip.y * phi_f2); + sp68.z = this->meleeWeaponInfo[0].posA.z + (baseToTip.z * phi_f2); - if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, &this->meleeWeaponInfo[0].tip, &sp5C, &groundPoly, + if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, &this->meleeWeaponInfo[0].posA, &sp5C, &groundPoly, true, false, false, true, &bgId) && !SurfaceType_IsIgnoredByEntities(&play->colCtx, groundPoly, bgId) && (SurfaceType_GetFloorType(&play->colCtx, groundPoly, bgId) != FLOOR_TYPE_6) && @@ -10705,7 +10705,7 @@ void func_80848A04(PlayState* play, Player* this) { this->unk_85C = temp; } - func_8002836C(play, &this->meleeWeaponInfo[0].tip, &D_808547A4, &D_808547B0, &D_808547BC, &D_808547C0, + func_8002836C(play, &this->meleeWeaponInfo[0].posA, &D_808547A4, &D_808547B0, &D_808547BC, &D_808547C0, temp * 200.0f, 0, 8); } From be4dc0156a8d77c81f7cec9fc62fdf7d3bb240ef Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Mon, 5 Feb 2024 22:28:53 +0100 Subject: [PATCH 2/3] format --- src/overlays/actors/ovl_player_actor/z_player.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index bcf03e75da5..5030c55dc49 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -8416,8 +8416,8 @@ s32 func_80842DF4(PlayState* play, Player* this) { sp68.y = this->meleeWeaponInfo[0].posA.y + (baseToTip.y * phi_f2); sp68.z = this->meleeWeaponInfo[0].posA.z + (baseToTip.z * phi_f2); - if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, &this->meleeWeaponInfo[0].posA, &sp5C, &groundPoly, - true, false, false, true, &bgId) && + if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, &this->meleeWeaponInfo[0].posA, &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)) { From 4191a647f74b31c1248a89aaa32b6ce816eeb341 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Wed, 4 Sep 2024 20:13:24 +0200 Subject: [PATCH 3/3] disasm metadata --- tools/disasm/ntsc-1.2/functions.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/disasm/ntsc-1.2/functions.txt b/tools/disasm/ntsc-1.2/functions.txt index 75ffeb36b0c..fcdb715a44f 100644 --- a/tools/disasm/ntsc-1.2/functions.txt +++ b/tools/disasm/ntsc-1.2/functions.txt @@ -1472,12 +1472,12 @@ Player_OverrideLimbDrawGameplayCommon = 0x8007ADD0; // type:func Player_OverrideLimbDrawGameplayDefault = 0x8007B124; // type:func Player_OverrideLimbDrawGameplayFirstPerson = 0x8007B410; // type:func Player_OverrideLimbDrawGameplayCrawling = 0x8007B560; // type:func -func_80090480 = 0x8007B5A4; // type:func +Player_UpdateWeaponInfo = 0x8007B5A4; // type:func Player_UpdateShieldCollider = 0x8007B72C; // type:func -func_800906D4 = 0x8007B800; // type:func +Player_UpdateMeleeWeaponInfo = 0x8007B800; // type:func Player_DrawGetItemImpl = 0x8007B910; // type:func Player_DrawGetItem = 0x8007BAA4; // type:func -func_80090A28 = 0x8007BB1C; // type:func +Player_CalcMeleeWeaponTipPositions = 0x8007BB1C; // type:func Player_DrawHookshotReticle = 0x8007BBF0; // type:func Player_PostLimbDrawGameplay = 0x8007BDC4; // type:func Player_InitPauseDrawData = 0x8007C72C; // type:func