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 FearMe v1.0.1
plugins/FearMe.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FearMe.Monsters.Config; using FearMe.PlayerGear; using FearMe.PlayerGear.Config; using HarmonyLib; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace FearMe { public class Config : IDisposable { private Dictionary<string, GearConfig> _gear; private Dictionary<GearSlot, GearSlotConfig> _gearSlots; private Dictionary<string, MonsterConfig> _monsters; private bool _enabled; private ConfigFile _configFile; private const string GENERAL_SECTION_NAME = "General"; private const string GEARDATA_SECTION_NAME = "GearData"; private const string GEAR_SECTION_NAME = "Gear"; private const string GEAR_SLOTS_SECTION_NAME = "Slots"; private const string MONSTERDATA_SECTION_NAME = "MonsterData"; private const string MONSTER_SECTION_NAME = "Monster"; private FileSystemWatcher _watcher; private const long RELOAD_DELAY = 10000000L; private DateTime _lastReloadTime; public bool Enabled { get { if (_configFile != null) { return _enabled; } return false; } } public int FormatVersion { get; private set; } public Config(ConfigFile configFile) { _configFile = configFile; } public bool Load() { if (_configFile == null) { return false; } ClearOldConfig(); AddKnownConfig(); _configFile.ConfigReloaded += Reloaded; return true; } private void ClearOldConfig() { if (((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)_configFile).Any((KeyValuePair<ConfigDefinition, ConfigEntryBase> kv) => string.Equals(kv.Key.Section, "Data", StringComparison.OrdinalIgnoreCase))) { _configFile.SaveOnConfigSet = false; _configFile.Clear(); _configFile.Save(); _configFile.SaveOnConfigSet = true; } } private void AddKnownConfig() { Reload(); _configFile.SaveOnConfigSet = false; bool flag = false; if (AddGeneralConfig()) { flag = true; } if (AddKnownGearSlotsConfig()) { flag = true; } if (AddKnownGearConfig()) { flag = true; } if (AddKnownMonstersConfig()) { flag = true; } if (flag) { _configFile.Save(); Reload(); } _configFile.SaveOnConfigSet = true; } private void Reloaded(object sender, EventArgs e) { if (_configFile != null) { Reload(); } } private void Reload() { bool enabled = true; int formatVersion = 1; Dictionary<GearSlot, GearSlotConfig> dictionary = new Dictionary<GearSlot, GearSlotConfig>(); Dictionary<string, GearConfig> dictionary2 = new Dictionary<string, GearConfig>(); Dictionary<string, MonsterConfig> dictionary3 = new Dictionary<string, MonsterConfig>(); foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in _configFile) { try { bool flag = false; bool flag2 = false; if (string.Equals(item.Key.Section, "General", StringComparison.OrdinalIgnoreCase)) { if (string.Equals(item.Key.Key, "Enabled", StringComparison.OrdinalIgnoreCase)) { flag = true; if (item.Value.BoxedValue is bool flag3) { flag2 = true; enabled = flag3; } } else if (string.Equals(item.Key.Key, "FormatVersion", StringComparison.OrdinalIgnoreCase)) { flag = true; if (item.Value.BoxedValue is int num) { flag2 = true; formatVersion = num; } } } else { string[] array = item.Key.Section.Split(new char[1] { '.' }); if (array.Length == 3) { string a = array[0]; string a2 = array[1]; if (string.Equals(a, "GearData", StringComparison.OrdinalIgnoreCase)) { if (string.Equals(a2, "Gear", StringComparison.OrdinalIgnoreCase)) { string text = array[2].ToLower(); string key = item.Key.Key; if (!dictionary2.TryGetValue(text, out var value)) { value = new GearConfig { Name = text }; dictionary2.Add(text, value); } if (string.Equals(key, "Level", StringComparison.OrdinalIgnoreCase)) { flag = true; BiomeLevel level = BiomeLevel.Unknown; if (item.Value.BoxedValue is string text2) { string value2 = text2.Trim(); if (Enum.TryParse<BiomeLevel>(value2, ignoreCase: true, out var result)) { flag2 = true; level = result; } } value.Level = level; } } else if (string.Equals(a2, "Slots", StringComparison.OrdinalIgnoreCase)) { string value3 = array[2]; string key2 = item.Key.Key; if (Enum.TryParse<GearSlot>(value3, ignoreCase: true, out var result2)) { if (!dictionary.TryGetValue(result2, out var value4)) { value4 = new GearSlotConfig { Slot = result2 }; dictionary.Add(result2, value4); } if (string.Equals(key2, "Weight", StringComparison.OrdinalIgnoreCase)) { flag = true; if (item.Value.BoxedValue is int weight) { flag2 = true; value4.Weight = weight; } else { value4.Weight = 0; } } } } } else if (string.Equals(a, "MonsterData", StringComparison.OrdinalIgnoreCase) && string.Equals(a2, "Monster", StringComparison.OrdinalIgnoreCase)) { string text3 = array[2].ToLower(); string key3 = item.Key.Key; if (!dictionary3.TryGetValue(text3, out var value5)) { value5 = new MonsterConfig { Name = text3 }; dictionary3.Add(text3, value5); } if (string.Equals(key3, "Fearless", StringComparison.OrdinalIgnoreCase)) { flag = true; if (item.Value.BoxedValue is bool fearless) { flag2 = true; value5.Fearless = fearless; } else { value5.Fearless = true; } } else if (string.Equals(key3, "CautionLevelThreshold", StringComparison.OrdinalIgnoreCase)) { flag = true; BiomeLevel cautionLevelThreshold = BiomeLevel.Unknown; if (item.Value.BoxedValue is string text4) { string value6 = text4.Trim(); if (Enum.TryParse<BiomeLevel>(value6, ignoreCase: true, out var result3)) { flag2 = true; cautionLevelThreshold = result3; } } value5.CautionLevelThreshold = cautionLevelThreshold; } else if (string.Equals(key3, "FearLevelThreshold", StringComparison.OrdinalIgnoreCase)) { flag = true; BiomeLevel fearLevelThreshold = BiomeLevel.Unknown; if (item.Value.BoxedValue is string text5) { string value7 = text5.Trim(); if (Enum.TryParse<BiomeLevel>(value7, ignoreCase: true, out var result4)) { flag2 = true; fearLevelThreshold = result4; } } value5.FearLevelThreshold = fearLevelThreshold; } } } } if (!flag) { Main.MyLogger.LogWarning((object)("Ignoring unknown setting: " + item.Key.Section + " " + item.Key.Key)); } else if (!flag2) { Main.MyLogger.LogWarning((object)("Ignoring invalid setting: " + item.Key.Section + " " + item.Key.Key + " = " + (item.Value.BoxedValue?.ToString() ?? "<NULL>"))); } } catch (Exception e) { Utils.LogException(e, "Exception during Config.Reload:"); } } FormatVersion = formatVersion; _gearSlots = dictionary; _gear = dictionary2; _monsters = dictionary3; _enabled = enabled; } private bool AddGeneralConfig() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown bool result = false; ConfigDefinition val = new ConfigDefinition("General", "Enabled"); if (!_configFile.ContainsKey(val)) { _configFile.Bind<bool>(val, true, new ConfigDescription("Enable this mod", (AcceptableValueBase)null, new object[0])); result = true; } ConfigDefinition val2 = new ConfigDefinition("General", "FormatVersion"); if (!_configFile.ContainsKey(val2)) { _configFile.Bind<int>(val2, 1, new ConfigDescription("The version of the config format", (AcceptableValueBase)null, new object[0])); result = true; } return result; } private bool AddKnownGearSlotsConfig() { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_0160: Expected O, but got Unknown bool result = false; foreach (GearSlotConfig item in new List<GearSlotConfig> { new GearSlotConfig { Slot = GearSlot.Head, Weight = 100 }, new GearSlotConfig { Slot = GearSlot.Chest, Weight = 100 }, new GearSlotConfig { Slot = GearSlot.Legs, Weight = 100 }, new GearSlotConfig { Slot = GearSlot.Shoulders, Weight = 50 }, new GearSlotConfig { Slot = GearSlot.Weapon, Weight = 0 }, new GearSlotConfig { Slot = GearSlot.Shield, Weight = 0 }, new GearSlotConfig { Slot = GearSlot.Ammo, Weight = 0 }, new GearSlotConfig { Slot = GearSlot.Utility, Weight = 0 }, new GearSlotConfig { Slot = GearSlot.Trinket, Weight = 0 } }) { GearSlot slot = item.Slot; if (!_gearSlots.ContainsKey(slot)) { string text = "GearData.Slots." + slot; _configFile.Bind<int>(new ConfigDefinition(text, "Weight"), item.Weight, new ConfigDescription("The gear slot's weight in calculating the player's gear level. 0 to ignore the slot, 100 to have full weight.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[0])).Value = item.Weight; result = true; } } return result; } private bool AddKnownGearConfig() { //IL_2a4f: Unknown result type (might be due to invalid IL or missing references) //IL_2a88: Unknown result type (might be due to invalid IL or missing references) //IL_2a92: Expected O, but got Unknown //IL_2a92: Expected O, but got Unknown //IL_2ac6: Unknown result type (might be due to invalid IL or missing references) //IL_2ad2: Expected O, but got Unknown bool result = false; ConfigEntry<string> val = default(ConfigEntry<string>); foreach (GearConfig item in new List<GearConfig> { new GearConfig { Name = "$item_helmet_celebration", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_fishinghat", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat1", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat2", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat3", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat4", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat5", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat6", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat7", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat8", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat9", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_hat10", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_strawhat", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_sweatband", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_witchhat", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_midsummercrown", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_yule", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_dverger", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_odin", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_rootcrown", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_helmet_leather", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_helmet_trollleather", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_helmet_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_helmet_berserker", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_helmet_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_helmet_root", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_helmet_fenris", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_helmet_drake", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_helmet_padded", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_helmet_berserker_undead", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_helmet_mage", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_helmet_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_helmet_mage_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_helmet_flametal", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_helmet_medium_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_helmet_crown_of_valheim", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_helmet_lox", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_helmet_heavy_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_helmet_medium_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_helmet_mage_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_chest_dress1", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress2", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress3", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress4", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress5", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress6", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress7", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress8", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress9", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_dress10", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_harvester1", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_harvester2", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_hildir1", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_hildir2", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_hildir3", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic1", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic2", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic3", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic4", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic5", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic6", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic7", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic8", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic9", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_tunic10", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_rags", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_chest_leather", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_chest_trollleather", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_chest_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_chest_berserker", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_chest_root", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_chest_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_chest_fenris", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_chest_wolf", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_chest_pcuirass", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_chest_berserker_undead", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_chest_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_chest_mage", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_chest_flametal", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_chest_mage_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_chest_medium_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_chest_lox", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_chest_heavy_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_chest_medium_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_chest_mage_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_cape_odin", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_cape_deerhide", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_cape_trollhide", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_cape_wolf", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_cape_lox", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_cape_linen", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_cape_feather", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_cape_ash", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_cape_asksvin", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_cape_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_cape_deepnorth_mage", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_legs_rags", Level = BiomeLevel.Starter }, new GearConfig { Name = "$item_legs_leather", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_legs_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_legs_trollleather", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_legs_berserker", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_legs_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_legs_root", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_legs_fenris", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_legs_wolf", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_legs_pgreaves", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_legs_berserker_undead", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_legs_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_legs_mage", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_legs_flametal", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_legs_mage_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_legs_medium_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_legs_lox", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_legs_heavy_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_legs_medium_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_legs_mage_deepnorth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_shield_wood", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_shield_woodtower", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_shield_bonetower", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_shield_bronzebuckler", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_shield_banded", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_shield_knight", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_shield_ironbuckler", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_shield_iron_square", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_shield_iron_tower", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_shield_silver", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_shield_serpentscale", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_shield_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_shield_blackmetal_tower", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_shield_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_shield_carapacebuckler", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_shield_flametal", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_shield_flametal_tower", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_shield_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_shield_gold_tower", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_shield_goldbuckler", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_shield_roots", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_arrow_wood", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_arrow_flint", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_arrow_fire", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_arrow_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_arrow_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_arrow_silver", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_arrow_obsidian", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_arrow_poison", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_arrow_frost", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_arrow_needle", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_arrow_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_arrow_charred", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_arrow_bloodgold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_bolt_bone", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_bolt_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_bolt_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_bolt_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_bolt_charred", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_bolt_bloodgold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_fishingbait", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_forest", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_swamp", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_ocean", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_cave", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_plains", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_mistlands", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_ashlands", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingbait_deepnorth", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bow", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_bow_finewood", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_bow_draugrfang", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_bow_huntsman", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_bow_snipesnap", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_bow_ashlands", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_bow_ashlandsblood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_bow_ashlandsroot", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_bow_ashlandsstorm", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_bow_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_bow_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_bow_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_crossbow_arbalest", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_crossbow_ripper", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_crossbow_ripper_blood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_crossbow_ripper_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_crossbow_ripper_nature", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_crossbow_bloodlightning_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_crossbow_frostfire_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_crossbow_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_torch", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_sparkler", Level = BiomeLevel.None }, new GearConfig { Name = "$item_torchmist", Level = BiomeLevel.None }, new GearConfig { Name = "$item_lanterndn", Level = BiomeLevel.None }, new GearConfig { Name = "$piece_hoodedlantern", Level = BiomeLevel.None }, new GearConfig { Name = "$item_cultivator", Level = BiomeLevel.None }, new GearConfig { Name = "$item_hoe", Level = BiomeLevel.None }, new GearConfig { Name = "$item_feaster", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fishingrod", Level = BiomeLevel.None }, new GearConfig { Name = "$item_hammer", Level = BiomeLevel.None }, new GearConfig { Name = "$item_knife_butcher", Level = BiomeLevel.None }, new GearConfig { Name = "$item_lantern", Level = BiomeLevel.None }, new GearConfig { Name = "$item_scythe", Level = BiomeLevel.None }, new GearConfig { Name = "$item_tankard", Level = BiomeLevel.None }, new GearConfig { Name = "$item_tankard_anniversary", Level = BiomeLevel.None }, new GearConfig { Name = "$item_tankard_odin", Level = BiomeLevel.None }, new GearConfig { Name = "$item_dvergrtankard", Level = BiomeLevel.None }, new GearConfig { Name = "$item_spear_chitin", Level = BiomeLevel.None }, new GearConfig { Name = "$item_graplinghook", Level = BiomeLevel.None }, new GearConfig { Name = "$item_snowshovel", Level = BiomeLevel.None }, new GearConfig { Name = "$item_pickaxe_stone", Level = BiomeLevel.None }, new GearConfig { Name = "$item_pickaxe_antler", Level = BiomeLevel.None }, new GearConfig { Name = "$item_pickaxe_bronze", Level = BiomeLevel.None }, new GearConfig { Name = "$item_pickaxe_iron", Level = BiomeLevel.None }, new GearConfig { Name = "$item_pickaxe_blackmetal", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_blue", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_cyan", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_green", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_purple", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_red", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_white", Level = BiomeLevel.None }, new GearConfig { Name = "$item_fireworkrocket_yellow", Level = BiomeLevel.None }, new GearConfig { Name = "$item_mace_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_club", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_mace_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_mace_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_mace_silver", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_mace_needle", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_mace_eldner", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_mace_eldner_blood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_mace_eldner_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_mace_eldner_nature", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_mace_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_mace_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_mace_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sledge_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_stagbreaker", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_sledge_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_sledge_demolisher", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_sledge_demolisher", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_mace2h_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_mace2h_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sledge_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_knife_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_knife_flint", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_knife_copper", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_knife_chitin", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_knife_silver", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_knife_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_knife_skollandhati", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_knife_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_knife_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_knife_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_knife_void", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_fistweapon_bjorn", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_fistweapon_fenris", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_fistweapon_bjorn_undead", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_fistweapon_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_fistweapon_frostfire_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_fistweapon_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sword_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_sword_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_sword_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_sword_silver", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_sword_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_sword_mistwalker", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_sword_niedhogg", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_niedhogg_blood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_niedhogg_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_niedhogg_nature", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_dyrnwyn", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_fire", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sword_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sword_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sword_wood_2h", Level = BiomeLevel.None }, new GearConfig { Name = "$item_sword_krom", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_sword_slayer", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_slayer_blood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_slayer_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword_slayer_nature", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_sword2h_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sword2h_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_sword2h_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_spear_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_spear_flint", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_spear_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_spear_ancientbark", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_spear_wolffang", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_spear_carapace", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_spear_splitner", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_spear_splitner_blood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_spear_splitner_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_spear_splitner_nature", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_spear_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_spear_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_spear_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_atgeir_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_atgeir_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_atgeir_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_atgeir_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_atgeir_himminafl", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_atgeir_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_atgeir_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_atgeir_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_axe_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_axe_stone", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_axe_flint", Level = BiomeLevel.Meadows }, new GearConfig { Name = "$item_axe_bronze", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_axe_iron", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_axe_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_axe_jotunbane", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_axe_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_axe_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_axe_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_axe_early", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_axe_berzerkr", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_axe_berzerkr_blood", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_axe_berzerkr_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_axe_berzerkr_nature", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_battleaxe_wood", Level = BiomeLevel.None }, new GearConfig { Name = "$item_battleaxe", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_battleaxe_crystal", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_battleaxe_blackmetal", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_battleaxe_skullsplittur", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_axe2h_gold", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_axe2h_gold_bloodlightning", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_axe2h_gold_frostfire", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_stafffireball", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_stafficeshards", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_staffshield", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_staffskeleton", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_staffredtroll", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_staffgreenroots", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_staffclusterbomb", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_staff_lightning", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_staff_frostorbs", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_staff_orbofahri", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_staff_spiritcaller", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_staff_thunderblood", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_beltstrength", Level = BiomeLevel.None }, new GearConfig { Name = "$item_wishbone", Level = BiomeLevel.None }, new GearConfig { Name = "$item_demister", Level = BiomeLevel.None }, new GearConfig { Name = "$item_iceshoes", Level = BiomeLevel.None }, new GearConfig { Name = "$item_iceskates", Level = BiomeLevel.None }, new GearConfig { Name = "$item_trinketbronzehealth", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_trinketbronzestamina", Level = BiomeLevel.BlackForest }, new GearConfig { Name = "$item_trinketironhealth", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_trinketironstamina", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_trinketchitinswim", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_trinketscalestaminadamage", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_trinketsilverdamage", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_trinketsilverresist", Level = BiomeLevel.Mountains }, new GearConfig { Name = "$item_trinketblackdamagedealth", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_trinketblackdtamina", Level = BiomeLevel.Plains }, new GearConfig { Name = "$item_trinketcarapaceeitr", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_trinketflametaleitr", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_trinketflametalstaminahealth", Level = BiomeLevel.Ashlands }, new GearConfig { Name = "$item_trinketbloodgoldhealth", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_trinketbloodgoldstamina", Level = BiomeLevel.DeepNorth }, new GearConfig { Name = "$item_oozebomb", Level = BiomeLevel.Swamp }, new GearConfig { Name = "$item_bilebomb", Level = BiomeLevel.Mistlands }, new GearConfig { Name = "$item_lavabomb", Level = BiomeLevel.None }, new GearConfig { Name = "$item_smokebomb", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bombblob_frost", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bombblob_lava", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bombblob_poison", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bombblob_poisonelite", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bombblob_tar", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bombblob_morkhalla", Level = BiomeLevel.None }, new GearConfig { Name = "$item_bomb_dynamite", Level = BiomeLevel.Unknown }, new GearConfig { Name = "$item_snowball", Level = BiomeLevel.None } }) { string name = item.Name; string text = "GearData.Gear." + name; BiomeLevel result2; if (!_gear.ContainsKey(name)) { _configFile.Bind<string>(new ConfigDefinition(text, "Level"), item.Level.ToString(), new ConfigDescription("The gear's biome level", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(BiomeLevel))), new object[0])).Value = item.Level.ToString(); result = true; } else if (item.Level > BiomeLevel.Unknown && _configFile.TryGetEntry<string>(new ConfigDefinition(text, "Level"), ref val) && (!Enum.TryParse<BiomeLevel>(val.Value, ignoreCase: true, out result2) || result2 == BiomeLevel.Unknown)) { val.Value = item.Level.ToString(); result = true; } } return result; } public bool AddDiscoveredGearConfig(IEnumerable<GearConfig> discoveredGear) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a2: Expected O, but got Unknown if (_configFile == null) { return false; } bool flag = false; _configFile.SaveOnConfigSet = false; foreach (GearConfig item in discoveredGear) { string text = item.Name.ToLower(); if (!_gear.ContainsKey(text)) { string text2 = "GearData.Gear." + text; _configFile.Bind<string>(new ConfigDefinition(text2, "Level"), item.Level.ToString(), new ConfigDescription("The gear's biome level", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(BiomeLevel))), new object[0])).Value = item.Level.ToString(); flag = true; } } if (flag) { _configFile.Save(); Reload(); } _configFile.SaveOnConfigSet = true; return flag; } private bool AddKnownMonstersConfig() { //IL_0a1c: Unknown result type (might be due to invalid IL or missing references) //IL_0a33: Unknown result type (might be due to invalid IL or missing references) //IL_0a3d: Expected O, but got Unknown //IL_0a3d: Expected O, but got Unknown //IL_0a55: Unknown result type (might be due to invalid IL or missing references) //IL_0a8e: Unknown result type (might be due to invalid IL or missing references) //IL_0a98: Expected O, but got Unknown //IL_0a98: Expected O, but got Unknown //IL_0abf: Unknown result type (might be due to invalid IL or missing references) //IL_0af8: Unknown result type (might be due to invalid IL or missing references) //IL_0b02: Expected O, but got Unknown //IL_0b02: Expected O, but got Unknown bool result = false; foreach (MonsterConfig item in new List<MonsterConfig> { new MonsterConfig("$enemy_neck", BiomeLevel.Meadows), new MonsterConfig("$enemy_boar", BiomeLevel.Meadows), new MonsterConfig("$enemy_greyling", BiomeLevel.Meadows), new MonsterConfig("$enemy_greydwarf", BiomeLevel.BlackForest), new MonsterConfig("$enemy_greydwarfshaman", BiomeLevel.BlackForest), new MonsterConfig("$enemy_greydwarfbrute", BiomeLevel.Swamp), new MonsterConfig("$enemy_ghost", BiomeLevel.Swamp), new MonsterConfig("$enemy_troll", BiomeLevel.Mountains), new MonsterConfig("$enemy_bjorn", BiomeLevel.Mountains), new MonsterConfig("$enemy_skeleton", BiomeLevel.Swamp), new MonsterConfig("$enemy_leech", BiomeLevel.Swamp), new MonsterConfig("$enemy_blob", BiomeLevel.Swamp), new MonsterConfig("$enemy_draugr", BiomeLevel.Swamp), new MonsterConfig("$enemy_surtling", BiomeLevel.Swamp), new MonsterConfig("$enemy_wraith", BiomeLevel.Mountains), new MonsterConfig("$enemy_skeletonpoison", BiomeLevel.Mountains), new MonsterConfig("$enemy_blobelite", BiomeLevel.Mountains), new MonsterConfig("$enemy_draugrelite", BiomeLevel.Mountains), new MonsterConfig("$enemy_abomination", BiomeLevel.Plains), new MonsterConfig("$enemy_kvastur"), new MonsterConfig("$enemy_blobfrost", BiomeLevel.Mountains), new MonsterConfig("$enemy_bat", BiomeLevel.Mountains), new MonsterConfig("$enemy_drake", BiomeLevel.Mountains), new MonsterConfig("$enemy_wolf", BiomeLevel.Mountains), new MonsterConfig("$enemy_ulv", BiomeLevel.Mountains), new MonsterConfig("$enemy_fenring", BiomeLevel.Plains), new MonsterConfig("$enemy_fenringcultist", BiomeLevel.Plains), new MonsterConfig("$enemy_stonegolem", BiomeLevel.Mistlands), new MonsterConfig("$enemy_blobtar", BiomeLevel.Plains), new MonsterConfig("$enemy_deathsquito", BiomeLevel.Plains), new MonsterConfig("$enemy_goblin", BiomeLevel.Plains), new MonsterConfig("$enemy_goblinshaman", BiomeLevel.Mistlands), new MonsterConfig("$enemy_goblinbrute", BiomeLevel.Mistlands), new MonsterConfig("$enemy_unbjorn", BiomeLevel.Ashlands), new MonsterConfig("$enemy_lox", BiomeLevel.Ashlands), new MonsterConfig("$enemy_babyseeker", BiomeLevel.Mistlands), new MonsterConfig("$enemy_dverger", BiomeLevel.Mistlands), new MonsterConfig("$enemy_dvergr", BiomeLevel.Mistlands), new MonsterConfig("$enemy_dvergr_mage", BiomeLevel.Mistlands), new MonsterConfig("$enemy_mistile"), new MonsterConfig("$enemy_tick", BiomeLevel.Mistlands), new MonsterConfig("$enemy_seeker", BiomeLevel.Mistlands), new MonsterConfig("$enemy_seekerbrute", BiomeLevel.Ashlands), new MonsterConfig("$enemy_gjall", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_serpent", BiomeLevel.Mistlands, BiomeLevel.NoFear), new MonsterConfig("$enemy_bloblava", BiomeLevel.Ashlands), new MonsterConfig("$enemy_asksvin", BiomeLevel.Ashlands), new MonsterConfig("$enemy_volture", BiomeLevel.Ashlands), new MonsterConfig("$enemy_charred_archer", BiomeLevel.Ashlands), new MonsterConfig("$enemy_charred_mage", BiomeLevel.Ashlands), new MonsterConfig("$enemy_charred_melee", BiomeLevel.Ashlands), new MonsterConfig("$enemy_charred_twitcher", BiomeLevel.Ashlands), new MonsterConfig("$enemy_charred_twitcher_summoned"), new MonsterConfig("$enemy_summonedroot"), new MonsterConfig("$enemy_summonedtroll"), new MonsterConfig("$enemy_fallenvalkyrie", (BiomeLevel)11), new MonsterConfig("$enemy_morgen", (BiomeLevel)11), new MonsterConfig("$enemy_bonemawserpent", BiomeLevel.Ashlands, BiomeLevel.NoFear), new MonsterConfig("$enemy_barka", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_dvergr_deepnorth", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_elaking", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_elakingmole", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_fallenwarrior", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_ghost_void", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_goblin_deepnorth", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_jotun_warrior", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_jotun_witch", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_moose", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_blobmork", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_blobmorkmini", BiomeLevel.DeepNorth), new MonsterConfig("$enemy_trollfrost", (BiomeLevel)12), new MonsterConfig("$enemy_shadowperson"), new MonsterConfig("$enemy_asksvin_hatchling"), new MonsterConfig("$enemy_hen"), new MonsterConfig("$enemy_skeleton_summoned"), new MonsterConfig("$spiritcaller_bjorn"), new MonsterConfig("$spiritcaller_boar"), new MonsterConfig("$spiritcaller_moose"), new MonsterConfig("$spiritcaller_wolf"), new MonsterConfig("$piece_trainingdummy"), new MonsterConfig("$enemy_frostwisp"), new MonsterConfig("$enemy_frysling"), new MonsterConfig("$enemy_fenringcultist_hildir"), new MonsterConfig("$enemy_goblin_hildir"), new MonsterConfig("$enemy_goblinbrute_hildir"), new MonsterConfig("$enemy_goblinbrute_hildircombined"), new MonsterConfig("$enemy_skeletonfire"), new MonsterConfig("$enemy_eikthyr"), new MonsterConfig("$enemy_gdking"), new MonsterConfig("$enemy_bonemass"), new MonsterConfig("$enemy_dragon"), new MonsterConfig("$enemy_goblinking"), new MonsterConfig("$enemy_seekerqueen"), new MonsterConfig("$enemy_fader"), new MonsterConfig("$enemy_charred_melee_fader"), new MonsterConfig("$enemy_frozenking"), new MonsterConfig("$enemy_frozenking_p3"), new MonsterConfig("$enemy_aspect_bonemass"), new MonsterConfig("$enemy_aspect_dragon"), new MonsterConfig("$enemy_aspect_eikthyr"), new MonsterConfig("$enemy_aspect_fader"), new MonsterConfig("$enemy_aspect_gdking"), new MonsterConfig("$enemy_aspect_goblinking"), new MonsterConfig("$enemy_aspect_seekerqueen"), new MonsterConfig("$enemy_hive"), new MonsterConfig("$enemy_thehive"), new MonsterConfig("$enemy_charred_melee_dyrnwyn", BiomeLevel.Unknown, BiomeLevel.Unknown, fearless: true) }) { string name = item.Name; if (!_monsters.ContainsKey(name)) { string text = "MonsterData.Monster." + name; _configFile.Bind<bool>(new ConfigDefinition(text, "Fearless"), item.Fearless, new ConfigDescription("Monster has no fear and is not affected by the player's gear level. Caution and Fear thresholds are ignored.", (AcceptableValueBase)null, new object[0])).Value = item.Fearless; _configFile.Bind<string>(new ConfigDefinition(text, "CautionLevelThreshold"), item.CautionLevelThreshold.ToString(), new ConfigDescription("Player gear level at which the monster becomes cautious of the player, and no longer attacks on sight. Typically the same as the biome level the monster spawns in.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(BiomeLevel))), new object[0])).Value = item.CautionLevelThreshold.ToString(); _configFile.Bind<string>(new ConfigDefinition(text, "FearLevelThreshold"), item.FearLevelThreshold.ToString(), new ConfigDescription("Player gear level at which the monster becomes fearful of the player, and runs on sight. Typically two levels above the CationLevelThreshold.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(BiomeLevel))), new object[0])).Value = item.FearLevelThreshold.ToString(); result = true; } } return result; } public bool AddDiscoveredMonsterConfig(IEnumerable<MonsterConfig> discoveredMonsters) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0083: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00de: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0148: Expected O, but got Unknown if (_configFile == null) { return false; } bool flag = false; _configFile.SaveOnConfigSet = false; foreach (MonsterConfig discoveredMonster in discoveredMonsters) { string text = discoveredMonster.Name.ToLower(); if (!_monsters.ContainsKey(text)) { string text2 = "MonsterData.Monster." + text; _configFile.Bind<bool>(new ConfigDefinition(text2, "Fearless"), discoveredMonster.Fearless, new ConfigDescription("Monster has no fear and is not affected by the player's gear level. Caution and Fear thresholds are ignored.", (AcceptableValueBase)null, new object[0])).Value = discoveredMonster.Fearless; _configFile.Bind<string>(new ConfigDefinition(text2, "CautionLevelThreshold"), discoveredMonster.CautionLevelThreshold.ToString(), new ConfigDescription("Player gear level at which the monster becomes cautious of the player, and no longer attacks on sight. Typically the same as the biome level the monster spawns in.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(BiomeLevel))), new object[0])).Value = discoveredMonster.CautionLevelThreshold.ToString(); _configFile.Bind<string>(new ConfigDefinition(text2, "FearLevelThreshold"), discoveredMonster.FearLevelThreshold.ToString(), new ConfigDescription("Player gear level at which the monster becomes fearful of the player, and runs on sight. Typically two levels above the CationLevelThreshold.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(BiomeLevel))), new object[0])).Value = discoveredMonster.FearLevelThreshold.ToString(); flag = true; } } if (flag) { _configFile.Save(); Reload(); } _configFile.SaveOnConfigSet = true; return flag; } private void SetupWatcher() { FileInfo fileInfo = new FileInfo(_configFile.ConfigFilePath); _watcher = new FileSystemWatcher(fileInfo.Directory.FullName, fileInfo.Name) { IncludeSubdirectories = true, SynchronizingObject = ThreadingHelper.SynchronizingObject, EnableRaisingEvents = true }; _watcher.Changed += FileChanged; _watcher.Created += FileChanged; _watcher.Renamed += FileChanged; } private void FileChanged(object sender, FileSystemEventArgs e) { if (_configFile != null && File.Exists(e.FullPath)) { DateTime now = DateTime.Now; if (now.Ticks - _lastReloadTime.Ticks >= 10000000) { _lastReloadTime = now; _configFile.Reload(); } } } public void Dispose() { _configFile = null; _enabled = false; _gearSlots = null; _gear = null; _monsters = null; if (_watcher != null) { _watcher.Changed -= FileChanged; _watcher.Created -= FileChanged; _watcher.Renamed -= FileChanged; _watcher.Dispose(); _watcher = null; } } public GearSlotConfig GetGearSlot(GearSlot slot) { if (_gearSlots == null) { return null; } _gearSlots.TryGetValue(slot, out var value); return value; } public GearConfig GetGear(string name) { if (_gear == null || string.IsNullOrWhiteSpace(name)) { return null; } _gear.TryGetValue(name.ToLower(), out var value); return value; } public MonsterConfig GetMonster(string name) { if (_monsters == null || string.IsNullOrWhiteSpace(name)) { return null; } _monsters.TryGetValue(name.ToLower(), out var value); return value; } } [BepInPlugin("tulivu.valheimmods.fearme", "FearMe", "1.0.1")] public class Main : BaseUnityPlugin { public const string PLUGIN_GUID = "tulivu.valheimmods.fearme"; public const string PLUGIN_NAME = "FearMe"; public const string PLUGIN_VERSION = "1.0.1"; private static bool _loaded; public static bool Enabled { get { if (_loaded && MyConfig != null) { return MyConfig.Enabled; } return false; } } public static ManualLogSource MyLogger { get; private set; } public static Config MyConfig { get; private set; } public void Awake() { if (_loaded) { throw new Exception("FearMe has already been initialized!"); } MyLogger = Logger.CreateLogSource("FearMe"); MyConfig = new Config(((BaseUnityPlugin)this).Config); if (!MyConfig.Load()) { throw new Exception("FearMe failed to load!"); } Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "tulivu.valheimmods.fearme"); _loaded = true; } public void OnDestroy() { if (_loaded) { _loaded = false; MyConfig.Dispose(); MyConfig = null; MyLogger.Dispose(); MyLogger = null; } } } public static class Utils { public static void LogException(Exception e, string note = null) { StringBuilder stringBuilder = new StringBuilder(); if (!string.IsNullOrWhiteSpace(note)) { stringBuilder.AppendLine(note); } for (Exception ex = e; ex != null; ex = ex.InnerException) { if (!string.IsNullOrWhiteSpace(note)) { stringBuilder.Append("\t"); } stringBuilder.AppendLine(ex.Message ?? string.Empty); } Main.MyLogger.LogError((object)stringBuilder.ToString()); } } } namespace FearMe.PlayerGear { public enum BiomeLevel { Unknown = 0, None = 1, Starter = 2, Meadows = 3, BlackForest = 4, Swamp = 5, Mountains = 6, Plains = 7, Mistlands = 8, Ashlands = 9, DeepNorth = 10, NoFear = 100 } public enum GearSlot { Unknown, Head, Chest, Legs, Shoulders, Weapon, Shield, Ammo, Utility, Trinket } public static class PlayerExtensions { private struct GearSums { public decimal LevelSum { get; } public decimal QualitySum { get; } public decimal CountSum { get; } public GearSums(decimal levelSum, decimal qualitySum, decimal countSum) { LevelSum = levelSum; QualitySum = qualitySum; CountSum = countSum; } } private static BiomeLevel _gearLevel = BiomeLevel.Unknown; private static readonly int GEAR_LEVEL = StringExtensionMethods.GetStableHashCode("GearLevel"); private const int NUM_QUALITY_LEVELS = 4; public static BiomeLevel GetGearLevel(this Player player) { BiomeLevel result = BiomeLevel.Unknown; try { if (!Main.Enabled) { return result; } if (((Character)player).m_nview.IsValid() && !((Character)player).m_nview.IsOwner()) { result = (BiomeLevel)((Character)player).m_nview.GetZDO().GetInt(GEAR_LEVEL, 0); } else { if (_gearLevel == BiomeLevel.Unknown) { player.UpdateGearLevel(); } result = _gearLevel; } } catch (Exception e) { Utils.LogException(e, "Exception during PlayerExtensions.GetGearLevel:"); } return result; } public static void UpdateGearLevel(this Player player) { try { if (!Main.Enabled || (((Character)player).m_nview.IsValid() && !((Character)player).m_nview.IsOwner())) { return; } BiomeLevel biomeLevel = CalculateGearLevel(SumGear(player)); if (biomeLevel != _gearLevel) { _gearLevel = biomeLevel; if (((Character)player).m_nview.IsValid()) { ((Character)player).m_nview.GetZDO().Set(GEAR_LEVEL, (int)biomeLevel, false); } } } catch (Exception e) { Utils.LogException(e, "Exception during PlayerExtensions.UpdateGearLevel:"); } } private static GearSums SumGear(Player player) { GearSums gearValue = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Head), ((Humanoid)player).m_helmetItem); GearSums gearValue2 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Chest), ((Humanoid)player).m_chestItem); GearSums gearValue3 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Legs), ((Humanoid)player).m_legItem); GearSums gearValue4 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Shoulders), ((Humanoid)player).m_shoulderItem); GearSums gearValue5 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Weapon), ((Humanoid)player).GetCurrentWeapon()); GearSlotConfig gearSlot = Main.MyConfig.GetGearSlot(GearSlot.Shield); ItemData val = ((Humanoid)player).GetCurrentBlocker(); if (val != null && val.IsWeapon()) { val = null; } GearSums gearValue6 = GetGearValue(gearSlot, val); GearSums gearValue7 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Ammo), ((Humanoid)player).m_ammoItem); GearSums gearValue8 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Utility), ((Humanoid)player).m_utilityItem); GearSums gearValue9 = GetGearValue(Main.MyConfig.GetGearSlot(GearSlot.Trinket), ((Humanoid)player).m_trinketItem); decimal levelSum = gearValue.LevelSum + gearValue2.LevelSum + gearValue3.LevelSum + gearValue4.LevelSum + gearValue5.LevelSum + gearValue6.LevelSum + gearValue7.LevelSum + gearValue8.LevelSum + gearValue9.LevelSum; decimal qualitySum = gearValue.QualitySum + gearValue2.QualitySum + gearValue3.QualitySum + gearValue4.QualitySum + gearValue5.QualitySum + gearValue6.QualitySum + gearValue7.QualitySum + gearValue8.QualitySum + gearValue9.QualitySum; decimal countSum = gearValue.CountSum + gearValue2.CountSum + gearValue3.CountSum + gearValue4.CountSum + gearValue5.CountSum + gearValue6.CountSum + gearValue7.CountSum + gearValue8.CountSum + gearValue9.CountSum; return new GearSums(levelSum, qualitySum, countSum); } private static GearSums GetGearValue(GearSlotConfig slotConfig, ItemData gear) { decimal levelSum = 0.0m; decimal qualitySum = 0.0m; decimal countSum = 0.0m; decimal num = 1.0m; if (slotConfig != null) { num = (decimal)slotConfig.Weight / 100.0m; } if (num > 0.0m) { if (gear != null) { GearConfig gear2 = Main.MyConfig.GetGear(gear.m_shared.m_name); if (gear2 != null && gear2.Level != BiomeLevel.Unknown) { levelSum = num * (decimal)(int)gear2.Level; qualitySum = num * (decimal)gear.m_quality; countSum = num; } } else { levelSum = num * 1m; qualitySum = num * 1m; countSum = num; } } return new GearSums(levelSum, qualitySum, countSum); } private static BiomeLevel CalculateGearLevel(GearSums gearSums) { BiomeLevel result = BiomeLevel.Unknown; if (gearSums.CountSum > 0.0m) { decimal num = 3m * gearSums.LevelSum + gearSums.QualitySum - gearSums.CountSum; decimal num2 = 3m * gearSums.CountSum; result = (BiomeLevel)(int)(num / num2); } return result; } } } namespace FearMe.PlayerGear.Config { public class GearConfig { public string Name { get; set; } public BiomeLevel Level { get; set; } } public class GearSlotConfig { public GearSlot Slot { get; set; } public int Weight { get; set; } } } namespace FearMe.PlayerGear.Patches { public class ZNetScene_Awake_Patch { [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class AwakePatch { public static void Postfix(ZNetScene __instance) { try { if (!Main.Enabled) { return; } Dictionary<string, MonsterConfig> dictionary = new Dictionary<string, MonsterConfig>(); foreach (GameObject value2 in __instance.m_namedPrefabs.Values) { if (!((Object)(object)value2.GetComponent<MonsterAI>() != (Object)null)) { continue; } Character component = value2.GetComponent<Character>(); if ((Object)(object)component != (Object)null && Object.op_Implicit((Object)(object)component)) { string text = component.m_name.ToLower(); if (!dictionary.ContainsKey(text)) { MonsterConfig value = new MonsterConfig { Name = text, Fearless = true, CautionLevelThreshold = BiomeLevel.Unknown, FearLevelThreshold = BiomeLevel.Unknown }; dictionary.Add(text, value); } } } if (dictionary.Any()) { Main.MyConfig.AddDiscoveredMonsterConfig(dictionary.Values); } } catch (Exception e) { Utils.LogException(e, "Exception during ObjectDB_Awake_Patch.Postfix:"); } } } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] public static class Humanoid_EquipItem_Patch { public static void Postfix(ItemData item, bool __result, Humanoid __instance) { try { if (Main.Enabled && __result) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && Object.op_Implicit((Object)(object)val)) { val.UpdateGearLevel(); } } } catch (Exception e) { Utils.LogException(e, "Exception during Humanoid_EquipItem_Patch.Postfix:"); } } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] public static class Humanoid_UnequipItem_Patch { public static void Postfix(ItemData item, Humanoid __instance) { try { if (Main.Enabled && item != null) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && Object.op_Implicit((Object)(object)val)) { val.UpdateGearLevel(); } } } catch (Exception e) { Utils.LogException(e, "Exception during Humanoid_UnequipItem_Patch.Postfix:"); } } } public class ObjectDB_Awake_Patch { [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class AwakePatch { public static void Postfix(ObjectDB __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) try { if (!Main.Enabled) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name == "main")) { return; } Dictionary<string, GearConfig> dictionary = new Dictionary<string, GearConfig>(); foreach (GameObject item in __instance.m_items) { ItemDrop component = item.GetComponent<ItemDrop>(); if (!((Object)(object)component != (Object)null) || !Object.op_Implicit((Object)(object)component)) { continue; } ItemData itemData = component.m_itemData; if (itemData == null || itemData.m_shared == null) { continue; } string name = itemData.m_shared.m_name; if (name != null && name.StartsWith("$") && itemData.IsEquipable()) { name = name.ToLower(); if (!dictionary.ContainsKey(name)) { GearConfig value = new GearConfig { Name = name, Level = BiomeLevel.Unknown }; dictionary.Add(name, value); } } } if (dictionary.Any()) { Main.MyConfig.AddDiscoveredGearConfig(dictionary.Values); } } catch (Exception e) { Utils.LogException(e, "Exception during ObjectDB_Awake_Patch.Postfix:"); } } } } } namespace FearMe.Monsters { public enum FearLevel { NotAfraid, Cautious, Afraid } public static class MonsterExtensions { public static FearLevel GetFearLevel(this BaseAI ai, Character targetCreature, bool checkAlerted) { try { if (!Main.Enabled) { return FearLevel.NotAfraid; } Player val = (Player)(object)((targetCreature is Player) ? targetCreature : null); if ((Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)val)) { return FearLevel.NotAfraid; } MonsterAI val2 = (MonsterAI)(object)((ai is MonsterAI) ? ai : null); if ((Object)(object)val2 == (Object)null || !Object.op_Implicit((Object)(object)val2) || (checkAlerted && !((BaseAI)val2).IsAlerted()) || val2.IsEventCreature()) { return FearLevel.NotAfraid; } Character character = ((BaseAI)val2).m_character; if ((Object)(object)character == (Object)null || !Object.op_Implicit((Object)(object)character) || character.m_name == null || character.IsTamed() || character.IsBoss()) { return FearLevel.NotAfraid; } MonsterConfig monster = Main.MyConfig.GetMonster(character.m_name); if (monster == null || monster.Fearless) { return FearLevel.NotAfraid; } BiomeLevel gearLevel = val.GetGearLevel(); if (gearLevel <= BiomeLevel.Unknown) { return FearLevel.NotAfraid; } return (monster.FearLevelThreshold > BiomeLevel.Unknown && gearLevel >= monster.FearLevelThreshold) ? FearLevel.Afraid : ((monster.CautionLevelThreshold > BiomeLevel.Unknown && gearLevel >= monster.CautionLevelThreshold) ? FearLevel.Cautious : FearLevel.NotAfraid); } catch (Exception e) { Utils.LogException(e, "Exception during MonsterExtensions.GetFearLevel:"); return FearLevel.NotAfraid; } } } } namespace FearMe.Monsters.Patches { [HarmonyPatch(typeof(BaseAI), "FindEnemy")] public static class BaseAI_FindEnemy_Patch { public static void Postfix(ref Character __result, BaseAI __instance) { try { if (Main.Enabled) { MonsterAI val = (MonsterAI)(object)((__instance is MonsterAI) ? __instance : null); if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val) && __instance.GetFearLevel(__result, checkAlerted: false) == FearLevel.Cautious) { __result = null; } } } catch (Exception e) { Utils.LogException(e, "Exception during BaseAI_FindEnemy_Patch.Postfix:"); } } } [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] public static class MonsterAI_UpdateAI_Patch { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator).MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(MonsterAI), "m_fleeIfHurtWhenTargetCantBeReached")), (string)null) }).ThrowIfInvalid("Could not find location of m_fleeIfHurtWhenTargetCantBeReached in MonsterAI.UpdateAI to patch"); List<Label> labels = val.Labels; val.Labels = new List<Label>(); Label label = default(Label); val.CreateLabel(ref label); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).AddLabels((IEnumerable<Label>)labels).Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_1, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MonsterAI_UpdateAI_Patch), "RunAway", (Type[])null, (Type[])null)) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Brfalse, (object)label) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ret, (object)null) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(BaseAI), "SetAlerted", (Type[])null, (Type[])null), (string)null) }).Advance(3).ThrowIfInvalid("Could not find location of SetAlerted in MonsterAI.UpdateAI to patch"); Label label2 = default(Label); val.CreateLabel(ref label2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_1, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MonsterAI_UpdateAI_Patch), "RunAway", (Type[])null, (Type[])null)) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Brfalse, (object)label2) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ret, (object)null) }); return val.Instructions(); } private static bool RunAway(this MonsterAI ai, float dt) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) try { if (!Main.Enabled) { return false; } bool result = false; Character targetCreature = ((BaseAI)ai).GetTargetCreature(); if (((BaseAI)(object)ai).GetFearLevel(targetCreature, checkAlerted: true) == FearLevel.Afraid) { result = true; ((BaseAI)ai).Flee(dt, ((Component)targetCreature).transform.position); ai.m_updateTargetTimer = 5f; } return result; } catch (Exception e) { Utils.LogException(e, "Exception during MonsterAI_UpdateAI_Patch.RunAway:"); return false; } } } } namespace FearMe.Monsters.Config { public class MonsterConfig { private BiomeLevel _cautionLevelThreshold; private BiomeLevel _fearLevelThreshold; public string Name { get; set; } public bool Fearless { get; set; } public BiomeLevel CautionLevelThreshold { get { return _cautionLevelThreshold; } set { if (value > BiomeLevel.DeepNorth) { _cautionLevelThreshold = BiomeLevel.NoFear; } else if (value < BiomeLevel.Unknown) { _cautionLevelThreshold = BiomeLevel.Unknown; } else { _cautionLevelThreshold = value; } } } public BiomeLevel FearLevelThreshold { get { return _fearLevelThreshold; } set { if (value > BiomeLevel.DeepNorth) { _fearLevelThreshold = BiomeLevel.NoFear; } else if (value < BiomeLevel.Unknown) { _fearLevelThreshold = BiomeLevel.Unknown; } else { _fearLevelThreshold = value; } } } public MonsterConfig() { Fearless = true; CautionLevelThreshold = BiomeLevel.Unknown; FearLevelThreshold = BiomeLevel.Unknown; } public MonsterConfig(string name, BiomeLevel cautionLevelThreshold, BiomeLevel? fearLevelThreshold = null, bool fearless = false) { Name = name; CautionLevelThreshold = cautionLevelThreshold; FearLevelThreshold = fearLevelThreshold ?? (cautionLevelThreshold + 2); Fearless = fearless; } public MonsterConfig(string name, bool fearless = true) { Name = name; CautionLevelThreshold = (fearless ? BiomeLevel.NoFear : BiomeLevel.Unknown); FearLevelThreshold = (fearless ? BiomeLevel.NoFear : BiomeLevel.Unknown); Fearless = fearless; } } }