Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Revert Fall Damage v1.1.0
RevertFallDamage/RevertFallDamage.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; 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("v40FallDamage")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("v40FallDamage")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("bc713062-eaeb-4cff-986e-4d75b7a3f7c7")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace RevertFallDamage { [BepInPlugin("Confusified.RevertFallDamage", "Revert Fall Damage", "1.1.0")] public class Main : BaseUnityPlugin { private const string modGUID = "Confusified.RevertFallDamage"; private const string modName = "Revert Fall Damage"; private const string modVersion = "1.1.0"; private readonly Harmony _harmony = new Harmony("Confusified.RevertFallDamage"); public static ManualLogSource mls; public ConfigFile Configuration = new ConfigFile(Utility.CombinePaths(new string[1] { Paths.ConfigPath + "\\" + "Confusified.RevertFallDamage".Replace(".", "\\") + ".cfg" }), false); public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<int> UsingFallingMode; public static ConfigEntry<bool> useTerminal; private void Awake() { SetModConfig(); _harmony.PatchAll(); mls = Logger.CreateLogSource("Confusified.RevertFallDamage"); mls = ((BaseUnityPlugin)this).Logger; mls.LogInfo((object)"Revert Fall Damage 1.1.0 has loaded"); if (UsingFallingMode.Value > 2 || UsingFallingMode.Value < 0) { UsingFallingMode.Value = 0; mls.LogWarning((object)"Changed config: using non existant mode\nMode has been set to standard."); } } private void SetModConfig() { ModEnabled = Configuration.Bind<bool>("Global Settings", "Enabled", true, "Allows the mod to function"); UsingFallingMode = Configuration.Bind<int>("Mod Settings", "FallDamageVersion", 0, "Set to how the fall damage works.\nCurrent Fall Damage = 0 (Default)\nVersion 45 Fall Damage = 1\nVersion 40 Fall Damage = 2"); useTerminal = Configuration.Bind<bool>("Mod Settings", "useTerminal", true, "Use Terminal keywords to change settings of this mod"); } } } namespace RevertFallDamage.Patches { [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerHitGroundEffectsPatch { [HarmonyPatch("PlayerHitGroundEffects")] [HarmonyPrefix] [HarmonyWrapSafe] public static void PatchedFallDamage(PlayerControllerB __instance) { //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) __instance.GetCurrentMaterialStandingOn(); if (__instance.fallValue < -9f) { if (__instance.fallValue < -16f) { __instance.movementAudio.PlayOneShot(StartOfRound.Instance.playerHitGroundHard, 1f); WalkieTalkie.TransmitOneShotAudio(__instance.movementAudio, StartOfRound.Instance.playerHitGroundHard, 1f); } else if (__instance.fallValue < -2f) { __instance.movementAudio.PlayOneShot(StartOfRound.Instance.playerHitGroundSoft, 1f); } __instance.LandFromJumpServerRpc(__instance.fallValue < -16f); } if (__instance.fallValueUncapped < -30f && Main.ModEnabled.Value && Main.UsingFallingMode.Value == 2) { __instance.takingFallDamage = true; } else if (__instance.fallValueUncapped < -40f && Main.ModEnabled.Value && Main.UsingFallingMode.Value == 1) { __instance.takingFallDamage = true; } if (__instance.takingFallDamage && !__instance.jetpackControls && !__instance.disablingJetpackControls && !__instance.isSpeedCheating) { Debug.Log((object)$"Fall damage: {__instance.fallValueUncapped}"); if (Main.ModEnabled.Value && Main.UsingFallingMode.Value != 0) { int num; if (Main.UsingFallingMode.Value == 1 || Main.UsingFallingMode.Value == 2) { num = Main.UsingFallingMode.Value; } else { num = 1; Main.mls.LogWarning((object)"Falling mode isn't set to v45 or v40, defaulting to v45 fall damage"); } if (__instance.fallValueUncapped < -50f) { __instance.DamagePlayer(100, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else { __instance.DamagePlayer(40 / num, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } } else if (__instance.fallValueUncapped < -48.5f) { __instance.DamagePlayer(100, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else if (__instance.fallValueUncapped < -45f) { __instance.DamagePlayer(80, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else if (__instance.fallValueUncapped < -40f) { __instance.DamagePlayer(50, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } else { __instance.DamagePlayer(30, true, true, (CauseOfDeath)2, 0, false, default(Vector3)); } } if (__instance.fallValue < -16f) { RoundManager.Instance.PlayAudibleNoise(((Component)__instance).transform.position, 7f, 0.5f, 0, false, 0); } } } [HarmonyPatch(typeof(Terminal))] public class TerminalPatch { private static string FallModeString = "<unknown value>"; private static TerminalNode MainMenuNode; private static bool CommandRanLegally; [HarmonyPatch("Start")] [HarmonyPrefix] [HarmonyWrapSafe] public static void TerminalPatchCommands(Terminal __instance) { if (Main.ModEnabled.Value && Main.useTerminal.Value) { if (Main.UsingFallingMode.Value == 0) { FallModeString = "standard"; } else if (Main.UsingFallingMode.Value == 1) { FallModeString = "v45"; } else if (Main.UsingFallingMode.Value == 2) { FallModeString = "v40"; } TerminalNode val = (MainMenuNode = ScriptableObject.CreateInstance<TerminalNode>()); val.displayText = "Revert Fall Damage Mod - Commands\n\n>STANDARD\nSet the fall damage to normal\n\n>V45\nRevert fall damage to v45\n\n>V40\nRevert fall damage to v40\n\n\nCurrently using " + FallModeString + " fall damage.\n\n"; val.clearPreviousText = true; val.terminalEvent = "rfd_mainmenu"; val.acceptAnything = false; TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>(); val2.displayText = "Revert Fall Damage Mod - Success\n\nFall damage has been set to v45.\n\n\n"; val2.clearPreviousText = true; val2.terminalEvent = "rfd_v45"; val2.acceptAnything = false; TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>(); val3.displayText = "Revert Fall Damage Mod - Success\n\nFall damage has been set to v40.\n\n\n"; val3.clearPreviousText = true; val3.terminalEvent = "rfd_v40"; val3.acceptAnything = false; TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>(); val4.displayText = "Revert Fall Damage Mod - Success\n\nFall damage has been set to normal.\n\n\n"; val4.clearPreviousText = true; val4.terminalEvent = "rfd_standard"; val4.acceptAnything = false; TerminalKeyword val5 = ScriptableObject.CreateInstance<TerminalKeyword>(); val5.isVerb = false; val5.word = "revertfalldamage"; val5.specialKeywordResult = val; TerminalKeyword val6 = ScriptableObject.CreateInstance<TerminalKeyword>(); val6.isVerb = false; val6.word = "rfd"; val6.specialKeywordResult = val; TerminalKeyword val7 = ScriptableObject.CreateInstance<TerminalKeyword>(); val7.isVerb = false; val7.word = "standard"; val7.specialKeywordResult = val4; TerminalKeyword val8 = ScriptableObject.CreateInstance<TerminalKeyword>(); val8.isVerb = false; val8.word = "v45"; val8.specialKeywordResult = val2; TerminalKeyword val9 = ScriptableObject.CreateInstance<TerminalKeyword>(); val9.isVerb = false; val9.word = "v40"; val9.specialKeywordResult = val3; __instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val5); __instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val6); __instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val7); __instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val8); __instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, val9); } } [HarmonyPatch("RunTerminalEvents")] [HarmonyPrefix] [HarmonyWrapSafe] public static void TerminalEventsPatch(TerminalNode node, Terminal __instance) { CommandRanLegally = true; if (string.IsNullOrWhiteSpace(node.terminalEvent)) { return; } if (node.terminalEvent == "rfd_standard") { if (__instance.currentNode.terminalEvent == "rfd_mainmenu" && Main.useTerminal.Value) { Main.UsingFallingMode.Value = 0; MainMenuNode.displayText = MainMenuNode.displayText.Replace(FallModeString, "standard"); FallModeString = "standard"; } else { CommandRanLegally = false; } } else if (node.terminalEvent == "rfd_v45") { if (__instance.currentNode.terminalEvent == "rfd_mainmenu" && Main.useTerminal.Value) { Main.UsingFallingMode.Value = 1; MainMenuNode.displayText = MainMenuNode.displayText.Replace(FallModeString, "v45"); FallModeString = "v45"; } else { CommandRanLegally = false; } } else if (node.terminalEvent == "rfd_v40") { if (__instance.currentNode.terminalEvent == "rfd_mainmenu" && Main.useTerminal.Value) { Main.UsingFallingMode.Value = 2; MainMenuNode.displayText = MainMenuNode.displayText.Replace(FallModeString, "v40"); FallModeString = "v40"; } else { CommandRanLegally = false; } } } [HarmonyPatch("LoadNewNode")] [HarmonyPostfix] [HarmonyWrapSafe] public static void LoadNodePostfix(TerminalNode node, Terminal __instance) { if (!CommandRanLegally) { HUDManager.Instance.DisplayTip("Revert Fall Damage", "You cannot run this command from outside the mod's terminal menu.", true, false, "LC_Tip1"); __instance.LoadNewNode(__instance.terminalNodes.specialNodes[12]); } } } }