From 155f5e165a563de82ca6941ee445a8124b42d2fe Mon Sep 17 00:00:00 2001
From: louist103 <35883445+louist103@users.noreply.github.com>
Date: Sun, 20 Aug 2023 14:00:28 -0400
Subject: [PATCH] Use a different color when aiming at hookshotable collision
(#3105)
* Colors
* Use VTX data in OTR file
* Move to equipment
---
.../objects/object_link_boy/object_link_boy.h | 3 ++
.../xml/GC_MQ_D/objects/object_link_boy.xml | 4 ++
.../xml/GC_NMQ_D/objects/object_link_boy.xml | 4 ++
.../GC_NMQ_PAL_F/objects/object_link_boy.xml | 4 ++
.../N64_PAL_11/objects/object_link_boy.xml | 4 ++
.../cosmetics/CosmeticsEditor.cpp | 5 +-
soh/soh/SohMenuBar.cpp | 3 ++
soh/src/code/z_player_lib.c | 46 ++++++++++++-------
8 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/soh/assets/objects/object_link_boy/object_link_boy.h b/soh/assets/objects/object_link_boy/object_link_boy.h
index 26af6703c..ff7b63291 100644
--- a/soh/assets/objects/object_link_boy/object_link_boy.h
+++ b/soh/assets/objects/object_link_boy/object_link_boy.h
@@ -308,6 +308,9 @@ static const ALIGN_ASSET(2) char gLinkAdultHookshotDesignTex[] = dgLinkAdultHook
#define dgLinkAdultHookshotChainTex "__OTR__objects/object_link_boy/gLinkAdultHookshotChainTex"
static const ALIGN_ASSET(2) char gLinkAdultHookshotChainTex[] = dgLinkAdultHookshotChainTex;
+#define dgLinkAdultHookshotRedicleVtx "__OTR__objects/object_link_boy/gLinkAdultHookshotRedicleVtx"
+static const ALIGN_ASSET(2) char gLinkAdultHookshotRedicleVtx[] = dgLinkAdultHookshotRedicleVtx;
+
#define dgLinkAdultHookshotReticleTex "__OTR__objects/object_link_boy/gLinkAdultHookshotReticleTex"
static const ALIGN_ASSET(2) char gLinkAdultHookshotReticleTex[] = dgLinkAdultHookshotReticleTex;
diff --git a/soh/assets/xml/GC_MQ_D/objects/object_link_boy.xml b/soh/assets/xml/GC_MQ_D/objects/object_link_boy.xml
index 2853a81eb..c2c424b5e 100644
--- a/soh/assets/xml/GC_MQ_D/objects/object_link_boy.xml
+++ b/soh/assets/xml/GC_MQ_D/objects/object_link_boy.xml
@@ -202,6 +202,10 @@
+
+
+
+
diff --git a/soh/assets/xml/GC_NMQ_D/objects/object_link_boy.xml b/soh/assets/xml/GC_NMQ_D/objects/object_link_boy.xml
index c3af97de6..946159a12 100644
--- a/soh/assets/xml/GC_NMQ_D/objects/object_link_boy.xml
+++ b/soh/assets/xml/GC_NMQ_D/objects/object_link_boy.xml
@@ -202,6 +202,10 @@
+
+
+
+
diff --git a/soh/assets/xml/GC_NMQ_PAL_F/objects/object_link_boy.xml b/soh/assets/xml/GC_NMQ_PAL_F/objects/object_link_boy.xml
index 49f439271..b26b36068 100644
--- a/soh/assets/xml/GC_NMQ_PAL_F/objects/object_link_boy.xml
+++ b/soh/assets/xml/GC_NMQ_PAL_F/objects/object_link_boy.xml
@@ -202,6 +202,10 @@
+
+
+
+
diff --git a/soh/assets/xml/N64_PAL_11/objects/object_link_boy.xml b/soh/assets/xml/N64_PAL_11/objects/object_link_boy.xml
index 49f439271..b26b36068 100644
--- a/soh/assets/xml/N64_PAL_11/objects/object_link_boy.xml
+++ b/soh/assets/xml/N64_PAL_11/objects/object_link_boy.xml
@@ -202,6 +202,10 @@
+
+
+
+
diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
index 2d7695af7..57a01840e 100644
--- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
+++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
@@ -195,7 +195,7 @@ static std::map cosmeticOptions = {
COSMETIC_OPTION("Link_Hair", "Hair", GROUP_LINK, ImVec4(255, 173, 27, 255), false, true, true),
COSMETIC_OPTION("Link_Linen", "Linen", GROUP_LINK, ImVec4(255, 255, 255, 255), false, true, true),
COSMETIC_OPTION("Link_Boots", "Boots", GROUP_LINK, ImVec4( 93, 44, 18, 255), false, true, true),
-
+
COSMETIC_OPTION("MirrorShield_Body", "Body", GROUP_MIRRORSHIELD, ImVec4(215, 0, 0, 255), false, true, false),
COSMETIC_OPTION("MirrorShield_Mirror", "Mirror", GROUP_MIRRORSHIELD, ImVec4(255, 255, 255, 255), false, true, true),
COSMETIC_OPTION("MirrorShield_Emblem", "Emblem", GROUP_MIRRORSHIELD, ImVec4(205, 225, 255, 255), false, true, true),
@@ -219,8 +219,9 @@ static std::map cosmeticOptions = {
COSMETIC_OPTION("Equipment_HammerHead", "Hammer Head", GROUP_EQUIPMENT, ImVec4(155, 192, 201, 255), false, true, false),
COSMETIC_OPTION("Equipment_HammerHandle", "Hammer Handle", GROUP_EQUIPMENT, ImVec4(110, 60, 0, 255), false, true, true),
// COSMETIC_OPTION("Equipment_HookshotChain", "Hookshot Chain", GROUP_EQUIPMENT, ImVec4(255, 255, 255, 255), false, true, true), // Todo (Cosmetics): Implement
- // COSMETIC_OPTION("Equipment_HookshotReticle", "Hookshot Reticle", GROUP_EQUIPMENT, ImVec4(255, 255, 255, 255), false, true, true), // Todo (Cosmetics): Implement
// COSMETIC_OPTION("Equipment_HookshotTip", "Hookshot Tip", GROUP_EQUIPMENT, ImVec4(255, 255, 255, 255), false, true, false), // Todo (Cosmetics): Implement
+ COSMETIC_OPTION("HookshotReticle_Target", "Hookshotable Reticle", GROUP_EQUIPMENT, ImVec4( 0, 255, 0, 255), false, false, false),
+ COSMETIC_OPTION("HookshotReticle_NonTarget", "Non-Hookshotable Reticle", GROUP_EQUIPMENT, ImVec4(255, 0, 0, 255), false, false, false),
COSMETIC_OPTION("Equipment_BowTips", "Bow Tips", GROUP_EQUIPMENT, ImVec4(200, 0, 0, 255), false, true, true),
COSMETIC_OPTION("Equipment_BowString", "Bow String", GROUP_EQUIPMENT, ImVec4(255, 255, 255, 255), false, true, true),
COSMETIC_OPTION("Equipment_BowBody", "Bow Body", GROUP_EQUIPMENT, ImVec4(140, 90, 10, 255), false, true, false),
diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp
index 6e188a1ab..59dee8444 100644
--- a/soh/soh/SohMenuBar.cpp
+++ b/soh/soh/SohMenuBar.cpp
@@ -868,6 +868,9 @@ void DrawEnhancementsMenu() {
UIWidgets::PaddedEnhancementCheckbox("Enemy Health Bars", "gEnemyHealthBar", true, false);
UIWidgets::Tooltip("Renders a health bar for enemies when Z-Targeted");
+ UIWidgets::PaddedEnhancementCheckbox("Targetable Hookshot Reticle", "gHookshotableReticle", true, false);
+ UIWidgets::Tooltip("Use a different color when aiming at hookshotable collision");
+
ImGui::EndMenu();
}
diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c
index ed9b359e1..78ef4932d 100644
--- a/soh/src/code/z_player_lib.c
+++ b/soh/src/code/z_player_lib.c
@@ -1325,38 +1325,50 @@ void func_80090A28(Player* this, Vec3f* vecs) {
Matrix_MultVec3f(&D_80126098, &vecs[2]);
}
-void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) {
+void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 hookshotRange) {
static Vec3f D_801260C8 = { -500.0f, -100.0f, 0.0f };
- CollisionPoly* sp9C;
+ CollisionPoly* colPoly;
s32 bgId;
- Vec3f sp8C;
- Vec3f sp80;
- Vec3f sp74;
+ Vec3f hookshotStart;
+ Vec3f hookshotEnd;
+ Vec3f firstHit;
Vec3f sp68;
f32 sp64;
- f32 sp60;
D_801260C8.z = 0.0f;
- Matrix_MultVec3f(&D_801260C8, &sp8C);
- D_801260C8.z = arg2;
- Matrix_MultVec3f(&D_801260C8, &sp80);
+ Matrix_MultVec3f(&D_801260C8, &hookshotStart);
+ D_801260C8.z = hookshotRange;
+ Matrix_MultVec3f(&D_801260C8, &hookshotEnd);
- if (BgCheck_AnyLineTest3(&play->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &bgId)) {
+ if (BgCheck_AnyLineTest3(&play->colCtx, &hookshotStart, &hookshotEnd, &firstHit, &colPoly, 1, 1, 1, 1, &bgId)) {
OPEN_DISPS(play->state.gfxCtx);
WORLD_OVERLAY_DISP = Gfx_SetupDL(WORLD_OVERLAY_DISP, 0x07);
- SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sp74, &sp68, &sp64);
+ SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &firstHit, &sp68, &sp64);
- sp60 = (sp64 < 200.0f) ? 0.08f : (sp64 / 200.0f) * 0.08f;
+ const f32 sp60 = (sp64 < 200.0f) ? 0.08f : (sp64 / 200.0f) * 0.08f;
- Matrix_Translate(sp74.x, sp74.y, sp74.z, MTXMODE_NEW);
+ Matrix_Translate(firstHit.x, firstHit.y, firstHit.z, MTXMODE_NEW);
Matrix_Scale(sp60, sp60, sp60, MTXMODE_APPLY);
- gSPMatrix(WORLD_OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx),
- G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
- gSPSegment(WORLD_OVERLAY_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment);
- gSPDisplayList(WORLD_OVERLAY_DISP++, gLinkAdultHookshotReticleDL);
+ gSPMatrix(WORLD_OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ char* tex = ResourceMgr_LoadTexOrDListByName(gLinkAdultHookshotReticleTex);
+ gSPMatrix(WORLD_OVERLAY_DISP++, SEG_ADDR(1, 0), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
+ gSPTexture(WORLD_OVERLAY_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
+ gDPLoadTextureBlock(WORLD_OVERLAY_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP,
+ G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD);
+ if (SurfaceType_IsHookshotSurface(&play->colCtx, colPoly, bgId) && CVarGetInteger("gHookshotableReticle", false)) {
+ const Color_RGBA8 defaultColor = { .r = 0, .g = 255, .b = 0, .a = 255 };
+ const Color_RGBA8 color = CVarGetColor("gCosmetics.HookshotReticle_Target.Value", defaultColor);
+ gDPSetPrimColor(WORLD_OVERLAY_DISP++, 0, 0, color.r, color.g, color.b, color.a);
+ } else {
+ const Color_RGBA8 defaultColor = { .r = 255, .g = 0, .b = 0, .a = 255 };
+ const Color_RGBA8 color = CVarGetColor("gCosmetics.HookshotReticle_NonTarget.Value", defaultColor);
+ gDPSetPrimColor(WORLD_OVERLAY_DISP++, 0, 0, color.r, color.g, color.b, color.a);
+ }
+ gSPVertex(WORLD_OVERLAY_DISP++, (uintptr_t)gLinkAdultHookshotReticleTex, 3, 0);
+ gSP1Triangle(WORLD_OVERLAY_DISP++, 0, 1, 2, 0);
CLOSE_DISPS(play->state.gfxCtx);
}