using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DontGetHit.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DontGetHit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DontGetHit")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6f985679-efe4-41dd-9e68-15681a1b7cb9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DontGetHit
{
[BepInPlugin("reptile.DontGetHit", "reptile Don't Get Hit", "1.0.0.0")]
public class OneHealthMod : BaseUnityPlugin
{
private const string modGUID = "reptile.DontGetHit";
private const string modName = "reptile Don't Get Hit";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("reptile.DontGetHit");
private static OneHealthMod Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("reptile.DontGetHit");
mls.LogInfo((object)"Health slashed! >:3");
harmony.PatchAll(typeof(OneHealthMod));
harmony.PatchAll(typeof(EnemyDamagePatch));
harmony.PatchAll(typeof(PlayerControllerBPatch));
}
}
}
namespace DontGetHit.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class EnemyDamagePatch
{
[HarmonyPatch("DamagePlayer")]
[HarmonyPrefix]
private static bool Instadeath(ref PlayerControllerB __instance, ref int damageNumber, ref bool hasDamageSFX, ref bool callRPC, ref CauseOfDeath causeOfDeath, ref int deathAnimation, ref bool fallDamage, ref Vector3 force)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsOwner || __instance.isPlayerDead || !__instance.AllowPlayerDeath())
{
return false;
}
__instance.health = Mathf.Clamp(__instance.health - damageNumber, 0, 100);
HUDManager.Instance.UpdateHealthUI(__instance.health, true);
if (__instance.health <= 0)
{
bool flag = deathAnimation != -1;
__instance.KillPlayer(force, flag, causeOfDeath, deathAnimation, default(Vector3));
}
return false;
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public class PlayerControllerBPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void HealthValuePatch(ref int ___health)
{
___health = 1;
}
}
}