From fcb286ae4d3cd563345291b2247a111d6d2941b2 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 13:41:12 -0300 Subject: [PATCH 1/5] Change 3d model when changing weapons. --- DFUVR/Plugin.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 72fb932..fc085eb 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1018,7 +1018,7 @@ static void Postfix(WeaponManager __instance) public class CorrectWeaponPatch : MonoBehaviour { [HarmonyPrefix] - static void Prefix(WeaponManager __instance) + internal static void Prefix(WeaponManager __instance) { if (Var.weaponObject != null) Destroy(Var.weaponObject); @@ -1074,6 +1074,18 @@ static void Prefix(WeaponManager __instance) } } + [HarmonyPatch(typeof(WeaponManager), "ApplyWeapon")] + public class ApplyWeaponPatch : MonoBehaviour + { + [HarmonyPostfix] + static void Postfix(WeaponManager __instance) + { + if (__instance.ScreenWeapon == null || __instance.ScreenWeapon.SpecificWeapon == null || + __instance.ScreenWeapon.SpecificWeapon.LongName != Var.currentWeaponName) + CorrectWeaponPatch.Prefix(__instance); + } + } + //fixes the billboard orientation of enemies [HarmonyPatch(typeof(DaggerfallMobileUnit), "Update")] public class UnitOrientationPatch : MonoBehaviour From d542f058559f940fbce1cb92ccf82e53b477c590 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 16:45:33 -0300 Subject: [PATCH 2/5] Fix loading weapon state when loading the game. --- DFUVR/Plugin.cs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index fc085eb..54c8717 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1017,25 +1017,32 @@ static void Postfix(WeaponManager __instance) [HarmonyPatch(typeof(WeaponManager), "ToggleSheath")] public class CorrectWeaponPatch : MonoBehaviour { - [HarmonyPrefix] - internal static void Prefix(WeaponManager __instance) + [HarmonyPostfix] + internal static void Postfix(WeaponManager __instance) { if (Var.weaponObject != null) Destroy(Var.weaponObject); - if (__instance.ScreenWeapon == null) + DaggerfallUnityItem rightHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand); + //DaggerfallUnityItem daggerfallUnityItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand); + + if (rightHandItem == null) { Var.currentWeaponName = null; + + Var.sheathObject.GetComponent().enabled = true; + Hands.rHand.SetActive(true); + Hands.lHand.SetActive(true); return; } - Var.currentWeaponName = __instance.ScreenWeapon.SpecificWeapon?.LongName ?? ""; + Var.currentWeaponName = rightHandItem.LongName ?? ""; HandObject currentHandObject = null; - if (__instance.ScreenWeapon.WeaponType != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentWeaponName)) + if (rightHandItem.GetWeaponType() != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentWeaponName)) currentHandObject = Var.handObjectsByName[Var.currentWeaponName]; else - currentHandObject = Var.handObjects[__instance.ScreenWeapon.WeaponType]; + currentHandObject = Var.handObjects[rightHandItem.GetWeaponType()]; GameObject tempObject = currentHandObject.gameObject; @@ -1044,6 +1051,18 @@ internal static void Prefix(WeaponManager __instance) // if it is unsheathing if (__instance.Sheathed) + { + Var.weaponObject.GetComponent().enabled = false; + Var.weaponObject.transform.SetParent(Var.sheathObject.transform); + + Var.weaponObject.transform.localPosition = currentHandObject.sheatedPositionOffset; + Var.weaponObject.transform.localRotation = currentHandObject.sheatedRotationOffset; + Var.sheathObject.GetComponent().enabled = currentHandObject.renderSheated; + + Hands.rHand.SetActive(true); + Hands.lHand.SetActive(true); + } + else { Var.sheathObject.GetComponent().enabled = true; @@ -1080,9 +1099,7 @@ public class ApplyWeaponPatch : MonoBehaviour [HarmonyPostfix] static void Postfix(WeaponManager __instance) { - if (__instance.ScreenWeapon == null || __instance.ScreenWeapon.SpecificWeapon == null || - __instance.ScreenWeapon.SpecificWeapon.LongName != Var.currentWeaponName) - CorrectWeaponPatch.Prefix(__instance); + CorrectWeaponPatch.Postfix(__instance); } } From 417db142d8f6b91d0168d80986d23b1748af9862 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 16:48:38 -0300 Subject: [PATCH 3/5] Remove incorrect message. --- DFUVR/Plugin.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 54c8717..3e9beea 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1049,7 +1049,6 @@ internal static void Postfix(WeaponManager __instance) Var.weaponObject = Instantiate(tempObject); Var.weaponObject.GetComponent().enabled = true; - // if it is unsheathing if (__instance.Sheathed) { Var.weaponObject.GetComponent().enabled = false; From e58c34612d0567dc0aa3b1392b48f24aac50bb28 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 16:58:52 -0300 Subject: [PATCH 4/5] Fix merge issue. --- DFUVR/Plugin.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 3e9beea..b538208 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1077,18 +1077,6 @@ internal static void Postfix(WeaponManager __instance) Hands.rHand.SetActive(false); Hands.lHand.SetActive(false); } - else - { - Var.weaponObject.GetComponent().enabled = false; - Var.weaponObject.transform.SetParent(Var.sheathObject.transform); - - Var.weaponObject.transform.localPosition = currentHandObject.sheatedPositionOffset; - Var.weaponObject.transform.localRotation = currentHandObject.sheatedRotationOffset; - Var.sheathObject.GetComponent().enabled = currentHandObject.renderSheated; - - Hands.rHand.SetActive(true); - Hands.lHand.SetActive(true); - } } } From 487dd7837ea1f320eb1bdae6cd3a1c5225810a80 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 17:21:00 -0300 Subject: [PATCH 5/5] Fix multiple hits on enemies. --- DFUVR/Plugin.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index b538208..a496467 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1086,7 +1086,9 @@ public class ApplyWeaponPatch : MonoBehaviour [HarmonyPostfix] static void Postfix(WeaponManager __instance) { - CorrectWeaponPatch.Postfix(__instance); + DaggerfallUnityItem rightHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand); + if (rightHandItem == null || rightHandItem.LongName != Var.currentWeaponName) + CorrectWeaponPatch.Postfix(__instance); } }