diff --git a/.Experimental/CVRLuaToolsExtension/LuaToolsExtension/Extensions/CVRLuaClientBehaviourExtensions.cs b/.Experimental/CVRLuaToolsExtension/LuaToolsExtension/Extensions/CVRLuaClientBehaviourExtensions.cs index 8c07542..5dc7b86 100644 --- a/.Experimental/CVRLuaToolsExtension/LuaToolsExtension/Extensions/CVRLuaClientBehaviourExtensions.cs +++ b/.Experimental/CVRLuaToolsExtension/LuaToolsExtension/Extensions/CVRLuaClientBehaviourExtensions.cs @@ -1,6 +1,7 @@ using ABI.CCK.Components; using ABI.Scripting.CVRSTL.Client; using System.Diagnostics; +using ABI_RC.Scripting.Persistence; using MTJobSystem; using UnityEngine; @@ -108,8 +109,11 @@ public static class CVRLuaClientBehaviourExtensions behaviour._startupMessageQueue.Clear(); // will be repopulated behaviour.LogInfo("[CVRLuaToolsExtension] Resetting script...\n"); + // remove the script from the persistence manager, as the storage needs to be reinitialized + PersistenceManager.HandleUnsubscribe(behaviour.Storage, behaviour.script, behaviour.Context.ParentContent.ContentType, behaviour.Context.AssetID); + behaviour.script = null; - behaviour.script = LuaScriptFactory.ForLuaBehaviour(behaviour, boundObjectEntries, behaviour.gameObject, behaviour.transform, PersistentDataPath); + behaviour.script = LuaScriptFactory.ForLuaBehaviour(behaviour, boundObjectEntries, behaviour.gameObject, behaviour.transform); behaviour.InitTimerIfNeeded(); // only null if crashed prior behaviour.script.AttachDebugger(behaviour.timer); // reattach the debugger diff --git a/ASTExtension/Main.cs b/ASTExtension/Main.cs index f7b7115..461dc16 100644 --- a/ASTExtension/Main.cs +++ b/ASTExtension/Main.cs @@ -121,7 +121,8 @@ public class ASTExtensionMod : MelonMod private void OnLocalAvatarLoad() { - if (!FindSupportedParameter(out string parameterName)) + _currentAvatarSupported = FindSupportedParameter(out string parameterName); + if (!_currentAvatarSupported) return; if (!AttemptCalibrateParameter(parameterName, out float minHeight, out float maxHeight, out float modifier)) diff --git a/ConfigureCalibrationPose/ConfigureCalibrationPose.csproj b/ConfigureCalibrationPose/ConfigureCalibrationPose.csproj new file mode 100644 index 0000000..5a8badc --- /dev/null +++ b/ConfigureCalibrationPose/ConfigureCalibrationPose.csproj @@ -0,0 +1,6 @@ + + + + YouAreMineNow + + diff --git a/ConfigureCalibrationPose/Main.cs b/ConfigureCalibrationPose/Main.cs new file mode 100644 index 0000000..179f7e4 --- /dev/null +++ b/ConfigureCalibrationPose/Main.cs @@ -0,0 +1,543 @@ +using System.Reflection; +using ABI_RC.Core.Player; +using ABI_RC.Systems.IK; +using ABI_RC.Systems.IK.SubSystems; +using ABI_RC.Systems.InputManagement; +using ABI_RC.Systems.Movement; +using HarmonyLib; +using MelonLoader; +using RootMotion.FinalIK; +using UnityEngine; + +namespace NAK.ConfigureCalibrationPose; + +public class ConfigureCalibrationPoseMod : MelonMod +{ + #region Enums + + private enum CalibrationPose + { + TPose, + APose, + IKPose, + BikePose, + RacushSit, + CCKSitting, + CCKCrouch, + CCKProne, + } + + #endregion Enums + + #region Melon Preferences + + private static readonly MelonPreferences_Category Category = + MelonPreferences.CreateCategory(nameof(ConfigureCalibrationPose)); + + private static readonly MelonPreferences_Entry EntryCalibrationPose = + Category.CreateEntry("calibration_pose", CalibrationPose.APose, display_name: "Calibration Pose", + description: "What pose to use for FBT calibration."); + + #endregion Melon Preferences + + #region Melon Events + + public override void OnInitializeMelon() + { + #region BodySystem Patches + + HarmonyInstance.Patch( + typeof(BodySystem).GetMethod(nameof(BodySystem.MuscleUpdate), + BindingFlags.Public | BindingFlags.Instance), + prefix: new HarmonyMethod(typeof(ConfigureCalibrationPoseMod).GetMethod(nameof(OnPreBodySystemMuscleUpdate), + BindingFlags.NonPublic | BindingFlags.Static)) + ); + + #endregion BodySystem Patches + } + + #endregion Melon Events + + #region Harmony Patches + + private static bool OnPreBodySystemMuscleUpdate(ref float[] muscles) + { + PlayerSetup playerSetup = PlayerSetup.Instance; + IKSystem ikSystem = IKSystem.Instance; + ref HumanPose humanPose = ref ikSystem._humanPose; + + if (BodySystem.isCalibrating) + { + switch (EntryCalibrationPose.Value) + { + default: + case CalibrationPose.TPose: + for (int i = 0; i < MusclePoses.TPoseMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, MusclePoses.TPoseMuscles[i], ref muscles); + break; + case CalibrationPose.APose: + for (int i = 0; i < MusclePoses.APoseMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, MusclePoses.APoseMuscles[i], ref muscles); + break; + case CalibrationPose.IKPose: + for (int i = 0; i < MusclePoses.IKPoseMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, MusclePoses.IKPoseMuscles[i], ref muscles); + break; + case CalibrationPose.BikePose: + for (int i = 0; i < MusclePoses.TPoseMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, 0f, ref muscles); + break; + case CalibrationPose.CCKSitting: + for (int i = 0; i < CCKSittingMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, CCKSittingMuscles[i], ref muscles); + break; + case CalibrationPose.CCKCrouch: + for (int i = 0; i < CCKCrouchMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, CCKCrouchMuscles[i], ref muscles); + break; + case CalibrationPose.CCKProne: + for (int i = 0; i < CCKProneMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, CCKProneMuscles[i], ref muscles); + break; + case CalibrationPose.RacushSit: + for (int i = 0; i < RacushSitMuscles.Length; i++) + ikSystem.ApplyMuscleValue((MuscleIndex) i, RacushSitMuscles[i], ref muscles); + break; + } + + humanPose.bodyPosition = Vector3.up; + humanPose.bodyRotation = Quaternion.identity; + } + else if (BodySystem.isCalibratedAsFullBody && BodySystem.TrackingPositionWeight > 0f) + { + BetterBetterCharacterController characterController = playerSetup.CharacterController; + + bool isRunning = characterController.IsMoving(); + bool isGrounded = characterController.IsGrounded(); + bool isFlying = characterController.IsFlying(); + bool isSwimming = characterController.IsSwimming(); + + if ((BodySystem.PlayRunningAnimationInFullBody + && (isRunning || !isGrounded && !isFlying && !isSwimming))) + { + ikSystem.applyOriginalHipPosition = true; + ikSystem.applyOriginalHipRotation = true; + + IKSolverVR solver = IKSystem.vrik.solver; + BodySystem.SetPelvisWeight(solver.spine, 0f); + BodySystem.SetLegWeight(solver.leftLeg, 0f); + BodySystem.SetLegWeight(solver.rightLeg, 0f); + } + else + { + ikSystem.applyOriginalHipPosition = true; + ikSystem.applyOriginalHipRotation = false; + humanPose.bodyRotation = Quaternion.identity; + } + } + + return false; // dont run original + } + + #endregion Harmony Patches + + #region Custom Pose Arrays + + private static readonly float[] CCKSittingMuscles = + [ + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + -0.8000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + -0.8000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + -1.0000f, + 0.0000f, + -0.3000f, + 0.3000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + -1.0000f, + 0.0000f, + -0.3000f, + 0.3000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f + ]; + + private static readonly float[] CCKCrouchMuscles = + [ + -1.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.5000f, + 0.0000f, + 0.0000f, + 0.5000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + -0.6279f, + 0.0000f, + 0.0000f, + -0.8095f, + 0.0000f, + -1.0091f, + 0.0000f, + 0.0000f, + -0.4126f, + 0.0013f, + -0.0860f, + -0.9331f, + -0.0869f, + -1.3586f, + 0.1791f, + 0.0000f, + 0.0000f, + 0.0000f, + -0.1998f, + -0.2300f, + 0.1189f, + 0.3479f, + 0.1364f, + -0.3737f, + 0.0069f, + 0.0000f, + 0.0000f, + -0.1994f, + -0.2301f, + 0.0267f, + 0.7532f, + 0.1922f, + 0.0009f, + -0.0005f, + -1.4747f, + -0.0443f, + -0.3347f, + -0.3062f, + -0.7596f, + -1.2067f, + -0.7329f, + -0.7329f, + -0.5984f, + -2.7162f, + -0.7439f, + -0.7439f, + -0.5812f, + 1.8528f, + -0.7520f, + -0.7520f, + -0.7242f, + 0.5912f, + -0.7632f, + -0.7632f, + -1.4747f, + -0.0443f, + -0.3347f, + -0.3062f, + -0.7596f, + -1.2067f, + -0.7329f, + -0.7329f, + -0.5984f, + -2.7162f, + -0.7439f, + -0.7439f, + -0.5812f, + 1.8528f, + -0.7520f, + 0.8104f, + -0.7242f, + 0.5912f, + -0.7632f, + 0.8105f + ]; + + private static readonly float[] CCKProneMuscles = + [ + 0.6604f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.7083f, + 0.0000f, + 0.0000f, + 0.7083f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.2444f, + -0.0554f, + -0.8192f, + 0.9301f, + 0.5034f, + 1.0274f, + -0.1198f, + 0.5849f, + 0.2360f, + -0.0837f, + -1.1803f, + 0.9676f, + 0.7390f, + 0.9944f, + -0.1717f, + 0.5849f, + 0.0000f, + 0.0000f, + 0.2823f, + -0.6297f, + 0.3200f, + -0.3376f, + 0.0714f, + 0.9260f, + -1.5768f, + 0.0000f, + 0.0000f, + 0.1561f, + -0.6712f, + 0.2997f, + -0.3392f, + 0.0247f, + 0.7672f, + -1.5269f, + -1.1422f, + 0.0392f, + 0.6457f, + 0.0000f, + 0.6185f, + -0.5393f, + 0.8104f, + 0.8104f, + 0.6223f, + -0.8225f, + 0.8104f, + 0.8104f, + 0.6218f, + -0.3961f, + 0.8104f, + 0.8104f, + 0.6160f, + -0.3721f, + 0.8105f, + 0.8105f, + -1.1422f, + 0.0392f, + 0.6457f, + 0.0000f, + 0.6185f, + -0.5393f, + 0.8104f, + 0.8104f, + 0.6223f, + -0.8226f, + 0.8104f, + 0.8104f, + 0.6218f, + -0.3961f, + 0.8104f, + 0.8104f, + 0.6160f, + -0.3721f, + 0.8105f, + 0.8105f + ]; + + private static readonly float[] RacushSitMuscles = + [ + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + -0.7500f, + -0.0002f, + 0.1599f, + -0.1500f, + 0.1000f, + 0.1300f, + -0.0001f, + 0.0000f, + -0.7500f, + -0.0002f, + 0.1599f, + -0.1500f, + 0.1000f, + 0.1300f, + -0.0001f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.3927f, + 0.3114f, + 0.0805f, + 0.9650f, + -0.0536f, + 0.0024f, + 0.0005f, + 0.0000f, + 0.0000f, + 0.3928f, + 0.3114f, + 0.0805f, + 0.9650f, + -0.0536f, + 0.0024f, + 0.0005f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f, + 0.0000f + ]; + + #endregion Custom Pose Arrays +} \ No newline at end of file diff --git a/ConfigureCalibrationPose/Properties/AssemblyInfo.cs b/ConfigureCalibrationPose/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1fdc09d --- /dev/null +++ b/ConfigureCalibrationPose/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using MelonLoader; +using NAK.ConfigureCalibrationPose.Properties; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.ConfigureCalibrationPose))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.ConfigureCalibrationPose))] + +[assembly: MelonInfo( + typeof(NAK.ConfigureCalibrationPose.ConfigureCalibrationPoseMod), + nameof(NAK.ConfigureCalibrationPose), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/ConfigureCalibrationPose" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] +[assembly: MelonColor(255, 246, 25, 99)] // red-pink +[assembly: MelonAuthorColor(255, 158, 21, 32)] // red +[assembly: HarmonyDontPatchAll] + +namespace NAK.ConfigureCalibrationPose.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/ConfigureCalibrationPose/README.md b/ConfigureCalibrationPose/README.md new file mode 100644 index 0000000..f17ba48 --- /dev/null +++ b/ConfigureCalibrationPose/README.md @@ -0,0 +1,14 @@ +# ConfigureCalibrationPose + +Select FBT calibration pose. + +--- + +Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI. +https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games + +> This mod is an independent creation not affiliated with, supported by, or approved by Alpha Blend Interactive. + +> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. + +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. diff --git a/ConfigureCalibrationPose/format.json b/ConfigureCalibrationPose/format.json new file mode 100644 index 0000000..6324d2b --- /dev/null +++ b/ConfigureCalibrationPose/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "ConfigureCalibrationPose", + "modversion": "1.0.0", + "gameversion": "2025r179", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Lets you bring held & attached props through world loads.\nhttps://youtu.be/9P6Jeh-VN58?si=eXTPGyKB_0wq1gZO", + "searchtags": [ + "prop", + "spawn", + "friend", + "load" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/ConfigureCalibrationPose.dll", + "sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/ConfigureCalibrationPose/", + "changelog": "- Initial Release", + "embedcolor": "#00FFFF" +} \ No newline at end of file diff --git a/README.md b/README.md index e3217d1..39be991 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,10 @@ |------|-------------|----------| | [ASTExtension](ASTExtension/README.md) | Extension mod for [Avatar Scale Tool](https://github.com/NotAKidoS/AvatarScaleTool): | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/ASTExtension.dll) | | [AvatarQueueSystemTweaks](AvatarQueueSystemTweaks/README.md) | Small tweaks to the Avatar Queue System. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/AvatarQueueSystemTweaks.dll) | +| [ConfigureCalibrationPose](ConfigureCalibrationPose/README.md) | Select FBT calibration pose. | No Download | | [CustomSpawnPoint](CustomSpawnPoint/README.md) | Replaces the unused Images button in the World Details page with a button to set a custom spawn point. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/CustomSpawnPoint.dll) | | [DoubleTapJumpToExitSeat](DoubleTapJumpToExitSeat/README.md) | Replaces seat exit controls with a double-tap of the jump button, avoiding accidental exits from joystick drift or opening the menu. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/DoubleTapJumpToExitSeat.dll) | -| [FuckToes](FuckToes/README.md) | Prevents VRIK from autodetecting toes in Halfbody or Fullbody. | No Download | +| [FuckToes](FuckToes/README.md) | Prevents VRIK from autodetecting toes in Halfbody or Fullbody. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/FuckToes.dll) | | [KeepVelocityOnExitFlight](KeepVelocityOnExitFlight/README.md) | Keeps the player's velocity when exiting flight mode. Makes it possible to fling yourself like in Garry's Mod. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/KeepVelocityOnExitFlight.dll) | | [LazyPrune](LazyPrune/README.md) | Prevents loaded objects from immediately unloading on destruction. Should prevent needlessly unloading & reloading all avatars/props on world rejoin or GS reconnection. | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/LazyPrune.dll) | | [PropLoadingHexagon](PropLoadingHexagon/README.md) | https://github.com/NotAKidoS/NAK_CVR_Mods/assets/37721153/a892c765-71c1-47f3-a781-bdb9b60ba117 | [Download](https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r46/PropLoadingHexagon.dll) |