Fall damage _(flops)_

This commit is contained in:
SDraw 2023-12-31 17:54:39 +03:00
parent 9e841cef1c
commit 1c9822dba2
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
14 changed files with 106 additions and 23 deletions

View file

@ -3,13 +3,13 @@ Merged set of MelonLoader mods for ChilloutVR.
**Table for game build 2023r173:**
| Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) |
|:---------:|:----------:|:--------------:| :----------------------------------------------------------------|
| [Avatar Motion Tweaker](/ml_amt/README.md) | ml_amt | 1.3.5 [:arrow_down:](../../releases/latest/download/ml_amt.dll)| ✔ Yes |
| [Avatar Synced Look](/ml_asl/README.md) | ml_asl | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_asl.dll)| :hourglass: On review |
| [Avatar Motion Tweaker](/ml_amt/README.md) | ml_amt | 1.3.6 [:arrow_down:](../../releases/latest/download/ml_amt.dll)| ✔ Yes<br>:hourglass: Update review |
| [Avatar Synced Look](/ml_asl/README.md) | ml_asl | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_asl.dll)| ✔ Yes |
| [Leap Motion Extension](/ml_lme/README.md)| ml_lme | 1.4.5 [:arrow_down:](../../releases/latest/download/ml_lme.dll)| ✔ Yes |
| [Pickup Arm Movement](/ml_pam/README.md)| ml_pam | 1.0.9 [:arrow_down:](../../releases/latest/download/ml_pam.dll)| ✔ Yes |
| [Player Movement Copycat](/ml_pmc/README.md)| ml_pmc | 1.0.4 [:arrow_down:](../../releases/latest/download/ml_pmc.dll)| ✔ Yes |
| [Player Ragdoll Mod](/ml_prm/README.md) | ml_prm | 1.1.1 [:arrow_down:](../../releases/latest/download/ml_prm.dll)| ✔ Yes |
| [Players Instance Notifier](/ml_pin/README.md) | ml_pin | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_ml_pin.dll)| :hourglass: On review |
| [Player Ragdoll Mod](/ml_prm/README.md) | ml_prm | 1.1.2 [:arrow_down:](../../releases/latest/download/ml_prm.dll)| ✔ Yes<br>:hourglass: Update review |
| [Players Instance Notifier](/ml_pin/README.md) | ml_pin | 1.0.1 [:arrow_down:](../../releases/latest/download/ml_ml_pin.dll)| ✔ Yes<br>:hourglass: Update review |
| [Vive Extended Input](/ml_vei/README.md) | ml_vei | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_vei.dll)| ✔ Yes |
**Archived mods:**

View file

@ -1,4 +1,4 @@
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.6", "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)]

View file

@ -16,7 +16,6 @@ namespace ml_amt
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_grounded.GetValue(MovementSystem.Instance);
public static bool IsGroundedRaw(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(MovementSystem.Instance);
public static bool HasToes(this IKSolverVR p_instance) => (bool)ms_hasToes.GetValue(p_instance);

View file

@ -6,7 +6,7 @@
<Company>None</Company>
<Product>AvatarMotionTweaker</Product>
<PackageId>AvatarMotionTweaker</PackageId>
<Version>1.3.5</Version>
<Version>1.3.6</Version>
<Platforms>x64</Platforms>
<AssemblyName>ml_amt</AssemblyName>
</PropertyGroup>

View file

@ -42,7 +42,7 @@ namespace ml_pin
try
{
bool l_isFriend = Friends.FriendsWith(p_player.ownerId);
bool l_notify = true;
bool l_notify = false;
switch(Settings.NotifyType)
{
@ -50,13 +50,13 @@ namespace ml_pin
l_notify = false;
break;
case Settings.NotificationType.Friends:
l_notify = (ShouldNotifyInCurrentInstance() && l_isFriend);
l_notify = (l_isFriend && ShouldNotifyInCurrentInstance());
break;
case Settings.NotificationType.All:
l_notify = ShouldNotifyInCurrentInstance();
break;
}
l_notify |= (Settings.FriendsAlways && l_isFriend);
l_notify |= (l_isFriend && Settings.FriendsAlways);
if(l_notify)
m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendJoin : SoundManager.SoundType.PlayerJoin);
@ -71,7 +71,7 @@ namespace ml_pin
try
{
bool l_isFriend = Friends.FriendsWith(p_player.ownerId);
bool l_notify = true;
bool l_notify = false;
switch(Settings.NotifyType)
{
@ -79,13 +79,13 @@ namespace ml_pin
l_notify = false;
break;
case Settings.NotificationType.Friends:
l_notify = (ShouldNotifyInCurrentInstance() && l_isFriend);
l_notify = (l_isFriend && ShouldNotifyInCurrentInstance());
break;
case Settings.NotificationType.All:
l_notify = ShouldNotifyInCurrentInstance();
break;
}
l_notify |= (Settings.FriendsAlways && l_isFriend);
l_notify |= (l_isFriend && Settings.FriendsAlways);
if(l_notify)
m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendLeave : SoundManager.SoundType.PlayerLeave);
@ -98,9 +98,9 @@ namespace ml_pin
bool ShouldNotifyInCurrentInstance()
{
bool l_isInPublic = (Settings.NotifyInPublic && MetaPort.Instance.CurrentInstancePrivacy.Contains("Public"));
bool l_isInFriends = (Settings.NotifyInFriends && MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends"));
bool l_isInPrivate = (Settings.NotifyInPrivate && MetaPort.Instance.CurrentInstancePrivacy.Contains("invite"));
bool l_isInPublic = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Public") && Settings.NotifyInPublic);
bool l_isInFriends = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends") && Settings.NotifyInFriends);
bool l_isInPrivate = (MetaPort.Instance.CurrentInstancePrivacy.Contains("invite") && Settings.NotifyInPrivate);
return (l_isInPublic || l_isInFriends || l_isInPrivate);
}
}

View file

@ -1,4 +1,4 @@
[assembly: MelonLoader.MelonInfo(typeof(ml_pin.PlayersInstanceNotifier), "PlayersInstanceNotifier", "1.0.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_pin.PlayersInstanceNotifier), "PlayersInstanceNotifier", "1.0.1", "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)]

View file

@ -7,6 +7,7 @@
<Authors>SDraw</Authors>
<Company>None</Company>
<Product>PlayersInstanceNotifier</Product>
<Version>1.0.1</Version>
</PropertyGroup>
<ItemGroup>

View file

@ -21,10 +21,12 @@ namespace ml_prm
ViewVelocity,
JumpRecover,
Buoyancy,
FallDamage,
VelocityMultiplier,
MovementDrag,
AngularDrag,
RecoverDelay
RecoverDelay,
FallLimit
}
static public event Action SwitchChange;
@ -85,6 +87,9 @@ namespace ml_prm
ms_uiElements.Add(l_modCategory.AddToggle("Buoyancy", "Enable buoyancy in fluid volumes. Warning: constantly changes movement and air drag of hips, spine and chest.", Settings.Buoyancy));
(ms_uiElements[(int)UiIndex.Buoyancy] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(UiIndex.Buoyancy, state);
ms_uiElements.Add(l_modCategory.AddToggle("Fall damage", "Enable ragdoll when falling from height", Settings.FallDamage));
(ms_uiElements[(int)UiIndex.FallDamage] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(UiIndex.FallDamage, state);
ms_uiElements.Add(l_modRoot.AddSlider("Velocity multiplier", "Velocity multiplier upon entering ragdoll state", Settings.VelocityMultiplier, 1f, 50f));
(ms_uiElements[(int)UiIndex.VelocityMultiplier] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(UiIndex.VelocityMultiplier, value);
@ -97,6 +102,9 @@ namespace ml_prm
ms_uiElements.Add(l_modRoot.AddSlider("Recover delay (seconds)", "Recover delay for automatic recover", Settings.RecoverDelay, 1f, 10f));
(ms_uiElements[(int)UiIndex.RecoverDelay] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(UiIndex.RecoverDelay, value);
ms_uiElements.Add(l_modRoot.AddSlider("Fall limit", "Height limit for fall damage", Settings.FallLimit, 0f, 100f));
(ms_uiElements[(int)UiIndex.FallLimit] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(UiIndex.FallLimit, value);
l_modCategory.AddButton("Reset settings", "", "Reset mod settings to default").OnPress += Reset;
}
@ -147,6 +155,10 @@ namespace ml_prm
case UiIndex.Buoyancy:
Settings.SetSetting(Settings.ModSetting.Buoyancy, p_state);
break;
case UiIndex.FallDamage:
Settings.SetSetting(Settings.ModSetting.FallDamage, p_state);
break;
}
if(p_force)
@ -172,6 +184,10 @@ namespace ml_prm
case UiIndex.RecoverDelay:
Settings.SetSetting(Settings.ModSetting.RecoverDelay, p_value);
break;
case UiIndex.FallLimit:
Settings.SetSetting(Settings.ModSetting.FallLimit, p_value);
break;
}
if(p_force)
@ -191,10 +207,12 @@ namespace ml_prm
OnToggleUpdate(UiIndex.ViewVelocity, false, true);
OnToggleUpdate(UiIndex.JumpRecover, false, true);
OnToggleUpdate(UiIndex.Buoyancy, true, true);
OnToggleUpdate(UiIndex.FallDamage, true, true);
OnSliderUpdate(UiIndex.VelocityMultiplier, 2f, true);
OnSliderUpdate(UiIndex.MovementDrag, 1f, true);
OnSliderUpdate(UiIndex.AngularDrag, 1f, true);
OnSliderUpdate(UiIndex.RecoverDelay, 3f, true);
OnSliderUpdate(UiIndex.FallLimit, 5f, true);
}
static Stream GetIconStream(string p_name)

View file

@ -1,4 +1,4 @@
[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.1.1", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.1.2", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPriority(2)]
[assembly: MelonLoader.MelonOptionalDependencies("BTKUILib")]

View file

@ -26,8 +26,9 @@ Optional mod's settings page with [BTKUILib](https://github.com/BTK-Development/
* **View direction velocity:** apply velocity to camera view direction instead of player movement direction; `false` by default.
* Note: Forcibly disabled in worlds that don't allow flight.
* **Jump recover:** enables recovering from ragdoll state by jumping; `false` by default.
* **Buoyancy:** enabled floating in fluid volumes; `true` by default.
* **Buoyancy:** enables floating in fluid volumes; `true` by default.
* Note: Forcibly enabled in worlds that don't allow flight.
* **Fall damage:** enables ragdoll when falling from specific height; `true` by default.
* **Velocity multiplier:** velocity force multiplier based on player's movement direction; `2.0` by default.
* Note: Limited according to world's fly multiplier.
* Note: Forcibly set to `1.0` in worlds that don't allow flight.
@ -35,6 +36,7 @@ Optional mod's settings page with [BTKUILib](https://github.com/BTK-Development/
* Note: Forcibly set to `1.0` in worlds that don't allow flight.
* **Angular movement drag:** angular movement resistance; `2.0` by default.
* **Recover delay:** time delay for enabled `Auto recover` in seconds; `3.0` by default.
* **Fall limit:** height limit for fall damage; `5.0` by default.
* **Reset settings:** resets mod settings to default.
Optional mod's settings in [UIExpansionKit](https://github.com/ddakebono/ChilloutMods):

View file

@ -52,6 +52,9 @@ namespace ml_prm
float m_groundedTime = 0f;
float m_downTime = float.MinValue;
bool m_inAir = false;
float m_inAirDistance = 0f;
internal RagdollController()
{
m_rigidBodies = new List<Rigidbody>();
@ -88,6 +91,7 @@ namespace ml_prm
Settings.SlipperinessChange += this.OnPhysicsMaterialChange;
Settings.BouncinessChange += this.OnPhysicsMaterialChange;
Settings.BuoyancyChange += this.OnBuoyancyChange;
Settings.FallDamageChange += this.OnFallDamageChange;
}
void OnDestroy()
@ -124,12 +128,29 @@ namespace ml_prm
Settings.SlipperinessChange -= this.OnPhysicsMaterialChange;
Settings.BouncinessChange -= this.OnPhysicsMaterialChange;
Settings.BuoyancyChange -= this.OnBuoyancyChange;
Settings.FallDamageChange -= this.OnFallDamageChange;
}
void Update()
{
if(m_avatarReady && !m_enabled && Settings.FallDamage && !MovementSystem.Instance.flying)
{
bool l_grounded = MovementSystem.Instance.IsGroundedRaw();
if(m_inAir && l_grounded && (m_inAirDistance > Settings.FallLimit))
{
m_inAirDistance = 0f;
SwitchRagdoll();
}
m_inAir = !l_grounded;
if(l_grounded)
m_inAirDistance = 0f;
}
if(m_avatarReady && m_enabled)
{
m_inAirDistance = 0f;
Vector3 l_dif = m_puppetReferences.hips.position - m_ragdollLastPos;
PlayerSetup.Instance.transform.position += l_dif;
m_puppetReferences.hips.position -= l_dif;
@ -142,6 +163,12 @@ namespace ml_prm
{
Vector3 l_pos = PlayerSetup.Instance.transform.position;
m_velocity = (m_velocity + (l_pos - m_lastPosition) / Time.deltaTime) * 0.5f;
if(m_inAir)
{
m_inAirDistance += (m_lastPosition - l_pos).y;
m_inAirDistance = Mathf.Clamp(m_inAirDistance, 0f, float.MaxValue);
}
m_lastPosition = l_pos;
if(!m_reachedGround && MovementSystem.Instance.IsGrounded())
@ -233,6 +260,8 @@ namespace ml_prm
m_groundedTime = 0f;
m_downTime = float.MinValue;
m_puppetRoot.localScale = Vector3.one;
m_inAir = false;
m_inAirDistance = 0f;
}
internal void OnAvatarSetup()
@ -410,6 +439,7 @@ namespace ml_prm
OnPhysicsMaterialChange(true);
OnMovementDragChange(Settings.MovementDrag);
OnBuoyancyChange(Settings.Buoyancy);
OnFallDamageChange(Settings.FallDamage);
}
internal void OnCombatDown()
@ -425,6 +455,8 @@ namespace ml_prm
internal void OnChangeFlight()
{
OnFallDamageChange(Settings.FallDamage);
if(m_avatarReady && m_enabled && MovementSystem.Instance.flying)
{
m_forcedSwitch = true;
@ -435,6 +467,8 @@ namespace ml_prm
internal void OnPlayerTeleport()
{
OnFallDamageChange(Settings.FallDamage);
if(m_avatarReady && m_enabled)
m_ragdollLastPos = m_puppetReferences.hips.position;
}
@ -530,6 +564,11 @@ namespace ml_prm
}
}
}
void OnFallDamageChange(bool p_state)
{
m_inAir = false;
m_inAirDistance = 0f;
}
// Arbitrary
public void SwitchRagdoll()

View file

@ -23,7 +23,9 @@ namespace ml_prm
Bounciness,
ViewVelocity,
JumpRecover,
Buoyancy
Buoyancy,
FallDamage,
FallLimit
}
public static bool Hotkey { get; private set; } = true;
@ -42,6 +44,8 @@ namespace ml_prm
public static bool ViewVelocity { get; private set; } = false;
public static bool JumpRecover { get; private set; } = false;
public static bool Buoyancy { get; private set; } = true;
public static bool FallDamage { get; private set; } = true;
public static float FallLimit { get; private set; } = 5f;
static public event Action<bool> HotkeyChange;
static public event Action<KeyCode> HotkeyKeyChange;
@ -59,6 +63,8 @@ namespace ml_prm
static public event Action<bool> ViewVelocityChange;
static public event Action<bool> JumpRecoverChange;
static public event Action<bool> BuoyancyChange;
static public event Action<bool> FallDamageChange;
static public event Action<float> FallLimitChange;
static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
@ -85,6 +91,8 @@ namespace ml_prm
ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity, null, null, true),
ms_category.CreateEntry(ModSetting.JumpRecover.ToString(), JumpRecover, null, null, true),
ms_category.CreateEntry(ModSetting.Buoyancy.ToString(), Buoyancy, null, null, true),
ms_category.CreateEntry(ModSetting.FallDamage.ToString(), FallDamage, null, null, true),
ms_category.CreateEntry(ModSetting.FallLimit.ToString(), FallLimit, null, null, true),
};
ms_entries[(int)ModSetting.HotkeyKey].OnEntryValueChangedUntyped.Subscribe(OnMelonSettingSave_HotkeyKey);
@ -105,6 +113,8 @@ namespace ml_prm
ViewVelocity = (bool)ms_entries[(int)ModSetting.ViewVelocity].BoxedValue;
JumpRecover = (bool)ms_entries[(int)ModSetting.JumpRecover].BoxedValue;
Buoyancy = (bool)ms_entries[(int)ModSetting.Buoyancy].BoxedValue;
FallDamage = (bool)ms_entries[(int)ModSetting.FallDamage].BoxedValue;
FallLimit = Mathf.Clamp((float)ms_entries[(int)ModSetting.FallLimit].BoxedValue, 0f, 100f);
}
static void OnMelonSettingSave_HotkeyKey(object p_oldValue, object p_newValue)
@ -198,6 +208,13 @@ namespace ml_prm
}
break;
case ModSetting.FallDamage:
{
FallDamage = (bool)p_value;
FallDamageChange?.Invoke((bool)p_value);
}
break;
// Floats
case ModSetting.VelocityMultiplier:
{
@ -226,6 +243,13 @@ namespace ml_prm
RecoverDelayChange?.Invoke((float)p_value);
}
break;
case ModSetting.FallLimit:
{
FallLimit = (float)p_value;
FallLimitChange?.Invoke((float)p_value);
}
break;
}
if(ms_entries != null)

View file

@ -31,7 +31,7 @@ namespace ml_prm
return l_result;
}
public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(p_instance);
public static bool IsGroundedRaw(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(p_instance);
public static Vector3 GetAppliedGravity(this MovementSystem p_instance) => (Vector3)ms_appliedGravity.GetValue(p_instance);
public static void SetAppliedGravity(this MovementSystem p_instance, Vector3 p_vec) => ms_appliedGravity.SetValue(p_instance, p_vec);
public static void ClearFluidVolumes(this MovementSystem p_instance) => (ms_touchingVolumes.GetValue(p_instance) as List<FluidVolume>)?.Clear();

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<Platforms>x64</Platforms>
<PackageId>PlayerRagdollMod</PackageId>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
<Authors>SDraw</Authors>
<Company>None</Company>
<Product>PlayerRagdollMod</Product>