Skip to content

Commit

Permalink
V62 Patch 1
Browse files Browse the repository at this point in the history
- Buffed drowning in VR, which now also works properly when crouching
- Dead players can no longer collide with the football
  • Loading branch information
DaXcess committed Aug 21, 2024
1 parent df08604 commit b96f799
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
26 changes: 13 additions & 13 deletions Source/Patches/PlayerControllerPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GameNetcodeStuff;
using System;
using GameNetcodeStuff;
using HarmonyLib;
using LCVR.Assets;
using LCVR.Input;
Expand All @@ -7,6 +8,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR;
Expand Down Expand Up @@ -308,8 +310,7 @@ private static void SwitchedToItemSlot(PlayerControllerB __instance)
}

/// <summary>
/// Fix for water suffocation to be calculated from a predetermined offset instead of the camera position,
/// which fixes an exploit where being too tall prevents drowning
/// Fix for water suffocation to be calculated from a clamped offset, so that play area hacks won't affect drowning
/// </summary>
[HarmonyPatch(typeof(PlayerControllerB), nameof(PlayerControllerB.SetFaceUnderwaterFilters))]
[HarmonyTranspiler]
Expand All @@ -321,17 +322,16 @@ [new CodeMatch(OpCodes.Call, Method(typeof(Bounds), nameof(Bounds.Contains), [ty
.Advance(-3)
.RemoveInstructions(3)
.InsertAndAdvance(new CodeInstruction(OpCodes.Call,
PropertyGetter(typeof(Component), nameof(Component.transform))))
.InsertAndAdvance(new CodeInstruction(OpCodes.Callvirt,
PropertyGetter(typeof(Transform), nameof(Transform.position))))
.InsertAndAdvance(new CodeInstruction(OpCodes.Ldc_R4, 0f))
.InsertAndAdvance(new CodeInstruction(OpCodes.Ldc_R4, 2.3f))
.InsertAndAdvance(new CodeInstruction(OpCodes.Ldc_R4, 0f))
.InsertAndAdvance(new CodeInstruction(OpCodes.Newobj,
Constructor(typeof(Vector3), [typeof(float), typeof(float), typeof(float)])))
.InsertAndAdvance(new CodeInstruction(OpCodes.Call,
Method(typeof(Vector3), "op_Addition", [typeof(Vector3), typeof(Vector3)])))
((Func<PlayerControllerB, Vector3>)GetClampedCameraPosition).Method))
.InstructionEnumeration();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Vector3 GetClampedCameraPosition(PlayerControllerB player)
{
var actualHeight = player.transform.InverseTransformPoint(player.gameplayCamera.transform.position).y;

return player.transform.position + Vector3.up * Mathf.Clamp(actualHeight, 0.5f, 2.35f);
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions Source/Patches/Spectating/EnvironmentPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reflection.Emit;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

namespace LCVR.Patches.Spectating;

Expand Down Expand Up @@ -152,4 +153,16 @@ private static void UnderwaterPreventDeath(PlayerControllerB __instance)

StartOfRound.Instance.drowningTimer = 1;
}

/// <summary>
/// Prevent dead players from interacting with footballs
/// </summary>
[HarmonyPatch(typeof(SoccerBallProp), nameof(SoccerBallProp.ActivatePhysicsTrigger))]
[HarmonyPrefix]
private static bool DontTouchBallPatch(SoccerBallProp __instance, Collider other)
{
return !other.CompareTag("Player") ||
other.GetComponent<PlayerControllerB>() != StartOfRound.Instance.localPlayerController ||
!StartOfRound.Instance.localPlayerController.isPlayerDead;
}
}
2 changes: 1 addition & 1 deletion Source/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Plugin : BaseUnityPlugin

private readonly string[] GAME_ASSEMBLY_HASHES =
[
"45E2312BEEE3C163658C247354F10EE84DE5D594ED18A3D2EFC6B80F07AC1737", // V62
"976BBA44E5F05AC3915A92FA26822F6F7E67BD52F4FFD0371190EF865460F4FB", // V62
];

public new static Config Config { get; private set; }
Expand Down

0 comments on commit b96f799

Please sign in to comment.