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 EpicJewels v1.1.2
plugins/EpicJewels.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EpicJewels.Common; using EpicJewels.EffectHelpers; using EpicJewels.GemEffects; using HarmonyLib; using JetBrains.Annotations; using Jewelcrafting; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("EpicJewels")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EpicJewels")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.1.2")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace Jewelcrafting { [Flags] public enum VisualEffectCondition : uint { IsSkill = 0xFFFu, Swords = 1u, Knives = 2u, Clubs = 3u, Polearms = 4u, Spears = 5u, Blocking = 6u, Axes = 7u, Bows = 8u, Unarmed = 0xBu, Pickaxes = 0xCu, WoodCutting = 0xDu, Crossbows = 0xEu, IsItem = 0xFF000u, Helmet = 0x6000u, Chest = 0x7000u, Legs = 0xB000u, Hands = 0xC000u, Shoulder = 0x11000u, Tool = 0x13000u, GenericExtraAttributes = 0xFF000000u, Blackmetal = 0x40000000u, TwoHanded = 0x80000000u, SpecificExtraAttributes = 0xF00000u, Hammer = 0x113000u, Hoe = 0x213000u, Buckler = 0x100006u, Towershield = 0x200006u, FineWoodBow = 0x100008u, BowHuntsman = 0x200008u, BowDraugrFang = 0x300008u, PickaxeIron = 0x10000Cu, Club = 0x100003u } [AttributeUsage(AttributeTargets.Field)] public abstract class PowerAttribute : Attribute { public abstract float Add(float a, float b); } [AttributeUsage(AttributeTargets.Field)] public class OptionalPowerAttribute : Attribute { public readonly float DefaultValue; public OptionalPowerAttribute(float defaultValue) { DefaultValue = defaultValue; } } public class MultiplicativePercentagePowerAttribute : PowerAttribute { public override float Add(float a, float b) { return (float)(((1.0 + (double)a / 100.0) * (1.0 + (double)b / 100.0) - 1.0) * 100.0); } } public class MinPowerAttribute : PowerAttribute { public override float Add(float a, float b) { return Mathf.Min(a, b); } } public class MaxPowerAttribute : PowerAttribute { public override float Add(float a, float b) { return Mathf.Max(a, b); } } public class InverseMultiplicativePercentagePowerAttribute : PowerAttribute { public override float Add(float a, float b) { return (float)((1.0 - (1.0 - (double)a / 100.0) * (1.0 - (double)b / 100.0)) * 100.0); } } public class AdditivePowerAttribute : PowerAttribute { public override float Add(float a, float b) { return a + b; } } [PublicAPI] public static class API { [PublicAPI] public class GemInfo { public readonly string gemPrefab; public readonly Sprite gemSprite; public readonly Dictionary<string, float> gemEffects; public GemInfo(string gemPrefab, Sprite gemSprite, Dictionary<string, float> gemEffects) { this.gemPrefab = gemPrefab; this.gemSprite = gemSprite; this.gemEffects = gemEffects; } } public delegate bool GemBreakHandler(ItemData? container, ItemData gem, int count = 1); public delegate bool ItemBreakHandler(ItemData? container); public delegate bool ItemMirroredHandler(ItemData? item); public static event Action? OnEffectRecalc; public static bool IsLoaded() { return false; } internal static void InvokeEffectRecalc() { API.OnEffectRecalc?.Invoke(); } public static GameObject CreateNecklaceFromTemplate(string colorName, Color color) { return null; } public static GameObject CreateNecklaceFromTemplate(string colorName, Material material) { return null; } public static GameObject CreateRingFromTemplate(string colorName, Color color) { return null; } public static GameObject CreateRingFromTemplate(string colorName, Material material) { return null; } public static void MarkJewelry(GameObject jewelry) { } public static void AddGems(string type, string colorName, Color color) { } public static List<GameObject> AddGems(string type, string colorName, Material material, Color color) { return null; } public static GameObject AddDestructibleFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddDestructibleFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject AddUncutFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddUncutFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject AddAndRegisterUncutFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddAndRegisterUncutFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject AddShardFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject AddShardFromTemplate(string type, string colorName, Material material) { return null; } public static GameObject[] AddTieredGemFromTemplate(string type, string colorName, Color color) { return null; } public static GameObject[] AddTieredGemFromTemplate(string type, string colorName, Material material, Color color) { return null; } public static void AddGem(GameObject prefab, string colorName) { } public static void AddShard(GameObject prefab, string colorName) { } public static void AddDestructible(GameObject prefab, string colorName) { } public static void AddUncutGem(GameObject prefab, string colorName, ConfigEntry<float>? dropChance = null) { } public static void AddGemEffect<T>(string name, string? englishDescription = null, string? englishDescriptionDetailed = null) where T : struct { } public static void AddGemConfig(string yaml) { } public static T GetEffectPower<T>(this Player player, string name) where T : struct { return default(T); } public static List<GemInfo?> GetGems(ItemData item) { return new List<GemInfo>(); } public static bool SetGems(ItemData item, List<GemInfo?> gems) { return false; } public static Sprite GetSocketBorder() { return null; } public static GameObject GetGemcuttersTable() { return null; } public static void AddParticleEffect(string prefabName, GameObject effect, VisualEffectCondition displayCondition) { } public static void SetSocketsLock(ItemData item, bool enabled) { } public static void OnGemBreak(GemBreakHandler callback) { } public static void OnItemBreak(ItemBreakHandler callback) { } public static void OnItemMirrored(ItemMirroredHandler callback) { } public static bool IsJewelryEquipped(Player player, string prefabName) { return false; } public static bool BlacklistItem(GameObject item) { return false; } } } namespace EpicJewels { [BepInPlugin("MidnightsFX.EpicJewels", "EpicJewels", "1.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class EpicJewels : BaseUnityPlugin { [HarmonyPatch(typeof(InventoryGui), "Awake")] public static class EnableSynergyTextfit { [HarmonyPriority(0)] public static void Postfix() { IEnumerable<GameObject> enumerable = from obj in Resources.FindObjectsOfTypeAll<GameObject>() where ((Object)obj).name.StartsWith("JC_Synergies_Window") select obj; EJLogger.LogDebug($"Found {enumerable.Count()} Synergy panels to update."); foreach (GameObject item in enumerable) { try { EJLogger.LogDebug($"Updating Synergy GO {item}"); ((Component)item.transform.Find("Bkg/Left_Text/Left_Text_1")).gameObject.GetComponent<Text>().resizeTextForBestFit = true; } catch (Exception) { } } } } public const string PluginGUID = "MidnightsFX.EpicJewels"; public const string PluginName = "EpicJewels"; public const string PluginVersion = "1.1.2"; public static ManualLogSource Log; internal static bool CrystalLightsLoaded = false; internal ValConfig cfg; internal static AssetBundle EmbeddedResourceBundle; internal static Harmony Harmony = new Harmony("MidnightsFX.EpicJewels"); public static IDeserializer yamldeserializer = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); public static ISerializer yamlserializer = ((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).DisableAliases().Build(); public static Material spiritCreature; public void Awake() { Log = ((BaseUnityPlugin)this).Logger; cfg = new ValConfig(((BaseUnityPlugin)this).Config); AddLocalizations(); EmbeddedResourceBundle = LoadAssetBundle("EpicJewels.AssetsEmbedded.epicjewels"); EJLogger.LogDebug("Logging embedded assets."); string[] allAssetNames = EmbeddedResourceBundle.GetAllAssetNames(); for (int i = 0; i < allAssetNames.Length; i++) { EJLogger.LogDebug(allAssetNames[i]); } EJLogger.LogInfo("Let the gems flow."); EffectList.AddGemEffects(); GemResources.AddGems(); if (Enumerable.Contains(BepInExUtils.GetPlugins(false).Keys, "org.bepinex.plugins.crystallights") || ValConfig.EnableCrystalLightsAlways.Value) { CrystalLightsLoaded = true; GemResources.AddAllCrystalLights(); EJLogger.LogInfo("Epic Crystal Lights enabled."); } spiritCreature = EmbeddedResourceBundle.LoadAsset<Material>("spirit_animal_mat.mat"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); Harmony.PatchAll(executingAssembly); ValConfig.cfg.SaveOnConfigSet = true; ValConfig.cfg.Save(); } public static AssetBundle LoadAssetBundle(string bundleName) { Assembly assembly = typeof(EpicJewels).Assembly; string text = null; try { text = assembly.GetManifestResourceNames().Single((string str) => str.EndsWith(bundleName)); } catch (Exception) { } if (text == null) { EJLogger.LogError("Could not find an embedded asset bundle matching '" + bundleName + "'."); return null; } using Stream stream = assembly.GetManifestResourceStream(text); return AssetBundle.LoadFromStream(stream); } public static string LoadEmbeddedAssetToString(string assetName) { Assembly assembly = typeof(EpicJewels).Assembly; string text = null; try { text = assembly.GetManifestResourceNames().Single((string str) => str.EndsWith(assetName)); } catch (Exception) { } if (text == null) { return null; } using Stream stream = assembly.GetManifestResourceStream(text); using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } private void AddLocalizations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); EJLogger.LogInfo("Loading Localizations."); string[] manifestResourceNames = typeof(EpicJewels).Assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.Contains("Localizations")) { EJLogger.LogDebug("Reading localization resource: " + text); string text2 = Regex.Replace(ReadEmbeddedResourceFile(text), "\\/\\/.*", ""); string[] array = text.Split(new char[1] { '.' }); EJLogger.LogDebug("Adding localization: " + array[2]); localization.AddJsonFile(array[2], text2); } } } internal static string ReadEmbeddedResourceFile(string filename) { using Stream stream = typeof(EpicJewels).Assembly.GetManifestResourceStream(filename); using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } } internal static class GemResources { private class GemDefition { public Color Color { get; set; } public Material Material { get; set; } } private static Dictionary<string, GemDefition> GemDefinitions = new Dictionary<string, GemDefition>(); private static Dictionary<string, string> GemMaterialOverrides = new Dictionary<string, string>(); private static bool GemMaterialPassRegistered = false; public static void AddGems() { //IL_003b: 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) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) Material material = EpicJewels.EmbeddedResourceBundle.LoadAsset<Material>("gem_jade.mat"); Color color = default(Color); ((Color)(ref color))..ctor(0.031f, 0.69f, 0.043f, 1f); GemDefinitions.Add("Jade", new GemDefition { Color = color, Material = material }); Material material2 = EpicJewels.EmbeddedResourceBundle.LoadAsset<Material>("garnet_gem.mat"); Color color2 = default(Color); ((Color)(ref color2))..ctor(1f, 0.141f, 0.039f, 1f); GemDefinitions.Add("Garnet", new GemDefition { Color = color2, Material = material2 }); Material material3 = EpicJewels.EmbeddedResourceBundle.LoadAsset<Material>("amber_gem.mat"); Color color3 = default(Color); ((Color)(ref color3))..ctor(81f / 85f, 0.7568628f, 5f / 51f, 1f); GemDefinitions.Add("Amber", new GemDefition { Color = color3, Material = material3 }); Material material4 = EpicJewels.EmbeddedResourceBundle.LoadAsset<Material>("opal_gem.mat"); Color color4 = default(Color); ((Color)(ref color4))..ctor(0.945f, 0.988f, 0.988f, 1f); GemDefinitions.Add("Opal", new GemDefition { Color = color4, Material = material4 }); Material material5 = EpicJewels.EmbeddedResourceBundle.LoadAsset<Material>("amethyst_gem.mat"); Color color5 = default(Color); ((Color)(ref color5))..ctor(0.784f, 0.302f, 0.98f, 1f); GemDefinitions.Add("Amethyst", new GemDefition { Color = color5, Material = material5 }); Material material6 = EpicJewels.EmbeddedResourceBundle.LoadAsset<Material>("aquamarine_gem.mat"); Color color6 = default(Color); ((Color)(ref color6))..ctor(0.259f, 0.663f, 0.71f, 1f); GemDefinitions.Add("Aquamarine", new GemDefition { Color = color6, Material = material6 }); AddGemRegisterOverride("Jade"); AddGemRegisterOverride("Amber"); AddGemRegisterOverride("Aquamarine"); AddGemRegisterOverride("Garnet"); AddGemRegisterOverride("Opal"); AddGemRegisterOverride("Amethyst"); API.AddGemConfig(EpicJewels.LoadEmbeddedAssetToString("EJConfig.yaml")); } internal static void AddGemRegisterOverride(string name) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) API.AddGems(name, name.ToLower(), GemDefinitions[name].Color); GemMaterialOverrides["Raw_" + name.ToLower() + "_Gemstone"] = name; if (!GemMaterialPassRegistered) { GemMaterialPassRegistered = true; MinimapManager.OnVanillaMapAvailable += ApplyGemMaterials; } } private static void ApplyGemMaterials() { GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject val in array) { if (GemMaterialOverrides.TryGetValue(((Object)val).name, out var gem_name)) { EJLogger.LogDebug("Applying " + gem_name + " gem material to " + ((Object)val).name + "."); val.GetComponentsInChildren<MeshRenderer>().ToList().ForEach(delegate(MeshRenderer renderer) { ((Renderer)renderer).material = GemDefinitions[gem_name].Material; }); } } } internal static void AddAllCrystalLights() { AddCrystalLightResources("Jade"); AddCrystalLightResources("Amber"); AddCrystalLightResources("Aquamarine"); AddCrystalLightResources("Garnet"); AddCrystalLightResources("Opal"); AddCrystalLightResources("Amethyst"); JotunnPiece.SetupJotunnPieces(); } internal static void AddCrystalLightResources(string name) { JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Brazier", Prefab = "CL_Brazier_" + name, Sprite = "CL_Brazier_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 10, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 4, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Brazier_" + name; component.m_description = "$EJ_Brazier_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Chandelier", Prefab = "CL_Chandelier_" + name, Sprite = "CL_Chandelier_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 15, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 5, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Chandelier_" + name; component.m_description = "$EJ_Chandelier_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Hanging Bowl", Prefab = "CL_Hanging_" + name, Sprite = "CL_Hanging_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 5, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 2, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Hanging_" + name; component.m_description = "$EJ_Hanging_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Large Wall Light", Prefab = "CL_Large_Wall_" + name, Sprite = "CL_Large_Wall_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 10, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 2, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Large_Wall_" + name; component.m_description = "$EJ_Large_Wall_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Pole Light", Prefab = "CL_Pole_" + name, Sprite = "CL_Pole_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 5, refundable = true }, new JotunnPiece.PieceCost { prefab = "Iron", amount = 2, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Pole_" + name; component.m_description = "$EJ_Pole_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Raw Crystal", Prefab = "CL_Raw_" + name, Sprite = "CL_Raw_" + name, Workbench = "piece_workbench", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 5, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Raw_" + name; component.m_description = "$EJ_Raw_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Small Wall Light", Prefab = "CL_Small_Wall_" + name, Sprite = "CL_Small_Wall_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 3, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 1, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Small_Wall_" + name; component.m_description = "$EJ_Small_Wall_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Standing Lamp", Prefab = "CL_Standing_Lamp_" + name, Sprite = "CL_Standing_Lamp_" + name, Workbench = "forge", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 1, refundable = true }, new JotunnPiece.PieceCost { prefab = "IronNails", amount = 1, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Standing_Lamp_" + name; component.m_description = "$EJ_Standing_Lamp_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); JotunnPiece.RegisterJotunnPiece(new JotunnPiece.JotunnBuildPiece { Name = name + " Standing Torch", Prefab = "CL_Standing_Torch_" + name, Sprite = "CL_Standing_Torch_" + name, Workbench = "none", Category = "Crystal Lights", PieceCost = new List<JotunnPiece.PieceCost> { new JotunnPiece.PieceCost { prefab = "Uncut_" + name.ToLower() + "_Stone", amount = 1, refundable = true }, new JotunnPiece.PieceCost { prefab = "Wood", amount = 2, refundable = true } }, BeforePrefabRegistered = delegate(JotunnPiece.JotunnBuildPiece jbuildpiece) { //IL_0065: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) Piece component = jbuildpiece.Objs.Prefab.GetComponent<Piece>(); component.m_name = "$EJ_Standing_Torch_" + name; component.m_description = "$EJ_Standing_Torch_" + name + "_Description"; ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<Light>().color = GemDefinitions[name].Color; MainModule main = ((Component)jbuildpiece.Objs.Prefab.transform).GetComponentInChildren<ParticleSystem>().main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(GemDefinitions[name].Color); } }); } } } namespace EpicJewels.GemEffects { public static class EffectList { public enum DmgEffect { AddBluntDamage, AddPierceDamage, AddSlashDamage, AddSpiritDamage, AddLightningDamage, AddPickaxeDamage, AddChopDamage } public static void AddGemEffects() { API.AddGemEffect<BluntResistance.Config>("Blunt Resistance", "Increases your blunt resistance.", "Reduces all blunt damage you take by $1%."); API.AddGemEffect<PierceResistance.Config>("Pierce Resistance", "Increases your pierce resistance.", "Reduces all pierce damage you take by $1%."); API.AddGemEffect<SlashResistance.Config>("Slash Resistance", "Increases your slash resistance.", "Reduces all slash damage you take by $1%."); API.AddGemEffect<FireResistance.Config>("Fire Resistance", "Increases your fire resistance.", "Reduces all fire damage you take by $1%."); API.AddGemEffect<PoisonResistance.Config>("Poison Resistance", "Increases your poison resistance.", "Reduces all poison damage you take by $1%."); API.AddGemEffect<LightningResistance.Config>("Lightning Resistance", "Increases your lightning resistance.", "Reduces all lightning damage you take by $1%."); API.AddGemEffect<AddBluntDamage.Config>("Add Blunt Damage", "Additional blunt damage.", "$2% chance to do blunt damage equal to $1% of your base weapons damage."); API.AddGemEffect<AddPierceDamage.Config>("Add Pierce Damage", "Additional piercing damage.", "$2% chance to do pierce damage equal to $1% of your base weapons damage."); API.AddGemEffect<AddSlashDamage.Config>("Add Slash Damage", "Additional slash damage.", "$2% chance to do slash damage equal to $1% of your base weapons damage."); API.AddGemEffect<AddSpiritDamage.Config>("Add Spirit Damage", "Additional spirit damage.", "$2% chance to do spirit damage equal to $1% of your base weapons damage."); API.AddGemEffect<AddLightningDamage.Config>("Add Lightning Damage", "Additional lightning damage.", "$2% chance to do lightning damage equal to $1% of your base weapons damage."); API.AddGemEffect<AddPickaxeDamage.Config>("Add Pickaxe Damage", "Additional pickaxe damage.", "$2% chance to do pickaxe damage equal to $1% of your base tools damage."); API.AddGemEffect<AddChopDamage.Config>("Add Chop Damage", "Additional woodcutting damage.", "$2% chance to do woodcutting damage equal to $1% of your base tools damage."); API.AddGemEffect<Inferno.Config>("Inferno", "Chance to do massive fire damage.", "$2% chance to do a bonus $1% of your total hits damage as fire damage."); API.AddGemEffect<IncreaseEitr.Config>("Increase Eitr", "Increases Eitr.", "Increases total eitr by $1%."); API.AddGemEffect<IncreaseStamina.Config>("Increase Stamina", "Increases stamina.", "Increases total stamina by $1%."); API.AddGemEffect<IncreaseStaminaRegen.Config>("Increase Stamina Regen", "Increases your stamina regeneration.", "Increases your stamina regeneration by $1%."); API.AddGemEffect<BlockReduceStamina.Config>("Block Reduce Stamina", "Reduces stamina cost when blocking.", "Reduces the stamina cost for blocking by $1%."); API.AddGemEffect<WeaponReducedStamina.Config>("Weapon Reduced Stamina", "Reduces stamina cost when attacking.", "Reduces the stamina cost for attacking by $1%."); API.AddGemEffect<CoinGreed.Config>("Coin Greed", "Enemies have a chance to drop coins.", "Enemies have a $2% chance to drop between 1-$1 coins."); API.AddGemEffect<CoinHoarder.Config>("Coin Hoarder", "Increases your damage based on carried coins.", "Increase all of your damage by a percentage of the total coins you carry."); API.AddGemEffect<WaterResistant.Config>("Water Resistant", "Prevents becoming wet for a period of time.", "Prevents becoming wet for $1 seconds water exposure."); API.AddGemEffect<WaterFrenzy.Config>("Water Frenzy", "Increases your damage done when wet.", "Increases your damage dealt by $1% when wet."); API.AddGemEffect<WaterSwiftness.Config>("Water Swiftness", "Increases your speed when wet.", "Increases your speed by $1% when wet."); API.AddGemEffect<BurningViking.Config>("Burning Viking", "Increases your speed when on fire.", "Increases your speed by $1% when burning."); API.AddGemEffect<BurningFrenzy.Config>("Burning Frenzy", "Increases your damage when on fire.", "Increases your damage dealt by $1% when burning."); API.AddGemEffect<ExpertFisher.Config>("Expert Fisher", "Increases your fishing skill.", "Your fishing skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertMage.Config>("Expert Mage", "Increases your elemental and blood magic skills.", "Your blood and elemental magic skills are $1% higher. Visible on your skills page."); API.AddGemEffect<ExpertHarvester.Config>("Expert Harvester", "Increase your chopping and pickaxe skills.", "Your chopping and pickaxe skills are $1% higher. Visible on your skills page."); API.AddGemEffect<ExpertBrawler.Config>("Expert Brawler", "Increases your fists skill.", "Your fists skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertAcrobat.Config>("Expert Acrobat", "Increases your jump skill.", "Your jump skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertDaggers.Config>("Expert Daggers", "Increases your knife skill.", "Your knives skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertSwordsman.Config>("Expert Swordsman", "Increases your swords skill.", "Your sword skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertSmasher.Config>("Expert Smasher", "Increases your maces skill.", "Your maces skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertPolearms.Config>("Expert Polearms", "Increases your polearm skill.", "Your polearms skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertSpearmaiden.Config>("Expert Spearmaiden", "Increases your spear skill.", "Your spear skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertAxemaster.Config>("Expert Axemaster", "Increases your axes skill.", "Your axes skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ExpertSprinter.Config>("Expert Sprinter", "Increases your running skill.", "Your running skill is $1 higher. Visible on your skills page."); API.AddGemEffect<ReduceWeight.Config>("Reduce Weight", "Reduces total weight of items.", "Reduces the total weight of everything you carry by $1%."); API.AddGemEffect<CoverOfDarkness.Config>("Cover of Darkness", "Chance to spawn friendly bats when fighting.", "$2% chance on hit to spawn a bat which lasts for $1 seconds."); API.AddGemEffect<EitrConversion.Config>("Eitr Conversion", "Chance to restore eitr on block.", "$2% chance on block to restore $1% eitr."); API.AddGemEffect<Retribution.Config>("Retribution", "Chance to return damage when blocking.", "$2% chance on block to return $1% damage to the attacker."); API.AddGemEffect<StaggeringBlock.Config>("Staggering Block", "Blocking can stagger attackers.", "$1% chance to stagger your attacker."); API.AddGemEffect<FlamingGuard.Config>("Burning Guard", "On block chance to return fire damage.", "$1% chance to set your attacker on fire for $2% of the blocked damage."); API.AddGemEffect<FreezingGuard.Config>("Freezing Guard", "On block chance to return frost damage.", "$1% chance to return frost damage for $2% of the blocked damage."); API.AddGemEffect<WetWorker.Config>("Wet Worker", "Reduces stamina usage when wet.", "$1% usage stamina cost reduction when wet."); API.AddGemEffect<EitrFused.Config>("Eitr Fused", "Uses eitr to increase damage.", "$1% increase to damage at the cost of $2 eitr per hit."); API.AddGemEffect<Farmer.Config>("Farmer", "Chance for bigger harvests, autopick nearby.", "$2% chance to get $1 additional crops when harvesting. Autopicks nearby crops."); API.AddGemEffect<Toxifier.Config>("Toxifier", "Gain adrenaline from poison damage around you.", "Gain $1 adrenaline whenever poison damage is applied within $2m."); API.AddGemEffect<AdrenalRewire.Config>("Adrenal Rewire", "Gain adrenaline from damage taken.", "Gain a small amount of adrenaline for each point of damage taken."); API.AddGemEffect<SoakedFury.Config>("Soaked Fury", "Gain additional adrenaline while wet.", "Gain $1% more adrenaline while you are wet."); API.AddGemEffect<BurningAdrenaline.Config>("Burning Adrenaline", "Gain additional adrenaline while on fire.", "Gain $1% more adrenaline while you are on fire."); API.AddGemEffect<HarvestAdrenaline.Config>("Harvest Adrenaline", "Chance to gain adrenaline from harvesting.", "$2% chance to gain $1% of damage done as adrenaline."); API.AddGemEffect<EitrFeedback.Config>("Eitr Feedback", "Chance to restore adrenaline from eitr use.", "$2% chance to restore $1 adrenaline when consuming eitr."); API.AddGemEffect<CombatSpirit.Config>("Combat Spirit", "A spirit helps you in combat.", "A spirit aids you in combat for $1 seconds. Returns after a cooldown."); API.AddGemEffect<IntenseFire.Config>("Intense Fire", "An affinity for fire.", "You are +$1% fire resistant and have a higher chance to trigger Inferno."); API.AddGemEffect<SlipperyWhenWet.Config>("Slippery When Wet", "Water quickens you.", "You are $1% faster when wet."); API.AddGemEffect<Waterproof.Config>("Waterproof", "You do not get wet.", "You do not get wet."); API.AddGemEffect<WeaponMaster.Config>("Weapon Master", "Experienced with weapons.", "Your skill with all weapons is $1% higher."); API.AddGemEffect<Spellsword.Config>("Spellsword", "Use eitr to increase weapon damage.", "$1% increase to damage at the cost of 5 eitr per hit."); } } public static class AddBluntDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddChopDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddLightningDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } internal class AddPickaxeDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddPierceDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddSlashDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } public static class AddSpiritDamage { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } } internal class AdrenalRewire { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class DamageTakenProvidesStamina { public static void Postfix(Character __instance, HitData hit) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsPlayer()) { return; } Player player = (Player)(object)((__instance is Player) ? __instance : null); float chance = player.GetEffectPower<Config>("Adrenal Rewire").Chance; if (!(Random.Range(0f, 100f) > chance)) { float power = player.GetEffectPower<Config>("Adrenal Rewire").Power; if (power > 0f) { float totalDamageOptions = hit.m_damage.GetTotalDamageOptions(); float num = totalDamageOptions * (power / (100f + __instance.GetMaxAdrenaline())); EJLogger.LogDebug($"Adrenal Rewire is restoring {num} stamina based on total damage of {totalDamageOptions} and power of {power}"); __instance.AddAdrenaline(num); } } } } } public static class BlockReduceStamina { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] public static class ModifyBlockStaminaUse_Humanoid_BlockAttack_Patch { public static void Prefix(Humanoid __instance, out float __state) { __state = __instance.m_blockStaminaDrain; Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower<Config>("Block Reduce Stamina").Power > 0f) { float num = 100f / (100f + val.GetEffectPower<Config>("Block Reduce Stamina").Power); __instance.m_blockStaminaDrain *= num; } } public static void Postfix(Humanoid __instance, float __state) { __instance.m_blockStaminaDrain = __state; } } } public static class BluntResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReduceBluntDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_blunt > 0f && val.GetEffectPower<Config>("Blunt Resistance").Power > 0f) { float num = (100f - val.GetEffectPower<Config>("Blunt Resistance").Power) / 100f; hit.m_damage.m_blunt *= num; } } } } } internal class BurningAdrenaline { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "AddAdrenaline")] public static class ReducePoisonDamageTaken { private static readonly int Wetstatus = StringExtensionMethods.GetStableHashCode("Burning"); [UsedImplicitly] private static void Prefix(Player __instance, ref float v) { float power = __instance.GetEffectPower<Config>("Burning Adrenaline").Power; if (power > 0f && ((Character)__instance).GetSEMan().HaveStatusEffect(Wetstatus)) { float num = (power + 100f) / 100f; EJLogger.LogDebug($"Burning Adrenaline is increasing adrenaline gain by {num}"); v *= num; } } } } public static class BurningFrenzy { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Character), "Damage")] private class AddBonusBonusDamageWhileOnFire { private static void Prefix(HitData hit) { if (hit.GetAttacker() is Player) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (((Character)val).GetSEMan().HaveStatusEffect(burningstatus)) { float num = (100f + val.GetEffectPower<Config>("Burning Frenzy").Power) / 100f; hit.m_damage.m_blunt *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_slash *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_spirit *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_pickaxe *= num; } } } } private static int burningstatus = StringExtensionMethods.GetStableHashCode("Burning"); } public static class BurningViking { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private class IncreaseJogSpeed { private static void Postfix(Player __instance, ref float __result) { if (((Character)__instance).GetSEMan().HaveStatusEffect(burningstatus) && __instance.GetEffectPower<Config>("Burning Viking").Power > 0f) { __result *= (__instance.GetEffectPower<Config>("Burning Viking").Power + 100f) / 100f; } } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] private class IncreaseRunSpeed { private static void Postfix(Player __instance, ref float __result) { if (((Character)__instance).GetSEMan().HaveStatusEffect(burningstatus) && __instance.GetEffectPower<Config>("Burning Viking").Power > 0f) { __result *= (__instance.GetEffectPower<Config>("Burning Viking").Power + 100f) / 100f; } } } private static int burningstatus = StringExtensionMethods.GetStableHashCode("Burning"); } public static class CoinGreed { [PublicAPI] public struct Config { [AdditivePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Character), "OnDeath")] public static class AddGreedOnDeathFromPlayer { [UsedImplicitly] private static void Postfix(Character __instance) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_lastHit == null) { return; } Character attacker = __instance.m_lastHit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val == (Object)null) { return; } float power = val.GetEffectPower<Config>("Coin Greed").Power; if (power > 0f) { float num = val.GetEffectPower<Config>("Coin Greed").Chance / 100f; if (Random.value < num) { int stack = Random.Range(1, Math.Max(1, (int)power) + 1); Object.Instantiate<GameObject>(ObjectDB.instance.GetItemPrefab("Coins"), ((Component)__instance).gameObject.transform.position, ((Component)__instance).gameObject.transform.rotation).GetComponent<ItemDrop>().m_itemData.m_stack = stack; } } } } } internal static class CoinHoarder { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "Damage")] internal static class IncreaseAllDamageByCoins { internal static void Prefix(HitData hit) { if (hit.GetAttacker() is Player) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val != (Object)null && val.GetEffectPower<Config>("Coin Hoarder").Power > 0f) { float num = CoinHoarderBonusCalc(val); hit.m_damage.m_blunt *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_slash *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_spirit *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_pickaxe *= num; } } } } internal static float CoinHoarderBonusCalc(Player player) { ItemData[] array = ((Humanoid)player).m_inventory.GetAllItems().Where(delegate(ItemData val2) { GameObject dropPrefab = val2.m_dropPrefab; return ((dropPrefab != null) ? ((Object)dropPrefab).name : null) == "Coins"; }).ToArray(); if (array.Length == 0) { return 1f; } float num = 0f; ItemData[] array2 = array; foreach (ItemData val in array2) { num += (float)val.m_stack; } return (float)Math.Log10(player.GetEffectPower<Config>("Coin Hoarder").Power * num) * 5.5f / 100f + 1f; } } public static class CombatSpirit { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Player), "OnTargeted")] public static class CombatCompanion { private static void Postfix(Player __instance, bool sensed, bool alerted) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.GetEffectPower<Config>("Combat Spirit").Power > 0f && sensed && alerted)) { return; } if ((Object)(object)wolf == (Object)null && !have_spirit_companion) { ZNetScene.instance.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode("Wolf"), out var value); if ((Object)(object)value == (Object)null) { EJLogger.LogWarning("Combat Spirit could not resolve the 'Wolf' prefab, skipping spawn."); return; } Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Vector3 position = ((Component)__instance).gameObject.transform.position; position.x += 1f; wolf = Object.Instantiate<GameObject>(value, position, val); cooldown_until = Time.time + 120f; have_spirit_companion = true; wolf.AddComponent<CharacterTimedDestruction>(); Character component = wolf.GetComponent<Character>(); wolf.GetComponent<CharacterTimedDestruction>().m_character = component; wolf.GetComponent<CharacterTimedDestruction>().Trigger(__instance.GetEffectPower<Config>("Combat Spirit").Power); SkinnedMeshRenderer componentInChildren = wolf.GetComponentInChildren<SkinnedMeshRenderer>(); if ((Object)(object)componentInChildren != (Object)null) { ((Renderer)componentInChildren).material = EpicJewels.spiritCreature; } Object.Destroy((Object)(object)wolf.GetComponent<CharacterDrop>()); Object.Destroy((Object)(object)wolf.GetComponent<Tameable>()); Humanoid component2 = wolf.GetComponent<Humanoid>(); wolf.GetComponent<Character>(); MonsterAI component3 = wolf.GetComponent<MonsterAI>(); if ((Object)(object)component3 != (Object)null) { component3.m_attackPlayerObjects = false; } ((Character)component2).m_health = 1000f; for (int i = 0; i < ((Character)component2).m_deathEffects.m_effectPrefabs.Length && i < 2; i++) { ((Character)component2).m_deathEffects.m_effectPrefabs[i].m_enabled = false; } ((Object)component2).name = "EJ_spirit_wolf"; if ((Object)(object)component2 != (Object)null) { ((Character)component2).m_faction = (Faction)0; } ((Object)wolf).name = "Spirit Wolf"; } if (Time.time < cooldown_until) { return; } if (recheck_spirit_spawn_timer > 3f) { recheck_spirit_spawn_timer = 0f; if (Character.s_characters.Any((Character c) => Vector3.Distance(((Component)__instance).gameObject.transform.position, ((Component)c).transform.position) < 100f && ((Object)c).name == "Spirit Wolf")) { have_spirit_companion = true; } else { have_spirit_companion = false; } } else { recheck_spirit_spawn_timer += Time.deltaTime; } } } private static GameObject wolf; private static bool have_spirit_companion; private static float recheck_spirit_spawn_timer; private static float cooldown_until; } public static class CoverOfDarkness { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; [AdditivePower] public float MaxCount; } [HarmonyPatch(typeof(Character), "Damage")] public static class SummonBatHelpers { private static void Prefix(HitData hit) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!(hit.GetAttacker() is Player)) { return; } Character attacker = hit.GetAttacker(); Player player = (Player)(object)((attacker is Player) ? attacker : null); if (!(player.GetEffectPower<Config>("Cover of Darkness").Power > 0f) || !(Random.value < player.GetEffectPower<Config>("Cover of Darkness").Chance / 100f)) { return; } int stars = 1; float power = player.GetEffectPower<Config>("Cover of Darkness").Power; if (power > 70f) { stars = 4; } else if (power > 50f) { stars = 3; } else if (power > 30f) { stars = 2; } if ((float)spawnedBats.Count >= player.GetEffectPower<Config>("Cover of Darkness").MaxCount) { List<ZDOID> list = new List<ZDOID>(); foreach (ZDOID spawnedBat in spawnedBats) { if ((Object)(object)ZNetScene.instance.FindInstance(spawnedBat) != (Object)null && !list.Contains(spawnedBat)) { list.Add(spawnedBat); } } spawnedBats = list; if ((float)spawnedBats.Count >= player.GetEffectPower<Config>("Cover of Darkness").MaxCount) { return; } } if (player.GetEffectPower<Config>("Cover of Darkness").Power > 90f) { SpawnBat(player, stars); SpawnBat(player, stars); } else { SpawnBat(player, stars); } } } public static List<ZDOID> spawnedBats = new List<ZDOID>(); private static GameObject bat = null; private static void SpawnBat(Player player, int stars = 1) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0120: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bat == (Object)null) { ZNetScene.instance.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode("Bat"), out bat); if ((Object)(object)bat == (Object)null) { EJLogger.LogWarning("Cover of Darkness could not resolve the 'Bat' prefab, skipping spawn."); return; } } Quaternion val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Vector3 position = ((Component)player).gameObject.transform.position; position.y += 1f; GameObject val2 = Object.Instantiate<GameObject>(bat, position, val); Character component = val2.GetComponent<Character>(); val2.GetComponent<ZNetView>().m_persistent = true; component.m_level = stars; Object.Destroy((Object)(object)val2.GetComponent<CharacterDrop>()); MonsterAI component2 = val2.GetComponent<MonsterAI>(); if ((Object)(object)component2 != (Object)null) { if ((Object)(object)val2.GetComponent<Tameable>() == (Object)null) { val2.AddComponent<Tameable>(); } component2.MakeTame(); } else { Object.Destroy((Object)(object)val2); } val2.AddComponent<CharacterTimedDestruction>(); val2.GetComponent<CharacterTimedDestruction>().m_character = component; val2.GetComponent<CharacterTimedDestruction>().Trigger(player.GetEffectPower<Config>("Cover of Darkness").Power); spawnedBats.Add(component.GetZDOID()); } } public static class EitrConversion { [PublicAPI] public struct Config { [AdditivePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class HealOnParry { private static void Postfix(Humanoid __instance, ref bool __result) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower<Config>("Eitr Conversion").Power > 0f && __result) { float value = Random.value; float num = val.GetEffectPower<Config>("Eitr Conversion").Chance / 100f; if (value < num) { ((Character)val).AddEitr(((Character)val).GetMaxEitr() * (val.GetEffectPower<Config>("Eitr Conversion").Power / 100f)); } } } } } internal class EitrFeedback { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Player), "RPC_UseEitr")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Player __instance, float v) { if (!(__instance.m_eitr <= 0f) && !(v < 1f)) { float chance = __instance.GetEffectPower<Config>("Eitr Feedback").Chance; if (chance > 0f && Random.Range(0f, 100f) <= chance) { float power = __instance.GetEffectPower<Config>("Eitr Feedback").Power; EJLogger.LogDebug($"Eitr Feedback restoring {power} adrenaline from eitr use."); ((Character)__instance).AddAdrenaline(power); } } } } } public static class EitrFused { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [AdditivePower] public float Cost; } } public static class ExpertAcrobat { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertAxemaster { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertBrawler { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertDaggers { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertFisher { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertHarvester { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertMage { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertPolearms { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSmasher { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSpearmaiden { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSprinter { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class ExpertSwordsman { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } } public static class Farmer { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; [AdditivePower] public float Pickup; } [HarmonyPatch(typeof(Pickable), "Interact")] public static class IncreaseCarryWeight { public static void Prefix(Pickable __instance, out bool __state) { __state = __instance.GetPicked(); } public static void Postfix(bool __result, Humanoid character, Pickable __instance, bool __state) { if (!__result || __state || !__instance.GetPicked() || !((Object)(object)character != (Object)null)) { return; } Player val = (Player)(object)((character is Player) ? character : null); if (val == null || !(val.GetEffectPower<Config>("Farmer").Power > 0f) || IsBlockedPickable(__instance)) { return; } float value = Random.value; float num = val.GetEffectPower<Config>("Farmer").Chance / 100f; if (value < num) { int num2 = 0; for (int i = 0; (float)i < val.GetEffectPower<Config>("Farmer").Power; i++) { __instance.Drop(__instance.m_itemPrefab, num2++, 1); } } } } [HarmonyPatch(typeof(Player), "Update")] public static class AutoPickupNearby_Pickables { private static readonly int pickableMask = LayerMask.GetMask(new string[3] { "piece_nonsolid", "item", "Default_small" }); private static float last_update = 0f; public static void Postfix(Player __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)null) || !(__instance.GetEffectPower<Config>("Farmer").Pickup > 0f) || Time.time < last_update + 0.5f) { return; } last_update = Time.time; Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, 2f + __instance.GetEffectPower<Config>("Farmer").Pickup, pickableMask); foreach (Collider val in array) { Pickable val2 = ((Component)val).GetComponent<Pickable>() ?? ((Component)val).GetComponentInParent<Pickable>(); if ((Object)(object)val2 != (Object)null && !IsBlockedPickable(val2) && (Object)(object)val2.m_nview != (Object)null && val2.CanBePicked()) { val2.m_nview.ClaimOwnership(); val2.Interact((Humanoid)(object)__instance, false, false); } } } } private static List<string> UnallowedGreenThumbPickables = new List<string> { "SurtlingCore", "Flint", "Wood", "Stone", "Amber", "AmberPearl", "Coins", "Ruby", "CryptRemains", "Obsidian", "Crystal", "Pot_Shard", "DragonEgg", "DvergrLantern", "DvergrMineTreasure", "SulfurRock", "VoltureEgg", "Swordpiece", "MoltenCore", "Hairstrands", "Tar", "BlackCore" }; private static bool IsBlockedPickable(Pickable pickable) { if ((Object)(object)pickable == (Object)null || (Object)(object)pickable.m_itemPrefab == (Object)null) { return true; } string item = ((Object)pickable.m_itemPrefab).name.Replace("(Clone)", "").Replace("Pickable_", ""); return UnallowedGreenThumbPickables.Contains(item); } } public static class FireResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_fire > 0f && (val.GetEffectPower<Config>("Fire Resistance").Power > 0f || val.GetEffectPower<Config>("Intense Fire").Power > 0f)) { float num = Mathf.Max(0f, (100f - (val.GetEffectPower<Config>("Fire Resistance").Power + val.GetEffectPower<Config>("Intense Fire").Power)) / 100f); hit.m_damage.m_fire *= num; } } } } } public static class FlamingGuard { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } [HarmonyPriority(600)] [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class FlamingBlock_Patch { private static int burningstatus = StringExtensionMethods.GetStableHashCode("Burning"); private static void Prefix(HitData hit, out float __state) { __state = hit.GetTotalDamage(); } private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result, float __state) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower<Config>("Burning Guard").Chance > 0f && __result && (Object)(object)attacker != (Object)null && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower<Config>("Burning Guard").Chance / 100f; if (value < num) { HitData val2 = new HitData(); val2.m_damage.m_fire = val.GetEffectPower<Config>("Burning Guard").Power / 100f * __state; val2.m_attacker = ((Character)val).GetZDOID(); val2.m_point = hit.m_point + new Vector3(0f, 0.5f); attacker.Damage(val2); attacker.m_seman.AddStatusEffect(burningstatus, true, 1, val.m_skills.GetSkill((SkillType)6).m_level, (short)(-1)); } } } } } internal class FreezingGuard { [PublicAPI] public struct Config { [AdditivePower] public float Power; [AdditivePower] public float Chance; } [HarmonyPriority(600)] [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class FreezingBlock_Patch { private static int froststatus = StringExtensionMethods.GetStableHashCode("Frost"); private static void Prefix(HitData hit, out float __state) { __state = hit.GetTotalDamage(); } private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result, float __state) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower<Config>("Freezing Guard").Chance > 0f && __result && (Object)(object)attacker != (Object)null && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower<Config>("Freezing Guard").Chance / 100f; if (value < num) { HitData val2 = new HitData(); val2.m_damage.m_frost = val.GetEffectPower<Config>("Freezing Guard").Power / 100f * __state; val2.m_attacker = ((Character)val).GetZDOID(); val2.m_point = hit.m_point + new Vector3(0f, 0.5f); attacker.Damage(val2); attacker.m_seman.AddStatusEffect(froststatus, true, 3, val.m_skills.GetSkill((SkillType)6).m_level, (short)(-1)); } } } } } internal class HarvestAdrenaline { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Destructible), "RPC_Damage")] public static class AdrenalineFromDestructibles { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(MineRock), "RPC_Hit")] public static class AdrenalineFromMineRocks { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] public static class AdrenalineFromMineRocks5 { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] public static class AdrenalineFromTreeBase { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] public static class AdrenalineFromTreeLog { public static void Postfix(HitData hit) { AddadrenalineForHarvest(hit); } } public static void AddadrenalineForHarvest(HitData hit) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((!(hit.m_damage.m_chop > 0f) && !(hit.m_damage.m_pickaxe > 0f)) || !(hit.GetAttacker() is Player)) { return; } float num = Random.Range(0f, 100f); Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (num <= val.GetEffectPower<Config>("Harvest Adrenaline").Chance) { float totalDamageOptions = hit.m_damage.GetTotalDamageOptions(include_poison: false, include_spirit: false, include_pickaxe_and_chop: true); float power = val.GetEffectPower<Config>("Harvest Adrenaline").Power; float num2 = totalDamageOptions * (power / 100f); EJLogger.LogDebug($"Harvest Adrenaline is restoring {num2} adrenaline based on total damage of {totalDamageOptions} and power of {power}"); if (((Character)val).IsOwner()) { ((Character)val).AddAdrenaline(num2); return; } ((Character)val).m_nview.InvokeRPC("RPC_AddAdrenaline", new object[1] { num2 }); } } } public static class IncreaseEitr { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class IncreaseTotalStamina { public static void Postfix(Player __instance, ref float eitr) { eitr += __instance.GetEffectPower<Config>("Increase Eitr").Power; } } } public static class IncreaseStamina { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class IncreaseTotalStamina { public static void Postfix(Player __instance, ref float stamina) { stamina += __instance.GetEffectPower<Config>("Increase Stamina").Power; } } } public static class IncreaseStaminaRegen { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(SEMan), "ModifyStaminaRegen")] public static class IncreasePlayerStaminaRegen { public static void Postfix(SEMan __instance, ref float staminaMultiplier) { Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && (Object)(object)val != (Object)null && val.GetEffectPower<Config>("Increase Stamina Regen").Power > 0f) { float num = (val.GetEffectPower<Config>("Increase Stamina Regen").Power + 100f) / 100f; staminaMultiplier *= num; } } } } public static class Inferno { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; [MultiplicativePercentagePower] public float Chance; } } public static class IntenseFire { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } public static class LightningResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_lightning > 0f && val.GetEffectPower<Config>("Lightning Resistance").Power > 0f) { float num = (100f - val.GetEffectPower<Config>("Lightning Resistance").Power) / 100f; hit.m_damage.m_lightning *= num; } } } } } public static class PierceResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePierceDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_pierce > 0f && val.GetEffectPower<Config>("Pierce Resistance").Power > 0f) { float num = (100f - val.GetEffectPower<Config>("Pierce Resistance").Power) / 100f; hit.m_damage.m_pierce *= num; } } } } } public static class PoisonResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReducePoisonDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_poison > 0f && val.GetEffectPower<Config>("Poison Resistance").Power > 0f) { float num = (100f - val.GetEffectPower<Config>("Poison Resistance").Power) / 100f; hit.m_damage.m_poison *= num; } } } } } public static class ReduceWeight { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(ItemData), "GetWeight")] public static class ReduceWeight_ItemData_GetWeight_Patch { public static void Postfix(ref float __result) { __result = ReduceWeightByPower(__result); } } [HarmonyPatch(typeof(ItemData), "GetNonStackedWeight")] public static class ReduceWeight_ItemData_GetNonstackedWeight_Patch { public static void Postfix(ref float __result) { __result = ReduceWeightByPower(__result); } } public static float ReduceWeightByPower(float original) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return original; } if (Player.m_localPlayer.GetEffectPower<Config>("Reduce Weight").Power > 0f) { float num = 100f / (Player.m_localPlayer.GetEffectPower<Config>("Reduce Weight").Power + 100f); original *= num; } return original; } } public static class Retribution { [PublicAPI] public struct Config { [AdditivePower] public float Power; [InverseMultiplicativePercentagePower] public float Chance; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class Retribution_Patch { private static void Prefix(HitData hit, out float __state) { __state = hit.GetTotalDamage(); } private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result, float __state) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //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_009b: 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_00b4: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower<Config>("Retribution").Power > 0f && __result && (Object)(object)attacker != (Object)null && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower<Config>("Retribution").Chance / 100f; if (value < num) { HitData val2 = new HitData(); val2.m_damage.m_damage = __state * (val.GetEffectPower<Config>("Retribution").Power / 100f); val2.m_attacker = ((Character)val).GetZDOID(); val2.m_point = hit.m_point + new Vector3(0f, 0.5f); attacker.Damage(val2); } } } } } public static class SlashResistance { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class ReduceSlashDamageTaken { [UsedImplicitly] private static void Prefix(Character __instance, HitData hit) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { Character attacker = hit.GetAttacker(); if (attacker != null && (Object)(object)attacker != (Object)(object)__instance && hit.m_damage.m_slash > 0f && val.GetEffectPower<Config>("Slash Resistance").Power > 0f) { float num = (100f - val.GetEffectPower<Config>("Slash Resistance").Power) / 100f; hit.m_damage.m_slash *= num; } } } } } public static class SlipperyWhenWet { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } internal class SoakedFury { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "AddAdrenaline")] public static class ReducePoisonDamageTaken { private static readonly int Wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); [UsedImplicitly] private static void Prefix(Player __instance, ref float v) { float power = __instance.GetEffectPower<Config>("Soaked Fury").Power; if (power > 0f && ((Character)__instance).GetSEMan().HaveStatusEffect(Wetstatus)) { float num = (power + 100f) / 100f; EJLogger.LogDebug($"Soaked Fury is increasing adrenaline gain by {num}"); v *= num; } } } } public static class Spellsword { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } public static class StaggeringBlock { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] private static class StaggeringBlock_Patch { private static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result) { //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) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && val.GetEffectPower<Config>("Staggering Block").Power > 0f && __result && (Object)(object)attacker != (Object)null && !attacker.IsDead()) { float value = Random.value; float num = val.GetEffectPower<Config>("Staggering Block").Power / 100f; if (value < num) { attacker.AddStaggerDamage(999f, -hit.m_dir, (HitData)null); } } } } } internal class Toxifier { [PublicAPI] public struct Config { [MultiplicativePercentagePower] public float Power; [MultiplicativePercentagePower] public float Distance; } [HarmonyPatch(typeof(Character), "AddPoisonDamage")] public static class ReducePoisonDamageTaken { [UsedImplicitly] private static void Postfix(Character __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { float power = Player.m_localPlayer.GetEffectPower<Config>("Toxifier").Power; if (power > 0f && Player.m_localPlayer.GetEffectPower<Config>("Toxifier").Distance > Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)__instance).transform.position)) { ((Character)Player.m_localPlayer).AddAdrenaline(power); } } } } } public static class WaterFrenzy { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Character), "Damage")] private class AddBonusSlashDamage { private static void Prefix(HitData hit) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (val != null && (Object)(object)val != (Object)null && ((Character)val).GetSEMan().HaveStatusEffect(wetstatus)) { float num = (val.GetEffectPower<Config>("Water Frenzy").Power + 100f) / 100f; hit.m_damage.m_blunt *= num; hit.m_damage.m_pierce *= num; hit.m_damage.m_slash *= num; hit.m_damage.m_fire *= num; hit.m_damage.m_lightning *= num; hit.m_damage.m_frost *= num; hit.m_damage.m_spirit *= num; hit.m_damage.m_poison *= num; hit.m_damage.m_pickaxe *= num; } } } private static int wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); } public static class Waterproof { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } internal class WaterResistant { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] public static class Waterproof_SEMan_AddStatusEffect_Patch { public static bool Prefix(SEMan __instance, int nameHash) { if (__instance.m_character.IsPlayer()) { Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && nameHash == wet_hash) { if (val.GetEffectPower<Waterproof.Config>("Waterproof").Power > 0f) { return false; } if (val.GetEffectPower<Config>("Water Resistant").Power > 0f) { if (delayWetTill == 0f) { delayWetTill = Time.time + val.GetEffectPower<Config>("Water Resistant").Power; return false; } if (delayWetTill < Time.time) { if (delayWetTill + 2f < Time.time) { delayWetTill = 0f; return false; } delayWetTill = 0f; return true; } return false; } } } return true; } } private static float delayWetTill = 0f; private static int wet_hash = StringExtensionMethods.GetStableHashCode("Wet"); } public static class WaterSwiftness { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private class IncreaseJogSpeed { private static void Postfix(Player __instance, ref float __result) { if ((((Character)__instance).GetSEMan().HaveStatusEffect(wetstatus) || __instance.GetEffectPower<Waterproof.Config>("Waterproof").Power > 0f) && (__instance.GetEffectPower<Config>("Water Swiftness").Power > 0f || __instance.GetEffectPower<SlipperyWhenWet.Config>("Slippery When Wet").Power > 0f)) { float num = (__instance.GetEffectPower<Config>("Water Swiftness").Power + __instance.GetEffectPower<SlipperyWhenWet.Config>("Slippery When Wet").Power + 100f) / 100f; __result *= num; } } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] private class IncreaseRunSpeed { private static void Postfix(Player __instance, ref float __result) { if ((((Character)__instance).GetSEMan().HaveStatusEffect(wetstatus) || __instance.GetEffectPower<Waterproof.Config>("Waterproof").Power > 0f) && (__instance.GetEffectPower<Config>("Water Swiftness").Power > 0f || __instance.GetEffectPower<SlipperyWhenWet.Config>("Slippery When Wet").Power > 0f)) { float num = (__instance.GetEffectPower<Config>("Water Swiftness").Power + __instance.GetEffectPower<SlipperyWhenWet.Config>("Slippery When Wet").Power + 100f) / 100f; __result *= num; } } } private static int wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); } public static class WeaponMaster { [PublicAPI] public struct Config { [AdditivePower] public float Power; } } public static class WeaponReducedStamina { [PublicAPI] public struct Config { [InverseMultiplicativePercentagePower] public float Power; } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] public class ReduceStaminaCostForAttack { public static void Postfix(Attack __instance, ref float __result) { Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && val.GetEffectPower<Config>("Weapon Reduced Stamina").Power > 0f) { float num = 100f / (val.GetEffectPower<Config>("Weapon Reduced Stamina").Power + 100f); __result *= num; } } } } public static class WetWorker { [PublicAPI] public struct Config { [AdditivePower] public float Power; } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] public class ReduceStaminaCostWet_Patch { public static void Postfix(Attack __instance, ref float __result) { Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && val.GetEffectPower<Config>("Wet Worker").Power > 0f && ((Character)val).GetSEMan().HaveStatusEffect(wetstatus)) { float num = 100f / (val.GetEffectPower<Config>("Wet Worker").Power + 100f); __result *= num; } } } private static int wetstatus = StringExtensionMethods.GetStableHashCode("Wet"); } } namespace EpicJewels.EffectHelpers { public static class AddDamageHarvestables { [HarmonyPatch(typeof(MineRock), "RPC_Hit")] private static class DamageRock { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(MineRock5), "RPC_Damage")] private static class DamageRock5 { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] private static class DamageTreebase { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] private static class DamageTreeLog { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } [HarmonyPatch(typeof(Destructible), "RPC_Damage")] private static class DamageDestructible { private static void Prefix(HitData hit) { ModifyHarvestDamage(hit); } } private static HitData ModifyHarvestDamage(HitData hit) { if (hit.GetAttacker() is Player && hit.GetAttacker().IsOwner()) { Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); float totalDamage = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); float num = 0f; if (val.GetEffectPower<AddPickaxeDamage.Config>("Add Pickaxe Damage").Chance / 100f >= Random.value) { num = totalDamage * (val.GetEffectPower<AddPickaxeDamage.Config>("Add Pickaxe Damage").Power / 100f); } float num2 = 0f; if (val.GetEffectPower<AddChopDamage.Config>("Add Chop Damage").Chance / 100f >= Random.value) { num2 = totalDamage * (val.GetEffectPower<AddChopDamage.Config>("Add Chop Damage").Power / 100f); } if (val.GetEffectPower<EitrFused.Config>("Eitr Fused").Power > 0f || val.GetEffectPower<Spellsword.Config>("Spellsword").Power > 0f) { float num3 = val.GetEffectPower<EitrFused.Config>("Eitr Fused").Cost; if (val.GetEffectPower<Spellsword.Config>("Spellsword").Power > 0f) { num3 += 5f; } if (((Character)val).HaveEitr(num3)) { float num4 = (val.GetEffectPower<EitrFused.Config>("Eitr Fused").Power + val.GetEffectPower<Spellsword.Config>("Spellsword").Power) / 100f; num2 += hit.m_damage.m_chop * num4; num += hit.m_damage.m_pickaxe * num4; ((Character)val).UseEitr(num3); } else { EJLogger.LogDebug($"Eitr powered attack not triggered due to cost {num3}"); } } float num5 = num2 + num; EJLogger.LogDebug($"Added Damage {num5} = pickaxe: {num} chop: {num2} original_total_dmg {totalDamage}"); hit.m_damage.m_chop += num2; hit.m_damage.m_pickaxe += num; } return hit; } } [HarmonyPatch(typeof(Character), "Damage")] public static class IncreaseDamageByPowers { private static void Prefix(HitData hit) { if (!(hit.GetAttacker() is Player)) { return; } Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); float totalDamage = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); float value = Random.value; float value2 = Random.value; float num = 0f; if (val.GetEffectPower<AddBluntDamage.Config>("Add Blunt Damage").Chance / 100f >= value2) { num = totalDamage * (val.GetEffectPower<AddBluntDamage.Config>("Add Blunt Damage").Power / 100f); } float num2 = 0f; if (val.GetEffectPower<AddSlashDamage.Config>("Add Slash Damage").Chance / 100f >= value2) { num2 = totalDamage * (val.GetEffectPower<AddSlashDamage.Config>("Add Slash Damage").Power / 100f); } float num3 = 0f; if (val.GetEffectPower<AddPierceDamage.Config>("Add Pierce Damage").Chance / 100f >= value2) { num3 = totalDamage * (val.GetEffectPower<AddPierceDamage.Config>("Add Pierce Damage").Power / 100f); } float num4 = 0f; if (val.GetEffectPower<AddLightningDamage.Config>("Add Lightning Damage").Chance / 100f >= value) { num4 = totalDamage * (val.GetEffectPower<AddLightningDamage.Config>("Add Lightning Damage").Power / 100f); } float num5 = 0f; if (val.GetEffectPower<AddSpiritDamage.Config>("Add Spirit Damage").Chance / 100f >= value) { num5 = totalDamage * (val.GetEffectPower<AddSpiritDamage.Config>("Add Spirit Damage").Power / 100f); } float num6 = 0f; if (val.GetEffectPower<AddPickaxeDamage.Config>("Add Pickaxe Damage").Chance / 100f >= value2) { num6 = totalDamage * (val.GetEffectPower<AddPickaxeDamage.Config>("Add Pickaxe Damage").Power / 100f); } float num7 = 0f; if (val.GetEffectPower<AddChopDamage.Config>("Add Chop Damage").Chance / 100f >= value2) { num7 = totalDamage * (val.GetEffectPower<AddChopDamage.Config>("Add Chop Damage").Power / 100f); } if (val.GetEffectPower<EitrFused.Config>("Eitr Fused").Power > 0f || val.GetEffectPower<Spellsword.Config>("Spellsword").Power > 0f) { float num8 = val.GetEffectPower<EitrFused.Config>("Eitr Fused").Cost; if (val.GetEffectPower<Spellsword.Config>("Spellsword").Power > 0f) { num8 += 5f; } if (((Character)val).HaveEitr(num8)) { float num9 = (val.GetEffectPower<EitrFused.Config>("Eitr Fused").Power + val.GetEffectPower<Spellsword.Config>("Spellsword").Power) / 100f; num7 += hit.m_damage.m_chop * num9; num6 += hit.m_damage.m_pickaxe * num9; num5 += hit.m_damage.m_spirit * num9; num4 += hit.m_damage.m_lightning * num9; num3 += hit.m_damage.m_pierce * num9; num2 += hit.m_damage.m_slash * num9; num += hit.m_damage.m_blunt * num9; ((Character)val).UseEitr(num8); } else { EJLogger.LogDebug($"Eitr powered attack not triggered due to cost {num8}"); } } float num10 = num + num2 + num3 + num4 + num5 + num6 + num7; float num11 = val.GetEffectPower<Inferno.Config>("Inferno").Chance; if (val.GetEffectPower<IntenseFire.Config>("Intense Fire").Power > 0f) { num11 *= 1.5f; } num11 /= 100f; float value3 = Random.value; if (val.GetEffectPower<Inferno.Config>("Inferno").Power > 0f && value3 < num11) { float num12 = totalDamage * (val.GetEffectPower<Inferno.Config>("Inferno").Power / 100f); hit.m_damage.m_fire += num12; EJLogger.LogDebug($"Inferno activated, added fire damage: {num12}"); } EJLogger.LogDebug($"Inferno chance: {value3} < {num11} | elemental chance: {value} physical chance: {value2} \n Added Damage {num10} = blunt:{num} slash:{num2} pierce:{num3} lightning: {num4} spirit: {num5} pickaxe: {num6} original_total_dmg {totalDamage}"); hit.m_damage.m_blunt += num; hit.m_damage.m_pierce += num3; hit.m_damage.m_slash += num2; hit.m_damage.m_lightning += num4; hit.m_damage.m_spirit += num5; hit.m_damage.m_chop += num7; hit.m_damage.m_pickaxe += num6; } } public static class ItemDisplay { [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int), typeof(bool) })] public static class ItemToolTipDisplayEnhancer { public static List<ItemType> allowed_item_types = new List<ItemType> { (ItemType)20, (ItemType)4, (ItemType)3, (ItemType)14, (ItemType)22 }; private static void Postfix(ItemData item, ref string __result) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || !((Humanoid)Player.m_localPlayer).IsItemEquiped(item) || !ValConfig.EnableItemTooltipDisplay.Value || !allowed_item_types.Contains(item.m_shared.m_itemType)) { return; } float min = default(float); float max = default(float); ((Character)Player.m_localPlayer).GetSkills().GetRandomSkillRange(ref min, ref max, item.m_shared.m_skillType); float totalDamage = ((DamageTypes)(ref item.m_shared.m_damages)).GetTotalDamage(); Dictionary<string, DmgModDetails> dictionary = DetermineCharacterDamageModifiers(); float num = Player.m_localPlayer.GetEffectPower<CoinHoarder.Config>("Coin Hoarder").Power; if (num > 0f) { num = CoinHoarder.CoinHoarderBonusCalc(Player.m_localPlayer); } float power = Player.m_localPlayer.GetEffectPower<Spellsword.Config>("Spellsword").Power; List<string> list = __result.Split(new char[1] { '\n' }).ToList(); List<string> list2 = new List<string>(list); for (int i = 0; i < list.Count; i++) { if (list[i].Length < 17) { continue; } switch (list[i].Split(new char[1] { ':' })[0].Trim()) { case "$inventory_fire": if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_fire, min, max, 0f, num, power); } break; case "$inventory_poison": if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_poison, min, max, 0f, num, power); } break; case "$inventory_frost": if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_frost, min, max, 0f, num, power); } break; case "$inventory_blunt": if (dictionary.ContainsKey("Add Blunt Damage")) { dictionary["Add Blunt Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, dictionary["Add Blunt Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_blunt, min, max, 0f, num, power); } break; case "$inventory_slash": if (dictionary.ContainsKey("Add Slash Damage")) { dictionary["Add Slash Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_slash, min, max, dictionary["Add Slash Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_slash, min, max, 0f, num, power); } break; case "$inventory_pierce": if (dictionary.ContainsKey("Add Pierce Damage")) { dictionary["Add Pierce Damage"].added = true; list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_shared.m_damages.m_pierce, min, max, dictionary["Add Pierce Damage"].power, num, power); } else if (num > 0f || power > 0f) { list2[i] = AddModifierExplainer(list[i], totalDamage, item.m_s