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 LuckyUpgrades v1.1.7
BepInEx/plugins/LuckyUpgrades.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; 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 BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("REPOShareMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("R.E.P.O 업그레이드 확률 공유 모드 - 스탯 아이템 획득 시 설정된 확률에 따라 다른 플레이어에게도 적용")] [assembly: AssemblyFileVersion("1.1.7.0")] [assembly: AssemblyInformationalVersion("1.1.7+f97fc833e3fb8cf1eef323b567ea68aae59655f6")] [assembly: AssemblyProduct("LuckyUpgrades")] [assembly: AssemblyTitle("LuckyUpgrades")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 LuckyUpgrades { [BepInPlugin("LuckyUpgrades", "LuckyUpgrades", "1.1.7")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private static bool _isApplyingSharedUpgrade = false; private static readonly Random _random = new Random(); internal static string _mySteamID = null; internal static readonly Dictionary<string, int> _sharedUpgrades = new Dictionary<string, int>(); private Harmony harmony; public static Plugin Instance { get; private set; } public static UpgradeConfig UpgradeConfiguration { get; private set; } private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) //IL_006c: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin LuckyUpgrades is loaded!"); UpgradeConfiguration = new UpgradeConfig(((BaseUnityPlugin)this).Config); harmony = new Harmony("LuckyUpgrades"); harmony.PatchAll(typeof(Plugin)); GameObject val = new GameObject("LuckyUpgrades_UpdateRunner"); val.AddComponent<UpgradeReapplyRunner>(); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; Logger.LogInfo((object)"Harmony patches applied!"); } internal static string GetMySteamID() { if (string.IsNullOrEmpty(_mySteamID)) { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if ((Object)(object)val != (Object)null) { _mySteamID = SemiFunc.PlayerGetSteamID(val); } } return _mySteamID; } [HarmonyPatch(typeof(PunManager), "ReceiveSyncData")] [HarmonyPrefix] public unsafe static void ReceiveSyncData_Prefix(ref Hashtable __0, PhotonMessageInfo __2, out bool __state) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //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) __state = false; Player sender = __2.Sender; if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient || sender != PhotonNetwork.MasterClient || _sharedUpgrades.Count == 0 || __0 == null) { return; } try { LogSyncedStats(__0, "before"); Hashtable val = new Hashtable(); DictionaryEntryEnumerator enumerator = __0.GetEnumerator(); try { while (((DictionaryEntryEnumerator)(ref enumerator)).MoveNext()) { DictionaryEntry current = ((DictionaryEntryEnumerator)(ref enumerator)).Current; val[current.Key] = current.Value; } } finally { ((IDisposable)(*(DictionaryEntryEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } SharedUpgradeSync.Merge(val, GetMySteamID(), _sharedUpgrades, delegate(string message) { Logger.LogInfo((object)message); }); __0 = val; __state = true; } catch (Exception ex) { Logger.LogWarning((object)("[LuckyUpgrades] Could not merge shared bonuses; continuing host sync: " + ex.Message)); } } [HarmonyPatch(typeof(PunManager), "ReceiveSyncData")] [HarmonyPostfix] public static void ReceiveSyncData_Postfix(Hashtable __0, bool __state) { if (__state) { LogSyncedStats(__0, "after"); } } private static void LogSyncedStats(Hashtable data, string phase) { string mySteamID = GetMySteamID(); if (string.IsNullOrEmpty(mySteamID) || (Object)(object)StatsManager.instance == (Object)null) { return; } foreach (KeyValuePair<string, int> sharedUpgrade in _sharedUpgrades) { if (SharedUpgradeSync.StatNames.TryGetValue(sharedUpgrade.Key, out var value) && ((Dictionary<object, object>)(object)data).ContainsKey((object)value)) { int? num = TryReadUpgradeCount(mySteamID, value); Logger.LogInfo((object)("[LuckyUpgrades] Sync " + phase + " " + sharedUpgrade.Key + ": actual=" + (num?.ToString() ?? "unavailable"))); } } } private static int? TryReadUpgradeCount(string steamID, string statName) { try { return ReadUpgradeCount(steamID, statName); } catch (Exception ex) { Logger.LogWarning((object)("[LuckyUpgrades] Stat diagnostics unavailable: " + ex.Message)); return null; } } [MethodImpl(MethodImplOptions.NoInlining)] private static int ReadUpgradeCount(string steamID, string statName) { if (!StatsManager.instance.FetchPlayerUpgrades(steamID).TryGetValue(statName, out var value)) { return 0; } return value; } private static void TrackSharedUpgrade(string upgradeType, int amount) { if (_sharedUpgrades.ContainsKey(upgradeType)) { _sharedUpgrades[upgradeType] += amount; } else { _sharedUpgrades[upgradeType] = amount; } Logger.LogInfo((object)$"[LuckyUpgrades] Tracked: {upgradeType} (total: {_sharedUpgrades[upgradeType]})"); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerHealth")] [HarmonyPostfix] public static void UpgradePlayerHealth_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("Health", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerHealth(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerEnergy")] [HarmonyPostfix] public static void UpgradePlayerEnergy_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("Energy", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerEnergy(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerExtraJump")] [HarmonyPostfix] public static void UpgradePlayerExtraJump_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("ExtraJump", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerExtraJump(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerGrabRange")] [HarmonyPostfix] public static void UpgradePlayerGrabRange_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("GrabRange", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerGrabRange(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerGrabStrength")] [HarmonyPostfix] public static void UpgradePlayerGrabStrength_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("GrabStrength", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerGrabStrength(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerThrowStrength")] [HarmonyPostfix] public static void UpgradePlayerThrowStrength_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("GrabThrow", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerThrowStrength(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerSprintSpeed")] [HarmonyPostfix] public static void UpgradePlayerSprintSpeed_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("SprintSpeed", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerSprintSpeed(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerTumbleLaunch")] [HarmonyPostfix] public static void UpgradePlayerTumbleLaunch_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("TumbleLaunch", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerTumbleLaunch(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradeMapPlayerCount")] [HarmonyPostfix] public static void UpgradeMapPlayerCount_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("MapPlayerCount", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradeMapPlayerCount(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerTumbleClimb")] [HarmonyPostfix] public static void UpgradePlayerTumbleClimb_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("TumbleClimb", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerTumbleClimb(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerTumbleWings")] [HarmonyPostfix] public static void UpgradePlayerTumbleWings_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("TumbleWings", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerTumbleWings(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradePlayerCrouchRest")] [HarmonyPostfix] public static void UpgradePlayerCrouchRest_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("CrouchRest", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradePlayerCrouchRest(mySteamID, amount); } }); } [HarmonyPatch(typeof(PunManager), "UpgradeDeathHeadBattery")] [HarmonyPostfix] public static void UpgradeDeathHeadBattery_Postfix(string _steamID, int value) { ApplySharedUpgradeToSelf("DeathHeadBattery", _steamID, value, delegate(int amount) { string mySteamID = GetMySteamID(); if (!string.IsNullOrEmpty(mySteamID)) { PunManager.instance.UpgradeDeathHeadBattery(mySteamID, amount); } }); } private static void ApplySharedUpgradeToSelf(string upgradeType, string sourceSteamID, int amount, Action<int> applyToSelf) { try { if (_isApplyingSharedUpgrade || amount <= 0) { return; } string mySteamID = GetMySteamID(); if (string.IsNullOrEmpty(mySteamID) || mySteamID == sourceSteamID) { return; } int shareChance = UpgradeConfiguration.GetShareChance(upgradeType); int num = _random.Next(100); if (num < shareChance) { try { _isApplyingSharedUpgrade = true; string statName = SharedUpgradeSync.StatNames[upgradeType]; int? num2 = TryReadUpgradeCount(mySteamID, statName); applyToSelf(amount); int? num3 = TryReadUpgradeCount(mySteamID, statName); Logger.LogInfo((object)("[LuckyUpgrades] Share " + upgradeType + ": before=" + (num2?.ToString() ?? "unavailable") + ", after=" + (num3?.ToString() ?? "unavailable"))); int num4 = ((num2.HasValue && num3.HasValue) ? (num3.Value - num2.Value) : amount); if (num4 > 0) { TrackSharedUpgrade(upgradeType, num4); Logger.LogInfo((object)$"[LuckyUpgrades] Shared upgrade applied: {upgradeType} +{num4} (rolled: {num} | chance: {shareChance}%) ✓"); } return; } finally { _isApplyingSharedUpgrade = false; } } Logger.LogInfo((object)$"[LuckyUpgrades] Shared upgrade missed: {upgradeType} (rolled: {num} | chance: {shareChance}%) ✗"); } catch (Exception ex) { Logger.LogError((object)("[LuckyUpgrades] Error in ApplySharedUpgradeToSelf: " + ex.Message)); } } } public class UpgradeReapplyRunner : MonoBehaviour { private static readonly HashSet<string> SESSION_END_LEVELS = new HashSet<string> { "Level - Main Menu", "Level - Lobby Menu" }; private string _lastLevelName = ""; private void Update() { string text = ""; try { if ((Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null) { text = ((Object)RunManager.instance.levelCurrent).name; } } catch { } if (!string.IsNullOrEmpty(text) && text != _lastLevelName) { Plugin.Logger.LogInfo((object)("[LuckyUpgrades] Level changed: " + _lastLevelName + " -> " + text)); _lastLevelName = text; if (SESSION_END_LEVELS.Contains(text)) { Plugin._sharedUpgrades.Clear(); Plugin._mySteamID = null; Plugin.Logger.LogInfo((object)"[LuckyUpgrades] Session ended. All tracked data cleared."); } } } } internal static class SharedUpgradeSync { internal static readonly Dictionary<string, string> StatNames = new Dictionary<string, string> { { "Health", "playerUpgradeHealth" }, { "Energy", "playerUpgradeStamina" }, { "ExtraJump", "playerUpgradeExtraJump" }, { "GrabRange", "playerUpgradeRange" }, { "GrabStrength", "playerUpgradeStrength" }, { "GrabThrow", "playerUpgradeThrow" }, { "SprintSpeed", "playerUpgradeSpeed" }, { "TumbleLaunch", "playerUpgradeLaunch" }, { "MapPlayerCount", "playerUpgradeMapPlayerCount" }, { "TumbleClimb", "playerUpgradeTumbleClimb" }, { "TumbleWings", "playerUpgradeTumbleWings" }, { "CrouchRest", "playerUpgradeCrouchRest" }, { "DeathHeadBattery", "playerUpgradeDeathHeadBattery" } }; internal unsafe static void Merge(Hashtable data, string steamID, Dictionary<string, int> sharedUpgrades, Action<string> log) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (data == null || string.IsNullOrEmpty(steamID)) { return; } foreach (KeyValuePair<string, int> sharedUpgrade in sharedUpgrades) { if (sharedUpgrade.Value <= 0 || !StatNames.TryGetValue(sharedUpgrade.Key, out var value)) { continue; } object obj = data[(object)value]; Hashtable val = (Hashtable)((obj is Hashtable) ? obj : null); if (val == null) { continue; } object value2; int num = (((Dictionary<object, object>)(object)val).TryGetValue((object)steamID, out value2) ? ((int)value2) : 0); int num2 = checked(num + sharedUpgrade.Value); Hashtable val2 = new Hashtable(); DictionaryEntryEnumerator enumerator2 = val.GetEnumerator(); try { while (((DictionaryEntryEnumerator)(ref enumerator2)).MoveNext()) { DictionaryEntry current2 = ((DictionaryEntryEnumerator)(ref enumerator2)).Current; val2[current2.Key] = current2.Value; } } finally { ((IDisposable)(*(DictionaryEntryEnumerator*)(&enumerator2))/*cast due to .constrained prefix*/).Dispose(); } val2[(object)steamID] = num2; data[(object)value] = val2; log($"[LuckyUpgrades] Sync {sharedUpgrade.Key}: host={num}, shared={sharedUpgrade.Value}, merged={num2}"); } } } public class UpgradeConfig { public ConfigEntry<int> ChanceToActivatePlayerHealth { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerEnergy { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerSprintSpeed { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerExtraJump { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerTumbleLaunch { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerGrabRange { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerGrabStrength { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerGrabThrow { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerTumbleClimb { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerTumbleWings { get; private set; } public ConfigEntry<int> ChanceToActivatePlayerCrouchRest { get; private set; } public ConfigEntry<int> ChanceToActivateDeathHeadBattery { get; private set; } public ConfigEntry<int> ChanceToActivateMapPlayerCount { get; private set; } public UpgradeConfig(ConfigFile config) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown ChanceToActivatePlayerHealth = config.Bind<int>("Upgrades", "ChanceToActivatePlayerHealth", 25, new ConfigDescription("% Chance to share the Health upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerEnergy = config.Bind<int>("Upgrades", "ChanceToActivatePlayerEnergy", 25, new ConfigDescription("% Chance to share the Energy (Stamina) upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerSprintSpeed = config.Bind<int>("Upgrades", "ChanceToActivatePlayerSprintSpeed", 25, new ConfigDescription("% Chance to share the Sprint Speed upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerExtraJump = config.Bind<int>("Upgrades", "ChanceToActivatePlayerExtraJump", 25, new ConfigDescription("% Chance to share the Extra Jump upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerTumbleLaunch = config.Bind<int>("Upgrades", "ChanceToActivatePlayerTumbleLaunch", 25, new ConfigDescription("% Chance to share the Tumble Launch upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerGrabRange = config.Bind<int>("Upgrades", "ChanceToActivatePlayerGrabRange", 25, new ConfigDescription("% Chance to share the Grab Range upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerGrabStrength = config.Bind<int>("Upgrades", "ChanceToActivatePlayerGrabStrength", 25, new ConfigDescription("% Chance to share the Grab Strength upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerGrabThrow = config.Bind<int>("Upgrades", "ChanceToActivatePlayerGrabThrow", 25, new ConfigDescription("% Chance to share the Grab Throw upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerTumbleClimb = config.Bind<int>("Upgrades", "ChanceToActivatePlayerTumbleClimb", 25, new ConfigDescription("% Chance to share the Tumble Climb upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerTumbleWings = config.Bind<int>("Upgrades", "ChanceToActivatePlayerTumbleWings", 25, new ConfigDescription("% Chance to share the Tumble Wings upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivatePlayerCrouchRest = config.Bind<int>("Upgrades", "ChanceToActivatePlayerCrouchRest", 25, new ConfigDescription("% Chance to share the Crouch Rest upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivateDeathHeadBattery = config.Bind<int>("Upgrades", "ChanceToActivateDeathHeadBattery", 25, new ConfigDescription("% Chance to share the Death Head Battery upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ChanceToActivateMapPlayerCount = config.Bind<int>("Upgrades", "ChanceToActivateMapPlayerCount", 25, new ConfigDescription("% Chance to share the Map Player Count upgrade", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); } public int GetShareChance(string upgradeType) { string text = upgradeType.ToLower(); if (text.Contains("health")) { return ChanceToActivatePlayerHealth.Value; } if (text.Contains("energy") || text.Contains("stamina")) { return ChanceToActivatePlayerEnergy.Value; } if (text.Contains("sprint") || text.Contains("speed")) { return ChanceToActivatePlayerSprintSpeed.Value; } if (text.Contains("jump")) { return ChanceToActivatePlayerExtraJump.Value; } if (text.Contains("tumblelaunch") || text.Contains("launch")) { return ChanceToActivatePlayerTumbleLaunch.Value; } if (text.Contains("tumbleclimb") || text.Contains("climb")) { return ChanceToActivatePlayerTumbleClimb.Value; } if (text.Contains("tumblewing") || text.Contains("wing")) { return ChanceToActivatePlayerTumbleWings.Value; } if (text.Contains("crouch") || text.Contains("rest")) { return ChanceToActivatePlayerCrouchRest.Value; } if (text.Contains("deathhead") || text.Contains("battery")) { return ChanceToActivateDeathHeadBattery.Value; } if (text.Contains("range")) { return ChanceToActivatePlayerGrabRange.Value; } if (text.Contains("strength")) { return ChanceToActivatePlayerGrabStrength.Value; } if (text.Contains("throw")) { return ChanceToActivatePlayerGrabThrow.Value; } if (text.Contains("map") || text.Contains("count")) { return ChanceToActivateMapPlayerCount.Value; } return 25; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LuckyUpgrades"; public const string PLUGIN_NAME = "LuckyUpgrades"; public const string PLUGIN_VERSION = "1.1.7"; } }