From 417b434738195e814ef7ae41b2e39f636da13c6c Mon Sep 17 00:00:00 2001 From: Patrick12115 Date: Mon, 29 Jan 2024 20:10:14 -0500 Subject: [PATCH] Moved to own branch --- soh/soh/Enhancements/mods.cpp | 24 +++++++++++++++++++ soh/soh/SohMenuBar.cpp | 6 +++++ soh/src/code/z_player_lib.c | 44 +++++++++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 329a8ee48..49b797b93 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -23,6 +23,8 @@ #include "src/overlays/actors/ovl_En_Tp/z_en_tp.h" #include "src/overlays/actors/ovl_En_Firefly/z_en_firefly.h" #include "src/overlays/actors/ovl_En_Xc/z_en_xc.h" +#include "objects/object_link_boy/object_link_boy.h" +#include "objects/object_link_child/object_link_child.h" extern "C" { #include @@ -687,6 +689,28 @@ void RegisterMirrorModeHandler() { }); } +void RegisterPatchChildHylianSHieldHandler() { + GameInteractor::Instance->RegisterGameHook([]() { + if ((CVarGetInteger("gRotateScaleChildHylianShield", 0) && LINK_IS_CHILD) && + (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KOKIRI)) { + ResourceMgr_PatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield1", 82, + gsSPDisplayListOTRFilePath(gLinkChildSwordAndSheathNearDL)); + ResourceMgr_PatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield2", 83, + gsSPEndDisplayList()); + } else { + ResourceMgr_UnpatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield1"); + ResourceMgr_UnpatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield2"); + } + if ((CVarGetInteger("gRotateScaleChildHylianShield", 0) && LINK_IS_CHILD) && + (gSaveContext.equips.buttonItems[0] == ITEM_NONE || gSaveContext.equips.buttonItems[0] == ITEM_STICK)) { + ResourceMgr_PatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield3", 82, + gsSPEndDisplayList()); + } else { + ResourceMgr_UnpatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield3"); + } + }); +} + f32 triforcePieceScale; void RegisterTriforceHunt() { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index e656a3a90..86f734148 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1337,6 +1337,12 @@ void DrawCheatsMenu() { UIWidgets::Tooltip("Prevents the Deku Shield from burning on contact with fire"); UIWidgets::PaddedEnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded", true, false); UIWidgets::Tooltip("This allows you to put up your shield with any two-handed weapon in hand except for Deku Sticks"); + UIWidgets::PaddedEnhancementCheckbox("Hold Hylian Shield as Child Link", "gChildHoldsHylianShield", true, false); + UIWidgets::Tooltip("Allows Child Link to hold the Hylian Shield the same way as the rest of the shields."); + if (CVarGetInteger("gChildHoldsHylianShield", 0) == 1) { + UIWidgets::PaddedEnhancementCheckbox("Rotate and Scale Child Hylian Shield", "gRotateScaleChildHylianShield", true, false); + UIWidgets::Tooltip("Rotates and scales the hylian shield for Child Link, so that it is the same orientation as the other shields. May not work properly with some mods."); + } UIWidgets::Spacer(2.0f); ImGui::Text("Deku Sticks:"); UIWidgets::EnhancementCombobox("gDekuStickCheat", DekuStickCheat, DEKU_STICK_NORMAL); diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index e20362fd3..eb803a7a4 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -580,7 +580,11 @@ s32 func_8008E9C4(Player* this) { } s32 Player_IsChildWithHylianShield(Player* this) { - return gSaveContext.linkAge != 0 && (this->currentShield == PLAYER_SHIELD_HYLIAN); + if (CVarGetInteger("gChildHoldsHylianShield", 0)) { + return 0; + } else { + return gSaveContext.linkAge != 0 && (this->currentShield == PLAYER_SHIELD_HYLIAN); + } } s32 Player_ActionToModelGroup(Player* this, s32 actionParam) { @@ -600,7 +604,11 @@ void Player_SetModelsForHoldingShield(Player* this) { if ((CVarGetInteger("gShieldTwoHanded", 0) && (this->heldItemAction != PLAYER_IA_DEKU_STICK) || !Player_HoldsTwoHandedWeapon(this)) && !Player_IsChildWithHylianShield(this)) { this->rightHandType = PLAYER_MODELTYPE_RH_SHIELD; - this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][gSaveContext.linkAge]; + if (LINK_IS_CHILD && (CVarGetInteger("gChildHoldsHylianShield", 0)) && (this->currentShield == PLAYER_SHIELD_HYLIAN)) { + this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][0]; + } else { + this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][gSaveContext.linkAge]; + } if (this->sheathType == PLAYER_MODELTYPE_SHEATH_18) { this->sheathType = PLAYER_MODELTYPE_SHEATH_16; } else if (this->sheathType == PLAYER_MODELTYPE_SHEATH_19) { @@ -622,6 +630,10 @@ void Player_SetModels(Player* this, s32 modelGroup) { this->rightHandType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_RIGHT_HAND]; this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][gSaveContext.linkAge]; + if (LINK_IS_CHILD && CVarGetInteger("gChildHoldsHylianShield", 0) && + this->rightHandType == PLAYER_MODELTYPE_RH_SHIELD && this->currentShield == PLAYER_SHIELD_HYLIAN) { + this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][0]; + } if (CVarGetInteger("gBowSlingShotAmmoFix", 0) && this->rightHandType == 11) { // If holding Bow/Slingshot this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][Player_HoldsSlingshot(this)]; } @@ -630,6 +642,13 @@ void Player_SetModels(Player* this, s32 modelGroup) { this->sheathType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_SHEATH]; this->sheathDLists = &sPlayerDListGroups[this->sheathType][gSaveContext.linkAge]; + if (CVarGetInteger("gRotateScaleChildHylianShield", 0)) { + if (LINK_IS_CHILD && this->sheathType == PLAYER_MODELTYPE_SHEATH_18 && this->currentShield == PLAYER_SHIELD_HYLIAN && + ((gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KOKIRI || gSaveContext.equips.buttonItems[0] == ITEM_NONE || gSaveContext.equips.buttonItems[0] == ITEM_STICK))) { + this->sheathDLists = &sPlayerDListGroups[this->sheathType][0]; + } + } + // Waist this->waistDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][4]][gSaveContext.linkAge]; @@ -1188,6 +1207,27 @@ void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* p s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; + if (CVarGetInteger("gChildHoldsHylianShield", 0) && CVarGetInteger("gRotateScaleChildHylianShield", 0) && + LINK_IS_CHILD) { + if (limbIndex == PLAYER_LIMB_SHEATH) { + if ((this->currentShield == PLAYER_SHIELD_HYLIAN && + (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KOKIRI || + gSaveContext.equips.buttonItems[0] == ITEM_NONE || + gSaveContext.equips.buttonItems[0] == ITEM_STICK)) && + ((this->sheathType == PLAYER_MODELTYPE_SHEATH_18) || + (this->sheathType == PLAYER_MODELTYPE_SHEATH_19))) { + Matrix_Translate(218, 0, 62, MTXMODE_APPLY); + Matrix_Scale(0.8, 0.8, 0.8, MTXMODE_APPLY); + } + } + if (limbIndex == PLAYER_LIMB_R_HAND) { + if (this->currentShield == PLAYER_SHIELD_HYLIAN && sRightHandType == PLAYER_MODELTYPE_RH_SHIELD && + gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KOKIRI) { + Matrix_Scale(0.8, 0.8, 0.8, MTXMODE_APPLY); + } + } + } + if (limbIndex == PLAYER_LIMB_ROOT) { sLeftHandType = this->leftHandType; sRightHandType = this->rightHandType;