using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using R2API; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; using UnityEngine.Networking; [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("VGMWorld")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adds an artifact that lets monsters, elites, and bosses drop items with configurable chances through Risk of Options. Every 10 player levels rolls a red-tier item.")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("vinestweaks")] [assembly: AssemblyTitle("vinestweaks")] [assembly: AssemblyVersion("0.1.0.0")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 VGMWorld.RiskOfRain2.VinesTweaks { [BepInPlugin("com.vgmworld.vinestweaks", "VinesTweaks", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("Risk of Rain 2.exe")] public sealed class VinesTweaksPlugin : BaseUnityPlugin { public const string PluginGuid = "com.vgmworld.vinestweaks"; public const string PluginName = "VinesTweaks"; public const string PluginVersion = "0.1.0"; private const string ArtifactToken = "VINESTWEAKS_REWARDING_VINES"; private const string ArtifactNameToken = "ARTIFACT_VINESTWEAKS_REWARDING_VINES_NAME"; private const string ArtifactDescriptionToken = "ARTIFACT_VINESTWEAKS_REWARDING_VINES_DESCRIPTION"; private static ArtifactDef? rewardingVinesArtifact; private static ConfigEntry? monsterDropChance; private static ConfigEntry? eliteDropChance; private static ConfigEntry? bossExtraDropChance; private static ConfigEntry? redTierLevelThreshold; private static ConfigEntry? redTierDropChance; private static ConfigEntry? commonTierWeight; private static ConfigEntry? uncommonTierWeight; private static ConfigEntry? legendaryTierWeight; private static ConfigEntry? dropUpVelocity; private static ConfigEntry? dropSideVelocity; private static ConfigEntry? debugLogging; private static int lastRewardedRedTierMilestone; private static VinesTweaksPlugin? instance; private void Awake() { instance = this; CreateConfig(); RegisterRiskOfOptions(); RegisterArtifact(); Run.onRunStartGlobal += OnRunStartGlobal; GlobalEventManager.onCharacterDeathGlobal += OnCharacterDeathGlobal; ((BaseUnityPlugin)this).Logger.LogInfo((object)"VinesTweaks loaded. Enable Artifact of Rewarding Vines to activate monster item drops."); } private void OnDestroy() { Run.onRunStartGlobal -= OnRunStartGlobal; GlobalEventManager.onCharacterDeathGlobal -= OnCharacterDeathGlobal; instance = null; } private void CreateConfig() { monsterDropChance = ((BaseUnityPlugin)this).Config.Bind("Rewarding Vines", "Monster drop chance percent", 0.3f, "Percent chance for a non-elite, non-boss monster kill to drop a normal weighted item while the artifact is enabled."); eliteDropChance = ((BaseUnityPlugin)this).Config.Bind("Rewarding Vines", "Elite drop chance percent", 1f, "Percent chance for an elite monster kill to drop a normal weighted item while the artifact is enabled."); bossExtraDropChance = ((BaseUnityPlugin)this).Config.Bind("Rewarding Vines", "Boss extra drop chance percent", 10f, "Percent chance for a boss/champion monster kill to drop an extra normal weighted item while the artifact is enabled."); redTierLevelThreshold = ((BaseUnityPlugin)this).Config.Bind("Rewarding Vines", "Player level red tier threshold", 10, "Player team level required before the red tier drop roll can happen."); redTierDropChance = ((BaseUnityPlugin)this).Config.Bind("Rewarding Vines", "Red tier milestone chance percent", 100f, "Percent chance to drop a red-tier item when the player team reaches each configured level milestone."); commonTierWeight = ((BaseUnityPlugin)this).Config.Bind("Item Tier Weights", "Common tier weight", 79f, "Relative weight for common items when a normal weighted item drops."); uncommonTierWeight = ((BaseUnityPlugin)this).Config.Bind("Item Tier Weights", "Uncommon tier weight", 20f, "Relative weight for uncommon items when a normal weighted item drops."); legendaryTierWeight = ((BaseUnityPlugin)this).Config.Bind("Item Tier Weights", "Legendary tier weight", 1f, "Relative weight for legendary items when a normal weighted item drops."); dropUpVelocity = ((BaseUnityPlugin)this).Config.Bind("Drop Physics", "Upward drop velocity", 20f, "Vertical launch velocity for item drops."); dropSideVelocity = ((BaseUnityPlugin)this).Config.Bind("Drop Physics", "Side drop velocity", 5f, "Sideways launch velocity for item drops."); debugLogging = ((BaseUnityPlugin)this).Config.Bind("Debug", "Enable debug logging", false, "Log artifact drop rolls and milestone checks to the BepInEx console."); } private static void RegisterRiskOfOptions() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown ModSettingsManager.SetModDescription("Adds Artifact of Rewarding Vines: monsters, elites, and bosses can drop items. Player level milestones can drop red-tier items."); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(monsterDropChance, PercentSlider(0f, 10f, 0.1f))); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(eliteDropChance, PercentSlider(0f, 25f, 0.1f))); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(bossExtraDropChance, PercentSlider(0f, 100f, 0.5f))); ModSettingsManager.AddOption((BaseOption)new IntSliderOption(redTierLevelThreshold, new IntSliderConfig { min = 1, max = 99 })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(redTierDropChance, PercentSlider(0f, 100f, 1f))); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(commonTierWeight, WeightSlider())); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(uncommonTierWeight, WeightSlider())); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(legendaryTierWeight, WeightSlider())); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(dropUpVelocity, new StepSliderConfig { min = 0f, max = 60f, increment = 1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(dropSideVelocity, new StepSliderConfig { min = 0f, max = 30f, increment = 1f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(debugLogging)); } private static StepSliderConfig PercentSlider(float min, float max, float increment) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown return new StepSliderConfig { min = min, max = max, increment = increment }; } private static StepSliderConfig WeightSlider() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown return new StepSliderConfig { min = 0f, max = 100f, increment = 1f }; } private static void RegisterArtifact() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) LanguageAPI.Add("ARTIFACT_VINESTWEAKS_REWARDING_VINES_NAME", "Artifact of Rewarding Vines"); LanguageAPI.Add("ARTIFACT_VINESTWEAKS_REWARDING_VINES_DESCRIPTION", "Monsters can drop items. Elites and bosses have higher configurable chances. Player level milestones can drop red-tier items."); rewardingVinesArtifact = ScriptableObject.CreateInstance(); rewardingVinesArtifact.cachedName = "VINESTWEAKS_REWARDING_VINES"; rewardingVinesArtifact.nameToken = "ARTIFACT_VINESTWEAKS_REWARDING_VINES_NAME"; rewardingVinesArtifact.descriptionToken = "ARTIFACT_VINESTWEAKS_REWARDING_VINES_DESCRIPTION"; rewardingVinesArtifact.smallIconSelectedSprite = CreateArtifactSprite(new Color(0.22f, 0.88f, 0.42f), new Color(0.06f, 0.2f, 0.08f)); rewardingVinesArtifact.smallIconDeselectedSprite = CreateArtifactSprite(new Color(0.18f, 0.22f, 0.18f), new Color(0.06f, 0.08f, 0.06f)); ContentAddition.AddArtifactDef(rewardingVinesArtifact); } private static Sprite CreateArtifactSprite(Color primary, Color secondary) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); ((Object)val).name = "VinesTweaksArtifactIcon"; ((Texture)val).filterMode = (FilterMode)0; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(63.5f, 63.5f); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = Vector2.Distance(new Vector2((float)j, (float)i), val2) / 64f; bool flag = Mathf.Abs(Mathf.Sin((float)(j + i) * 0.12f)) < 0.22f || Mathf.Abs(Mathf.Sin((float)(j - i) * 0.12f)) < 0.18f; Color val3 = ((num <= 0.88f && flag) ? primary : secondary); val3.a = ((num <= 0.96f) ? 1f : 0f); val.SetPixel(j, i, val3); } } val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f); } private static void OnCharacterDeathGlobal(DamageReport damageReport) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 if (!NetworkServer.active || (Object)(object)rewardingVinesArtifact == (Object)null || (Object)(object)Run.instance == (Object)null || !Object.op_Implicit((Object)(object)RunArtifactManager.instance) || !RunArtifactManager.instance.IsArtifactEnabled(rewardingVinesArtifact)) { return; } CharacterBody victimBody = damageReport.victimBody; if (Object.op_Implicit((Object)(object)victimBody) && Object.op_Implicit((Object)(object)victimBody.teamComponent) && (int)victimBody.teamComponent.teamIndex == 2 && (!Object.op_Implicit((Object)(object)victimBody.master) || !Object.op_Implicit((Object)(object)victimBody.master.playerCharacterMasterController))) { bool isChampion = victimBody.isChampion; if (victimBody.isElite) { TryDropWeightedItem(victimBody, eliteDropChance.Value); } else if (!isChampion) { TryDropWeightedItem(victimBody, monsterDropChance.Value); } if (isChampion) { TryDropWeightedItem(victimBody, bossExtraDropChance.Value); } TryDropRedTierMilestoneReward(victimBody); } } private static void OnRunStartGlobal(Run run) { lastRewardedRedTierMilestone = 0; } private static void TryDropRedTierMilestoneReward(CharacterBody victimBody) { int num = Mathf.Max(1, redTierLevelThreshold.Value); int num2 = Mathf.FloorToInt(GetPlayerTeamLevel() / (float)num) * num; DebugLog($"Player level {GetPlayerTeamLevel():0.##}; red milestone {num2}; last rewarded {lastRewardedRedTierMilestone}."); if (num2 > 0 && num2 > lastRewardedRedTierMilestone) { lastRewardedRedTierMilestone = num2; TryDropTierItem(victimBody, Run.instance.availableTier3DropList, redTierDropChance.Value); } } private static float GetPlayerTeamLevel() { if (!Object.op_Implicit((Object)(object)TeamManager.instance)) { return 1f; } return TeamManager.instance.GetTeamLevel((TeamIndex)1); } private static void TryDropWeightedItem(CharacterBody victimBody, float chancePercent) { if (!Roll(chancePercent)) { DebugLog($"Weighted item roll failed at {chancePercent:0.##}%."); return; } DebugLog($"Weighted item roll succeeded at {chancePercent:0.##}%."); TryDropTierItem(victimBody, SelectWeightedDropList(), 100f); } private static List SelectWeightedDropList() { Run val = Run.instance; float num = Mathf.Max(0f, commonTierWeight.Value); float num2 = Mathf.Max(0f, uncommonTierWeight.Value); float num3 = Mathf.Max(0f, legendaryTierWeight.Value); float num4 = num + num2 + num3; if (num4 <= 0f) { return val.availableTier1DropList; } float num5 = Random.Range(0f, num4); if (num5 < num) { return val.availableTier1DropList; } num5 -= num; if (num5 < num2) { return val.availableTier2DropList; } return val.availableTier3DropList; } private static void TryDropTierItem(CharacterBody victimBody, List dropList, float chancePercent) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (dropList == null || dropList.Count == 0 || !Roll(chancePercent)) { DebugLog($"Tier item roll failed or empty list. Chance={chancePercent:0.##}%, count={dropList?.Count ?? 0}."); return; } PickupIndex val = dropList[Random.Range(0, dropList.Count)]; if (val == PickupIndex.none) { DebugLog("Selected PickupIndex.none; skipping drop."); return; } Vector3 corePosition = victimBody.corePosition; Vector3 val2 = Random.insideUnitSphere; val2.y = 0f; val2 = ((Vector3)(ref val2)).normalized * dropSideVelocity.Value; Vector3 val3 = Vector3.up * dropUpVelocity.Value + val2; PickupDropletController.CreatePickupDroplet(val, corePosition, val3); DebugLog($"Dropped pickup {val.value} at {corePosition}."); } private static bool Roll(float chancePercent) { chancePercent = Mathf.Clamp(chancePercent, 0f, 100f); return Util.CheckRoll(chancePercent, 0f, (CharacterMaster)null); } private static void DebugLog(string message) { ConfigEntry? obj = debugLogging; if (obj != null && obj.Value) { VinesTweaksPlugin? vinesTweaksPlugin = instance; if (vinesTweaksPlugin != null) { ((BaseUnityPlugin)vinesTweaksPlugin).Logger.LogInfo((object)("[Debug] " + message)); } } } } }