Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ProcSolver v1.1.4
ProcSolver.dll
Decompiled 5 days agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using R2API; using RoR2; using RoR2BepInExPack.Utilities; 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 = "")] [assembly: AssemblyCompany("ProcSolver")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ProcSolver")] [assembly: AssemblyTitle("ProcSolver")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ProcSolver; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.RiskOfBrainrot.ProcSolver", "ProcSolver", "1.1.1")] public class ProcSolverPlugin : BaseUnityPlugin { public const string guid = "com.RiskOfBrainrot.ProcSolver"; public const string teamName = "RiskOfBrainrot"; public const string modName = "ProcSolver"; public const string version = "1.1.1"; public static FixedConditionalWeakTable<DamageInfo, MoreDamageInfoStats> moreDamageInfoStats = new FixedConditionalWeakTable<DamageInfo, MoreDamageInfoStats>(); public static ModdedProcType ProccedBySkill; public static PluginInfo PInfo { get; private set; } internal static ConfigFile CustomConfigFile { get; private set; } public static ConfigEntry<bool> BandsDamageSourceRequirement { get; set; } public static ConfigEntry<int> MaxChainLength { get; set; } public static ConfigEntry<int> AutoplayChainLength { get; set; } public static ConfigEntry<float> AutoplayProcRate { get; set; } public static ConfigEntry<float> ChainProcRate { get; set; } private static int maxChainLength => MaxChainLength.Value; private static int allowedChainDepthOnAutoplay => AutoplayChainLength.Value; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\ProcSolver.cfg", true); BandsDamageSourceRequirement = CustomConfigFile.Bind<bool>("Proc Solver : Bands", "Bands Damage Source", true, "Should Proc Patcher disable band procs on non-skill or non-equipment sources?"); MaxChainLength = CustomConfigFile.Bind<int>("Proc Solver : Proc Chains", "Max Proc Chain Length Initiated By Skill Or Equipment", 3, "When a proc chain is initiated from a skill or equipment, how many times can proc items be recursively triggered before the chain is cut off. Set to -1 to uncap proc chains, or 0 to disallow entirely. For example: If this number is 3, then a chain would be SKILL > PROC > PROC > PROC. "); AutoplayChainLength = CustomConfigFile.Bind<int>("Proc Solver : Proc Chains", "Max Proc Chain Length Initiated By Items (Autoplay)", 1, "When a proc chain is initiated from an item, how many times can proc items be recursively triggered before the chain is cut off. Set to -1 to uncap proc chains, or 0 to disallow entirely. For example: If this number is 1, then a chain would be ITEM > PROC. "); ChainProcRate = CustomConfigFile.Bind<float>("Proc Solver : Proc Rate", "Proc Rate Modifier On Proc Chains Initiated By Skill Or Equipment", 0.5f, "Proc chain items will proc other items at a reduced rate based on this modifier. For example: If this number is 0.5, then ATG Missile has a 12.5% chance to proc Ukulele instead of 25%."); AutoplayProcRate = CustomConfigFile.Bind<float>("Proc Solver : Proc Rate", "Proc Rate Modifier On Proc Chains Initiated By Items (Autoplay)", 0.2f, "Proc chain items will proc other items at a reduced rate based on this modifier. For example: If this number is 0.2, then Ceremonial Dagger has a 5% chance to proc Ukulele instead of 25%."); ProccedBySkill = ProcTypeAPI.ReserveProcType(); HealthComponent.TakeDamage += new Manipulator(AddProcRateMod); GlobalEventManager.OnHitEnemy += new Manipulator(AddProcRateMod); } public static float GetProcRateMod(DamageInfo damageInfo) { if (damageInfo == null) { return 1f; } return moreDamageInfoStats.GetOrCreateValue(damageInfo).procRate; } private void AddProcRateMod(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Action<DamageInfo>>((Action<DamageInfo>)delegate(DamageInfo damageInfo) { MoreDamageInfoStats orCreateValue = moreDamageInfoStats.GetOrCreateValue(damageInfo); orCreateValue.procRate = GetProcRate(damageInfo); if (orCreateValue.procRate == 0f && ((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)26)) { ((ProcChainMask)(ref damageInfo.procChainMask)).RemoveProc((ProcType)26); } }); } private static float GetProcRate(DamageInfo damageInfo) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0079: 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_008a: 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) if (maxChainLength < 0) { return 1f; } if (maxChainLength == 0) { return 0f; } if (((DamageTypeCombo)(ref damageInfo.damageType)).IsDamageSourceSkillBased || (int)damageInfo.damageType.damageSource == 64) { ProcTypeAPI.AddModdedProc(ref damageInfo.procChainMask, ProccedBySkill); return 1f; } int num = GetProcChainDepth(damageInfo.procChainMask); bool flag = ProcTypeAPI.HasModdedProc(damageInfo.procChainMask, ProccedBySkill); if (flag) { num--; } else if (allowedChainDepthOnAutoplay >= 0) { num += Mathf.Max(0, maxChainLength - allowedChainDepthOnAutoplay); } if (num < maxChainLength) { return flag ? ChainProcRate.Value : AutoplayProcRate.Value; } return 0f; } public static int GetProcChainDepth(ProcChainMask procChainMask) { //IL_0004: 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_0055: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 int num = 1; for (ProcType val = (ProcType)0; (int)val < 29; val = (ProcType)(val + 1)) { if ((int)val != 14 && (int)val != 15 && (int)val != 17 && (int)val != 14 && (int)val != 19 && (int)val != 20 && (int)val != 25 && (int)val != 26 && ((ProcChainMask)(ref procChainMask)).HasProc(val)) { num++; } } BitArray moddedMask = ProcTypeAPI.GetModdedMask(procChainMask); for (int i = 1; i < moddedMask.Count; i++) { if (moddedMask.Get(i)) { num++; } } return num; } } public class MoreDamageInfoStats { public float procRate = 1f; public int procChainDepth = 0; public bool isAutoplay = false; }