This commit is contained in:
Patrick12115 2024-04-12 11:32:19 +09:00 committed by GitHub
commit 349b0bcf98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 110 additions and 8 deletions

View File

@ -717,6 +717,50 @@ void RegisterMirrorModeHandler() {
});
}
void UpdatePatchChildHylianShield() {
if ((CVarGetInteger("gEnhancements.RotateScaleChildHylianShield", 0) && LINK_IS_CHILD) &&
(gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KOKIRI || gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE)) {
ResourceMgr_PatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield1", 82, gsSPDisplayListOTRFilePath(gLinkChildSwordAndSheathNearDL));
ResourceMgr_PatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield2", 83, gsSPEndDisplayList());
} else {
ResourceMgr_UnpatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield1");
ResourceMgr_UnpatchGfxByName(gLinkAdultHylianShieldSwordAndSheathNearDL, "childHylianShield2");
}
if ((CVarGetInteger("gEnhancements.RotateScaleChildHylianShield", 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");
}
}
void RegisterPatchChildHylianShieldHandler() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
static uint16_t lastItemOnB = gSaveContext.equips.buttonItems[0];
if (lastItemOnB != gSaveContext.equips.buttonItems[0]) {
UpdatePatchChildHylianShield();
lastItemOnB = gSaveContext.equips.buttonItems[0];
}
});
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](int32_t sceneNum) {
UpdatePatchChildHylianShield();
});
}
void UpdateChildHylianShieldState() {
if (gPlayState == nullptr) {
return;
}
Player* player = GET_PLAYER(gPlayState);
Player_SetModels(player, Player_ActionToModelGroup(player, player->heldItemAction));
}
void RegisterChildHylianShielStatedHandler() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
UpdateChildHylianShieldState();
});
}
void UpdatePatchHand() {
if ((CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) && LINK_IS_CHILD) {
ResourceMgr_PatchGfxByName(gLinkAdultLeftHandHoldingHammerNearDL, "childHammer1", 92, gsSPDisplayListOTRFilePath(gLinkChildLeftFistNearDL));
@ -1429,6 +1473,8 @@ void InitMods() {
RegisterOpenAllHours();
RegisterToTMedallions();
NameTag_RegisterHooks();
RegisterPatchChildHylianShieldHandler();
RegisterChildHylianShielStatedHandler();
RegisterFloorSwitchesHook();
RegisterPatchHandHandler();
RegisterHurtContainerModeHandler();

View File

@ -15,6 +15,8 @@ void UpdatePermanentHeartLossState();
void UpdateHyperEnemiesState();
void UpdateHyperBossesState();
void InitMods();
void UpdatePatchChildHylianShield();
void UpdateChildHylianShieldState();
void UpdatePatchHand();
#ifdef __cplusplus

View File

@ -260,6 +260,8 @@ const std::vector<const char*> enhancementsCvars = {
"gAddTraps.Tele",
"gAddTraps.Void",
"gToTMedallionsColors",
"gEnhancements.ChildHoldsHylianShield",
"gEnhancements.RotateScaleChildHylianShield",
"gCuccoStayDurationMultiplier",
"gDeleteFileOnDeath",
"gEnemySizeScalesHealth",

View File

@ -714,6 +714,20 @@ void DrawEnhancementsMenu() {
}
}
UIWidgets::Tooltip("Allows strength to be toggled on and off by pressing A on the strength upgrade in the equipment subscreen of the pause menu (This allows performing some glitches that require the player to not have strength).");
if (UIWidgets::PaddedEnhancementCheckbox("Hold Hylian Shield as Child Link", "gEnhancements.ChildHoldsHylianShield", true, false)) {
if (CVarGetInteger("gEnhancements.ChildHoldsHylianShield", 0) == 0) {
CVarSetInteger("gEnhancements.RotateScaleChildHylianShield", 0);
}
UpdateChildHylianShieldState();
}
UIWidgets::Tooltip("Allows Child Link to hold the Hylian Shield the same way as the rest of the shields.");
if (CVarGetInteger("gEnhancements.ChildHoldsHylianShield", 0) == 1) {
if (UIWidgets::PaddedEnhancementCheckbox("Rotate and Scale Child Hylian Shield", "gEnhancements.RotateScaleChildHylianShield", true, false)) {
UpdateChildHylianShieldState();
UpdatePatchChildHylianShield();
}
}
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.");
ImGui::EndMenu();
}

View File

@ -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("gEnhancements.ChildHoldsHylianShield", 0)) {
return false; // Skip vanilla check for making child Link have the Hylian Shield on his back, allowing for it to be used in hand
} else {
return gSaveContext.linkAge != 0 && (this->currentShield == PLAYER_SHIELD_HYLIAN);
}
}
s32 Player_ActionToModelGroup(Player* this, s32 actionParam) {
@ -600,12 +604,16 @@ 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;
if (LINK_IS_CHILD && (CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) && (this->currentShield == PLAYER_SHIELD_MIRROR)) {
if (LINK_IS_CHILD && CVarGetInteger("gEnhancements.ChildHoldsHylianShield", 0) &&
this->currentShield == PLAYER_SHIELD_HYLIAN) {
this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][LINK_AGE_ADULT];
} else if (LINK_IS_CHILD && (CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) && (this->currentShield == PLAYER_SHIELD_MIRROR)) {
this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][0];
} else if (LINK_IS_ADULT && (CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) && (this->currentShield == PLAYER_SHIELD_DEKU)) {
this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][1];
} else {
this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][gSaveContext.linkAge];
} else if (LINK_IS_ADULT && (CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) && (this->currentShield == PLAYER_SHIELD_DEKU)) {
this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][1];
} else {
this->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][gSaveContext.linkAge];
}
if (this->sheathType == PLAYER_MODELTYPE_SHEATH_18) {
this->sheathType = PLAYER_MODELTYPE_SHEATH_16;
@ -646,8 +654,10 @@ void Player_SetModels(Player* this, s32 modelGroup) {
this->rightHandType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_RIGHT_HAND];
this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][gSaveContext.linkAge];
this->rightHandType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_RIGHT_HAND];
this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][gSaveContext.linkAge];
if (LINK_IS_CHILD && CVarGetInteger("gEnhancements.ChildHoldsHylianShield", 0) &&
this->rightHandType == PLAYER_MODELTYPE_RH_SHIELD && this->currentShield == PLAYER_SHIELD_HYLIAN) {
this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][LINK_AGE_ADULT];
}
if (CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) {
if (LINK_IS_CHILD &&
@ -668,6 +678,12 @@ void Player_SetModels(Player* this, s32 modelGroup) {
this->sheathType = gPlayerModelTypes[modelGroup][PLAYER_MODELGROUPENTRY_SHEATH];
this->sheathDLists = &sPlayerDListGroups[this->sheathType][gSaveContext.linkAge];
if (CVarGetInteger("gEnhancements.RotateScaleChildHylianShield", 0)) {
if (LINK_IS_CHILD && this->sheathType == PLAYER_MODELTYPE_SHEATH_18 && this->currentShield == PLAYER_SHIELD_HYLIAN) {
this->sheathDLists = &sPlayerDListGroups[this->sheathType][LINK_AGE_ADULT];
}
}
if (CVarGetInteger("gEnhancements.EquimentAlwaysVisible", 0)) {
if (LINK_IS_CHILD &&
(this->currentShield == PLAYER_SHIELD_HYLIAN || this->currentShield == PLAYER_SHIELD_MIRROR) &&
@ -1279,6 +1295,28 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx**
}
}
if (CVarGetInteger("gEnhancements.ChildHoldsHylianShield", 0) && CVarGetInteger("gEnhancements.RotateScaleChildHylianShield", 0) &&
LINK_IS_CHILD) {
if (limbIndex == PLAYER_LIMB_SHEATH) {
if (this->currentShield == PLAYER_SHIELD_HYLIAN &&
(this->sheathType == PLAYER_MODELTYPE_SHEATH_18 || this->sheathType == PLAYER_MODELTYPE_SHEATH_19) &&
(gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KOKIRI ||
gSaveContext.equips.buttonItems[0] == ITEM_NONE ||
gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE)) {
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 ||
gSaveContext.equips.buttonItems[0] == ITEM_NONE ||
gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE)) {
Matrix_Scale(0.8, 0.8, 0.8, MTXMODE_APPLY);
}
}
}
if (limbIndex == PLAYER_LIMB_ROOT) {
sLeftHandType = this->leftHandType;
sRightHandType = this->rightHandType;