using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.PrimordialWyrm; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.AstrumDeus; using CalamityMod.NPCs.BrimstoneElemental; using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.Polterghast; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.Ravager; using CalamityMod.NPCs.Signus; using CalamityMod.NPCs.SlimeGod; using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; using System; using System.Collections.Generic; using System.Linq; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod { public static partial class NPCStats { #region Boss Stats Container Struct internal partial struct EnemyStats { public static SortedDictionary> DebuffImmunities; }; #endregion #region Stat Retrieval Methods public static void SetNPCDebuffImmunities(this NPC npc) { // Safety check: If for some reason the debuff array is not initialized yet, return and do nothing. // If the npc is not in the dictionary, return and do nothing. // Also, can I just say that I hate Sorted Dictionaries and Tuples and want to make something explode? -Ben bool exists = EnemyStats.DebuffImmunities.TryGetValue(npc.type, out var stupidTupleThing); if (npc.ModNPC is null || !exists) return; // If the npc is immune to everything, make it immune to everything if (stupidTupleThing.Item1) { for (int k = 0; k < npc.buffImmune.Length; k++) npc.buffImmune[k] = true; } // Then set debuff vulnerabilities, or immunities if not immune to everything for (int i = 0; i < stupidTupleThing.Item2.Length; ++i) npc.buffImmune[stupidTupleThing.Item2[i]] = !stupidTupleThing.Item1; // Declare the immunity sets in 1.4's new registry. if (!NPCID.Sets.DebuffImmunitySets.ContainsKey(npc.type) && !stupidTupleThing.Item1) { NPCID.Sets.DebuffImmunitySets[npc.type] = new NPCDebuffImmunityData() { SpecificallyImmuneTo = stupidTupleThing.Item2 }; } } #endregion #region Load/Unload // A static function, called exactly once, which initializes the EnemyStats struct at a predictable time. // This is necessary to ensure this dictionary is populated as early as possible. // Any boss not listed in here is only immune to Confusion and Pearl Aura. internal static void LoadDebuffs() { EnemyStats.DebuffImmunities = new SortedDictionary> { { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { NPCID.Deerclops, new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { NPCID.Plantera, new Tuple(false, new int[] { BuffID.Venom }) }, { NPCID.PlanterasTentacle, new Tuple(false, new int[] { BuffID.Venom }) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Venom }) }, { NPCID.HallowBoss, new Tuple(false, CalamityMod.holyEnemyImmunities) }, // She resists the cold because of her ice-related abilities. { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { NPCID.MoonLordCore, new Tuple(false, new int[] { ModContent.BuffType() }) }, { NPCID.MoonLordHand, new Tuple(false, new int[] { ModContent.BuffType() }) }, { NPCID.MoonLordHead, new Tuple(false, new int[] { ModContent.BuffType() }) }, { NPCID.MoonLordLeechBlob, new Tuple(false, new int[] { ModContent.BuffType() }) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType() }) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType(), ModContent.BuffType() }) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.OnFire }) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, // 20FEB2023: Ozzatron: made Ares immune to Miracle Blight, because otherwise he vanishes when affected by it // The "correct" way to fix this involves a colossal amount of work and will be handled at a later date { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType() }) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sunkenSeaEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.abyssEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.astralEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.plagueEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.holyEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(true, Array.Empty()) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Poisoned, BuffID.Venom }) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Poisoned, BuffID.Venom }) }, { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.slimeEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) } }; } // Destroys the EnemyStats struct to save memory because mod assemblies will not be fully unloaded until TML 1.4. internal static void UnloadDebuffs() { EnemyStats.DebuffImmunities = null; } #endregion } }