Please disclose if your mod was created primarily 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 Boss Summons Allies v0.7.1
BossSummonsAllies.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BossSummonsAllies")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BossSummonsAllies")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d5643bc9-cac7-4c7a-b28f-1c4db62b2ab4")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace BossSummonAllies; [BepInPlugin("Severon.BossSummonsAllies", "Boss Summons Allies", "0.7.1")] [BepInProcess("Valheim.exe")] public class BossSummonAllies : BaseUnityPlugin { [HarmonyPatch(typeof(Character), "OnEnable")] private class CaptureBossOnAwake { private static void Postfix(Character __instance) { if (__instance.m_boss) { Controller.RegisterBoss(__instance); } } } [HarmonyPatch(typeof(RandEventSystem), "GetCurrentSpawners")] public static class RaidSpawnerPatch { private static void Postfix(ref List<SpawnData> __result) { if (Controller != null && Controller.HasActiveRaids) { List<SpawnData> spawners = Controller.GetSpawners(); if (spawners != null && spawners.Count > 0) { __result = spawners; } } } } public static BossRaidController Controller; private readonly Harmony harmony = new Harmony("Severon.BossSummonsAllies"); public static ConfigEntry<float> FirstWaveDelay; public static ConfigEntry<float> EikthyrInterval; public static ConfigEntry<float> ElderInterval; public static ConfigEntry<float> BonemassInterval; public static ConfigEntry<float> ModerInterval; public static ConfigEntry<float> YagluthInterval; public static ConfigEntry<float> QueenInterval; public static ConfigEntry<float> FaderInterval; private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown FirstWaveDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "First Wave Delay Seconds", 10f, new ConfigDescription("The delay before the first wave is summoned in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>())); EikthyrInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Eikthyr Wave Interval", 30f, new ConfigDescription("The frequency Eikthyr summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); ElderInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Elder Wave Interval", 120f, new ConfigDescription("The frequency The Elder summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); BonemassInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Bonemass Wave Interval", 120f, new ConfigDescription("The frequency Bonemass summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); ModerInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Moder Wave Interval", 240f, new ConfigDescription("The frequency Moder summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); YagluthInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Yagluth Wave Interval", 360f, new ConfigDescription("The frequency Yagluth summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); QueenInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Queen Wave Interval", 360f, new ConfigDescription("The frequency The Queen summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); FaderInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Timers", "Fader Wave Interval", 360f, new ConfigDescription("The frequency Fader summons a new wave of enemies in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); Controller = new BossRaidController(); FirstWaveDelay.SettingChanged += delegate { Controller?.OnConfigChanged(); }; EikthyrInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; ElderInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; BonemassInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; ModerInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; YagluthInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; QueenInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; FaderInterval.SettingChanged += delegate { Controller?.OnConfigChanged(); }; harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[BossRaid] Loaded"); } private void Update() { Controller?.Update(Time.deltaTime); } } public class RaidInstance { public Character Boss; public RandomEvent Event; public bool Active; public float WaveTimer; public float WaveInterval; public bool WaveTriggered; } public class BossRaidController { private Dictionary<Character, RaidInstance> _raids = new Dictionary<Character, RaidInstance>(); private Dictionary<string, string> _bossRaidMap = new Dictionary<string, string> { { "$enemy_eikthyr", "army_eikthyr" }, { "$enemy_gdking", "army_theelder" }, { "$enemy_bonemass", "army_bonemass" }, { "$enemy_dragon", "army_moder" }, { "$enemy_goblinking", "army_goblin" }, { "$enemy_seekerqueen", "army_seekers" }, { "$enemy_fader", "army_charred" } }; public bool HasActiveRaids => _raids.Count > 0; private float GetIntervalForBoss(string bossName) { return bossName switch { "$enemy_eikthyr" => BossSummonAllies.EikthyrInterval.Value, "$enemy_gdking" => BossSummonAllies.ElderInterval.Value, "$enemy_bonemass" => BossSummonAllies.BonemassInterval.Value, "$enemy_dragon" => BossSummonAllies.ModerInterval.Value, "$enemy_goblinking" => BossSummonAllies.YagluthInterval.Value, "$enemy_seekerqueen" => BossSummonAllies.QueenInterval.Value, "$enemy_fader" => BossSummonAllies.FaderInterval.Value, _ => 120f, }; } public void OnConfigChanged() { foreach (RaidInstance value in _raids.Values) { Debug.Log((object)"Raid config updated for active raid."); } } public void RegisterBoss(Character boss) { //IL_00bc: 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) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer()) { return; } string name = boss.m_name; if (_bossRaidMap.TryGetValue(name, out var raidName)) { RandomEvent val = RandEventSystem.instance.m_events.Find((RandomEvent e) => e.m_name == raidName); if (val == null) { Debug.LogWarning((object)("Raid template not found for " + raidName)); return; } RaidInstance raidInstance = new RaidInstance(); raidInstance.Boss = boss; raidInstance.Event = val.Clone(); raidInstance.Event.m_pos = ((Component)boss).transform.position; raidInstance.Event.m_time = 0f; raidInstance.Event.m_duration = 0f; raidInstance.Event.OnStart(); raidInstance.Active = true; raidInstance.WaveInterval = GetIntervalForBoss(name); raidInstance.WaveTimer = raidInstance.WaveInterval - BossSummonAllies.FirstWaveDelay.Value; _raids.Add(boss, raidInstance); } } public void Update(float dt) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (_raids.Count == 0) { return; } List<RaidInstance> list = _raids.Values.ToList(); foreach (RaidInstance item in list) { if (!item.Active) { continue; } if ((Object)(object)item.Boss == (Object)null || item.Boss.IsDead()) { StopRaid(item); continue; } bool flag = ArePlayersInRaidArea(item); item.Event.m_pos = ((Component)item.Boss).transform.position; item.Event.Update(true, false, flag, dt); item.WaveTimer += dt; if (item.WaveTimer < item.WaveInterval) { item.WaveTriggered = false; } } } private void StopRaid(RaidInstance raid) { if (raid.Active) { raid.Event.OnStop(); _raids.Remove(raid.Boss); raid.Active = false; } } public List<SpawnData> GetSpawners() { if (_raids.Count == 0) { return null; } List<SpawnData> list = new List<SpawnData>(); foreach (RaidInstance value in _raids.Values) { if (value.Active && value.Event != null) { float waveInterval = value.WaveInterval; int num = CountPlayersInRaidArea(value); float num2 = 1f - 0.05f * (float)num; num2 = Mathf.Clamp(num2, 0.5f, 1f); float num3 = waveInterval * num2; if (value.WaveTimer >= num3 && !value.WaveTriggered) { MessageHud.instance.ShowMessage((MessageType)2, GetSummonText(value.Boss), 0, (Sprite)null, false); list.AddRange(value.Event.m_spawn); value.WaveTimer = 0f; value.WaveTriggered = true; } } } return (list.Count > 0) ? list : null; } private string GetSummonText(Character boss) { return boss.m_name switch { "$enemy_eikthyr" => boss.m_name + " rallies the creatures of the forest!", "$enemy_gdking" => boss.m_name + " commands the forest to aid him!", "$enemy_bonemass" => boss.m_name + " lures the undead of the swamp to him!", "$enemy_dragon" => boss.m_name + " calls to her children!", "$enemy_goblinking" => "Yagluth summons the horde!", "$enemy_seekerqueen" => boss.m_name + " cries out for her brood!", "$enemy_fader" => boss.m_name + " gathers his armies!", _ => null, }; } private int CountPlayersInRaidArea(RaidInstance raid) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (Player allPlayer in Player.GetAllPlayers()) { float num2 = Vector3.Distance(((Component)allPlayer).transform.position, raid.Event.m_pos); if (num2 < raid.Event.m_eventRange) { num++; } } return num; } private bool ArePlayersInRaidArea(RaidInstance raid) { return CountPlayersInRaidArea(raid) > 0; } }