Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of FallDamageChanges v1.0.2
FallDamageChanges.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FallDamageChanges")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ea7a57ac5190360172084d86053441cddf8f29a2")] [assembly: AssemblyProduct("FallDamageChanges")] [assembly: AssemblyTitle("FallDamageChanges")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FallDamageChanges { [BepInPlugin("prodzpod.FallDamageChanges", "FallDamageChanges", "1.0.0")] public class Main : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnTeleport_GameObject_Vector3_Vector3_Quaternion_bool <>9__16_0; public static Func<Instruction, bool> <>9__16_3; public static Func<float, CharacterBody, float> <>9__16_4; public static Func<Instruction, bool> <>9__16_5; public static Func<DamageInfo, DamageInfo> <>9__16_6; public static Manipulator <>9__16_1; public static hook_OnCharacterHitGroundServer <>9__16_2; internal void <Awake>b__16_0(orig_OnTeleport_GameObject_Vector3_Vector3_Quaternion_bool orig, GameObject obj, Vector3 pos, Vector3 vel, Quaternion a, bool b) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(obj, pos, vel, a, b); if (!(vel.y <= 0f)) { CharacterBody component = obj.GetComponent<CharacterBody>(); if (!oob.Contains(component)) { oob.Add(component); } } } internal void <Awake>b__16_1(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 4) }); val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Func<float, CharacterBody, float>>((Func<float, CharacterBody, float>)delegate(float orig, CharacterBody self) { orig *= FallMultiplier.Value; if (oob.Contains(self)) { orig *= OOBMultiplier.Value; } float num = MathF.Max(self.healthComponent.health - orig * self.maxHealth / 60f, FallThreshold.Value * self.maxHealth); if (oob.Contains(self)) { num = MathF.Max(num, OOBThreshold.Value * self.maxHealth); } return <Awake>g__inverseHP|16_7(num, self); }); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "TakeDamage") }); val.EmitDelegate<Func<DamageInfo, DamageInfo>>((Func<DamageInfo, DamageInfo>)delegate(DamageInfo info) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) bool flag = Run.instance.runRNG.RangeFloat(0f, 1f) < CritFall.Value; if (FallIsLethal.Value || flag) { info.damageType &= DamageTypeCombo.op_Implicit((DamageType)(-2)); info.damageType |= DamageTypeCombo.op_Implicit((DamageType)262144); } if (flag) { info.crit = true; } return info; }); } internal bool <Awake>b__16_3(Instruction x) { return ILPatternMatchingExt.MatchStloc(x, 4); } internal float <Awake>b__16_4(float orig, CharacterBody self) { orig *= FallMultiplier.Value; if (oob.Contains(self)) { orig *= OOBMultiplier.Value; } float num = MathF.Max(self.healthComponent.health - orig * self.maxHealth / 60f, FallThreshold.Value * self.maxHealth); if (oob.Contains(self)) { num = MathF.Max(num, OOBThreshold.Value * self.maxHealth); } return <Awake>g__inverseHP|16_7(num, self); } internal bool <Awake>b__16_5(Instruction x) { return ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "TakeDamage"); } internal DamageInfo <Awake>b__16_6(DamageInfo info) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) bool flag = Run.instance.runRNG.RangeFloat(0f, 1f) < CritFall.Value; if (FallIsLethal.Value || flag) { info.damageType &= DamageTypeCombo.op_Implicit((DamageType)(-2)); info.damageType |= DamageTypeCombo.op_Implicit((DamageType)262144); } if (flag) { info.crit = true; } return info; } internal void <Awake>b__16_2(orig_OnCharacterHitGroundServer orig, GlobalEventManager self, CharacterBody body, HitGroundInfo vel) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, body, vel); body.healthComponent.ospTimer = (oob.Contains(body) ? OOBIFrames.Value : FallIFrames.Value); oob.Remove(body); } } public const string PluginGUID = "prodzpod.FallDamageChanges"; public const string PluginAuthor = "prodzpod"; public const string PluginName = "FallDamageChanges"; public const string PluginVersion = "1.0.0"; public static ManualLogSource Log; public static PluginInfo pluginInfo; public static ConfigFile Config; public static ConfigEntry<bool> FallIsLethal; public static ConfigEntry<float> FallMultiplier; public static ConfigEntry<float> OOBMultiplier; public static ConfigEntry<float> FallThreshold; public static ConfigEntry<float> OOBThreshold; public static ConfigEntry<float> FallIFrames; public static ConfigEntry<float> OOBIFrames; public static ConfigEntry<float> CritFall; public static List<CharacterBody> oob = new List<CharacterBody>(); public void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown pluginInfo = ((BaseUnityPlugin)this).Info; Log = ((BaseUnityPlugin)this).Logger; Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.FallDamageChanges.cfg"), true); FallIsLethal = Config.Bind<bool>("General", "Fall Damage is Lethal", false, "Eclipse Real??"); FallMultiplier = Config.Bind<float>("General", "Fall Damage Multiplier", 1f, "Affects all fall damage."); OOBMultiplier = Config.Bind<float>("General", "Out of Bounds Damage Multiplier", 1f, "Affects damage from falling off the map."); FallThreshold = Config.Bind<float>("General", "Fall Damage Threshold", 0f, "Portion of HP that fall damage can't go below. default is 0 for 1HP. set to 1 to disable fall damage."); OOBThreshold = Config.Bind<float>("General", "Out of Bounds Damage Threshold", 0.3f, "Portion of HP that falling off the map can't deal below. Default is just enough to not pop potion/stealthkit/gloop/break low health stuff."); FallIFrames = Config.Bind<float>("General", "Fall Damage Invulnerability Seconds", 0.1f, "Amount of time invulnerable since fall damage. default is default OSP."); OOBIFrames = Config.Bind<float>("General", "Out of Bounds Damage Invulnerability Seconds", 0.5f, "Amount of time invulnerable since tp back. default is commonly modded OSP."); CritFall = Config.Bind<float>("General", "Critical Fall Chance", 0f, "The Cracked In Me Awakens..."); object obj2 = <>c.<>9__16_0; if (obj2 == null) { hook_OnTeleport_GameObject_Vector3_Vector3_Quaternion_bool val = delegate(orig_OnTeleport_GameObject_Vector3_Vector3_Quaternion_bool orig, GameObject obj, Vector3 pos, Vector3 vel, Quaternion a, bool b) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(obj, pos, vel, a, b); if (!(vel.y <= 0f)) { CharacterBody component = obj.GetComponent<CharacterBody>(); if (!oob.Contains(component)) { oob.Add(component); } } }; <>c.<>9__16_0 = val; obj2 = (object)val; } TeleportHelper.OnTeleport_GameObject_Vector3_Vector3_Quaternion_bool += (hook_OnTeleport_GameObject_Vector3_Vector3_Quaternion_bool)obj2; object obj3 = <>c.<>9__16_1; if (obj3 == null) { Manipulator val2 = delegate(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val4 = new ILCursor(il); val4.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 4) }); val4.Emit(OpCodes.Ldarg_1); val4.EmitDelegate<Func<float, CharacterBody, float>>((Func<float, CharacterBody, float>)delegate(float orig, CharacterBody self) { orig *= FallMultiplier.Value; if (oob.Contains(self)) { orig *= OOBMultiplier.Value; } float num = MathF.Max(self.healthComponent.health - orig * self.maxHealth / 60f, FallThreshold.Value * self.maxHealth); if (oob.Contains(self)) { num = MathF.Max(num, OOBThreshold.Value * self.maxHealth); } return inverseHP(num, self); }); val4.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "TakeDamage") }); val4.EmitDelegate<Func<DamageInfo, DamageInfo>>((Func<DamageInfo, DamageInfo>)delegate(DamageInfo info) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) bool flag = Run.instance.runRNG.RangeFloat(0f, 1f) < CritFall.Value; if (FallIsLethal.Value || flag) { info.damageType &= DamageTypeCombo.op_Implicit((DamageType)(-2)); info.damageType |= DamageTypeCombo.op_Implicit((DamageType)262144); } if (flag) { info.crit = true; } return info; }); }; <>c.<>9__16_1 = val2; obj3 = (object)val2; } GlobalEventManager.OnCharacterHitGroundServer += (Manipulator)obj3; object obj4 = <>c.<>9__16_2; if (obj4 == null) { hook_OnCharacterHitGroundServer val3 = delegate(orig_OnCharacterHitGroundServer orig, GlobalEventManager self, CharacterBody body, HitGroundInfo vel) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, body, vel); body.healthComponent.ospTimer = (oob.Contains(body) ? OOBIFrames.Value : FallIFrames.Value); oob.Remove(body); }; <>c.<>9__16_2 = val3; obj4 = (object)val3; } GlobalEventManager.OnCharacterHitGroundServer += (hook_OnCharacterHitGroundServer)obj4; static float inverseHP(float orig, CharacterBody self) { return (self.healthComponent.health - orig) * 60f / self.maxHealth; } } [CompilerGenerated] internal static float <Awake>g__inverseHP|16_7(float orig, CharacterBody self) { return (self.healthComponent.health - orig) * 60f / self.maxHealth; } } }