diff --git a/include/z64player.h b/include/z64player.h index dfa0be5215..27a4fe3fe2 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -695,6 +695,9 @@ 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 posA; // For melee weapons, this is the tip (furthest from the player hand) diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index c50265e731..20ff0e0354 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].posA, 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; @@ -1669,7 +1669,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve if (this->meleeWeaponState != 0) { Player_UpdateMeleeWeaponInfo(play, this, tipPositions); } else { - Math_Vec3f_Copy(&this->meleeWeaponInfo[0].posA, &tipPositions[0]); + Math_Vec3f_Copy(MELEE_WEAPON_INFO_TIP(&this->meleeWeaponInfo[0]), &tipPositions[0]); } } 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 8f586a5846..a3f35f0280 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 @@ -295,8 +295,8 @@ void BgYdanSp_FloorWebIdle(BgYdanSp* this, PlayState* play) { 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)) { - this->dyna.actor.home.pos.x = player->meleeWeaponInfo[0].posA.x; - this->dyna.actor.home.pos.z = player->meleeWeaponInfo[0].posA.z; + 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].posA); + 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].posA); + 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_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index ba05571f70..8e1fd609b7 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].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; + 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].posA.y); + this->posYTarget = MAX(player->actor.world.pos.y + 30.0f, MELEE_WEAPON_INFO_TIP(&player->meleeWeaponInfo[0])->y); EnButte_Turn(this); @@ -352,8 +354,9 @@ 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].posA.x, player->meleeWeaponInfo[0].posA.z, - this->actor.world.pos.x, this->actor.world.pos.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_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index f35ab0bd85..626d457214 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].posA, &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 8fa91e2f1d..11d202e51c 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -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].posA, - &this->meleeWeaponInfo[0].posB, &baseToTip); + 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].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); + 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].posA, &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)) { @@ -11473,8 +11474,8 @@ void Player_UpdateBurningDekuStick(PlayState* play, Player* this) { this->unk_85C = temp; } - func_8002836C(play, &this->meleeWeaponInfo[0].posA, &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) {