From 25ceca0fbf9f24625fad531afe0490baf0e1c149 Mon Sep 17 00:00:00 2001 From: RaelCappra Date: Sat, 22 Apr 2023 22:59:34 -0300 Subject: [PATCH] Enhancement: Aiming reticle for the bow/slingshot (#2715) * Bow reticle enhancement * Menu bar checkbox * fix * simplify bow/slingshot reticle logic * Comment on RETICLE_MAX * Tooltip clarity update --------- Co-authored-by: briaguya --- soh/soh/GameMenuBar.cpp | 2 ++ soh/src/code/z_player_lib.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index 48e5ea682..483d93c6f 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -503,6 +503,8 @@ namespace GameMenuBar { UIWidgets::Tooltip("Explosions are now a static size, like in Majora's Mask and OoT3D. Makes bombchu hovering much easier."); UIWidgets::PaddedEnhancementCheckbox("Prevent Bombchus Forcing First-Person", "gDisableFirstPersonChus", true, false); UIWidgets::Tooltip("Prevent bombchus from forcing the camera into first-person mode when released."); + UIWidgets::PaddedEnhancementCheckbox("Aiming reticle for the bow/slingshot", "gBowReticle", true, false); + UIWidgets::Tooltip("Aiming with a bow or slingshot will display a reticle as with the hookshot when the projectile is ready to fire."); ImGui::EndMenu(); } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 5bae84443..8df5b5a91 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1391,6 +1391,11 @@ Vec3f D_801261E0[] = { { 200.0f, 200.0f, 0.0f }, }; +// OTRTODO: Figure out why this value works/what this value should be +// This was originally obtained by working down from FLT_MAX until the math +// started working out properly +#define RETICLE_MAX 3.402823466e+12f + void func_80090D20(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; @@ -1555,6 +1560,24 @@ void func_80090D20(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void play, this, ((this->heldItemAction == PLAYER_IA_HOOKSHOT) ? 38600.0f : 77600.0f) * CVarGetFloat("gCheatHookshotReachMultiplier", 1.0f)); } } + } else if (CVarGetInteger("gBowReticle", 0) && ( + (this->heldItemAction == PLAYER_IA_BOW_FIRE) || + (this->heldItemAction == PLAYER_IA_BOW_ICE) || + (this->heldItemAction == PLAYER_IA_BOW_LIGHT) || + (this->heldItemAction == PLAYER_IA_BOW) || + (this->heldItemAction == PLAYER_IA_SLINGSHOT))) { + if (heldActor != NULL) { + MtxF sp44; + s32 pad; + + Matrix_RotateZYX(0, -15216, -17496, MTXMODE_APPLY); + Matrix_Get(&sp44); + + if (func_8002DD78(this) != 0) { + Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY); + Player_DrawHookshotReticle(play, this, RETICLE_MAX); + } + } } if ((this->unk_862 != 0) || ((func_8002DD6C(this) == 0) && (heldActor != NULL))) {