From fe5e1dfd3c65766811f9c79d7c6c180d5d9f2de1 Mon Sep 17 00:00:00 2001 From: SDraw Date: Sun, 9 Apr 2023 13:59:53 +0000 Subject: [PATCH] Pose transitions in FBT with enabled game's option for running FBT animations Limit movement drag to 50 Settings listener on destroy --- README.md | 2 +- ml_amt/MotionTweaker.cs | 18 ++++++++++++++++-- ml_amt/Properties/AssemblyInfo.cs | 6 +++--- ml_lme/LeapInput.cs | 2 ++ ml_prm/RagdollController.cs | 7 ++++--- ml_prm/Settings.cs | 4 ++-- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ecf23f1..07df240 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Merged set of MelonLoader mods for ChilloutVR. | Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes | |-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------| | Avatar Change Info | ml_aci | 1.0.3 | Retired | Retired | Superseded by `Extended Game Notifications` -| Avatar Motion Tweaker | ml_amt | 1.2.4 | Yes | Working | +| Avatar Motion Tweaker | ml_amt | 1.2.5 | Yes, update review | Working | | Desktop Head Tracking | ml_dht | 1.1.2 | Yes | Working | | Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working | | Extended Game Notifications | ml_egn | 1.0.1 | Yes | Working diff --git a/ml_amt/MotionTweaker.cs b/ml_amt/MotionTweaker.cs index 95527c1..98ace85 100644 --- a/ml_amt/MotionTweaker.cs +++ b/ml_amt/MotionTweaker.cs @@ -1,4 +1,5 @@ using ABI_RC.Core.Player; +using ABI_RC.Core.Savior; using ABI_RC.Systems.IK; using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.MovementSystem; @@ -37,6 +38,7 @@ namespace ml_amt Transform m_avatarHips = null; float m_viewPointHeight = 1f; bool m_inVR = false; + bool m_fbtAnimations = true; bool m_avatarReady = false; bool m_compatibleAvatar = false; @@ -93,6 +95,9 @@ namespace ml_amt Settings.FollowHipsChange += this.SetFollowHips; Settings.MassCenterChange += this.OnMassCenterChange; Settings.ScaledStepsChange += this.OnScaledStepsChange; + + m_fbtAnimations = MetaPort.Instance.settings.GetSettingsBool("GeneralEnableRunningAnimationFullBody"); + MetaPort.Instance.settings.settingBoolChanged.AddListener(this.OnGameSettingBoolChange); } void OnDestroy() @@ -108,6 +113,8 @@ namespace ml_amt Settings.DetectEmotesChange -= this.SetDetectEmotes; Settings.FollowHipsChange -= this.SetFollowHips; Settings.MassCenterChange -= this.OnMassCenterChange; + + MetaPort.Instance.settings.settingBoolChanged.RemoveListener(this.OnGameSettingBoolChange); } void Update() @@ -147,8 +154,8 @@ namespace ml_amt if(m_poseTransitions) { - PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", (m_poseState == PoseState.Crouching) && !m_compatibleAvatar && !BodySystem.isCalibratedAsFullBody); - PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", (m_poseState == PoseState.Proning) && !m_compatibleAvatar && !BodySystem.isCalibratedAsFullBody); + PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", (m_poseState == PoseState.Crouching) && !m_compatibleAvatar && (!BodySystem.isCalibratedAsFullBody || m_fbtAnimations)); + PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", (m_poseState == PoseState.Proning) && !m_compatibleAvatar && (!BodySystem.isCalibratedAsFullBody || m_fbtAnimations)); } } @@ -441,6 +448,13 @@ namespace ml_amt } } + // Game settings + void OnGameSettingBoolChange(string p_name, bool p_state) + { + if(p_name == "GeneralEnableRunningAnimationFullBody") + m_fbtAnimations = p_state; + } + // Arbitrary float GetRelativeScale() { diff --git a/ml_amt/Properties/AssemblyInfo.cs b/ml_amt/Properties/AssemblyInfo.cs index 9a84e96..ba6d274 100644 --- a/ml_amt/Properties/AssemblyInfo.cs +++ b/ml_amt/Properties/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Reflection; [assembly: AssemblyTitle("AvatarMotionTweaker")] -[assembly: AssemblyVersion("1.2.4")] -[assembly: AssemblyFileVersion("1.2.4")] +[assembly: AssemblyVersion("1.2.5")] +[assembly: AssemblyFileVersion("1.2.5")] -[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.2.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.2.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] \ No newline at end of file diff --git a/ml_lme/LeapInput.cs b/ml_lme/LeapInput.cs index aa0cef4..585fbf1 100644 --- a/ml_lme/LeapInput.cs +++ b/ml_lme/LeapInput.cs @@ -111,6 +111,8 @@ namespace ml_lme { Settings.EnabledChange -= this.OnEnableChange; Settings.InputChange -= this.OnInputChange; + + MetaPort.Instance.settings.settingBoolChanged.RemoveListener(this.OnGameSettingBoolChange); } void Update() diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index 5d6f2aa..47c28e4 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -284,6 +284,7 @@ namespace ml_prm if(BodySystem.isCalibratedAsFullBody) BodySystem.TrackingPositionWeight = 0f; + // Copy before set to non-kinematic to reduce stacked forces foreach(var l_link in m_boneLinks) l_link.Item2.CopyGlobal(l_link.Item1); @@ -322,10 +323,10 @@ namespace ml_prm } } } - } - foreach(Collider l_collider in m_colliders) - l_collider.enabled = m_enabled; + foreach(Collider l_collider in m_colliders) + l_collider.enabled = m_enabled; + } } public bool IsRagdolled() => (m_enabled && m_avatarReady); diff --git a/ml_prm/Settings.cs b/ml_prm/Settings.cs index cd2cb60..e1fef82 100644 --- a/ml_prm/Settings.cs +++ b/ml_prm/Settings.cs @@ -62,7 +62,7 @@ namespace ml_prm Hotkey = (bool)ms_entries[(int)ModSetting.Hotkey].BoxedValue; VelocityMultiplier = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.VelocityMultiplier].BoxedValue, 0f, 50f); RestorePosition = (bool)ms_entries[(int)ModSetting.RestorePosition].BoxedValue; - MovementDrag = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0f, 100f); + MovementDrag = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0f, 50f); AngularDrag = UnityEngine.Mathf.Clamp((float)ms_entries[(int)ModSetting.MovementDrag].BoxedValue, 0.5f, 50f); Gravity = (bool)ms_entries[(int)ModSetting.Gravity].BoxedValue; @@ -116,7 +116,7 @@ namespace ml_prm VelocityMultiplierChange?.Invoke(value); }; - ms_uiElements.Add(l_page.AddSlider("Movement drag", "Movement resistance", MovementDrag, 0f, 100f)); + ms_uiElements.Add(l_page.AddSlider("Movement drag", "Movement resistance", MovementDrag, 0f, 50f)); (ms_uiElements[(int)UiElementIndex.MovementDrag] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => { MovementDrag = value;