From 15f84e49fc0dbfa62c1601c488397280298a9082 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 17:24:45 -0300 Subject: [PATCH] Do not allow the player to hit themselves. Only trigger haptic if the player hit something that caused an action. --- DFUVR/WeaponCollision.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/DFUVR/WeaponCollision.cs b/DFUVR/WeaponCollision.cs index fe1b359..a0ad3b2 100644 --- a/DFUVR/WeaponCollision.cs +++ b/DFUVR/WeaponCollision.cs @@ -6,6 +6,7 @@ using HarmonyLib; using DaggerfallWorkshop.Game.Items; using DaggerfallWorkshop.Game.Questing; + namespace DFUVR { public class WeaponCollision : MonoBehaviour @@ -31,9 +32,8 @@ void Start() private void OnTriggerEnter(Collider other) { - - //Plugin.LoggerInstance.LogInfo("Hit something"); + bool hitSomething = false; if (other.GetComponent()) { @@ -55,41 +55,41 @@ private void OnTriggerEnter(Collider other) hitDirection = hitDirection.normalized; //Debug.Log("Hit Direction: " + hitDirection); - weaponManager.WeaponDamage(currentRightHandWeapon, false, false, hitTransform, hitTransform.localPosition, hitDirection); - + var playerId = GameManager.Instance.PlayerObject.GetInstanceID(); + if (playerId != other.gameObject.GetInstanceID()) + { + weaponManager.WeaponDamage(currentRightHandWeapon, false, false, hitTransform, hitTransform.localPosition, hitDirection); + hitSomething = true; + } } else if (other.GetComponent()) { Plugin.LoggerInstance.LogInfo("Hit action"); - DaggerfallAction action= other.GetComponent(); + DaggerfallAction action = other.GetComponent(); if (Var.weaponManager != null) { GameObject player = (GameObject)AccessTools.Field(typeof(WeaponManager), "player").GetValue(Var.weaponManager); action.Receive(player, DaggerfallAction.TriggerTypes.Attack); + hitSomething = true; } else { Plugin.LoggerInstance.LogError("null"); } - } - else if (other.GetComponent()) + else if (other.GetComponent()) { //Plugin.LoggerInstance.LogInfo("Hit door"); DaggerfallActionDoor actionDoor = other.GetComponent(); if (actionDoor) { actionDoor.AttemptBash(true); + hitSomething = true; } - - } - Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.RightHand, 0.6f); - //else if() - + if (hitSomething) + Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.RightHand, 0.6f); } - - } }