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 balrond MonsterMayehm v1.2.5
plugins/BalrondMonsterMayhem.dll
Decompiled 2 days 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.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; 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 BalrondMonsterMayhem.Commands; using BalrondMonsterMayhem.Compatibility; using BalrondMonsterMayhem.Config; using BalrondMonsterMayhem.Diagnostics; using BalrondMonsterMayhem.Features.AI; using BalrondMonsterMayhem.Features.Optimization; using BalrondMonsterMayhem.Features.Taming; using BalrondMonsterMayhem.Integrations; using BalrondMonsterMayhem.Networking; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LitJson2; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BalrondMonsterMayhem")] [assembly: AssemblyDescription("Balrond Monster Mayhem")] [assembly: AssemblyCompany("Balrond")] [assembly: AssemblyProduct("BalrondMonsterMayhem")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.2.5.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.5.0")] [module: UnverifiableCode] public static class BalrondHashCompat { private static readonly MethodInfo _getStableHashCodeStringBool; private static readonly MethodInfo _getStableHashCodeString; static BalrondHashCompat() { try { Type typeFromHandle = typeof(StringExtensionMethods); _getStableHashCodeStringBool = typeFromHandle.GetMethod("GetStableHashCode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(string), typeof(bool) }, null); _getStableHashCodeString = typeFromHandle.GetMethod("GetStableHashCode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); } catch { } } public static int StableHash(string value) { if (value == null) { return 0; } try { if (_getStableHashCodeStringBool != null) { return (int)_getStableHashCodeStringBool.Invoke(null, new object[2] { value, false }); } if (_getStableHashCodeString != null) { return (int)_getStableHashCodeString.Invoke(null, new object[1] { value }); } } catch { } return FallbackStableHash(value); } private static int FallbackStableHash(string value) { int num = 5381; int num2 = num; for (int i = 0; i < value.Length; i += 2) { num = ((num << 5) + num) ^ value[i]; if (i == value.Length - 1) { break; } num2 = ((num2 << 5) + num2) ^ value[i + 1]; } return num + num2 * 1566083941; } } public static class CreatureFactionRegistry { public enum Mode { Static, DynamicBiome } public enum TimeCondition { Any, Day, Night } public sealed class BiomeTimeFactionRule { public Biome Biome; public TimeCondition Time; public string FactionName; public BiomeTimeFactionRule(Biome biome, TimeCondition time, string factionName) { //IL_0009: 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) Biome = biome; Time = time; FactionName = factionName; } } public sealed class CreatureFactionRule { public string PrefabName; public string DefaultFactionName; public Mode Mode = Mode.Static; public Dictionary<Biome, string> BiomeFactions = new Dictionary<Biome, string>(); public List<BiomeTimeFactionRule> BiomeTimeFactions = new List<BiomeTimeFactionRule>(); } private static readonly Dictionary<string, CreatureFactionRule> Rules = new Dictionary<string, CreatureFactionRule>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<Biome, string> DefaultBiomeFactions = new Dictionary<Biome, string>(); public static void RegisterCreature(CreatureFactionRule rule) { if (rule != null && !string.IsNullOrEmpty(rule.PrefabName)) { Rules[rule.PrefabName] = rule; } } public static void SetBiomeFaction(Biome biome, string factionName) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) DefaultBiomeFactions[biome] = factionName; } public static void RegisterDefaultBiomeFactionMap() { SetBiomeFaction((Biome)1, "AnimalsVeg"); SetBiomeFaction((Biome)8, "ForestMonsters"); SetBiomeFaction((Biome)2, "Undead"); SetBiomeFaction((Biome)4, "MountainMonsters"); SetBiomeFaction((Biome)16, "PlainsMonsters"); SetBiomeFaction((Biome)256, "SeaMonsters"); SetBiomeFaction((Biome)512, "MistlandsMonsters"); SetBiomeFaction((Biome)32, "Demon"); SetBiomeFaction((Biome)64, "MountainMonsters"); } public static void InitExampleRegistry() { RegisterDefaultBiomeFactionMap(); } public static void Apply(Character character) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return; } string prefabName = GetPrefabName(((Component)character).gameObject); if (!Rules.TryGetValue(prefabName, out var value)) { return; } string text = value.DefaultFactionName; if (value.Mode == Mode.DynamicBiome) { Biome biome = GetBiome(((Component)character).transform.position); BiomeTimeFactionRule biomeTimeFactionRule = FindBiomeTimeRule(value, biome); string value2; if (biomeTimeFactionRule != null) { text = biomeTimeFactionRule.FactionName; } else if (value.BiomeFactions.TryGetValue(biome, out value2)) { text = value2; } else if (string.IsNullOrEmpty(text) && DefaultBiomeFactions.TryGetValue(biome, out value2)) { text = value2; } } if (!string.IsNullOrEmpty(text) && CustomFactionRegistry.TryGetFaction(text, out var faction)) { character.m_faction = (Faction)faction.ID; } } private static BiomeTimeFactionRule FindBiomeTimeRule(CreatureFactionRule rule, Biome biome) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (rule.BiomeTimeFactions == null || rule.BiomeTimeFactions.Count == 0) { return null; } TimeCondition timeCondition = ((!IsNight()) ? TimeCondition.Day : TimeCondition.Night); BiomeTimeFactionRule result = null; for (int i = 0; i < rule.BiomeTimeFactions.Count; i++) { BiomeTimeFactionRule biomeTimeFactionRule = rule.BiomeTimeFactions[i]; if (biomeTimeFactionRule != null && biomeTimeFactionRule.Biome == biome) { if (biomeTimeFactionRule.Time == timeCondition) { return biomeTimeFactionRule; } if (biomeTimeFactionRule.Time == TimeCondition.Any) { result = biomeTimeFactionRule; } } } return result; } private static bool IsNight() { return (Object)(object)EnvMan.instance != (Object)null && EnvMan.instance.CalculateNight(); } private static Biome GetBiome(Vector3 position) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) if (WorldGenerator.instance != null) { return WorldGenerator.instance.GetBiome(position.x, position.z, 0.02f, false); } return Heightmap.FindBiome(position); } private static string GetPrefabName(GameObject go) { string text = ((Object)go).name; int num = text.IndexOf("(Clone)", StringComparison.Ordinal); if (num >= 0) { text = text.Substring(0, num); } return text; } } [HarmonyPatch(typeof(Character), "Awake")] public static class Character_Awake_CreatureFactionPatch { private static void Postfix(Character __instance) { CreatureFactionRegistry.Apply(__instance); } } public static class CustomFactionRegistry { public sealed class FactionDefinition { public int ID; public string Name; public List<FactionRelation> Relations = new List<FactionRelation>(); } public sealed class FactionRelation { public string Name; public bool Enemy; public FactionRelation(string name, bool enemy) { Name = name; Enemy = enemy; } } private static readonly Dictionary<string, FactionDefinition> ByName = new Dictionary<string, FactionDefinition>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<int, FactionDefinition> ById = new Dictionary<int, FactionDefinition>(); private static readonly Dictionary<string, bool> Relations = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<ulong, bool> RelationIds = new Dictionary<ulong, bool>(); private static readonly HashSet<int> ExplicitCustomIds = new HashSet<int>(); private static bool _vanillaRegistered; public static void InitExampleRegistry() { Init(); } public static void Init() { RegisterVanillaFactions(); } public static void RegisterFaction(FactionDefinition faction) { Init(); ByName[faction.Name] = faction; ById[faction.ID] = faction; ExplicitCustomIds.Add(faction.ID); RebuildRelationIds(); SetRelation(faction.Name, faction.Name, enemy: false); foreach (FactionRelation relation in faction.Relations) { SetRelation(faction.Name, relation.Name, relation.Enemy); } } public static void SetRelation(string factionA, string factionB, bool enemy) { Relations[Key(factionA, factionB)] = enemy; Relations[Key(factionB, factionA)] = enemy; if (TryResolveId(factionA, out var id) && TryResolveId(factionB, out var id2)) { RelationIds[PairKey(id, id2)] = enemy; RelationIds[PairKey(id2, id)] = enemy; } } public static bool TryGetFaction(string name, out FactionDefinition faction) { Init(); return ByName.TryGetValue(name, out faction); } public static Faction GetFaction(string name) { //IL_0032: 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) Init(); if (!ByName.TryGetValue(name, out var value)) { throw new Exception("Unknown faction: " + name); } return (Faction)value.ID; } public static string GetFactionName(Faction faction) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected I4, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected I4, but got Unknown Init(); if (ById.TryGetValue((int)faction, out var value)) { return value.Name; } return ((int)faction).ToString(); } public static bool IsRegistered(Faction faction) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown Init(); return ById.ContainsKey((int)faction); } public static bool AreEnemies(Character a, Character b) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected I4, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected I4, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null || (Object)(object)a == (Object)(object)b) { return false; } Init(); int num = (int)a.m_faction; int num2 = (int)b.m_faction; if (RelationIds.TryGetValue(PairKey(num, num2), out var value)) { return value; } if ((!ById.ContainsKey(num) || !ById.ContainsKey(num2)) && Relations.TryGetValue(Key(GetFactionName(a.m_faction), GetFactionName(b.m_faction)), out value)) { return value; } if (!IsCustomFaction(a.m_faction) && !IsCustomFaction(b.m_faction)) { return false; } return num != num2; } internal static bool TryResolveEnemyOverride(Character a, Character b, out bool enemy) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected I4, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected I4, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) enemy = false; if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null) { return false; } if (!_vanillaRegistered) { Init(); } if (ExplicitCustomIds.Count == 0 && Relations.Count == 0) { return false; } int num = (int)a.m_faction; int num2 = (int)b.m_faction; bool flag = ExplicitCustomIds.Contains(num) || ExplicitCustomIds.Contains(num2); bool flag2 = RelationIds.TryGetValue(PairKey(num, num2), out enemy); if (!flag2 && (!ById.ContainsKey(num) || !ById.ContainsKey(num2))) { flag2 = Relations.TryGetValue(Key(GetFactionName(a.m_faction), GetFactionName(b.m_faction)), out enemy); } if (!flag && !flag2) { return false; } if ((Object)(object)a == (Object)(object)b) { enemy = false; } else if (!flag2) { enemy = num != num2; } return true; } public static bool HasExplicitRelation(Character a, Character b) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected I4, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected I4, but got Unknown //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) if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null) { return false; } Init(); int num = (int)a.m_faction; int num2 = (int)b.m_faction; if (RelationIds.ContainsKey(PairKey(num, num2))) { return true; } return (!ById.ContainsKey(num) || !ById.ContainsKey(num2)) && Relations.ContainsKey(Key(GetFactionName(a.m_faction), GetFactionName(b.m_faction))); } public static bool IsCustomFaction(Faction faction) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown Init(); return ExplicitCustomIds.Contains((int)faction); } private static ulong PairKey(int first, int second) { return ((ulong)(uint)first << 32) | (uint)second; } private static bool TryResolveId(string faction, out int id) { id = 0; if (string.IsNullOrEmpty(faction)) { return false; } if (ByName.TryGetValue(faction, out var value)) { id = value.ID; return true; } return int.TryParse(faction, out id); } private static void RebuildRelationIds() { RelationIds.Clear(); foreach (KeyValuePair<string, bool> relation in Relations) { int num = relation.Key.IndexOf("->", StringComparison.Ordinal); if (num >= 0 && TryResolveId(relation.Key.Substring(0, num), out var id) && TryResolveId(relation.Key.Substring(num + 2), out var id2)) { RelationIds[PairKey(id, id2)] = relation.Value; } } } private unsafe static void RegisterVanillaFactions() { //IL_0038: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown if (_vanillaRegistered) { return; } _vanillaRegistered = true; Array values = Enum.GetValues(typeof(Faction)); foreach (object item in values) { Faction val = (Faction)item; FactionDefinition factionDefinition = new FactionDefinition { ID = (int)val, Name = ((object)(*(Faction*)(&val))/*cast due to .constrained prefix*/).ToString() }; ByName[factionDefinition.Name] = factionDefinition; ById[factionDefinition.ID] = factionDefinition; } RebuildRelationIds(); } private static string Key(string a, string b) { return a + "->" + b; } } [HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[] { typeof(Character), typeof(Character) })] public static class BaseAI_IsEnemy_CustomFactionPatch { private static bool Prefix(Character a, Character b, ref bool __result) { if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null) { return true; } if (CustomFactionRegistry.TryResolveEnemyOverride(a, b, out __result)) { return false; } return true; } } namespace BalrondMonsterMayhem { public class BalrondTranslator { public static Dictionary<string, Dictionary<string, string>> translations = new Dictionary<string, Dictionary<string, string>>(); public static Dictionary<string, string> getLanguage(string language) { Dictionary<string, string> value; return (language != null && translations.TryGetValue(language, out value)) ? value : null; } } internal static class ProceduralMinibossService { internal const string SchemaKey = "BMM_MiniSchema"; internal const string TypeKey = "BMM_MiniType"; internal const string NameKey = "BMM_MiniName"; internal const string LevelKey = "BMM_MiniLevel"; internal const string SecondaryMutationKey = "BMM_MiniMut2Type"; internal const string SecondaryResistanceKey = "BMM_MiniMut2Resist"; internal const string SecondaryMutationSchemaKey = "BMM_MiniMut2Schema"; internal const int MaximumPromotedLevel = 7; internal const string DungeonScaleKey = "BMM_MiniDungeonScale"; internal const float DungeonAltitude = 2000f; internal const string BaseHpKey = "BMM_MiniBaseHP"; internal const string ScaledHpKey = "BMM_MiniScaledHP"; private static string _lastAllowlist; private static readonly HashSet<string> Allowed = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, string[]> Forenames = new Dictionary<string, string[]>(StringComparer.Ordinal) { { "Troll", new string[12] { "Bouldermaw", "Grumrock", "Hrokk", "Cragtooth", "Ulgor", "Stonebelly", "Brakk", "Mossback", "Dungr", "Rockhide", "Throm", "Graveljaw" } }, { "Greydwarf", new string[12] { "Thornroot", "Gnarlsap", "Briarspite", "Murkbranch", "Bogknuckle", "Rotthorn", "Mossfang", "Splinterjaw", "Rootgnash", "Hollowbark", "Sapgrin", "Bramblemaw" } }, { "Undead", new string[12] { "Vargoth", "Morthan", "Draugmir", "Skaldr", "Nekros", "Graveborn", "Ossigar", "Veldran", "Mournak", "Karvoss", "Dolmirk", "Ashwight" } }, { "Goblin", new string[12] { "Grik", "Snagga", "Urkash", "Grombit", "Vrek", "Snikrot", "Grubzag", "Narguk", "Brakka", "Skrit", "Zogrin", "Rukka" } }, { "Bear", new string[12] { "Ironpaw", "Brumclaw", "Frostsnout", "Grizzlemane", "Mossfur", "Rumblehide", "Boulderclaw", "Ashpaw", "Snowmaw", "Thornback", "Growlmaw", "Stormfur" } }, { "Serpent", new string[12] { "Tidemaw", "Deepcoil", "Stormscale", "Saltfang", "Blackfin", "Brinefang", "Wavebreaker", "Coldcoil", "Seamurk", "Undertow", "Drownscale", "Riftfin" } }, { "Golem", new string[12] { "Flintheart", "Obsidian", "Shardback", "Basalt", "Crystalfist", "Granite", "Rimecore", "Ironshard", "Stonepulse", "Rubblefist", "Quartz", "Mountainheart" } }, { "Seeker", new string[12] { "Chittermaw", "Huskfang", "Carapax", "Skitterclaw", "Mandibrix", "Broodcarver", "Razorhusk", "Spineclick", "Shellrend", "Clackthorn", "Voidmandible", "Grindwing" } }, { "Fenring", new string[12] { "Moonfang", "Nighthowl", "Frostpelt", "Duskclaw", "Wolfsbane", "Greyhowl", "Rimefang", "Darkmane", "Bloodmoon", "Shadowpelt", "Winterjaw", "Nightmaw" } }, { "Abomination", new string[12] { "Rotwillow", "Gravebough", "Bogheart", "Witchroot", "Drownbark", "Sourwood", "Duskroot", "Hollowtrunk", "Wraithwood", "Siltbranch", "Fenbough", "Blightroot" } }, { "Skeleton", new string[12] { "Rattlejaw", "Graveknell", "Knucklebone", "Boneclatter", "Skullgrin", "Marrowfang", "Dustknight", "Ribcage", "Grimskull", "Ossik", "Bonechill", "Cinderbone" } }, { "Draugr", new string[12] { "Varkul", "Draugmir", "Rothelm", "Voldr", "Mournblade", "Bogwight", "Mirethane", "Deadhand", "Fenroth", "Dreadmourn", "Rustjaw", "Nekvar" } }, { "UndeadTroll", new string[12] { "Graveboulder", "Rotcrusher", "Boneback", "Tombgrum", "Corpsecliff", "Deadrock", "Mossgrave", "Sundermaw", "Tombhide", "Cryptbelly", "Gravejaw", "Rotmaul" } }, { "GoblinShaman", new string[12] { "Hexgrik", "Ashchant", "Rituk", "Sporeseer", "Cinderzog", "Totembit", "Murkhex", "Grimshruk", "Skritseer", "Nargspell", "Runek", "Shamruk" } }, { "Wraith", new string[8] { "Duskwisp", "Nightshroud", "Veilshade", "Hollowmist", "Blackveil", "Ebonhaze", "Whisperfog", "Soulgloom" } }, { "GreydwarfShaman", new string[8] { "Briarhex", "Rootsayer", "Sporechant", "Thornwhisper", "Saporacle", "Runebark", "Rotseer", "Mosshex" } }, { "Drake", new string[8] { "Frostpinion", "Glacierwing", "Rimebeak", "Snowtalon", "Icecrest", "Windclaw", "Hailfeather", "Winterwing" } }, { "Wolf", new string[8] { "Greyfang", "Nightpelt", "Frostjaw", "Ashfur", "Howlback", "Whiteclaw", "Stormmuzzle", "Ironfang" } }, { "Ulv", new string[8] { "Moonmaw", "Bonepelt", "Howlgrin", "Nightmauler", "Clawscar", "Duskhowl", "Ribfang", "Grimmuzzle" } }, { "FenringCultist", new string[8] { "Ashmask", "Bloodchant", "Moonritual", "Hexhowl", "Fangpriest", "Cinderpelt", "Smokechant", "Runefang" } }, { "Bird", new string[8] { "Skyreaver", "Stormbeak", "Ironpinion", "Cloudtalon", "Hailwing", "Sunpiercer", "Bonefeather", "Windripper" } }, { "Frog", new string[8] { "Bogcroak", "Mudgullet", "Slimeback", "Riverjaw", "Mireleap", "Reedthroat", "Fenbelly", "Marshhop" } }, { "CorpseCollector", new string[8] { "Gravesack", "Corpsegrip", "Bonehauler", "Rotcarrier", "Mournpack", "Grimcollector", "Deadweight", "Tombdrag" } }, { "Valkyrie", new string[8] { "Dreadwing", "Cinderspear", "Ashenplume", "Ruinfeather", "Emberhelm", "Flamepinion", "Ashlance", "Pyretalon" } }, { "Lox", new string[8] { "Thunderhide", "Stonehorn", "Mossmane", "Gravelback", "Marshhorn", "Thickhide", "Duskhoof", "Ironbrow" } }, { "Asksvin", new string[8] { "Ashtusk", "Coalhide", "Cinderhoof", "Flameridge", "Emberjaw", "Brimstoneback", "Charhorn", "Scorchhide" } }, { "CharredTwitcher", new string[8] { "Cinderjerk", "Ashspasm", "Emberlimb", "Flinchbone", "Coalshiver", "Sootrattle", "Scorchtwitch", "Charclack" } }, { "CharredMage", new string[8] { "Pyrehex", "Ashbinder", "Emberseer", "Flamechant", "Cinderoracle", "Sootweaver", "Charspell", "Blazewight" } }, { "CharredWarrior", new string[8] { "Coalblade", "Ashcleaver", "Emberfist", "Charshield", "Cindermaul", "Pyrehelm", "Sootsteel", "Scorchbrand" } }, { "Other", new string[12] { "Blackthorn", "Duskrend", "Ironbane", "Grimclaw", "Riftborn", "Ashfang", "Moonrend", "Nightfall", "Shadowmaw", "Thunderspine", "Bloodscar", "Frostbane" } } }; private static readonly Dictionary<string, string[]> Epithets = new Dictionary<string, string[]>(StringComparer.Ordinal) { { "Troll", new string[8] { "the Cliffbreaker", "the Cave Tyrant", "the Mountain Crusher", "the Rock-Eater", "the Bridgebreaker", "the Hillshaker", "the Boulder King", "the Stonebreaker" } }, { "Greydwarf", new string[8] { "of the Rotten Grove", "the Root-Eater", "the Thornbound", "of the Hollow Trees", "the Sapdrinker", "the Briar Lord", "the Moss-Crowned", "the Blighted" } }, { "Undead", new string[8] { "the Unburied", "the Gravebound", "the Restless", "the Hollow", "the Bonekeeper", "the Deathless", "the Tombwarden", "the Forsaken" } }, { "Goblin", new string[8] { "the Bonechewer", "the Campbreaker", "the Warcaller", "the Cruel", "the Skullsmasher", "the Torchbearer", "the Plunderer", "the Blacktooth" } }, { "Bear", new string[8] { "the Ancient", "the Denkeeper", "the Bear of Winter", "the Ravager", "the Great-Hided", "the Fierce", "the Old Hunter", "the Unbroken" } }, { "Serpent", new string[8] { "of the Black Depths", "the Shipbreaker", "the Drowned", "the Wave-Tyrant", "the Abyssal", "the Stormborn", "of the Deep Current", "the Tidehunter" } }, { "Golem", new string[8] { "the Unmoving", "of the Old Peaks", "the Shardforged", "the Living Mountain", "the Crystalbound", "the Unyielding", "the Stone Sentinel", "the Ancient Core" } }, { "Seeker", new string[8] { "the Swarm-Herald", "the Hiveborn", "the Broodguard", "the Carapaced", "the Eggbreaker", "the Relentless", "the Burrower", "the Acid-Mandibled" } }, { "Fenring", new string[8] { "of the Pale Moon", "the Night Hunter", "the Howler", "the Blood-Fanged", "the Rime Stalker", "the Moon-Cursed", "the Winter Hunter", "the Feral" } }, { "Abomination", new string[8] { "of the Deep Mire", "the Rootbound", "the Drowned Tree", "the Rotting One", "the Marsh Horror", "the Bog Walker", "the Spore-Ridden", "the Withered" } }, { "Skeleton", new string[8] { "the Bone Rattler", "of the Forgotten Crypt", "the Tomb Sentinel", "the Ossuary Guard", "the Dust-Crowned", "the Marrow Knight", "the Grave Watcher", "the Hollow Skull" } }, { "Draugr", new string[8] { "the Rotting", "the Drowned Warrior", "of the Sunken Crypt", "the Swamp Reaver", "the Grave-Marked", "the Rusted Blade", "the Restless Warrior", "the Bog-Cursed" } }, { "UndeadTroll", new string[8] { "the Grave Colossus", "the Cryptbreaker", "the Dead Hill", "the Tombcrusher", "the Bone-Heavy", "the Buried Giant", "the Rotting Mountain", "the Barrow Tyrant" } }, { "GoblinShaman", new string[8] { "the Hexcaller", "the Fire Seer", "the Bone Oracle", "the Totem Keeper", "the Spirit Whisperer", "the Rune-Cursed", "the Ash Prophet", "the Cinder Witch" } }, { "Wraith", new string[8] { "the Veiled", "the Dread Whisper", "of the Lost Marsh", "the Unseen", "the Silent Harbinger", "of the Fog", "the Lifedrinker", "the Lanternless" } }, { "GreydwarfShaman", new string[8] { "the Rootcaller", "the Grove Witch", "the Blight Seer", "the Bark Oracle", "the Spore Speaker", "the Thornbinder", "the Seed Keeper", "the Rotshaman" } }, { "Drake", new string[8] { "of the Frozen Peaks", "the Stormwing", "the Shardbreather", "the Ice Howler", "the Rime Hunter", "the Cloudpiercer", "the Hoarfrost", "the Blizzard Eye" } }, { "Wolf", new string[8] { "the Packbreaker", "the Silent Tracker", "the Winter Fang", "the Den Hunter", "the Red-Eyed", "the Frost Runner", "the Lone Howl", "the Pale Hunter" } }, { "Ulv", new string[8] { "the Moon-Cursed", "the Savage", "the Ravener", "the Bloodtrail", "the Night Stalker", "the Fang-Lord", "the Dark Howler", "the Pit Hunter" } }, { "FenringCultist", new string[8] { "the Fire Cultist", "the Moon Prophet", "the Red Ritualist", "the Bone Speaker", "the Ashbound", "the Blood Summoner", "the Cinder Priest", "the Flame Devotee" } }, { "Bird", new string[8] { "the High Hunter", "the Sky Tyrant", "the Windbreaker", "of the Sunlit Plains", "the Storm Rider", "the Talon King", "the Cliff Sentinel", "the Gale Harrier" } }, { "Frog", new string[8] { "the Marsh Lurker", "the Bog Jumper", "the Mire Prince", "the Reed Eater", "the Croaking Horror", "the Swamp Skipper", "the Mud-Crowned", "the Pond Tyrant" } }, { "CorpseCollector", new string[8] { "the Gatherer", "the Body Thief", "the Grave Hoarder", "the Carrion Bearer", "the Crypt Scavenger", "the Flesh Collector", "the Tomb Carrier", "the Unburied" } }, { "Valkyrie", new string[8] { "the Fallen Herald", "the Ember-Winged", "the Ashen Judge", "the Flamebearer", "the Ruined Shieldmaiden", "the Scorched", "the Sky Reaper", "the Burning Oath" } }, { "Lox", new string[8] { "the Plains Titan", "the Hillcrusher", "the Ancient Grazer", "the Great-Horned", "the Grassland Behemoth", "the Rolling Boulder", "the Dust Stomper", "the Untamed" } }, { "Asksvin", new string[8] { "the Lava Runner", "the Ashland Tusker", "the Furnace-Born", "the Fire Grazer", "the Basalt Breaker", "the Ember Charge", "the Molten Hide", "the Charred Beast" } }, { "CharredTwitcher", new string[8] { "the Restless Ash", "the Skittering Dead", "the Ember-Bitten", "the Cinder Crawler", "the Burned Bones", "the Ashbound", "the Blackened", "the Writhing" } }, { "CharredMage", new string[8] { "the Furnace Sage", "the Pyre Caller", "the Cinder Witch", "the Ash Conjurer", "the Ember Prophet", "the Flame Herald", "the Blackened Seer", "the Burning Rune" } }, { "CharredWarrior", new string[8] { "the Ashen Vanguard", "the Charred Blade", "the Pyre Sentinel", "the Burning Warrior", "the Blackened Guard", "the Ember Champion", "the Cinder Soldier", "the Scorched Knight" } }, { "Other", new string[8] { "the Ancient", "the Relentless", "the Unbroken", "the Feral", "of the Wilds", "the Scarred", "the Ruthless", "the Devourer" } } }; internal static float ExtraVisualFactor { get { float num = ((MonsterMayhemConfig.MinibossExtraVisualScalePercent != null) ? MonsterMayhemConfig.MinibossExtraVisualScalePercent.Value : 25f); return 1f + Mathf.Clamp(num, 0f, 50f) / 100f; } } internal static bool Enabled => MonsterMayhemConfig.EnableProceduralMinibosses != null && MonsterMayhemConfig.EnableProceduralMinibosses.Value; internal static int CalculatePromotedLevel(int originalLevel) { return Mathf.Min(7, Mathf.Max(1, originalLevel) + 3); } internal static float GetPromotionChance01(int level) { if (level < 2) { return 0f; } float num = ((MonsterMayhemConfig.MinibossChancePercent != null) ? MonsterMayhemConfig.MinibossChancePercent.Value : 1f); return Mathf.Clamp01(Mathf.Max(0f, num) * (float)(level - 1) / 100f); } internal static bool IsDungeonHeight(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return position.y >= 2000f; } internal static string NameFamily(string prefabId) { string text = prefabId ?? string.Empty; if (text.IndexOf("Troll", StringComparison.OrdinalIgnoreCase) >= 0 && text.IndexOf("Undead", StringComparison.OrdinalIgnoreCase) >= 0) { return "UndeadTroll"; } if (text.IndexOf("Troll", StringComparison.OrdinalIgnoreCase) >= 0) { return "Troll"; } if (text.IndexOf("Greydwarf", StringComparison.OrdinalIgnoreCase) >= 0 && text.IndexOf("Shaman", StringComparison.OrdinalIgnoreCase) >= 0) { return "GreydwarfShaman"; } if (text.IndexOf("Greydwarf", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Greyling", StringComparison.OrdinalIgnoreCase) >= 0) { return "Greydwarf"; } if (text.IndexOf("Draugr", StringComparison.OrdinalIgnoreCase) >= 0) { return "Draugr"; } if (text.IndexOf("Skeleton", StringComparison.OrdinalIgnoreCase) >= 0) { return "Skeleton"; } if (text.IndexOf("Undead", StringComparison.OrdinalIgnoreCase) >= 0) { return "Undead"; } if ((text.IndexOf("Goblin", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Fuling", StringComparison.OrdinalIgnoreCase) >= 0) && text.IndexOf("Shaman", StringComparison.OrdinalIgnoreCase) >= 0) { return "GoblinShaman"; } if (text.IndexOf("Goblin", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Fuling", StringComparison.OrdinalIgnoreCase) >= 0) { return "Goblin"; } if (text.IndexOf("Bjorn", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Bear", StringComparison.OrdinalIgnoreCase) >= 0) { return "Bear"; } if (text.IndexOf("Serpent", StringComparison.OrdinalIgnoreCase) >= 0) { return "Serpent"; } if (text.IndexOf("Golem", StringComparison.OrdinalIgnoreCase) >= 0) { return "Golem"; } if (text.IndexOf("Seeker", StringComparison.OrdinalIgnoreCase) >= 0) { return "Seeker"; } if (text.IndexOf("Fenring", StringComparison.OrdinalIgnoreCase) >= 0 && text.IndexOf("Cultist", StringComparison.OrdinalIgnoreCase) >= 0) { return "FenringCultist"; } if (text.Equals("Ulv", StringComparison.OrdinalIgnoreCase)) { return "Ulv"; } if (text.Equals("Wolf", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Wolf_", StringComparison.OrdinalIgnoreCase)) { return "Wolf"; } if (text.IndexOf("Fenring", StringComparison.OrdinalIgnoreCase) >= 0) { return "Fenring"; } if (text.IndexOf("Abomination", StringComparison.OrdinalIgnoreCase) >= 0) { return "Abomination"; } if (text.IndexOf("Wraith", StringComparison.OrdinalIgnoreCase) >= 0) { return "Wraith"; } if (text.Equals("Hatchling", StringComparison.OrdinalIgnoreCase) || text.IndexOf("Drake", StringComparison.OrdinalIgnoreCase) >= 0) { return "Drake"; } if (text.IndexOf("Habrok", StringComparison.OrdinalIgnoreCase) >= 0) { return "Bird"; } if (text.IndexOf("Frog", StringComparison.OrdinalIgnoreCase) >= 0) { return "Frog"; } if (text.IndexOf("CorpseCollector", StringComparison.OrdinalIgnoreCase) >= 0) { return "CorpseCollector"; } if (text.IndexOf("Valkyrie", StringComparison.OrdinalIgnoreCase) >= 0) { return "Valkyrie"; } if (text.Equals("Lox", StringComparison.OrdinalIgnoreCase)) { return "Lox"; } if (text.IndexOf("Asksvin", StringComparison.OrdinalIgnoreCase) >= 0) { return "Asksvin"; } if (text.IndexOf("Charred_Twitcher", StringComparison.OrdinalIgnoreCase) >= 0) { return "CharredTwitcher"; } if (text.IndexOf("Charred_Mage", StringComparison.OrdinalIgnoreCase) >= 0) { return "CharredMage"; } if (text.IndexOf("Charred_Melee", StringComparison.OrdinalIgnoreCase) >= 0) { return "CharredWarrior"; } return "Other"; } internal static void Reset() { Allowed.Clear(); _lastAllowlist = null; } internal static bool ShouldAttachRuntime(Character character) { if ((Object)(object)character == (Object)null || character is Player || OdinHorseCompatibility.OwnsCreature(((Component)character).gameObject)) { return false; } string prefabId = MinorMutationService.GetPrefabId(character); if (string.IsNullOrEmpty(prefabId) || prefabId.StartsWith("FrozenKing", StringComparison.OrdinalIgnoreCase)) { return false; } if (IsMiniboss(character)) { return (Object)(object)((Component)character).GetComponent<MonsterAI>() != (Object)null; } if (!Enabled) { return false; } RefreshAllowlist(); return Allowed.Contains(prefabId) && (Object)(object)((Component)character).GetComponent<MonsterAI>() != (Object)null; } internal static bool IsOutsideCenterSafeZone(Vector3 position) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) float num = ((MonsterMayhemConfig.MinibossMinimumDistanceFromCenter != null) ? MonsterMayhemConfig.MinibossMinimumDistanceFromCenter.Value : 1000f); num = Mathf.Max(0f, num); return position.x * position.x + position.z * position.z >= num * num; } internal static List<string> GetConfiguredPrefabIds() { RefreshAllowlist(); List<string> list = new List<string>(Allowed); list.Sort(StringComparer.OrdinalIgnoreCase); return list; } internal static bool IsConfiguredPrefabId(string prefabId) { if (string.IsNullOrEmpty(prefabId)) { return false; } RefreshAllowlist(); return Allowed.Contains(prefabId); } internal static bool TryForcePromoteForDebug(Character character, out string reason) { reason = "Unable to make miniboss."; if ((Object)(object)character == (Object)null || character.IsPlayer() || character.IsBoss() || character.IsDead() || character.IsTamed() || OdinHorseCompatibility.OwnsCreature(((Component)character).gameObject)) { return false; } string prefabId = MinorMutationService.GetPrefabId(character); if (!IsConfiguredPrefabId(prefabId) || prefabId.StartsWith("FrozenKing", StringComparison.OrdinalIgnoreCase)) { return false; } if (CreatureRoleRegistry.Resolve(prefabId, character) != CreatureRole.WorldCreature || MinorMutationService.IsExcluded(prefabId)) { return false; } MonsterAI component = ((Component)character).GetComponent<MonsterAI>(); if ((Object)(object)component == (Object)null || component.IsEventCreature() || ((BaseAI)component).HuntPlayer()) { return false; } Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Character)val).m_defeatSetGlobalKey)) { return false; } ZNetView nview = character.m_nview; if ((Object)(object)nview == (Object)null || !nview.IsValid() || !nview.IsOwner()) { reason = "Unable to make miniboss: the newly spawned creature has no local ZDO authority."; return false; } ZDO zDO = nview.GetZDO(); if (zDO == null || zDO.GetInt("BMM_MiniSchema", 0) != 0) { return false; } if (character.GetLevel() < 2) { character.SetLevel(2); } if (!TryCommitOwnerPromotion(character, zDO)) { reason = "Unable to make miniboss: no valid mandatory mutation is available."; return false; } zDO.Set("BMM_MiniSchema", 1); ProceduralMinibossRuntime proceduralMinibossRuntime = ((Component)character).GetComponent<ProceduralMinibossRuntime>(); if ((Object)(object)proceduralMinibossRuntime == (Object)null) { proceduralMinibossRuntime = ((Component)character).gameObject.AddComponent<ProceduralMinibossRuntime>(); } if ((Object)(object)proceduralMinibossRuntime != (Object)null) { proceduralMinibossRuntime.ApplyPromotedStateNow(); } if (!IsMiniboss(character)) { return false; } reason = "Spawned miniboss " + GetName(character) + " (" + prefabId + ", level " + zDO.GetInt("BMM_MiniLevel", 1) + ", two mutations)."; return true; } internal static bool TryCommitOwnerPromotion(Character character, ZDO zdo) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || zdo == null) { return false; } MinorMutationType mutation = (MinorMutationType)zdo.GetInt("BMM_MutType", 0); MinorMutationResistance resistance = (MinorMutationResistance)zdo.GetInt("BMM_MutResist", 0); if (mutation == MinorMutationType.None && !MinorMutationService.TryChooseMutation(character, out mutation, out resistance)) { return false; } if (!MinorMutationService.TryChooseMutation(character, mutation, out var mutation2, out var resistance2)) { return false; } int num = CalculatePromotedLevel(character.GetLevel()); zdo.Set("BMM_MutType", (int)mutation); zdo.Set("BMM_MutResist", (int)resistance); zdo.Set("BMM_MutLevel", num); zdo.Set("BMM_MutChance", 1f); zdo.Set("BMM_MutSchema", 1); zdo.Set("BMM_MiniMut2Type", (int)mutation2); zdo.Set("BMM_MiniMut2Resist", (int)resistance2); zdo.Set("BMM_MiniMut2Schema", 1); zdo.Set("BMM_MiniName", RollName(MinorMutationService.GetPrefabId(character))); zdo.Set("BMM_MiniLevel", num); zdo.Set("BMM_MiniDungeonScale", IsDungeonHeight(((Component)character).transform.position) ? 1 : 0); zdo.Set("BMM_MiniType", 1); return true; } internal static void EnsureSecondMutation(ZDO zdo, Character creature) { if (zdo != null && !((Object)(object)creature == (Object)null) && zdo.GetInt("BMM_MiniMut2Schema", 0) == 0) { MinorMutationType minorMutationType = (MinorMutationType)zdo.GetInt("BMM_MutType", 0); if (minorMutationType != MinorMutationType.None && MinorMutationService.TryChooseMutation(creature, minorMutationType, out var mutation, out var resistance)) { zdo.Set("BMM_MiniMut2Type", (int)mutation); zdo.Set("BMM_MiniMut2Resist", (int)resistance); zdo.Set("BMM_MiniMut2Schema", 1); } } } internal static bool IsEligible(Character character) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || character.IsPlayer() || character.IsBoss() || character.IsTamed() || character.IsDead() || OdinHorseCompatibility.OwnsCreature(((Component)character).gameObject)) { return false; } string prefabId = MinorMutationService.GetPrefabId(character); if (string.IsNullOrEmpty(prefabId) || prefabId.StartsWith("FrozenKing", StringComparison.OrdinalIgnoreCase)) { return false; } if (CreatureRoleRegistry.Resolve(prefabId, character) != CreatureRole.WorldCreature || MinorMutationService.IsExcluded(prefabId) || !IsOutsideCenterSafeZone(((Component)character).transform.position)) { return false; } MonsterAI component = ((Component)character).GetComponent<MonsterAI>(); if ((Object)(object)component == (Object)null || component.IsEventCreature() || ((BaseAI)component).HuntPlayer()) { return false; } Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Character)val).m_defeatSetGlobalKey)) { return false; } RefreshAllowlist(); return Allowed.Contains(prefabId); } private static void RefreshAllowlist() { string text = ((MonsterMayhemConfig.MinibossPrefabIds != null) ? MonsterMayhemConfig.MinibossPrefabIds.Value : ""); if (string.Equals(text, _lastAllowlist, StringComparison.Ordinal)) { return; } Allowed.Clear(); string[] array = text.Split(new char[1] { ',' }); foreach (string text2 in array) { string text3 = text2.Trim(); if (text3.Length > 0 && text3.Length < 100) { Allowed.Add(text3); } } _lastAllowlist = text; } internal static bool IsMiniboss(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.m_nview == (Object)null || !character.m_nview.IsValid()) { return false; } ZDO zDO = character.m_nview.GetZDO(); return zDO != null && zDO.GetInt("BMM_MiniSchema", 0) == 1 && zDO.GetInt("BMM_MiniType", 0) == 1; } internal static string GetName(Character character) { if (!IsMiniboss(character)) { return null; } ZDO zDO = character.m_nview.GetZDO(); return (zDO != null) ? zDO.GetString("BMM_MiniName", "") : null; } private static bool NameOverlaps(string name, string title) { string text = name.ToLowerInvariant(); string text2 = title.ToLowerInvariant(); for (int i = 0; i + 5 <= text.Length; i++) { if (text2.Contains(text.Substring(i, 5))) { return true; } } string[][] array = new string[6][] { new string[3] { "grave", "tomb", "crypt" }, new string[4] { "frost", "rime", "ice", "winter" }, new string[3] { "bone", "skull", "marrow" }, new string[3] { "rot", "corpse", "dead" }, new string[3] { "storm", "thunder", "lightning" }, new string[4] { "flame", "fire", "cinder", "ember" } }; string[][] array2 = array; foreach (string[] array3 in array2) { bool flag = false; bool flag2 = false; string[] array4 = array3; foreach (string value in array4) { flag |= text.Contains(value); flag2 |= text2.Contains(value); } if (flag && flag2) { return true; } } return false; } internal static bool HasNearbyMiniboss(Character self) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) float num = ((MonsterMayhemConfig.MinibossMinimumSeparation != null) ? MonsterMayhemConfig.MinibossMinimumSeparation.Value : 80f); float num2 = num * num; List<BaseAI> instances = BaseAI.m_instances; for (int i = 0; i < instances.Count; i++) { BaseAI val = instances[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.m_character == (Object)null) && !((Object)(object)val.m_character == (Object)(object)self) && !val.m_character.IsDead()) { Vector3 val2 = ((Component)val.m_character).transform.position - ((Component)self).transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > num2) && IsMiniboss(val.m_character)) { return true; } } } return false; } internal static string RollName(string prefabId) { string key = NameFamily(prefabId); string[] array = Forenames[key]; string[] array2 = Epithets[key]; string text = array[Random.Range(0, array.Length)]; int num = Random.Range(0, array2.Length); string text2 = array2[num]; for (int i = 0; i < array2.Length; i++) { string text3 = array2[(num + i) % array2.Length]; if (!NameOverlaps(text, text3)) { text2 = text3; break; } } return text + " " + text2; } } internal sealed class ProceduralMinibossRuntime : MonoBehaviour { private struct VisualScaleSnapshot { internal Vector3 NativeScale; internal Vector3 AppliedScale; internal float AppliedFactor; } private Character _character; private ZNetView _view; private readonly Dictionary<Transform, VisualScaleSnapshot> _visualScales = new Dictionary<Transform, VisualScaleSnapshot>(); private bool _rollAttempted; private bool _corpseCollectorVisualChecked; private void Awake() { _character = ((Component)this).GetComponent<Character>(); _view = ((Component)this).GetComponent<ZNetView>(); } private void OnEnable() { float num = 0.8f + Mathf.Repeat((float)Mathf.Abs(((Object)this).GetInstanceID()) * 0.0031f, 1f); ((MonoBehaviour)this).InvokeRepeating("CheckOwnerState", num, 3f); } private void OnDisable() { ((MonoBehaviour)this).CancelInvoke("CheckOwnerState"); } private void OnDestroy() { ((MonoBehaviour)this).CancelInvoke("CheckOwnerState"); } private void CheckOwnerState() { //IL_0267: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character == (Object)null || (Object)(object)_view == (Object)null || !_view.IsValid()) { return; } ZDO zDO = _view.GetZDO(); if (zDO == null || (!ProceduralMinibossService.IsMiniboss(_character) && !ProceduralMinibossService.Enabled)) { return; } if (_view.IsOwner() && zDO.GetInt("BMM_MiniSchema", 0) == 0 && !_rollAttempted) { _rollAttempted = true; if (!ProceduralMinibossService.IsEligible(_character)) { zDO.Set("BMM_MiniType", 0); zDO.Set("BMM_MiniSchema", 1); ((MonoBehaviour)this).CancelInvoke("CheckOwnerState"); return; } int num = ((MonsterMayhemConfig.MinibossMinLevel != null) ? MonsterMayhemConfig.MinibossMinLevel.Value : 2); int level = _character.GetLevel(); bool flag = level >= Mathf.Max(2, num) && Random.value < ProceduralMinibossService.GetPromotionChance01(level); if (flag && ProceduralMinibossService.HasNearbyMiniboss(_character)) { flag = false; } if (flag) { flag = ProceduralMinibossService.TryCommitOwnerPromotion(_character, zDO); } if (!flag) { zDO.Set("BMM_MiniType", 0); } zDO.Set("BMM_MiniSchema", 1); } if (!ProceduralMinibossService.IsMiniboss(_character)) { if (zDO.GetInt("BMM_MiniSchema", 0) > 0) { ((MonoBehaviour)this).CancelInvoke("CheckOwnerState"); } return; } _character.m_boss = true; if (_view.IsOwner()) { int num2 = Mathf.Clamp(zDO.GetInt("BMM_MiniLevel", 5), 1, 7); if (_character.GetLevel() != num2) { _character.SetLevel(num2); } ProceduralMinibossService.EnsureSecondMutation(zDO, _character); } DisableTamingAndFear(); if (zDO.GetInt("BMM_MiniDungeonScale", -1) < 0 && _view.IsOwner()) { zDO.Set("BMM_MiniDungeonScale", ProceduralMinibossService.IsDungeonHeight(((Component)_character).transform.position) ? 1 : 0); } ApplyVisualScale(zDO); RepairCorpseCollectorVisualIfLost(); MinorMutationRuntime minorMutationRuntime = ((Component)this).GetComponent<MinorMutationRuntime>(); if ((Object)(object)minorMutationRuntime == (Object)null) { minorMutationRuntime = ((Component)this).gameObject.AddComponent<MinorMutationRuntime>(); } minorMutationRuntime.EnsureForcedMinibossMutation(); } private void DisableTamingAndFear() { Tameable component = ((Component)this).GetComponent<Tameable>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; component.m_commandable = false; AnimalFeedRuntime.CancelPendingRequest(component); Object.Destroy((Object)(object)component); } Procreation component2 = ((Component)this).GetComponent<Procreation>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; Object.Destroy((Object)(object)component2); } TamedStanceController component3 = ((Component)this).GetComponent<TamedStanceController>(); if ((Object)(object)component3 != (Object)null) { ((Behaviour)component3).enabled = false; Object.Destroy((Object)(object)component3); } TamedStanceRpc component4 = ((Component)this).GetComponent<TamedStanceRpc>(); if ((Object)(object)component4 != (Object)null) { ((Behaviour)component4).enabled = false; Object.Destroy((Object)(object)component4); } AnimalFeedingBehaviour component5 = ((Component)this).GetComponent<AnimalFeedingBehaviour>(); if ((Object)(object)component5 != (Object)null) { ((Behaviour)component5).enabled = false; Object.Destroy((Object)(object)component5); } AnimalAiGroundFeedingBehaviour component6 = ((Component)this).GetComponent<AnimalAiGroundFeedingBehaviour>(); if ((Object)(object)component6 != (Object)null) { ((Behaviour)component6).enabled = false; Object.Destroy((Object)(object)component6); } JuvenileGrowthPauseRpc component7 = ((Component)this).GetComponent<JuvenileGrowthPauseRpc>(); if ((Object)(object)component7 != (Object)null) { ((Behaviour)component7).enabled = false; Object.Destroy((Object)(object)component7); } MonsterAI component8 = ((Component)this).GetComponent<MonsterAI>(); if ((Object)(object)component8 != (Object)null && _view.IsOwner()) { component8.m_fleeIfLowHealth = 0f; component8.m_fleeIfHurtWhenTargetCantBeReached = false; component8.m_fleeIfNotAlerted = false; ((BaseAI)component8).m_afraidOfFire = false; ((BaseAI)component8).m_avoidFire = false; } } internal void ApplyPromotedStateNow() { CheckOwnerState(); } internal void OnLevelEffectsApplied(Transform levelEffectTransform) { if (!((Object)(object)_character == (Object)null) && !((Object)(object)_view == (Object)null) && _view.IsValid() && ProceduralMinibossService.IsMiniboss(_character)) { ZDO zDO = _view.GetZDO(); if (zDO != null && zDO.GetInt("BMM_MiniDungeonScale", -1) >= 0) { ApplyScaleToNode(zDO, levelEffectTransform); } } } private void ApplyVisualScale(ZDO zdo) { if (zdo == null || zdo.GetInt("BMM_MiniDungeonScale", -1) < 0) { return; } Transform val = ((Component)this).transform.Find("Visual"); if ((Object)(object)val == (Object)null) { return; } LevelEffects[] componentsInChildren = ((Component)val).GetComponentsInChildren<LevelEffects>(true); bool flag = false; foreach (LevelEffects val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { flag = true; ApplyScaleToNode(zdo, ((Component)val2).transform); } } if (!flag) { ApplyScaleToNode(zdo, val); } } private static bool Approximately(Vector3 a, Vector3 b) { //IL_0001: 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_001a: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(a.x - b.x) < 0.0001f && Mathf.Abs(a.y - b.y) < 0.0001f && Mathf.Abs(a.z - b.z) < 0.0001f; } private Transform FindTemplateNode(Transform instanceNode) { if ((Object)(object)_character == (Object)null || (Object)(object)instanceNode == (Object)null) { return null; } string prefabId = MinorMutationService.GetPrefabId(_character); GameObject val = RuntimePrefabRegistry.FindExact(prefabId); if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)((Component)_character).gameObject) { return null; } List<string> list = new List<string>(); Transform val2 = instanceNode; while ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)((Component)this).transform) { list.Add(((Object)val2).name); val2 = val2.parent; } if ((Object)(object)val2 != (Object)(object)((Component)this).transform || list.Count == 0) { return null; } list.Reverse(); return val.transform.Find(string.Join("/", list.ToArray())); } private void ApplyScaleToNode(ZDO zdo, Transform node) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_015b: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) if ((Object)(object)node == (Object)null || zdo == null || zdo.GetInt("BMM_MiniDungeonScale", -1) == 1) { return; } float extraVisualFactor = ProceduralMinibossService.ExtraVisualFactor; VisualScaleSnapshot value; bool flag = _visualScales.TryGetValue(node, out value) && Approximately(node.localScale, value.AppliedScale); if (!flag || !(Mathf.Abs(value.AppliedFactor - extraVisualFactor) < 0.0001f)) { Vector3 val = (flag ? value.NativeScale : node.localScale); Transform val2 = FindTemplateNode(node); if ((Object)(object)val2 != (Object)null) { Vector3 localScale = val2.localScale; val.x = Mathf.Sign(val.x) * Mathf.Max(Mathf.Abs(val.x), Mathf.Abs(localScale.x)); val.y = Mathf.Sign(val.y) * Mathf.Max(Mathf.Abs(val.y), Mathf.Abs(localScale.y)); val.z = Mathf.Sign(val.z) * Mathf.Max(Mathf.Abs(val.z), Mathf.Abs(localScale.z)); } Vector3 appliedScale = (node.localScale = val * extraVisualFactor); _visualScales[node] = new VisualScaleSnapshot { NativeScale = val, AppliedScale = appliedScale, AppliedFactor = extraVisualFactor }; } } private void RepairCorpseCollectorVisualIfLost() { if (_corpseCollectorVisualChecked || (Object)(object)_character == (Object)null || !string.Equals(MinorMutationService.GetPrefabId(_character), "CorpseCollector_bal", StringComparison.OrdinalIgnoreCase)) { return; } _corpseCollectorVisualChecked = true; Transform val = ((Component)this).transform.Find("Visual"); if ((Object)(object)val == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (IsBodyRenderer(componentsInChildren[i]) && componentsInChildren[i].enabled && ((Component)componentsInChildren[i]).gameObject.activeInHierarchy) { return; } } Transform val2 = FindTemplateNode(val); if ((Object)(object)val2 == (Object)null) { return; } if (!((Component)val).gameObject.activeSelf && ((Component)val2).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } Renderer[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<Renderer>(true); int num = 0; foreach (Renderer val3 in componentsInChildren2) { if (!IsBodyRenderer(val3) || !val3.enabled) { continue; } List<string> list = new List<string>(); Transform val4 = ((Component)val3).transform; bool flag = true; while ((Object)(object)val4 != (Object)null && (Object)(object)val4 != (Object)(object)val2) { if (!((Component)val4).gameObject.activeSelf) { flag = false; } list.Add(((Object)val4).name); val4 = val4.parent; } if ((Object)(object)val4 != (Object)(object)val2 || !flag) { continue; } list.Reverse(); Transform val5 = val.Find(string.Join("/", list.ToArray())); if ((Object)(object)val5 == (Object)null) { continue; } Component component = ((Component)val5).GetComponent(((object)val3).GetType()); Renderer val6 = (Renderer)(object)((component is Renderer) ? component : null); if ((Object)(object)val6 == (Object)null) { continue; } Transform val7 = val5; while ((Object)(object)val7 != (Object)null && (Object)(object)val7 != (Object)(object)val) { if (!((Component)val7).gameObject.activeSelf) { ((Component)val7).gameObject.SetActive(true); } val7 = val7.parent; } if (!val6.enabled) { val6.enabled = true; } num++; } if (Launch.IsVerboseDiagnosticsEnabled) { Launch.LogVerbose("CorpseCollector miniboss missing visible body renderers after level change: restored=" + num + ". Confirm AssetBundle Visual hierarchy and authored mesh materials in Unity if still invisible."); } } private static bool IsBodyRenderer(Renderer renderer) { return renderer is SkinnedMeshRenderer || renderer is MeshRenderer; } } [DisallowMultipleComponent] internal sealed class MonsterHunger : MonoBehaviour { private static readonly int ZdoLastFedKey = StringExtensionMethods.GetStableHashCode("BalrondMonsterMayhem_LastFed"); private static readonly List<ItemDrop> EmptyDiet = new List<ItemDrop>(); public float hungerTime = 600f; public bool gateEatingByHunger = true; public float minHeal = 10f; public float minHealFraction = 0.1f; public float maxHealFraction = 0.25f; public bool clampToMissingHealth = true; private MonsterAI _ai; private ZNetView _nview; private Character _character; private Tameable _tameable; private const float HungerCheckInterval = 0.5f; private List<ItemDrop> _cachedDiet; private bool _dietCached; private float _nextHungerCheck; private void Awake() { _ai = ((Component)this).GetComponent<MonsterAI>(); _nview = ((Component)this).GetComponent<ZNetView>(); _character = ((Component)this).GetComponent<Character>(); _tameable = ((Component)this).GetComponent<Tameable>(); if ((Object)(object)_ai == (Object)null || (Object)(object)_character == (Object)null) { ((Behaviour)this).enabled = false; return; } if ((Object)(object)_tameable != (Object)null) { ((Behaviour)this).enabled = false; return; } CacheDietIfNeeded(); if (!_dietCached) { ((Behaviour)this).enabled = false; return; } MonsterAI ai = _ai; ai.m_onConsumedItem = (Action<ItemDrop>)Delegate.Combine(ai.m_onConsumedItem, new Action<ItemDrop>(OnConsumedItem)); EnsureLastFedInitialized(); _nextHungerCheck = Time.time + (float)(Mathf.Abs(((Object)this).GetInstanceID()) % 50) * 0.01f; } private void OnDestroy() { if ((Object)(object)_ai != (Object)null) { MonsterAI ai = _ai; ai.m_onConsumedItem = (Action<ItemDrop>)Delegate.Remove(ai.m_onConsumedItem, new Action<ItemDrop>(OnConsumedItem)); } } private void Update() { if ((Object)(object)_ai == (Object)null) { ((Behaviour)this).enabled = false; } else { if (!gateEatingByHunger) { return; } float time = Time.time; if (time < _nextHungerCheck) { return; } _nextHungerCheck = time + 0.5f; if (!IsOwner()) { return; } CacheDietIfNeeded(); if (!_dietCached) { return; } if (IsHungryNow()) { if (_ai.m_consumeItems == null || _ai.m_consumeItems.Count == 0 || _ai.m_consumeItems == EmptyDiet) { _ai.m_consumeItems = _cachedDiet; } } else if (_ai.m_consumeItems != EmptyDiet) { _ai.m_consumeItems = EmptyDiet; } } } public bool IsHungryNow() { DateTime lastFedTime = GetLastFedTime(); return (GetSafeTime() - lastFedTime).TotalSeconds > (double)hungerTime; } private void OnConsumedItem(ItemDrop item) { if (IsOwner()) { SetLastFedNow(); if (gateEatingByHunger && (Object)(object)_ai != (Object)null) { _ai.m_consumeItems = EmptyDiet; } _nextHungerCheck = Time.time + 0.5f; HealFromConsumedItem(item); } } private void HealFromConsumedItem(ItemDrop item) { if ((Object)(object)_character == (Object)null) { return; } float health = _character.GetHealth(); float maxHealth = _character.GetMaxHealth(); if (maxHealth <= 0f) { return; } float num = maxHealth - health; if (!(num <= 0.01f)) { float num2 = Mathf.Clamp01(minHealFraction); float num3 = Mathf.Clamp01(maxHealFraction); if (num3 < num2) { num3 = num2; } float num4 = maxHealth * Random.Range(num2, num3); if (num4 < minHeal) { num4 = minHeal; } if (clampToMissingHealth && num4 > num) { num4 = num; } if (!(num4 <= 0f)) { _character.Heal(num4, true); } } } private void CacheDietIfNeeded() { if (!_dietCached && !((Object)(object)_ai == (Object)null) && _ai.m_consumeItems != null && _ai.m_consumeItems.Count > 0) { _cachedDiet = new List<ItemDrop>(_ai.m_consumeItems); _dietCached = true; } } private bool IsOwner() { if ((Object)(object)_nview == (Object)null) { return true; } return _nview.IsValid() && _nview.IsOwner(); } private void EnsureLastFedInitialized() { if (!IsOwner()) { return; } ZDO zdo = GetZdo(); if (zdo != null) { long num = zdo.GetLong(ZdoLastFedKey, 0L); if (num == 0) { SetLastFedNow(); } } } private DateTime GetLastFedTime() { ZDO zdo = GetZdo(); if (zdo == null) { return GetSafeTime(); } long num = zdo.GetLong(ZdoLastFedKey, 0L); if (num <= 0) { return GetSafeTime(); } try { return new DateTime(num); } catch { return GetSafeTime(); } } private void SetLastFedNow() { if (IsOwner()) { ZDO zdo = GetZdo(); if (zdo != null) { zdo.Set(ZdoLastFedKey, GetSafeTime().Ticks); } } } private ZDO GetZdo() { if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return null; } return _nview.GetZDO(); } private DateTime GetSafeTime() { return ((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTime() : DateTime.Now; } } [BepInPlugin("balrond.astafaraios.BalrondMonsterMayhem", "BalrondMonsterMayhem", "1.2.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Launch : BaseUnityPlugin { [HarmonyPatch(typeof(Game), "Awake")] private static class Game_Awake_Patch { private static void Prefix() { SpawnSystemLifecyclePatch.Reset(); TamingRuntimeService.Reset(); MonsterTraversalService.Reset(); MonsterPathRecoveryService.Reset(); MonsterObstacleTargetService.Reset(); ProceduralMinibossService.Reset(); MonsterSafeLedgeDescentService.Reset(); FrozenKingEncounterService.Reset(); BossEncounterEventService.Reset(); BossEncounterNestLifetime.ClearScene(); BossBattleCurseService.Reset(); MonsterDiagnosticsCoordinator.Reset(); AudioRoutingService.Reset(); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { private static void Prefix(ZNetScene __instance) { if ((Object)(object)__instance == (Object)null || __instance.m_prefabs == null) { LogWarning("ZNetScene prefab list is not ready."); return; } RuntimePrefabRegistry.Rebuild(__instance); modResourceLoader.AddPrefabsToZnetScene(__instance); monsterCloneService.RegisterVariants(__instance, MonsterVariantRegistry.Variants); KvasturBuildableService.RegisterScenePrefab(__instance); if (MonsterMayhemConfig.EnableGeneratedCreatureSpawners == null || MonsterMayhemConfig.EnableGeneratedCreatureSpawners.Value) { CreatureSpawnerPrefabBuilder.RegisterAll(__instance); } } [HarmonyPriority(0)] [HarmonyAfter(new string[] { "balrond.astafaraios.BalrondAbsoluteOverhaul", "balrond.astafaraios.BalrondHumanoidRandomizer" })] private static void Postfix(ZNetScene __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.m_prefabs != null) { RuntimePrefabRegistry.Rebuild(__instance); CreatureDisplayNameService.Apply(); KvasturBuildableService.FinalizeScene(__instance); if (MonsterMayhemConfig.EnableMonsterDoorInteraction == null || MonsterMayhemConfig.EnableMonsterDoorInteraction.Value) { MonsterDoorSensorService.RegisterDefaultRules(); MonsterDoorSensorService.ApplyToZNetScene(__instance); } BossEncounterEventService.RegisterScenePrefab(__instance); MonsterDiagnosticsCoordinator.CaptureSceneBaseline(__instance); modResourceLoader.FixAllFx(); BossPhaseStatusService.RegisterStatus(); BossBattleCurseService.RegisterStatuses(); MonsterDropAuthorityService.SanitizeOwnedInvalidRows(__instance.m_prefabs); MonsterDropAuthorityService.CaptureNativeTables(__instance.m_prefabs); DeepNorthCreatureService.CaptureNative(__instance.m_prefabs); if ((MonsterMayhemConfig.EnableEventOverhaul == null || MonsterMayhemConfig.EnableEventOverhaul.Value) && (Object)(object)RandEventSystem.instance != (Object)null && RandEventSystem.instance.m_events != null) { eventBuilder.EditEvents(RandEventSystem.instance.m_events, __instance.m_prefabs); eventBuilder.AddNewEvents(RandEventSystem.instance.m_events, __instance.m_prefabs); eventBuilder.ValidateNativeEventTopology(RandEventSystem.instance.m_events); } if (MonsterMayhemConfig.EnableCreatureRules == null || MonsterMayhemConfig.EnableCreatureRules.Value) { baoCreatureRuleService.Apply(__instance.m_prefabs); monsterManager.SetupMonsterList(__instance.m_prefabs); monsterManager.EditMonsters(); DeepNorthCreatureService.ApplyOwnedProfiles(__instance.m_prefabs); } else { monsterManager.SetupMonsterList(__instance.m_prefabs); monsterManager.EnsureLevelVisuals(); } BossAttackPhaseService.ClearRules(); if (MonsterMayhemConfig.EnableBossAttackRules == null || MonsterMayhemConfig.EnableBossAttackRules.Value) { BossAttackDefinitions.RegisterAll(); BossAttackPhaseService.Apply(__instance.m_prefabs); } BossCombatProfileService.ClearProfiles(); BossCombatProfileDefinitions.RegisterAll(); BossCombatProfileService.Apply(__instance.m_prefabs); FrozenKingEncounterService.PreparePrefabs(__instance.m_prefabs); if (MonsterMayhemConfig.EnableResistanceOverhaul == null || MonsterMayhemConfig.EnableResistanceOverhaul.Value) { MonsterResistanceManager.ApplyFinalProfiles(__instance.m_prefabs); } MonsterDropAuthorityService.ValidateFinalTables(__instance.m_prefabs); DeepNorthCreatureService.ValidateFinal(__instance.m_prefabs); CustomFactionRegistry.InitExampleRegistry(); CreatureFactionRegistry.RegisterDefaultBiomeFactionMap(); CreatureFactionRegistry.InitExampleRegistry(); if (MonsterMayhemConfig.EnableEggHatching == null || MonsterMayhemConfig.EnableEggHatching.Value) { EggHatchService.SetupEggHatching(__instance); } if (MonsterMayhemConfig.EnableGrowth == null || MonsterMayhemConfig.EnableGrowth.Value) { GrowthService.SetupGrowth(__instance); } MountInteractionService.CapturePrefabs(__instance); TamableService.SetupBreeding(__instance); TamingRuntimeService.PrepareScene(__instance); AudioRoutingService.OnSceneReady(); MonsterDiagnosticsCoordinator.OnSceneFinalized(__instance, "ZNetScene.Awake final MM pass"); SpawnSystemLifecyclePatch.NotifyZNetSceneReady(__instance); if (!IsDedicatedServer()) { ShaderReplacment.RunMaterialFix(); } } } } private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondMonsterMayhem"); private bool initialized; private static ManualLogSource log; public const string PluginGUID = "balrond.astafaraios.BalrondMonsterMayhem"; public const string PluginName = "BalrondMonsterMayhem"; public const string PluginVersion = "1.2.5"; public static readonly ModResourceLoader modResourceLoader = new ModResourceLoader(); public static readonly DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods(); public static readonly MonsterManager monsterManager = new MonsterManager(); internal static readonly BaoCreatureRuleService baoCreatureRuleService = new BaoCreatureRuleService(); public static readonly SpawnerBuilder spawnerBuilder = new SpawnerBuilder(); public static readonly MonsterAttackItemEditService monsterAttackItemEdits = new MonsterAttackItemEditService(); public static readonly EventBuilder eventBuilder = new EventBuilder(); public static readonly MonsterFeeding monsterFeeding = new MonsterFeeding(); public static readonly JsonLoader jsonLoader = new JsonLoader(); public static readonly MonsterCloneService monsterCloneService = new MonsterCloneService(); public static string projectName = "BalrondMonsterMayhem"; public static GameObject RootObject; public static GameObject PrefabContainer; public static bool IsDiagnosticsEnabled => MonsterMayhemConfig.DiagnosticsEnabled != null && MonsterMayhemConfig.DiagnosticsEnabled.Value; public static bool IsVerboseDiagnosticsEnabled => IsDiagnosticsEnabled && MonsterMayhemConfig.VerboseDiagnosticLogging != null && MonsterMayhemConfig.VerboseDiagnosticLogging.Value; private void Awake() { log = ((BaseUnityPlugin)this).Logger; ServerSyncBridge.Initialize("balrond.astafaraios.BalrondMonsterMayhem", "BalrondMonsterMayhem", "1.2.5"); MonsterMayhemConfig.Initialize(this); LogVerbose("[Startup 1/4] Configuration ready."); CreatureUpdateOptimizationService.Initialize(); try { LogVerbose("[Startup 2/4] Loading translations..."); jsonLoader.loadJson(); CreatePrefabContainer(); LogVerbose("[Startup 3/4] Loading content assets..."); if (!modResourceLoader.LoadAssets()) { LogError("Initialization aborted because required assets could not be loaded."); CleanupRuntimeState(); return; } monsterManager.RegisterLootAliases(MonsterVariantRegistry.BuildLootAliasMap()); LogVerbose("[Startup 4/4] Registering gameplay patches..."); harmony.PatchAll(Assembly.GetExecutingAssembly()); initialized = true; LogVerbose("BalrondMonsterMayhem 1.2.5 initialized."); } catch (Exception ex) { LogError("Fatal initialization error: " + ex); harmony.UnpatchSelf(); CleanupRuntimeState(); } } public void CreatePrefabContainer() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (!((Object)(object)RootObject != (Object)null) || !((Object)(object)PrefabContainer != (Object)null)) { RootObject = new GameObject("_BalrondMonsterMayhemRoot"); Object.DontDestroyOnLoad((Object)(object)RootObject); PrefabContainer = new GameObject("Prefabs"); PrefabContainer.transform.SetParent(RootObject.transform, false); PrefabContainer.SetActive(false); } } public static GameObject cloneMe(GameObject source, string name) { if ((Object)(object)source == (Object)null) { return null; } if ((Object)(object)PrefabContainer == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform); ((Object)val).name = (string.IsNullOrEmpty(name) ? ((Object)source).name : name); fixMaterials(val, source); val.SetActive(true); return val; } public static GameObject fixMaterials(GameObject clone, GameObject source) { if ((Object)(object)clone == (Object)null || (Object)(object)source == (Object)null) { return clone; } MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>(true); MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren<MeshRenderer>(true); Dictionary<string, MeshRenderer> dictionary = new Dictionary<string, MeshRenderer>(StringComparer.Ordinal); foreach (MeshRenderer val in componentsInChildren2) { if (!((Object)(object)val == (Object)null)) { string relativePath = GetRelativePath(clone.transform, ((Component)val).transform); if (!dictionary.ContainsKey(relativePath)) { dictionary.Add(relativePath, val); } } } foreach (MeshRenderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { string relativePath2 = GetRelativePath(source.transform, ((Component)val2).transform); if (dictionary.TryGetValue(relativePath2, out var value) && (Object)(object)value != (Object)null) { ((Renderer)value).sharedMaterials = ((Renderer)val2).sharedMaterials; } } } return clone; } private static string GetRelativePath(Transform root, Transform child) { if ((Object)(object)root == (Object)null || (Object)(object)child == (Object)null) { return string.Empty; } if (root == child) { return string.Empty; } Stack<string> stack = new Stack<string>(); Transform val = child; while ((Object)(object)val != (Object)null && val != root) { stack.Push(((Object)val).name); val = val.parent; } return string.Join("/", stack.ToArray()); } private void OnDestroy() { if (initialized) { harmony.UnpatchSelf(); } initialized = false; CleanupRuntimeState(); } private static void CleanupRuntimeState() { RuntimePrefabRegistry.Clear(); baoCreatureRuleService.Reset(); MonsterDropAuthorityService.Reset(); DeepNorthCreatureService.Reset(); BossAttackPhaseService.ClearRules(); BossCombatProfileService.ClearProfiles(); FrozenKingEncounterService.Reset(); BossPhaseStatusService.Reset(); BossBattleCurseService.Reset(); BossEncounterEventService.Reset(); BossEncounterNestLifetime.ClearScene(); MinorMutationService.Reset(); SpawnSystemLifecyclePatch.Reset(); TamingRuntimeService.Reset(); MonsterTraversalService.Reset(); MonsterPathRecoveryService.Reset(); MonsterObstacleTargetService.Reset(); ProceduralMinibossService.Reset(); MonsterSafeLedgeDescentService.Reset(); MonsterMayhemConfig.Reset(); ServerSyncBridge.Reset(); ShaderReplacment.Clear(); MonsterDiagnosticsCoordinator.Reset(); MonsterCommandService.Reset(); KvasturBuildableService.Reset(); AudioRoutingService.Reset(); modResourceLoader.Reset(); if ((Object)(object)RootObject != (Object)null) { Object.Destroy((Object)(object)RootObject); } PrefabContainer = null; RootObject = null; } public static bool IsObjectDBValid() { return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items != null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes != null && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } public static void LogDiagnostic(string message) { if (IsVerboseDiagnosticsEnabled) { LogInfo(message); } } public static void LogVerbose(string message) { if (IsVerboseDiagnosticsEnabled) { LogInfo(message); } } public static void LogInfo(string message) { if (log != null) { log.LogInfo((object)message); } else { Debug.Log((object)("[BalrondMonsterMayhem] " + message)); } } public static void LogWarning(string message) { if (log != null) { log.LogWarning((object)message); } else { Debug.LogWarning((object)("[BalrondMonsterMayhem] " + message)); } } public static void LogError(string message) { if (log != null) { log.LogError((object)message); } else { Debug.LogError((object)("[BalrondMonsterMayhem] " + message)); } } [HarmonyPrefix] [HarmonyPatch(typeof(RandEventSystem), "StartRandomEvent")] private static void RandEventSystem_StartRandomEvent(ref bool __runOriginal) { if (!((Object)(object)ZNet.instance == (Object)null)) { int nrOfPlayers = ZNet.instance.GetNrOfPlayers(); int num = ((MonsterMayhemConfig.MinimumPlayersForRaids != null) ? MonsterMayhemConfig.MinimumPlayersForRaids.Value : 2); if (!ZNet.IsSinglePlayer && nrOfPlayers < num) { __runOriginal = false; LogDiagnostic("Not enough players online for raid. Min player count: " + num + ", currently online: " + nrOfPlayers); } } } private static bool IsDedicatedServer() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 try { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsDedicated(); } } catch { } return (int)SystemInfo.graphicsDeviceType == 4; } } internal sealed class BaoCreatureRuleService { private static readonly HashSet<string> ManagedMonsterNames = new HashSet<string>(StringComparer.Ordinal) { "Skeleton_Hildir", "GoblinShaman_Hildir", "Fenring_Cultist_Hildir", "Skeleton_Hildir_nochest", "GoblinBruteBros_nochest", "GoblinShaman_Hildir_nochest", "GoblinBrute_Hildir", "Fenring_Cultist_Hildir_nochest", "Abomination", "Hare", "Leech", "Troll_ru", "Troll", "Charred_Archer", "Charred_Melee", "Charred_Mage", "Charred_Twitcher", "FallenWarrior", "Surtling", "Dragon", "GoblinKing", "GoblinBrute", "GoblinShaman", "Goblin", "Draugr_Elite", "Greydwarf_Elite", "Skeleton_Poison", "Skeleton", "Skeleton_NoArcher", "DraugrRanged", "DraugrArcher", "Draugr", "gd_king", "Deer", "Hatchling", "BlobElite", "Blob", "BlobLava", "DvergerMage", "DvergerMageFire", "DvergerMageIce", "DvergerMageSupport", "Dverger", "Tick", "StoneGolem", "BogWitchKvastur", "Bonemass", "Greyling", "Greydwarf", "Greydwarf_Shaman", "SeekerBrood", "SeekerBrute", "Seeker", "SeekerQueen", "Eikthyr", "Neck", "Boar", "Ghost", "Ulv", "Fenring", "Fenring_Cultist", "Bat", "Serpent", "BonemawSerpent" }; private readonly Dictionary<string, GameObject> prefabsByName = new Dictionary<string, GameObject>(StringComparer.Ordinal); private readonly HashSet<string> missingWarnings = new HashSet<string>(StringComparer.Ordinal); private readonly HashSet<int> configuredMonsterIds = new HashSet<int>(); private readonly HashSet<int> configuredSpawnerIds = new HashSet<int>(); private List<GameObject> indexedSource; private int indexedSourceCount = -1; private static readonly string[] ManagedSpawnerNames = new string[9] { "PoisonGeyserSpawner_bal", "SeekerBroodSpawner_bal", "BonePileSpawner", "Spawner_DraugrPile", "Spawner_GreydwarfNest", "SurtlingSpawner_bal", "DrakeSpawner_bal", "DeathsquitoHive_bal", "RockGolemSpawn_bal" }; internal void Apply(List<GameObject> prefabs) { if (prefabs == null) { return; } EnsurePrefabIndex(prefabs); for (int i = 0; i < prefabs.Count; i++) { GameObject val = prefabs[i]; if (!((Object)(object)val == (Object)null) && ManagedMonsterNames.Contains(((Object)val).name)) { ApplyMonsterRule(val); } } ApplySpawnerRules(); } internal void Reset() { prefabsByName.Clear(); missingWarnings.Clear(); configuredMonsterIds.Clear(); configuredSpawnerIds.Clear(); indexedSource = null; indexedSourceCount = -1; } private void ApplyMonsterRule(GameObject monster) { if ((Object)(object)monster == (Object)null || !configuredMonsterIds.Add(((Object)monster).GetInstanceID())) { return; } CharacterDrop val = monster.GetComponent<CharacterDrop>(); if ((Object)(object)val == (Object)null) { val = monster.AddComponent<CharacterDrop>(); } if (val.m_drops == null) { val.m_drops = new List<Drop>(); } switch (((Object)monster).name) { case "Skeleton_Hildir": case "GoblinShaman_Hildir": case "Fenring_Cultist_Hildir": case "Skeleton_Hildir_nochest": case "GoblinBruteBros_nochest": case "GoblinShaman_Hildir_nochest": case "GoblinBrute_Hildir": case "Fenring_Cultist_Hildir_nochest": addItemToLootTable(val, "SeaPearl_bal", 1, 2, 0.2f); addItemToLootTable(val, "Amber", 1, 2, 0.3f); addItemToLootTable(val, "Ruby", 2, 3, 0.4f); addItemToLootTable(val, "Coins", 20, 40, 0.5f); addItemToLootTable(val, "CorruptedEitr_bal", 3, 5, 0.6f); addItemToLootTable(val, "Peningar_bal", 30, 40, 0.7f); addItemToLootTable(val, "RustedScrap_bal", 3, 6, 0.1f, multiplier: false); break; case "Abomination": editDrop(val, "Root", 4, 8, 1f); editMonsterHealth(monster, 1000); addItemToLootTable(val, "CorruptedEitr_bal", 1, 3, 0.3f); addItemToLootTable(val, "AncientSeed", 1, 1, 0.1f); addItemToLootTable(val, "SwampTreeSeeds_bal", 1, 1, 0.2f); addItemToLootTable(val, "HardWood_bal", 1, 3, 0.5f); addItemToLootTable(val, "FineWood", 1, 3, 0.5f); addItemToLootTable(val, "Mycelium_bal", 1, 2, 0.25f); addItemToLootTable(val, "WillowBark_bal", 1, 2, 0.2f); addItemToLootTable(val, "HangingMossSeeds_bal", 1, 1, 0.15f); addItemToLootTable(val, "WillowSeeds_bal", 1, 1, 0.1f); break; case "Hare": editMonsterHealth(monster, 25); addItemToLootTable(val, "LeatherScraps", 1, 3, 0.5f); addItemToLootTable(val, "AcaiSeeds_bal", 1, 1, 0.1f); addItemToLootTable(val, "Straw_bal", 1, 2, 0.2f); break; case "Leech": addItemToLootTable(val, "SmallBloodSack_bal", 1, 1, 0.5f); addItemToLootTable(val, "RottenMeat", 1, 1, 0.4f); addItemToLootTable(val, "Cattail_bal", 1, 1, 0.1f); addItemToLootTable(val, "WaterLilySeeds_bal", 1, 1, 0.05f); break; case "Troll_ru": case "Troll": removeDrop(val, "Coins"); removeDrop(val, "LeatherScraps"); editDrop(val, "TrollHide", 3, 5, 1f); addItemToLootTable(val, "TrollMeat_bal", 1, 2, 0.8f); addItemToLootTable(val, "Clay_bal", 1, 3, 0.35f); addItemToLootTable(val, "Peningar_bal", 40, 55, 0.55f); addItemToLootTable(val, "RustedScrap_bal", 1, 2, 0.15f, multiplier: false); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); addItemToLootTable(val, "Crystal", 1, 2, 0.15f); addItemToLootTable(val, "SilverScrap_bal", 1, 1, 0.08f, multiplier: false); addItemToLootTable(val, "RottenMeat", 1, 1, 0.15f); addItemToLootTable(val, "RustyBrokenSword_bal", 1, 1, 0.025f, multiplier: false); break; case "Charred_Archer": case "Charred_Melee": case "Charred_Mage": case "Charred_Twitcher": removeDrop(val, "VikingTalisman_bal"); removeDrop(val, "Amethyst_bal"); removeDrop(val, "Emerald_bal"); removeDrop(val, "Sapphire_bal"); addItemToLootTable(val, "CorruptedEitr_bal", 1, 1, 0.3f); addItemToLootTable(val, "MagmaStone_bal", 1, 2, 0.1f); addItemToLootTable(val, "FlametalScrap_bal", 1, 2, 0.1f, multiplier: false); addItemToLootTable(val, "Ruby", 1, 1, 0.03f, multiplier: false); addItemToLootTable(val, "Opal_bal", 1, 1, 0.03f, multiplier: false); addItemToLootTable(val, "Onyx_bal", 1, 1, 0.03f, multiplier: false); addItemToLootTable(val, "LeatherScraps", 1, 3, 0.1f); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.5f, multiplier: false); addItemToLootTable(val, "SilverNecklace", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); if (string.Equals(((Object)monster).name, "Charred_Mage", StringComparison.Ordinal)) { addItemToLootTable(val, "SurtrAmulet_bal", 1, 1, 0.03f, multiplier: false); } break; case "FallenWarrior": addItemToLootTableLike(val, "OrbSoulBlight_bal", "OrbFrostFire", "OrbThunderBlood"); break; case "Surtling": addItemToLootTable(val, "CorruptedEitr_bal", 1, 2, 0.1f); addItemToLootTable(val, "MagmaStone_bal", 1, 2, 0.1f); addItemToLootTable(val, "SurtrAmulet_bal", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "Ruby", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "Opal_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "Onyx_bal", 1, 1, 0.05f, multiplier: false); editMonsterHealth(monster, 50); break; case "Dragon": addItemToLootTable(val, "CorruptedEitr_bal", 4, 8, 0.8f); addItemToLootTable(val, "LeatherScraps", 1, 2, 0.7f); addItemToLootTable(val, "Onyx_bal", 1, 1, 0.05f); addItemToLootTable(val, "Sapphire_bal", 1, 1, 0.05f); addItemToLootTable(val, "Peningar_bal", 50, 200, 0.5f); addItemToLootTable(val, "DrakeMeat_bal", 2, 4, 0.33f); addItemToLootTable(val, "DrakeSkin_bal", 3, 6, 0.33f); break; case "GoblinKing": addItemToLootTable(val, "CorruptedEitr_bal", 5, 10, 0.9f, multiplier: false); addItemToLootTable(val, "JuteRed", 2, 4, 0.7f); addItemToLootTable(val, "CursedBone_bal", 6, 12, 0.8f, multiplier: true, perPlayer: true); addItemToLootTable(val, "SilverScrap_bal", 3, 5, 0.1f, multiplier: false); addItemToLootTable(val, "IronScrap", 3, 5, 0.2f); addItemToLootTable(val, "BronzeScrap", 3, 5, 0.3f, multiplier: false); addItemToLootTable(val, "CopperScrap", 3, 5, 0.4f, multiplier: false); addItemToLootTable(val, "Amethyst_bal", 1, 1, 0.5f); addItemToLootTable(val, "Emerald_bal", 1, 1, 0.5f); addItemToLootTable(val, "Opal_bal", 1, 1, 0.5f); addItemToLootTable(val, "Onyx_bal", 1, 1, 0.5f); addItemToLootTable(val, "Sapphire_bal", 1, 1, 0.5f); addItemToLootTable(val, "Coins", 25, 100, 0.5f); addItemToLootTable(val, "Peningar_bal", 50, 200, 0.5f); addItemToLootTable(val, "RustedScrap_bal", 5, 8, 0.5f, multiplier: false); break; case "GoblinBrute": editDrop(val, "GoblinTotem", 1, 1, 0.33f, multiplier: false); addItemToLootTable(val, "SilverScrap_bal", 1, 1, 0.06f, multiplier: false); addItemToLootTable(val, "Peningar_bal", 10, 20, 0.5f); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.5f, multiplier: false); addItemToLootTable(val, "SilverNecklace", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); addItemToLootTable(val, "IronScrap", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.15f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.2f, multiplier: false); addItemToLootTable(val, "FulingEffigy_bal", 1, 1, 0.03f, multiplier: false); break; case "GoblinShaman": addItemToLootTable(val, "CorruptedEitr_bal", 2, 4, 0.7f); addItemToLootTable(val, "Ectoplasm", 1, 1, 0.5f); addItemToLootTable(val, "SilverScrap_bal", 1, 1, 0.06f, multiplier: false); addItemToLootTable(val, "Peningar_bal", 10, 20, 0.5f); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.5f, multiplier: false); addItemToLootTable(val, "SilverNecklace", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); addItemToLootTable(val, "IronScrap", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.15f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.2f, multiplier: false); addItemToLootTable(val, "GoblinTotem", 1, 1, 0.55f, multiplier: false); addItemToLootTable(val, "FulingEffigy_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "GoblinEar_bal", 1, 3, 0.5f); break; case "Goblin": addItemToLootTable(val, "GoblinTotem", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "RustyBrokenSword_bal", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "Peningar_bal", 10, 20, 0.25f); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.25f, multiplier: false); addItemToLootTable(val, "GoblinEar_bal", 1, 3, 0.5f); break; case "Draugr_Elite": addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.5f, multiplier: false); addItemToLootTable(val, "RustyBrokenSword_bal", 1, 1, 0.2f, multiplier: false); addItemToLootTable(val, "CorruptedEitr_bal", 1, 1, 0.2f); addItemToLootTable(val, "Ectoplasm", 1, 1, 0.75f); addItemToLootTable(val, "ArrowFlint", 1, 3, 0.5f); addItemToLootTable(val, "SilverScrap_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "IronScrap", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.15f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.2f, multiplier: false); addItemToLootTable(val, "Peningar_bal", 10, 20, 0.5f); if (!IsZenWorldSettingsLoaded()) { addItemToLootTable(val, "CryptKey", 1, 1, 0.5f, multiplier: false); } removeDrop(val, "CultInsignia_bal"); addItemToLootTable(val, "Mycelium_bal", 1, 2, 0.8f); addItemToLootTable(val, "SilverNecklace", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "VikingTalisman_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "Chain", 1, 1, 0.15f); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); editMonsterHealth(monster, 350); break; case "Greydwarf_Elite": addItemToLootTable(val, "CorruptedEitr_bal", 1, 1, 0.02f); addItemToLootTable(val, "StrawSeeds_bal", 1, 1, 0.3f); addItemToLootTable(val, "AppleSeeds_bal", 1, 1, 0.25f); addItemToLootTable(val, "Thistle", 1, 1, 0.1f); addItemToLootTable(val, "Dandelion", 1, 1, 0.1f); addItemToLootTable(val, "Moss_bal", 1, 1, 0.4f); addItemToLootTable(val, "CopperScrap", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "BasicSeed_bal", 1, 1, 0.5f); addItemToLootTable(val, "RottenVegetable_bal", 1, 1, 0.55f); addItemToLootTable(val, "GreydwarfCharm_bal", 1, 1, 0.01f, multiplier: false); editMonsterHealth(monster, 250); break; case "Skeleton_Poison": addItemToLootTable(val, "CorruptedEitr_bal", 1, 1, 0.05f); addItemToLootTable(val, "RustyBrokenSword_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.25f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "IronScrap", 1, 1, 0.005f, multiplier: false); addItemToLootTable(val, "BrassScrap_bal", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.01f); editMonsterHealth(monster, 150); break; case "Skeleton": case "Skeleton_NoArcher": addItemToLootTable(val, "RustyBrokenSword_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.005f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "SilverNecklace", 1, 1, 0.01f, multiplier: false); break; case "DraugrRanged": case "DraugrArcher": case "Draugr": addItemToLootTable(val, "CorruptedEitr_bal", 1, 1, 0.02f); addItemToLootTable(val, "RustyBrokenSword_bal", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "ArrowFlint", 1, 3, 0.1f); addItemToLootTable(val, "Ectoplasm", 1, 1, 0.03f); addItemToLootTable(val, "IronScrap", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "Peningar_bal", 5, 10, 0.5f); if (!IsZenWorldSettingsLoaded()) { addItemToLootTable(val, "CryptKey", 0, 1, 0.005f, multiplier: false); } addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.15f); removeDrop(val, "CultInsignia_bal"); addItemToLootTable(val, "Mycelium_bal", 1, 1, 0.1f); addItemToLootTable(val, "VikingTalisman_bal", 1, 1, 0.01f, multiplier: false); addItemToLootTable(val, "Chain", 1, 1, 0.05f); addItemToLootTable(val, "SilverNecklace", 1, 1, 0.05f, multiplier: false); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); break; case "gd_king": addItemToLootTable(val, "WatcherHeart_bal", 1, 1, 1f, multiplier: false, perPlayer: true); addItemToLootTable(val, "CorruptedEitr_bal", 2, 4, 0.1f, multiplier: false); addItemToLootTable(val, "Amethyst_bal", 1, 2, 0.1f); addItemToLootTable(val, "FineWood", 2, 4, 0.7f); addItemToLootTable(val, "RoundLog", 4, 6, 0.8f); addItemToLootTable(val, "Wood", 8, 10, 0.9f); addItemToLootTable(val, "ElderBark", 1, 2, 0.6f); addItemToLootTable(val, "Root", 1, 3, 0.6f); addItemToLootTable(val, "AppleSeeds_bal", 4, 8, 0.75f); addItemToLootTable(val, "Thistle", 2, 4, 0.5f); editMonsterHealth(monster, 3300); break; case "Deer": editDrop(val, "TrophyDeer", 1, 1, 0.25f, multiplier: false); editDrop(val, "DeerHide", 1, 1, 0.75f); editDrop(val, "DeerMeat", 1, 1, 1f); addItemToLootTable(val, "LeatherScraps", 1, 1, 0.33f); break; case "Hatchling": editDrop(val, "FreezeGland", 1, 2, 0.75f); addItemToLootTable(val, "DrakeSkin_bal", 1, 1, 0.15f); addItemToLootTable(val, "LeatherScraps", 0, 2, 0.5f); addItemToLootTable(val, "BoneFragments", 1, 2, 0.1f); addItemToLootTable(val, "DrakeMeat_bal", 1, 1, 0.55f); break; case "BlobElite": editDrop(val, "IronScrap", 1, 1, 0.11f); addItemToLootTable(val, "LeatherScraps", 1, 2, 0.5f); addItemToLootTable(val, "BoneFragments", 2, 4, 0.5f); addItemToLootTable(val, "Guck", 1, 1, 0.5f); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.22f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.33f, multiplier: false); addItemToLootTable(val, "RustedScrap_bal", 1, 2, 0.44f, multiplier: false); break; case "Blob": addItemToLootTable(val, "LeatherScraps", 1, 2, 0.5f); addItemToLootTable(val, "BoneFragments", 1, 2, 0.5f); addItemToLootTable(val, "Guck", 1, 1, 0.1f); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.25f, multiplier: false); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.8f, multiplier: false); break; case "BlobLava": addItemToLootTable(val, "Tar", 1, 1, 0.4f); addItemToLootTable(val, "MagmaStone_bal", 1, 1, 0.3f); addItemToLootTable(val, "Obsidian", 1, 1, 0.1f); addItemToLootTable(val, "Coal", 1, 1, 0.7f); addItemToLootTable(val, "SulfurStone", 1, 1, 0.3f); addItemToLootTable(val, "FlametalScrap_bal", 1, 1, 0.25f, multiplier: false); addItemToLootTable(val, "DarksteelScrap_bal", 1, 1, 0.35f, multiplier: false); addItemToLootTable(val, "RustedScrap_bal", 1, 1, 0.5f, multiplier: false); addItemToLootTable(val, "Opal_bal", 0, 1, 0.05f); addItemToLootTable(val, "Onyx_bal", 0, 1, 0.05f); break; case "DvergerMage": case "DvergerMageFire": case "DvergerMageIce": case "DvergerMageSupport": case "Dverger": addItemToLootTable(val, "Ruby", 0, 1, 0.05f); addItemToLootTable(val, "Amethyst_bal", 0, 1, 0.05f); addItemToLootTable(val, "Emerald_bal", 0, 1, 0.05f); addItemToLootTable(val, "Opal_bal", 0, 1, 0.05f); addItemToLootTable(val, "Onyx_bal", 0, 1, 0.05f); addItemToLootTable(val, "Sapphire_bal", 0, 1, 0.05f); addItemToLootTable(val, "SilverScrap_bal", 1, 1, 0.1f, multiplier: false); addItemToLootTable(val, "IronScrap", 1, 1, 0.25f, multiplier: false); addItemToLootTable(val, "BronzeScrap", 1, 1, 0.35f, multiplier: false); addItemToLootTable(val, "CopperScrap", 1, 1, 0.4f, multiplier: false); addItemToLootTable(val, "Peningar_bal", 10, 20, 0.5f); addItemToLootTable(val, "JuteRed", 1, 1, 0.5f); addItemToLootTable(val, "JuteBlue", 1, 1, 0.5f); addItemToLootTable(val, "GemChunks_bal", 1, 1, 0.1f); addItemToLootTable(val, "DvergrRunePendant_bal", 1, 1, 0.02f, multiplier: false); addGlobalKey(monster, "killedDverger"); break; case "Tick": addItemToLootTable(val, "SmallBloodSack_bal", 1, 1, 0.5f); addItemToLootTable(val, "Bloodbag", 1, 1, 0.15f); addGlobalKey(monster, "killedInsecto"); break; case "StoneGolem": addItemToLootTable(val, "LeadOre_bal", 1, 1, 0.1f); addItemToLootTable(val, "CopperOre", 1, 1, 0.15f); addItemToLootTable(val, "TinOre", 1,