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 Herbalist v1.4.8
Herbalist.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Herbalist.Functions; using Herbalist.SE; using Herbalist.Utils; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("blacks7ar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.8")] [assembly: AssemblyInformationalVersion("1.0.0+71d91bebca5d46b9ef85ddc99cafc49d95f45111")] [assembly: AssemblyProduct("Herbalist")] [assembly: AssemblyTitle("Herbalist")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.8.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Herbalist { [BepInPlugin("blacks7ar.Herbalist", "Herbalist", "1.4.8")] public class Plugin : BaseUnityPlugin { private const string modGUID = "blacks7ar.Herbalist"; public const string modName = "Herbalist"; public const string modAuthor = "blacks7ar"; public const string modVersion = "1.4.8"; public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/Herbalist/"; private static readonly Harmony _harmony = new Harmony("blacks7ar.Herbalist"); public static readonly ManualLogSource HLogger = Logger.CreateLogSource("Herbalist"); private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.Herbalist") { DisplayName = "Herbalist", CurrentVersion = "1.4.8", MinimumRequiredVersion = "1.4.8", ModRequired = true }; private static ConfigEntry<Toggle> _serverConfigLocked; private static ConfigEntry<float> _expGainFactor; public static ConfigEntry<Toggle> _displayExpGained; public static ConfigEntry<float> _dandelionHealthOverTime; public static ConfigEntry<float> _dandelionDuration; public static ConfigEntry<float> _dandelionInterval; public static ConfigEntry<float> _thistleHealthOverTime; public static ConfigEntry<float> _thistleDuration; public static ConfigEntry<float> _thistleInterval; public static ConfigEntry<float> _healBonusFactor; public static ConfigEntry<float> _durationBonusFactor; public static ConfigEntry<int> _minorLevel; public static ConfigEntry<int> _mediumLevel; public static ConfigEntry<int> _largeLevel; public static ConfigEntry<float> _expCooldownTimer; private static ConfigEntry<int> _expLoss; public static ConfigEntry<Toggle> _returnBottles; public static ConfigEntry<string> _potionsList; public static ConfigEntry<float> _craftingExp; public static Plugin _Instance; private static Skill _herbalist; public static readonly HashSet<string> _ToReduceCooldown = new HashSet<string> { "MeadEitrMinor", "MeadHealthMajor", "MeadHealthMedium", "MeadHealthMinor", "MeadStaminaMedium", "MeadStaminaMinor", "Flask_of_the_Gods", "Grand_Healing_Tide_Potion", "Grand_Spiritual_Healing_Potion", "Grand_Stamina_Elixir", "Medium_Healing_Tide_Flask", "Medium_Spiritual_Healing_Flask", "Medium_Stamina_Flask", "Lesser_Healing_Tide_Vial", "Lesser_Spiritual_Healing_Vial", "Lesser_Stamina_Vial", "Lesser_Group_Healing", "Medium_Group_Healing", "Grand_Group_Healing", "Lesser_Mana_Potion", "Large_Mana_Potion", "Grand_Mana_Potion" }; public static readonly HashSet<string> _ToIncreaseDuration = new HashSet<string> { "BarleyWine", "MeadFrostResist", "MeadPoisonResist", "MeadStaminaLingering", "MeadTasty", "Flask_of_Elements", "Flask_of_Fortification", "Flask_of_Magelight", "Flask_of_Second_Wind", "Grand_Healing_Tide_Potion", "Grand_Stamina_Elixir", "Grand_Stealth_Elixir", "Medium_Healing_Tide_Flask", "Lesser_Healing_Tide_Vial", "Brew_of_Cunning_Toxicity", "Brew_of_Fiery_Revenge", "Brew_of_Icy_Touch", "Brew_of_Spiritual_Death", "Brew_of_Thunderous_Words" }; private static readonly HashSet<string> _herbalistPotions = new HashSet<string> { "BH_BeserkerElixer", "BH_DefenderElixer", "BH_GhostElixer", "BH_HeavyLifterElixer", "BH_JumpElixer", "BH_LargeEitrTonic", "BH_LargeHealthTonic", "BH_LargeStaminaTonic", "BH_LearningElixer", "BH_MediumEitrTonic", "BH_MediumHealthTonic", "BH_MediumStaminaTonic", "BH_MinorEitrTonic", "BH_MinorHealthTonic", "BH_MinorStaminaTonic", "BH_RunnerElixer", "BH_SlowFallElixer" }; public static HashSet<string> _potionsToGainExpList; public ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool _synchronizedConfig = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (_synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); _configSync.AddConfigEntry<T>(val2).SynchronizedConfig = _synchronizedConfig; return val2; } private ConfigEntry<T> config2<T>(string group, string name, T value, string desc, bool synchronizedConfig = true) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown Herbalist.Functions.ConfigurationManagerAttributes configurationManagerAttributes = new Herbalist.Functions.ConfigurationManagerAttributes { CustomDrawer = TextBox }; return config(group, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), synchronizedConfig); } public void Awake() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Expected O, but got Unknown //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Expected O, but got Unknown //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Expected O, but got Unknown //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Expected O, but got Unknown //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Expected O, but got Unknown _Instance = this; Localizer.Load(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; _herbalist = new Skill("Herbalist", "herbalist.png"); _herbalist.Description.English("Makes pickable plants like Dandelion and Thistle into healing medicines."); _herbalist.Configurable = false; _serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _healBonusFactor = config("2- General", "Heal Bonus Factor", 10f, new ConfigDescription("Heal bonus factor at skill level 100 for dandelion and thistle.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); _durationBonusFactor = config("2- General", "Duration Bonus Factor", 10f, new ConfigDescription("Heal duration bonus factor at skill level 100 for dandelion and thistle.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 15f), Array.Empty<object>())); _dandelionHealthOverTime = config("3- Dandelion", "Heal Amount", 5f, new ConfigDescription("Dandelion base heal amount.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), new object[1] { new Herbalist.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _returnBottles = config("2- General", "Return Bottles", Toggle.On, new ConfigDescription("If On, bottles and containers will return to your inventory after you consume tonics or elixirs.", (AcceptableValueBase)null, Array.Empty<object>())); _potionsList = config2("2- General", "Additional Potions To Gain Exp", "", "Additional potions you added to the mortar and pestle that you want to gain an exp."); _potionsList.SettingChanged += delegate { GeneratePotionsList(); }; _dandelionDuration = config("3- Dandelion", "Heal Duration", 10f, new ConfigDescription("Dandelion base heal duration in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); _dandelionInterval = config("3- Dandelion", "Heal Interval", 0.5f, new ConfigDescription("Dandelion heal interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), new object[1] { new Herbalist.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _thistleHealthOverTime = config("4- Thistle", "Heal Amount", 15f, new ConfigDescription("Thistle base heal amount.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>())); _thistleDuration = config("4- Thistle", "Heal Duration", 10f, new ConfigDescription("Thistle base heal duration in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); _thistleInterval = config("4- Thistle", "Heal Interval", 0.5f, new ConfigDescription("Thistle heal interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), new object[1] { new Herbalist.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _minorLevel = config("4- Tonics Requirement Level", "Minor Tonics Level", 1, new ConfigDescription("Required skill level to craft minor tonics.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), new object[1] { new Herbalist.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _mediumLevel = config("4- Tonics Requirement Level", "Medium Tonics Level", 30, new ConfigDescription("Required skill level to craft medium tonics.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), new object[1] { new Herbalist.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _largeLevel = config("4- Tonics Requirement Level", "Large Tonics Level", 60, new ConfigDescription("Required skill level to craft large tonics.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), new object[1] { new Herbalist.Functions.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _expGainFactor = config("5- Skill Exp", "Exp Gain Factor", 1f, new ConfigDescription("Exp gain factor for herbalist skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); _expGainFactor.SettingChanged += delegate { _herbalist.SkillGainFactor = _expGainFactor.Value; }; _herbalist.SkillGainFactor = _expGainFactor.Value; _displayExpGained = config("5- Skill Exp", "Display Exp Gained", Toggle.On, new ConfigDescription("Enable/Disables exp gain notification.", (AcceptableValueBase)null, Array.Empty<object>())); _expCooldownTimer = config("5- Skill Exp", "Exp Gain Cooldown", 30f, new ConfigDescription("Cooldown timer in seconds, before getting exp when picking up dandelion and thistle.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>())); _expLoss = config("5- Skill Exp", "Exp Loss Amount", 0, new ConfigDescription("Skill exp loss on death.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); _expLoss.SettingChanged += delegate { _herbalist.SkillLoss = _expLoss.Value; }; _herbalist.SkillLoss = _expLoss.Value; _craftingExp = config("5- Skill Exp", "Potion Crafting Exp Gain Factor", 1f, new ConfigDescription("Exp gain factor from crafting potions in mortar and pestle.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); ConfigSetup.Init(); PrefabManager.Init(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); GeneratePotionsList(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private static void GeneratePotionsList() { HashSet<string> other = new HashSet<string>(_potionsList.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)); _herbalistPotions.UnionWith(other); _potionsToGainExpList = _herbalistPotions; } private static void TextBox(ConfigEntryBase entryBase) { entryBase.BoxedValue = GUILayout.TextArea((string)entryBase.BoxedValue, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } } [PublicAPI] internal class Skill { public static class LocalizationCache { private static readonly Dictionary<string, Localization> localizations = new Dictionary<string, Localization>(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = Enumerable.FirstOrDefault(localizations, (KeyValuePair<string, Localization> l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage(string? language = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out var value)) { return value; } value = new Localization(); if (language != null) { value.SetupLanguage(language); } return value; } } [PublicAPI] public class LocalizeKey { private static readonly List<LocalizeKey> keys = new List<LocalizeKey>(); public readonly string Key; public readonly Dictionary<string, string> Localizations = new Dictionary<string, string>(); public LocalizeKey(string key) { Key = key.Replace("$", ""); keys.Add(this); } public void Alias(string alias) { Localizations.Clear(); if (!alias.Contains("$")) { alias = "$" + alias; } Localizations["alias"] = alias; if (Localization.m_instance != null) { Localization.instance.AddWord(Key, Localization.instance.Localize(alias)); } } public LocalizeKey English(string key) { return addForLang("English", key); } public LocalizeKey Swedish(string key) { return addForLang("Swedish", key); } public LocalizeKey French(string key) { return addForLang("French", key); } public LocalizeKey Italian(string key) { return addForLang("Italian", key); } public LocalizeKey German(string key) { return addForLang("German", key); } public LocalizeKey Spanish(string key) { return addForLang("Spanish", key); } public LocalizeKey Russian(string key) { return addForLang("Russian", key); } public LocalizeKey Romanian(string key) { return addForLang("Romanian", key); } public LocalizeKey Bulgarian(string key) { return addForLang("Bulgarian", key); } public LocalizeKey Macedonian(string key) { return addForLang("Macedonian", key); } public LocalizeKey Finnish(string key) { return addForLang("Finnish", key); } public LocalizeKey Danish(string key) { return addForLang("Danish", key); } public LocalizeKey Norwegian(string key) { return addForLang("Norwegian", key); } public LocalizeKey Icelandic(string key) { return addForLang("Icelandic", key); } public LocalizeKey Turkish(string key) { return addForLang("Turkish", key); } public LocalizeKey Lithuanian(string key) { return addForLang("Lithuanian", key); } public LocalizeKey Czech(string key) { return addForLang("Czech", key); } public LocalizeKey Hungarian(string key) { return addForLang("Hungarian", key); } public LocalizeKey Slovak(string key) { return addForLang("Slovak", key); } public LocalizeKey Polish(string key) { return addForLang("Polish", key); } public LocalizeKey Dutch(string key) { return addForLang("Dutch", key); } public LocalizeKey Portuguese_European(string key) { return addForLang("Portuguese_European", key); } public LocalizeKey Portuguese_Brazilian(string key) { return addForLang("Portuguese_Brazilian", key); } public LocalizeKey Chinese(string key) { return addForLang("Chinese", key); } public LocalizeKey Japanese(string key) { return addForLang("Japanese", key); } public LocalizeKey Korean(string key) { return addForLang("Korean", key); } public LocalizeKey Hindi(string key) { return addForLang("Hindi", key); } public LocalizeKey Thai(string key) { return addForLang("Thai", key); } public LocalizeKey Abenaki(string key) { return addForLang("Abenaki", key); } public LocalizeKey Croatian(string key) { return addForLang("Croatian", key); } public LocalizeKey Georgian(string key) { return addForLang("Georgian", key); } public LocalizeKey Greek(string key) { return addForLang("Greek", key); } public LocalizeKey Serbian(string key) { return addForLang("Serbian", key); } public LocalizeKey Ukrainian(string key) { return addForLang("Ukrainian", key); } private LocalizeKey addForLang(string lang, string value) { Localizations[lang] = value; if (Localization.m_instance != null) { if (Localization.instance.GetSelectedLanguage() == lang) { Localization.instance.AddWord(Key, value); } else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key)) { Localization.instance.AddWord(Key, value); } } return this; } [HarmonyPriority(300)] internal static void AddLocalizedKeys(Localization __instance, string language) { foreach (LocalizeKey key in keys) { string value2; if (key.Localizations.TryGetValue(language, out var value) || key.Localizations.TryGetValue("English", out value)) { __instance.AddWord(key.Key, value); } else if (key.Localizations.TryGetValue("alias", out value2)) { __instance.AddWord(key.Key, Localization.instance.Localize(value2)); } } } } private class ConfigurationManagerAttributes { [UsedImplicitly] public string? Category; } [HarmonyPatch(typeof(Skills), "IsSkillValid")] private static class Patch_Skills_IsSkillValid { private static void Postfix(SkillType type, ref bool __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!__result && skills.ContainsKey(type)) { __result = true; } } } private static readonly Dictionary<SkillType, Skill> skills; internal static readonly Dictionary<string, Skill> skillByName; private readonly string skillName; private readonly string internalSkillName; private readonly SkillDef skillDef; public readonly LocalizeKey Name; public readonly LocalizeKey Description; private float skillEffectFactor = 1f; private int skillLoss = 5; public bool Configurable; private static bool InitializedTerminal; private static Localization? _english; private static BaseUnityPlugin? _plugin; private static bool hasConfigSync; private static object? _configSync; public float SkillGainFactor { get { return skillDef.m_increseStep; } set { skillDef.m_increseStep = value; this.SkillGainFactorChanged?.Invoke(value); } } public float SkillEffectFactor { get { return skillEffectFactor; } set { skillEffectFactor = value; this.SkillEffectFactorChanged?.Invoke(value); } } public int SkillLoss { get { return skillLoss; } set { skillLoss = value; this.SkillLossChanged?.Invoke(value); } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); private static BaseUnityPlugin plugin { get { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown object obj = _plugin; if (obj == null) { BaseUnityPlugin val = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)Enumerable.First(Assembly.GetExecutingAssembly().DefinedTypes, (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); _plugin = val; obj = (object)val; } return (BaseUnityPlugin)obj; } } private static object? configSync { get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " SkillManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public event Action<float>? SkillGainFactorChanged; public event Action<float>? SkillEffectFactorChanged; public event Action<float>? SkillLossChanged; public Skill(string englishName, string icon) : this(englishName, loadSprite(icon, 64, 64)) { } public Skill(string englishName, Sprite icon) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown SkillType val = fromName(englishName); string text = new Regex("[^a-zA-Z]").Replace(englishName, "_"); skills[val] = this; skillByName[englishName] = this; skillDef = new SkillDef { m_description = "$skilldesc_" + text, m_icon = icon, m_increseStep = 1f, m_skill = val }; internalSkillName = text; skillName = englishName; Name = new LocalizeKey("skill_" + ((object)(SkillType)(ref val)).ToString()).English(englishName); Description = new LocalizeKey("skilldesc_" + text); } public static SkillType fromName(string englishName) { return (SkillType)Math.Abs(StringExtensionMethods.GetStableHashCode(englishName)); } static Skill() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0066: 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_00a1: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01ab: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_023c: Expected O, but got Unknown skills = new Dictionary<SkillType, Skill>(); skillByName = new Dictionary<string, Skill>(); InitializedTerminal = false; hasConfigSync = true; Harmony val = new Harmony("org.bepinex.helpers.skillmanager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "GetSkillDef", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_GetSkillDef", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "CheatRaiseSkill", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_CheatRaiseskill", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "CheatResetSkill", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_CheatResetSkill", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Terminal), "InitTerminal", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Terminal_InitTerminal_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Terminal_InitTerminal", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "OnDeath", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_OnDeath_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_OnDeath_Finalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null); } private static void Patch_FejdStartup() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown foreach (Skill skill in skills.Values) { if (skill.Configurable) { string key = skill.Name.Key; string group = new Regex("['[\"\\]]").Replace(english.Localize(key), "").Trim(); string category = Localization.instance.Localize(key).Trim(); ConfigEntry<float> skillGain = config(group, "Skill gain factor", skill.SkillGainFactor, new ConfigDescription("The rate at which you gain experience for the skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), new object[1] { new ConfigurationManagerAttributes { Category = category } })); skill.SkillGainFactor = skillGain.Value; skillGain.SettingChanged += delegate { skill.SkillGainFactor = skillGain.Value; }; ConfigEntry<float> skillEffect = config(group, "Skill effect factor", skill.SkillEffectFactor, new ConfigDescription("The power of the skill, based on the default power.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), new object[1] { new ConfigurationManagerAttributes { Category = category } })); skill.SkillEffectFactor = skillEffect.Value; skillEffect.SettingChanged += delegate { skill.SkillEffectFactor = skillEffect.Value; }; ConfigEntry<int> skillLoss = config(group, "Skill loss", skill.skillLoss, new ConfigDescription("How much experience to lose on death.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1] { new ConfigurationManagerAttributes { Category = category } })); skill.skillLoss = skillLoss.Value; skillLoss.SettingChanged += delegate { skill.skillLoss = skillLoss.Value; }; } } } private static void Patch_Skills_GetSkillDef(ref SkillDef? __result, List<SkillDef> ___m_skills, SkillType type) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (__result == null) { SkillDef val = GetSkillDef(type); if (val != null) { ___m_skills.Add(val); __result = val; } } } private static bool Patch_Skills_CheatRaiseskill(Skills __instance, string name, float value, Player ___m_player) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) foreach (SkillType key in skills.Keys) { SkillType current = key; Skill skill = skills[current]; if (string.Equals(skill.internalSkillName, name, StringComparison.CurrentCultureIgnoreCase)) { Skill skill2 = __instance.GetSkill(current); skill2.m_level += value; skill2.m_level = Mathf.Clamp(skill2.m_level, 0f, 100f); ((Character)___m_player).Message((MessageType)1, "Skill increased " + Localization.instance.Localize("$skill_" + ((object)(SkillType)(ref current)).ToString()) + ": " + (int)skill2.m_level, 0, skill2.m_info.m_icon); Console.instance.Print("Skill " + skill.internalSkillName + " = " + skill2.m_level); return false; } } return true; } private static bool Patch_Skills_CheatResetSkill(Skills __instance, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) foreach (SkillType key in skills.Keys) { Skill skill = skills[key]; if (string.Equals(skill.internalSkillName, name, StringComparison.CurrentCultureIgnoreCase)) { __instance.ResetSkill(key); Console.instance.Print("Skill " + skill.internalSkillName + " reset"); return false; } } return true; } private static void Patch_Skills_OnDeath_Prefix(Skills __instance, ref Dictionary<SkillType, Skill>? __state) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (__state == null) { __state = new Dictionary<SkillType, Skill>(); } foreach (KeyValuePair<SkillType, Skill> skill in skills) { if (__instance.m_skillData.TryGetValue(skill.Key, out var value)) { __state[skill.Key] = value; if (skill.Value.skillLoss > 0) { Skill obj = value; obj.m_level -= value.m_level * (float)skill.Value.SkillLoss / 100f; value.m_accumulator = 0f; } __instance.m_skillData.Remove(skill.Key); } } } private static void Patch_Skills_OnDeath_Finalizer(Skills __instance, ref Dictionary<SkillType, Skill>? __state) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (__state == null) { return; } foreach (KeyValuePair<SkillType, Skill> item in __state) { __instance.m_skillData[item.Key] = item.Value; } __state = null; } private static void Patch_Terminal_InitTerminal_Prefix() { InitializedTerminal = Terminal.m_terminalInitialized; } private static void Patch_Terminal_InitTerminal() { if (!InitializedTerminal) { AddSkill(Terminal.commands["raiseskill"]); AddSkill(Terminal.commands["resetskill"]); } static void AddSkill(ConsoleCommand command) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ConsoleOptionsFetcher fetcher = command.m_tabOptionsFetcher; command.m_tabOptionsFetcher = (ConsoleOptionsFetcher)delegate { List<string> list = fetcher.Invoke(); list.AddRange(Enumerable.Select(skills.Values, (Skill skill) => skill.internalSkillName)); return list; }; } } private static SkillDef? GetSkillDef(SkillType skillType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!skills.ContainsKey(skillType)) { return null; } return skills[skillType].skillDef; } private static byte[] ReadEmbeddedFileBytes(string name) { using MemoryStream memoryStream = new MemoryStream(); Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream); return memoryStream.ToArray(); } private static Texture2D loadTexture(string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_001f: Expected O, but got Unknown Texture2D val = new Texture2D(0, 0); ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("icons." + name)); return val; } private static Sprite loadSprite(string name, int width, int height) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return Sprite.Create(loadTexture(name), new Rect(0f, 0f, (float)width, (float)height), Vector2.zero); } private static ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description) { ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry<T> config<T>(string group, string name, T value, string description) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } } [PublicAPI] internal static class SkillExtensions { public static float GetSkillFactor(this Character character, string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return character.GetSkillFactor(Skill.fromName(name)) * Skill.skillByName[name].SkillEffectFactor; } public static float GetSkillFactor(this Skills skills, string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return skills.GetSkillFactor(Skill.fromName(name)) * Skill.skillByName[name].SkillEffectFactor; } public static void RaiseSkill(this Character character, string name, float value = 1f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) character.RaiseSkill(Skill.fromName(name), value); } public static void RaiseSkill(this Skills skill, string name, float value = 1f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) skill.RaiseSkill(Skill.fromName(name), value); } public static void LowerSkill(this Character character, string name, float factor = 1f) { character.GetSkills().LowerSkill(name, factor); } public static void LowerSkill(this Skills skills, string name, float factor) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (factor > 0f && skills.m_skillData.TryGetValue(Skill.fromName(name), out var value)) { Skill obj = value; obj.m_level -= value.m_level * factor; value.m_accumulator = 0f; } } } internal static class SkillManagerVersion { public const string Version = "1.7.0"; } } namespace Herbalist.SE { public class SE_Berserker : SE_Stats { public float m_baseDuration; public float m_damageMultiplier; public float m_actualDuration; public float m_bonusDuration; public void Awake() { ((StatusEffect)this).m_name = "Berserker"; ((Object)this).name = "bh_berserker_elixir"; UpdateTooltip(); ((StatusEffect)this).m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_BeserkerElixer.png"); } private void UpdateTooltip() { ((StatusEffect)this).m_tooltip = "Boost your attack damage but makes you weak to physical and range attacks." + $"\nDamage Multiplier: <color=orange>{m_damageMultiplier:F0}x</color>" + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float damage, float duration, float bonus) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; m_damageMultiplier = damage; ((StatusEffect)this).m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); ((StatusEffect)this).m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; ((StatusEffect)this).m_startEffects = val; ((SE_Stats)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = ((StatusEffect)this).m_ttl; } if (m_actualDuration != ((StatusEffect)this).m_ttl) { ((StatusEffect)this).m_ttl = m_actualDuration; } } public override void ModifyAttack(SkillType skill, ref HitData hitData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).ModifyAttack(skill, ref hitData); ((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMultiplier); } public override void ModifyDamageMods(ref DamageModifiers modifiers) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).ModifyDamageMods(ref modifiers); List<DamageModPair> list = new List<DamageModPair> { new DamageModPair { m_type = (DamageType)1, m_modifier = (DamageModifier)6 }, new DamageModPair { m_type = (DamageType)8, m_modifier = (DamageModifier)6 }, new DamageModPair { m_type = (DamageType)31, m_modifier = (DamageModifier)6 }, new DamageModPair { m_type = (DamageType)16, m_modifier = (DamageModifier)6 }, new DamageModPair { m_type = (DamageType)4, m_modifier = (DamageModifier)6 }, new DamageModPair { m_type = (DamageType)2, m_modifier = (DamageModifier)6 } }; ((DamageModifiers)(ref modifiers)).Apply(list); } } public class SE_Chicory : StatusEffect { public float m_duration { get { return base.m_ttl; } set { base.m_ttl = value; } } public void Awake() { base.m_name = "Chicory"; ((Object)this).name = "bh_chicory_buff"; base.m_tooltip = "Cures poison and gives you a poison resist for a short amount of time. \n<color=orange>Resistant</color> Vs. <color=orange>Poison</color>"; base.m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_Chicory.png"); } public override void Setup(Character character) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown m_duration = 10f; EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("sfx_creature_consume"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); } } public class SE_Daisy : StatusEffect { public float m_duration { get { return base.m_ttl; } set { base.m_ttl = value; } } public void Awake() { base.m_name = "Daisy"; ((Object)this).name = "bh_daisy_buff"; base.m_tooltip = "Removes freezing status effect and gives you a freezing resist for a short amount of time. \n<color=orange>Resistant</color> Vs. <color=orange>Freezing</color>"; base.m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_Daisy.png"); } public override void Setup(Character character) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown m_duration = 10f; EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("sfx_creature_consume"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); } } public class SE_Defender : SE_Stats { public float m_baseDuration; public float m_bonusDuration; public float m_actualDuration; public void Awake() { ((StatusEffect)this).m_name = "Defender"; ((Object)this).name = "bh_defender_elixir"; UpdateTooltip(); ((StatusEffect)this).m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_DefenderElixer.png"); } private void UpdateTooltip() { ((StatusEffect)this).m_tooltip = "Boost your overall defense but makes your attacks very weak." + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float duration, float bonus) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; ((StatusEffect)this).m_ttl = duration; UpdateTooltip(); } public void ScaleWithPlayer(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); ((StatusEffect)this).m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; ((StatusEffect)this).m_startEffects = val; ((SE_Stats)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithPlayer(val2); } if (m_actualDuration <= 0f) { m_actualDuration = ((StatusEffect)this).m_ttl; } if (m_actualDuration != ((StatusEffect)this).m_ttl) { ((StatusEffect)this).m_ttl = m_actualDuration; } } public override void ModifyAttack(SkillType skill, ref HitData hitData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).ModifyAttack(skill, ref hitData); ((DamageTypes)(ref hitData.m_damage)).Modify(0.2f); } public override void ModifyDamageMods(ref DamageModifiers modifiers) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).ModifyDamageMods(ref modifiers); List<DamageModPair> list = new List<DamageModPair> { new DamageModPair { m_type = (DamageType)1, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)8, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)31, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)16, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)4, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)2, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)224, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)32, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)64, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)128, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)256, m_modifier = (DamageModifier)5 }, new DamageModPair { m_type = (DamageType)512, m_modifier = (DamageModifier)5 } }; ((DamageModifiers)(ref modifiers)).Apply(list); } } public class SE_EitrTonic : StatusEffect { public float m_baseEitrOverTime; public float m_baseDuration; public float m_skillLevel; public float m_actualEitrOverTime; public float m_actualDuration; public float m_bonusDuration; public void Awake() { UpdateTooltip(); } private void UpdateTooltip() { base.m_tooltip = "Recovers your eitr over time." + $"\n<color=orange>Eitr: {m_actualEitrOverTime:F0}</color>" + $"\n<color=orange>Duration: {m_actualDuration / 60f:F1} min</color>" + "\n\nRequirement:" + $"\n<color=orange>Herbalist Lv: {m_skillLevel:F0}</color>"; } public void SetupStats(float eitrOverTime, float duration, float bonus, float skillLevel) { m_baseEitrOverTime = eitrOverTime; m_baseDuration = duration; m_bonusDuration = bonus; m_skillLevel = skillLevel; m_actualEitrOverTime = eitrOverTime; m_actualDuration = duration; base.m_ttl = m_actualDuration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualEitrOverTime = m_baseEitrOverTime * (1f + 0.5f * skillFactor); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); base.m_ttl = m_actualDuration; UpdateTooltip(); } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("vfx_Potion_eitr_minor"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualEitrOverTime > 0f && m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (m_actualDuration != base.m_ttl) { base.m_ttl = m_actualDuration; } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (m_actualEitrOverTime != 0f && base.m_time <= m_actualDuration) { float num = m_actualDuration / dt; base.m_character.AddEitr(m_actualEitrOverTime / num * 50f); } } } public class SE_FastLearner : StatusEffect { public float m_baseDuration; public float m_bonusDuration; public float m_actualDuration; public float m_expMultiplier; public void Awake() { base.m_name = "FastLearner"; ((Object)this).name = "bh_fastlearner_elixir"; UpdateTooltip(); base.m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_LearningElixer.png"); } private void UpdateTooltip() { base.m_tooltip = "You're quick to learn things. " + $"\nExperience Gained: <color=orange>x{m_expMultiplier:F1}</color>" + "\nSide Effects: <color=orange>Halved Health Points</color>" + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float duration, float bonus, float expMultiplier) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; m_expMultiplier = expMultiplier; base.m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); base.m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (m_actualDuration != base.m_ttl) { m_actualDuration = base.m_ttl; } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); Character character = base.m_character; Character obj = ((character is Player) ? character : null); float num = default(float); float num2 = default(float); float num3 = default(float); ((Player)obj).GetTotalFoodValue(ref num, ref num2, ref num3); ((Player)obj).SetMaxHealth(num / 2f, false); } } public class SE_Ghost : SE_Stats { public float m_baseDuration; public float m_actualDuration; public float m_bonusDuration; public void Awake() { ((StatusEffect)this).m_name = "Invisibility"; ((Object)this).name = "bh_invisibility_elixir"; UpdateTooltip(); ((StatusEffect)this).m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_GhostElixer.png"); } private void UpdateTooltip() { ((StatusEffect)this).m_tooltip = $"Makes you invisible for <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float duration, float bonus) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; ((StatusEffect)this).m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); ((StatusEffect)this).m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; ((StatusEffect)this).m_startEffects = val; ((SE_Stats)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = ((StatusEffect)this).m_ttl; } if (m_actualDuration != ((StatusEffect)this).m_ttl) { ((StatusEffect)this).m_ttl = m_actualDuration; } } } public class SE_HealthTonic : StatusEffect { public float m_baseHealOverTime; public float m_baseInterval; public float m_baseDuration; public float m_healTimer; public float m_ticksRemaining; public float m_healPerTick; public int m_skillLevel; public float m_actualHealOverTime; public float m_actualDuration; public float m_actualInterval; public float m_bonusDuration; public void Awake() { UpdateTooltip(); } private void UpdateTooltip() { float num = m_actualHealOverTime / m_actualDuration; base.m_tooltip = "Recovers your health over time." + $"\n<color=orange>Heal Rate: {num * 50f:F1} HP/s</color>" + $"\n<color=orange>Duration: {m_actualDuration / 60f:F1} min</color>" + $"\n<color=orange>Tick Interval: {m_actualInterval:F1}s</color>" + "\n\nRequirement:" + $"\n<color=orange>Herbalist Lv: {m_skillLevel:F0}</color>"; } public void SetupStats(float healOverTime, float duration, float bonus, float interval, int skillLevel) { m_baseHealOverTime = healOverTime; m_baseDuration = duration; m_bonusDuration = bonus; m_baseInterval = Mathf.Max(0.5f, interval); m_skillLevel = skillLevel; m_actualHealOverTime = healOverTime; m_actualDuration = duration; m_actualInterval = interval; base.m_ttl = m_actualDuration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); m_actualHealOverTime = m_baseHealOverTime * (1f + 0.5f * skillFactor); m_actualInterval = m_baseInterval; base.m_ttl = m_actualDuration; UpdateTooltip(); } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("vfx_Potion_health_medium"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (!(m_actualHealOverTime <= 0f) && !(m_actualInterval <= 0f)) { m_ticksRemaining = Mathf.CeilToInt(m_actualDuration / m_actualInterval); m_healPerTick = m_actualHealOverTime / m_ticksRemaining; m_healTimer = 0f; } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (!(m_ticksRemaining <= 0f)) { m_healTimer += dt; if (!(m_healTimer < m_actualInterval)) { m_healTimer = 0f; m_ticksRemaining -= 1f; base.m_character.Heal(m_healPerTick, true); } } } } public class SE_HeavyLifter : StatusEffect { public float m_baseDuration; public float m_actualDuration; public float m_bonusDuration; public void Awake() { base.m_name = "HeavyLifter"; ((Object)this).name = "bh_heavylifter_elixir"; UpdateTooltip(); base.m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_HeavyLifterElixer.png"); } private void UpdateTooltip() { base.m_tooltip = "Doubles your max carry weight.\nSide Effects: <color=orange>Halved Stamina Points</color>" + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1}min/s</color>"; } public void SetupStats(float duration, float bonus) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; base.m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); base.m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (m_actualDuration != base.m_ttl) { base.m_ttl = m_actualDuration; } } public override void ModifyMaxCarryWeight(float baseLimit, ref float limit) { ((StatusEffect)this).ModifyMaxCarryWeight(baseLimit, ref limit); limit *= 2f; } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); Character character = base.m_character; Character obj = ((character is Player) ? character : null); float num = default(float); float num2 = default(float); float num3 = default(float); ((Player)obj).GetTotalFoodValue(ref num, ref num2, ref num3); ((Player)obj).SetMaxStamina(num2 / 2f, false); } } public class SE_Herbalist : StatusEffect { public float m_healthOverTime; public float m_healthOverTimeInterval; public float m_healthOverTimeDuration; public float m_healthOverTimeTimer; public float m_healthOverTimeTicks; public float m_healthOverTimeTickHP; public float m_skillFactor; public float m_healBonusFactor; public float m_durationFactor; public void SetHealthOverTimeInterval(float bonus) { m_healthOverTimeInterval = bonus; } public void SetSkillFactor(float bonus) { m_skillFactor = bonus; } public void SetHealthOverTime(float bonus) { m_healthOverTime = bonus; } public void SetHealthOverTimeDuration(float bonus) { m_healthOverTimeDuration = bonus; } public void SetHealBonusFactor(float bonus) { m_healBonusFactor = bonus; } public void SetDurationFactor(float bonus) { m_durationFactor = bonus; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("sfx_creature_consume"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); if (m_healthOverTime > 0f && m_healthOverTimeInterval > 0f) { if (m_healthOverTimeDuration <= 0f) { m_healthOverTimeDuration = base.m_ttl; } m_healthOverTimeTicks = m_healthOverTimeDuration + m_durationFactor * m_skillFactor / m_healthOverTimeInterval; m_healthOverTimeTickHP = m_healthOverTime + m_healBonusFactor * m_skillFactor / m_healthOverTimeTicks; } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (m_healthOverTimeTicks > 0f) { m_healthOverTimeTimer += dt; if (m_healthOverTimeTimer > m_healthOverTimeInterval) { m_healthOverTimeTimer = 0f; m_healthOverTimeTicks -= m_healthOverTimeInterval; base.m_character.Heal(m_healthOverTimeTickHP / 10f, true); } } } } public class SE_Jump : StatusEffect { public float m_baseDuration; public float m_actualDuration; public float m_bonusDuration; public float m_jumpMultiplier; public void Awake() { base.m_name = "JumpElixir"; ((Object)this).name = "bh_jump_elixir"; UpdateTooltip(); base.m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_JumpElixer.png"); } private void UpdateTooltip() { base.m_tooltip = "Boost your jump ability.\nSide Effects: <color=orange>Doubles Jump Stamina Usage</color>" + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float duration, float bonus, float jumpMultiplier) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; m_jumpMultiplier = jumpMultiplier; base.m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); base.m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (m_actualDuration != base.m_ttl) { base.m_ttl = m_actualDuration; } } public override void ModifyJump(Vector3 baseJump, ref Vector3 jump) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).ModifyJump(baseJump, ref jump); jump *= m_jumpMultiplier; } public override void ModifyJumpStaminaUsage(float baseStaminaUse, ref float staminaUse) { ((StatusEffect)this).ModifyJumpStaminaUsage(baseStaminaUse, ref staminaUse); staminaUse *= 2f; } } public class SE_SlowFall : SE_Stats { public float m_baseDuration; public float m_actualDuration; public float m_bonusDuration; public void Awake() { ((StatusEffect)this).m_name = "SlowFall"; ((Object)this).name = "bh_slowfall_elixir"; UpdateTooltip(); ((StatusEffect)this).m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_SlowFallElixer.png"); } private void UpdateTooltip() { ((StatusEffect)this).m_tooltip = "Makes you fall slowly." + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float duration, float bonus) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; ((StatusEffect)this).m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); ((StatusEffect)this).m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; ((StatusEffect)this).m_startEffects = val; ((SE_Stats)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = ((StatusEffect)this).m_ttl; } if (m_actualDuration != ((StatusEffect)this).m_ttl) { ((StatusEffect)this).m_ttl = m_actualDuration; } } } public class SE_StaminaTonic : StatusEffect { public float m_baseStaminaOverTime; public float m_baseDuration; public float m_skillLevel; public float m_actualStaminaOverTime; public float m_actualDuration; public float m_bonusDuration; public void Awake() { UpdateTooltip(); } private void UpdateTooltip() { base.m_tooltip = "Recovers your stamina over time." + $"\n<color=orange>Stamina: {m_actualStaminaOverTime:F0}</color>" + $"\n<color=orange>Duration: {m_actualDuration / 60f:F1} min</color>" + "\n\nRequirement:" + $"\n<color=orange>Herbalist Lv: {m_skillLevel:F0}</color>"; } public void SetupStats(float staminaOverTime, float duration, float bonus, float skillLevel) { m_baseStaminaOverTime = staminaOverTime; m_baseDuration = duration; m_bonusDuration = bonus; m_skillLevel = skillLevel; m_actualStaminaOverTime = staminaOverTime; m_actualDuration = duration; base.m_ttl = m_actualDuration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualStaminaOverTime = m_baseStaminaOverTime * (1f + 0.5f * skillFactor); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); base.m_ttl = m_actualDuration; UpdateTooltip(); } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("vfx_Potion_stamina_medium"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualStaminaOverTime > 0f && m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (m_actualDuration != base.m_ttl) { base.m_ttl = m_actualDuration; } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); if (m_actualStaminaOverTime != 0f && base.m_time <= m_actualDuration) { float num = m_actualDuration / dt; base.m_character.AddStamina(m_actualStaminaOverTime / num * 50f); } } } public class SE_Swift : StatusEffect { public float m_baseDuration; public float m_actualDuration; public float m_bonusDuration; public float m_speedMultiplier; public void Awake() { base.m_name = "Swift"; ((Object)this).name = "bh_swift_elixir"; UpdateTooltip(); base.m_icon = PrefabManager._herbalistBundle.LoadAsset<Sprite>("BH_RunnerElixer.png"); } private void UpdateTooltip() { base.m_tooltip = "Makes you run faster but makes you fragile." + $"\nRunSpeed Multiplier: <color=orange>x{m_speedMultiplier:F1}</color>" + "\nSide Effects: <color=orange>Halved Health Points</color>" + $"\nDuration: <color=orange>{m_actualDuration / 60f:F1} min</color>"; } public void SetupStats(float duration, float bonus, float speedMultiplier) { m_baseDuration = duration; m_actualDuration = duration; m_bonusDuration = bonus; m_speedMultiplier = speedMultiplier; base.m_ttl = duration; UpdateTooltip(); } public void ScaleWithSkill(Player player) { float skillFactor = ((Character)(object)player).GetSkillFactor("Herbalist"); m_actualDuration = (m_baseDuration + m_bonusDuration) * (1f + 0.75f * skillFactor); base.m_ttl = m_actualDuration; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Activation"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); Player val2 = (Player)(object)((character is Player) ? character : null); if (val2 != null) { ScaleWithSkill(val2); } if (m_actualDuration <= 0f) { m_actualDuration = base.m_ttl; } if (m_actualDuration != base.m_ttl) { base.m_ttl = m_actualDuration; } } public override void UpdateStatusEffect(float dt) { ((StatusEffect)this).UpdateStatusEffect(dt); Character character = base.m_character; Character obj = ((character is Player) ? character : null); float num = default(float); float num2 = default(float); float num3 = default(float); ((Player)obj).GetTotalFoodValue(ref num, ref num2, ref num3); ((Player)obj).SetMaxHealth(num / 2f, false); } public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).ModifySpeed(baseSpeed, ref speed, character, dir); speed *= m_speedMultiplier; } } } namespace Herbalist.Patches { [HarmonyPatch] public class HudPatch { [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "FlashHealthBar")] public static void FlashHealthBar_Postfix(Hud __instance) { if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bh_fastlearner_elixir")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bh_swift_elixir"))) { __instance.m_healthAnimator.ResetTrigger("Flash"); } } [HarmonyPostfix] [HarmonyPatch(typeof(Hud), "StaminaBarUppgradeFlash")] public static void StaminaBarUpgradeFlash_Postfix(Hud __instance) { if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bh_heavylifter_elixir"))) { __instance.m_staminaAnimator.ResetTrigger("Flash"); } } } [HarmonyPatch] public class InventoryGuiPatch { private static bool _RequirementsMet; [HarmonyPostfix] [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] public static void DoCrafting_Postfix(InventoryGui __instance, ref Player player) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main") && !((Object)(object)__instance == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer) && !((Object)(object)__instance.m_craftRecipe == (Object)null) && __instance.m_availableRecipes.Count > 0) { string name = ((Object)__instance.m_craftRecipe.m_item).name; if (Plugin._potionsToGainExpList.Contains(name) && _RequirementsMet) { ((Character)player).RaiseSkill(Skill.fromName("Herbalist"), Plugin._craftingExp.Value); } } } [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] public static bool DoCrafting_Prefix(InventoryGui __instance, ref Player player) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "main") { return false; } if ((Object)(object)__instance == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || (Object)(object)__instance.m_craftRecipe == (Object)null) { return false; } ((Character)player).GetSkills().m_skillData.TryGetValue((SkillType)Math.Abs(StringExtensionMethods.GetStableHashCode("Herbalist")), out var value); if (((Object)((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe.m_item).name.ToLower().Contains("bh_minor") && value.m_level < (float)Plugin._minorLevel.Value) { ((Character)player).Message((MessageType)2, "<size=28>Herbalist level not high enough.</size>", 0, (Sprite)null); _RequirementsMet = false; return false; } if (((Object)((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe.m_item).name.ToLower().Contains("bh_medium") && value.m_level < (float)Plugin._mediumLevel.Value) { ((Character)player).Message((MessageType)2, "<size=28>Herbalist level not high enough.</size>", 0, (Sprite)null); _RequirementsMet = false; return false; } if (((Object)((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe.m_item).name.ToLower().Contains("bh_large") && value.m_level < (float)Plugin._largeLevel.Value) { ((Character)player).Message((MessageType)2, "<size=28>Herbalist level not high enough.</size>", 0, (Sprite)null); _RequirementsMet = false; return false; } _RequirementsMet = true; return true; } } [HarmonyPatch] public class ItemDataPatch { [HarmonyPostfix] [HarmonyPatch(typeof(ItemData), "GetStatusEffectTooltip")] public static string GetStatusEffectTooltip_Postfix(string __result, ItemData __instance) { try { if (__instance?.m_shared == null) { return __result; } StringBuilder stringBuilder = new StringBuilder(__result); ((Character)Player.m_localPlayer).GetSkills().m_skillData.TryGetValue((SkillType)Math.Abs(StringExtensionMethods.GetStableHashCode("Herbalist")), out var value); float? num = ((value != null && value.m_level <= 0f) ? new float?(0f) : value?.m_level); float skillFactor = ((Character)(object)Player.m_localPlayer).GetSkillFactor("Herbalist"); float num2 = Plugin._dandelionDuration.Value + Plugin._durationBonusFactor.Value * skillFactor; float num3 = Plugin._thistleDuration.Value + Plugin._durationBonusFactor.Value * skillFactor; float num4 = num2 / Plugin._dandelionInterval.Value; float num5 = num3 / Plugin._thistleInterval.Value; float num6 = Plugin._dandelionHealthOverTime.Value + Plugin._healBonusFactor.Value * skillFactor / num4; float num7 = Plugin._thistleHealthOverTime.Value + Plugin._healBonusFactor.Value * skillFactor / num5; string name = ((Object)__instance.m_dropPrefab).name; if (!(name == "Dandelion")) { if (name == "Thistle") { stringBuilder.Append($"<color=red>Herbalist Lv: {num}</color>"); stringBuilder.Append("\nHeals you over time."); stringBuilder.Append($"\n<color=orange>HealOvertime: {num7 / 10f:#.##}</color>"); stringBuilder.Append($"\n<color=orange>Interval: {Plugin._thistleInterval.Value}</color>"); stringBuilder.Append($"\n<color=orange>Duration: {num3}</color>"); return stringBuilder.ToString(); } return __result; } stringBuilder.Append($"<color=red>Herbalist Lv: {num}</color>"); stringBuilder.Append("\nHeals you over time."); stringBuilder.Append($"\n<color=orange>HealOvertime: {num6 / 10f:#.##}</color>"); stringBuilder.Append($"\n<color=orange>Interval: {Plugin._dandelionInterval.Value}</color>"); stringBuilder.Append($"\n<color=orange>Duration: {num2}</color>"); return stringBuilder.ToString(); } catch { return __result; } } } [HarmonyPatch] public class ObjectDBPatch { [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] public static void Awake_Postfix(ObjectDB __instance) { RegisterPrefabsToObjectDB.Init(); RegisterRecipesToObjectDB.Init(); __instance.UpdateRegisters(); } [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static void CopyOtherDB_Postfix(ObjectDB __instance) { RegisterPrefabsToObjectDB.Init(); RegisterRecipesToObjectDB.Init(); __instance.UpdateRegisters(); } } [HarmonyPatch] public class PickablePatch { private static DateTime _pickTimer = DateTime.MinValue; [HarmonyPrefix] [HarmonyPatch(typeof(Pickable), "Interact")] private static void PickableInteract_Prefix(Pickable __instance) { if (__instance.m_nview.IsValid() && IsHerbal(__instance.m_itemPrefab) && __instance.m_respawnTimeMinutes > 0f) { __instance.m_nview.GetZDO().Set("Herbalist Skill Level", ((Character)(object)Player.m_localPlayer).GetSkillFactor("Herbalist")); } } [HarmonyPrefix] [HarmonyPatch(typeof(Pickable), "RPC_Pick")] private static void RpcPick_Prefix(Pickable __instance, long sender, ref int? __state) { if (!__instance.m_nview.IsOwner() || __instance.m_picked) { __state = -1; } else if (__instance.m_nview.IsValid() && IsHerbal(__instance.m_itemPrefab) && __instance.m_respawnTimeMinutes > 0f) { Player val = Enumerable.FirstOrDefault((IEnumerable<Player>)Player.s_players, (Func<Player, bool>)((Player p) => ((ZDOID)(ref ((Character)p).m_nview.GetZDO().m_uid)).UserID == sender)); if (val != null && (DateTime.Now - _pickTimer).TotalSeconds > (double)Plugin._expCooldownTimer.Value) { _pickTimer = DateTime.Now; ((Character)val).m_nview.InvokeRPC("Herbalist IncreaseSkill", new object[1] { 1 }); } } } private static bool IsHerbal(GameObject gameObject) { string name = gameObject.GetComponent<ItemDrop>().m_itemData.m_shared.m_name; if (!name.Contains("dandelion") && !name.Contains("thistle") && !name.Contains("chicory") && !name.Contains("daisy") && !name.Contains("boswellia") && !name.Contains("chamomile") && !name.Contains("echinacea") && !name.Contains("lavender") && !name.Contains("valkyriefern") && !name.Contains("vikingsbreadcap") && !name.Contains("bjorncap") && !name.Contains("skaldsivy") && !name.Contains("aslaugsherb") && !name.Contains("lokistrickcap") && !name.Contains("helshadefungus") && !name.Contains("seidrblossoms") && !name.Contains("thorstoadstool") && !name.Contains("valhallaberry")) { return name.Contains("nordicfirebloom"); } return true; } } [HarmonyPatch] public class PlayerPatch { [HarmonyPriority(800)] [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Awake")] private static void PlayerAwake_Postfix(Player __instance) { ((Character)__instance).m_nview.Register<int>("Herbalist IncreaseSkill", (Action<long, int>)delegate(long _, int factor) { ((Character)(object)__instance).RaiseSkill("Herbalist", factor); }); } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Update")] private static void PlayerUpdate_Postfix(ref Player __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { ((Character)__instance).m_nview.GetZDO().Set("Herbalist Skill Factor", ((Character)__instance).GetSkillFactor(Skill.fromName("Herbalist"))); } } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "ConsumeItem")] private static bool ConsumeItem_Prefix(Inventory inventory, ItemData item, ref Player __instance) { float skillFactor = ((Character)(object)__instance).GetSkillFactor("Herbalist"); Math.Ceiling(Plugin._durationBonusFactor.Value * 30f * skillFactor); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("BH_EmptyContainer"); GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("BH_EmptyBottle"); GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab("BH_EmptyLargeBottle"); GameObject itemPrefab4 = ObjectDB.instance.GetItemPrefab("BH_EmptyElixerBottle"); switch ((item != null) ? ((Object)item.m_dropPrefab).name : null) { case "BH_MinorHealthTonic": { if (((Character)__instance).GetHealth() >= ((Character)__instance).GetMaxHealth()) { ((Character)__instance).Message((MessageType)2, "<size=28>Can't consume right now.</size>", 0, (Sprite)null); return false; } if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bh_minorhealthtonic")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bh_mediumhealthtonic")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("bh_largehealthtonic"))) { ((Character)__instance).Message((MessageType)2, "<size=28>Can't consume right now.</size>", 0, (Sprite)null); return false; } bool flag17 = false; if (Plugin._returnBottles.Value == Toggle.On) { flag17 = inventory.AddItem(itemPrefab, 1); } if (flag17) { ((Character)__instance).ShowPickupMessage(itemPrefab.GetComponent<ItemDrop>().m_itemData, 1); } else if (!flag17 && Plugin._returnBottles.Value == Toggle.On) { ((Character)__instance).Message((MessageType)2, "$msg_noroom", 0, (Sprite)null); } return true; } case "BH_MinorStaminaTonic": { if (__instance.GetStamina() >= ((Character)__instance).GetMaxStamina()) { ((Character)__instance).Message((MessageType)2, "<size=28>Can't consume right now.</size>", 0, (Sprite)null); return false; } if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetS