diff --git a/DataStructures/DebuffData.cs b/DataStructures/DebuffData.cs index 69e430fd75..ab27f901aa 100644 --- a/DataStructures/DebuffData.cs +++ b/DataStructures/DebuffData.cs @@ -1,7 +1,6 @@ using System; -using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Accessories; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -157,8 +156,8 @@ namespace CalamityMod.DataStructures public static StatModifier ApplyScalingToStatModifer(StatModifier Modifer, float scaling) { StatModifier output = new(); - output += (Modifer.Additive-1) * scaling; - output *= 1 + (Modifer.Multiplicative-1) * scaling; + output += (Modifer.Additive - 1) * scaling; + output *= 1 + (Modifer.Multiplicative - 1) * scaling; output.Base = Modifer.Base * scaling; output.Flat = Modifer.Flat * scaling; return output; @@ -172,9 +171,9 @@ namespace CalamityMod.DataStructures public static StatModifier ForceModifierPositiveWithScaling(StatModifier Modifer, float scaling) { StatModifier output = new(); - output += MathHelper.Max((Modifer.Additive - 1) * scaling,0); - output *= MathHelper.Max(1 + (Modifer.Multiplicative - 1) * scaling,1); - output.Base = MathHelper.Max(Modifer.Base * scaling,0); + output += MathHelper.Max((Modifer.Additive - 1) * scaling, 0); + output *= MathHelper.Max(1 + (Modifer.Multiplicative - 1) * scaling, 1); + output.Base = MathHelper.Max(Modifer.Base * scaling, 0); output.Flat = MathHelper.Max(Modifer.Flat * scaling, 0); return output; } @@ -185,7 +184,7 @@ namespace CalamityMod.DataStructures /// public void DefaultUpdateOnPlayer(Player player, int buffType, ref int buffIndex, ref int damage) { - + } /// @@ -210,13 +209,13 @@ namespace CalamityMod.DataStructures //Ensure at least 25% effectiveness if (totalScaling.Multiplicative <= 0.25f) - totalScaling.Multiplicative = 0.25f; + totalScaling.Multiplicative = 0.25f; if (totalScaling.Additive < 0.25f) totalScaling.Additive = 0.25f; totalDPS = totalScaling.ApplyTo(totalDPS); - var totalDPSAdjusted = totalDPS-EnemyVanillaRegenToCancelOut; - npc.Calamity().ApplyDPSDebuff((int)(totalDPSAdjusted), (int)Math.Max(totalDPS*MultiplierDamageTickSize,MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + var totalDPSAdjusted = totalDPS - EnemyVanillaRegenToCancelOut; + npc.Calamity().ApplyDPSDebuff((int)(totalDPSAdjusted), (int)Math.Max(totalDPS * MultiplierDamageTickSize, MinimumDamageTickSize), ref npc.lifeRegen, ref damage); } /// /// DoT functionality that takes into account Electric debuff's 4x DPS when moving @@ -278,7 +277,7 @@ namespace CalamityMod.DataStructures // If there are no Daybreak impaled spears, Daybroken has 1x potency (it was applied some other way) int adjustedSpears = Math.Max(1, numImpaledSpears); int baseDaybreakDoTValue = (int)(npc.Calamity().ActiveHeatDebuffMultiplier.ApplyTo(Daybroken.EnemyLostRegen) + (Daybroken.EnemyLostRegen * (adjustedSpears - 1))); - int totalDPSAdjusted = baseDaybreakDoTValue - Daybroken.EnemyVanillaRegenToCancelOut*numImpaledSpears; + int totalDPSAdjusted = baseDaybreakDoTValue - Daybroken.EnemyVanillaRegenToCancelOut * numImpaledSpears; if (numImpaledSpears == 0) { totalDPSAdjusted -= Daybroken.EnemyVanillaRegenToCancelOut; @@ -291,10 +290,10 @@ namespace CalamityMod.DataStructures public static void OiledNPCMethod(NPC npc, int buffType, ref int buffIndex, ref int damage) { var cnpc = npc.Calamity(); - double totalDPS = ApplyScalingToStatModifer(cnpc.ActiveHeatDebuffMultiplier,Oiled.HeatDebuffScaling).ApplyTo(Oiled.EnemyLostRegen); + double totalDPS = ApplyScalingToStatModifer(cnpc.ActiveHeatDebuffMultiplier, Oiled.HeatDebuffScaling).ApplyTo(Oiled.EnemyLostRegen); if (totalDPS <= 0) return; - npc.Calamity().ApplyDPSDebuff((int)(totalDPS), damage+(int)Math.Max(totalDPS * Oiled.MultiplierDamageTickSize, Oiled.MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + npc.Calamity().ApplyDPSDebuff((int)(totalDPS), damage + (int)Math.Max(totalDPS * Oiled.MultiplierDamageTickSize, Oiled.MinimumDamageTickSize), ref npc.lifeRegen, ref damage); } /// /// Has Dryad's Bane scale with Calamity's town NPC buffs @@ -419,5 +418,38 @@ namespace CalamityMod.DataStructures NPCLifeRegenMethod = DryadsBaneNPCMethod }; #endregion + + #region Helpers + public static int GetDebuffRegenValue(NPC npc, int type) + { + var debuffData = CalamityBuffSets.DebuffDataset[type]; + if (debuffData == null) + return 0; + + var oldRegen = npc.lifeRegen; + var oldCount = npc.lifeRegenCount; + int dmg = 1; + npc.lifeRegenCount = 0; + npc.lifeRegen = 0; + + int index = npc.FindBuffIndex(type); + + if (debuffData == Oiled) + { + bool hasVanillaOil = npc.onFrostBurn || npc.onFrostBurn2 || npc.onFire || npc.onFire2 || npc.onFire3 || npc.shadowFlame; + if (hasVanillaOil) + npc.lifeRegen -= Oiled.EnemyVanillaRegenToCancelOut; + Oiled.NPCLifeRegenMethod(npc, BuffID.Oiled, ref index, ref dmg); + } + + debuffData.NPCLifeRegenMethod(npc, type, ref index, ref dmg); + + int done = npc.lifeRegen; + npc.lifeRegen = oldRegen; + npc.lifeRegenCount = oldCount; + return done; + } + + #endregion } } diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 4addae66e0..63097f183c 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.TownNPCs; @@ -2256,6 +2257,14 @@ namespace CalamityMod return new ArgumentException("ERROR: The first argument to \"AddToBossHPScalingConfig\" must be an int or short ID."); return AddToHPScaling(npcType6); } + case "GetDebuffDamage": + { + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify an NPC and a buff type int"); + if (args[1] is not NPC npc || args[2] is not int type) + return new ArgumentException("ERROR: The first argument to \"GetDebuffDamage\" must be an NPC, and the second must be an int."); + return DebuffData.GetDebuffRegenValue(npc, type); + } default: return new ArgumentException("ERROR: Invalid method name."); } diff --git a/ModSupport/TestingEfficiency.cs b/ModSupport/TestingEfficiency.cs new file mode 100644 index 0000000000..b769d14c30 --- /dev/null +++ b/ModSupport/TestingEfficiency.cs @@ -0,0 +1,311 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Items.SummonItems; +using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.NPCs.BrimstoneElemental; +using CalamityMod.NPCs.Bumblebirb; +using CalamityMod.NPCs.CalClone; +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.Crabulon; +using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Apollo; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Artemis; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.NPCs.HiveMind; +using CalamityMod.NPCs.Leviathan; +using CalamityMod.NPCs.OldDuke; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.Polterghast; +using CalamityMod.NPCs.PrimordialWyrm; +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.SupremeCalamitas; +using CalamityMod.NPCs.Yharon; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.ModSupport +{ + //This uses its own class so the entire class can simply not load when TE is not enabled. + public class TestingEfficiencySupport : ModSystem + { + + internal static Mod testingEfficiency = null; + public override bool IsLoadingEnabled(Mod mod) + { + testingEfficiency = null; + return ModLoader.TryGetMod("TestingEfficiency", out testingEfficiency); + } + + List<(string name, float tier, Func getter, Action setter, Func> texture)> BossTogles = new() + { + ("Desert Scourge", 1.5f, + () => DownedBossSystem.downedDesertScourge, + x => DownedBossSystem.downedDesertScourge = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Crabulon", 2.5f, + () => DownedBossSystem.downedCrabulon, + x => DownedBossSystem.downedCrabulon = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Hive Mind / Perforators", 3.5f, + () => DownedBossSystem.downedHiveMind || DownedBossSystem.downedPerforator, + x => DownedBossSystem.downedHiveMind = DownedBossSystem.downedPerforator = x, + () => WorldGen.crimson + ? TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]] + : TextureAssets.NpcHeadBoss[HiveMind.phase2IconIndex]), + + ("Slime God", 6.5f, + () => DownedBossSystem.downedSlimeGod, + x => DownedBossSystem.downedSlimeGod = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Cryogen", 8.5f, + () => DownedBossSystem.downedCryogen, + x => DownedBossSystem.downedCryogen = x, + () => TextureAssets.NpcHeadBoss[Cryogen.cryoIconIndex]), + + ("Aquatic Scourge", 9.25f, + () => DownedBossSystem.downedAquaticScourge, + x => DownedBossSystem.downedAquaticScourge = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Brimstone Elemental", 10.25f, + () => DownedBossSystem.downedBrimstoneElemental, + x => DownedBossSystem.downedBrimstoneElemental = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Calamitas Clone", 11.5f, + () => DownedBossSystem.downedCalamitasClone, + x => DownedBossSystem.downedCalamitasClone = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Leviathan & Anahita", 12.25f, + () => DownedBossSystem.downedLeviathan, + x => DownedBossSystem.downedLeviathan = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Astrum Aureus", 12.5f, + () => DownedBossSystem.downedAstrumAureus, + x => DownedBossSystem.downedAstrumAureus = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Plaguebringer Goliath", 14.25f, + () => DownedBossSystem.downedPlaguebringer, + x => DownedBossSystem.downedPlaguebringer = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Ravager", 15.25f, + () => DownedBossSystem.downedRavager, + x => DownedBossSystem.downedRavager = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Astrum Deus", 16.5f, + () => DownedBossSystem.downedAstrumDeus, + x => DownedBossSystem.downedAstrumDeus = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Dragonfolly", 17.25f, + () => DownedBossSystem.downedDragonfolly, + x => DownedBossSystem.downedDragonfolly = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Profaned Guardians", 17.5f, + () => DownedBossSystem.downedGuardians, + x => DownedBossSystem.downedGuardians = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Providence", 18f, + () => DownedBossSystem.downedProvidence, + x => DownedBossSystem.downedProvidence = x, + () => TextureAssets.Item[ModContent.ItemType()]), + + ("Ceaseless Void", 18.25f, + () => DownedBossSystem.downedCeaselessVoid, + x => DownedBossSystem.downedCeaselessVoid = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Storm Weaver", 18.5f, + () => DownedBossSystem.downedStormWeaver, + x => DownedBossSystem.downedStormWeaver = x, + () => TextureAssets.NpcHeadBoss[StormWeaverHead.normalIconIndex]), + + ("Signus", 18.75f, + () => DownedBossSystem.downedSignus, + x => DownedBossSystem.downedSignus = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Polterghast", 19f, + () => DownedBossSystem.downedPolterghast, + x => DownedBossSystem.downedPolterghast = x, + () => TextureAssets.NpcHeadBoss[Polterghast.phase1IconIndex]), + + ("Old Duke", 19.5f, + () => DownedBossSystem.downedBoomerDuke, + x => DownedBossSystem.downedBoomerDuke = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Devourer of Gods", 20f, + () => DownedBossSystem.downedDoG, + x => DownedBossSystem.downedDoG = x, + () => TextureAssets.NpcHeadBoss[DevourerofGodsHead.phase1IconIndex]), + + ("Yharon", 21f, + () => DownedBossSystem.downedYharon, + x => DownedBossSystem.downedYharon = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Exo Mechs", 22f, + () => DownedBossSystem.downedExoMechs, + x => DownedBossSystem.downedExoMechs = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]), + + ("Supreme Calamitas", 23f, + () => DownedBossSystem.downedCalamitas, + x => DownedBossSystem.downedCalamitas = x, + () => TextureAssets.NpcHeadBoss[SupremeCalamitas.hoodedHeadIconIndex]), + + ("Primordial Wyrm", 23.5f, + () => DownedBossSystem.downedPrimordialWyrm, + x => DownedBossSystem.downedPrimordialWyrm = x, + () => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]) + }; + + public override void PostSetupContent() + { + foreach (var item in BossTogles) + { + testingEfficiency.Call("RegisterBoss", item.name, item.tier, item.getter, item.setter, item.texture); + } + } + } + + [ReinitializeDuringResizeArrays] + public class TestingEfficiencyIdSets + { + //These being set by Calamity is important so that boss reworks can update these on Cal's end in development + //Otherwise, reworks to bosses would often require their own build, similar to issues CalTestHelpers had before. + //Because these are ID sets, other mods that may be interested in similar info can also use them regardless of if TE is loaded + + internal static int[] NpcToCountAs = NPCID.Sets.Factory.CreateNamedSet("TestingEfficiency/NpcToCountAs") + .RegisterIntSet(-1, + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType() , + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType() + ); + + + public static bool[] ShouldMergeInstances = NPCID.Sets.Factory.CreateNamedSet("TestingEfficiency/ShouldMergeInstances") + .RegisterBoolSet( + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + ); + + public static bool[] ShouldBlacklist = NPCID.Sets.Factory.CreateNamedSet("TestingEfficiency/ShouldBlacklist") + .RegisterBoolSet(ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + ); + + public static bool[] ShouldTrackAsABoss = NPCID.Sets.Factory.CreateNamedSet("TestingEfficiency/ShouldTrackAsABoss") + .Description("NPC types that should be whitelisted to count as a boss") + .RegisterBoolSet( + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + ); + } +} diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index 6204ae467e..06cb703727 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -105,8 +105,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.timeLeft *= 20; NPC.npcSlots = 16f; NPC.damage = NPC.defDamage; - CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); - calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.KillTime = CalamityNPCSets.BossKillTimes[NPC.type]; calamityGlobalNPC.newAI[0] = 1f; nonHostile = false; NPC.chaseable = true; diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index cec29d817c..cfdf30ce32 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -101,8 +101,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.timeLeft *= 20; NPC.npcSlots = 16f; NPC.damage = NPC.defDamage; - CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); - calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.KillTime = CalamityNPCSets.BossKillTimes[NPC.type]; calamityGlobalNPC.newAI[0] = 1f; nonHostile = false; NPC.chaseable = true; diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 9b0e5564aa..291c2cbf78 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -146,8 +146,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.timeLeft *= 20; NPC.npcSlots = 16f; NPC.damage = NPC.defDamage; - CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); - calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.KillTime = CalamityNPCSets.BossKillTimes[NPC.type];s calamityGlobalNPC.newAI[0] = 1f; nonHostile = false; NPC.boss = true; diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index 66538d7824..fcb8ec54a1 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -100,8 +100,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.timeLeft *= 20; NPC.npcSlots = 16f; NPC.damage = NPC.defDamage; - CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); - calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.KillTime = CalamityNPCSets.BossKillTimes[NPC.type]; calamityGlobalNPC.newAI[0] = 1f; nonHostile = false; NPC.chaseable = true; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index be5bd62f3d..ded8afe8f5 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -93,9 +93,6 @@ namespace CalamityMod.NPCs { #region Variables - /// Data structure used for storing Calamity's intended boss kill times. - public static SortedDictionary BossKillTimes; - /// Data structure used for storing the damage reduction values of NPCs. public static SortedDictionary DRValues { get; set; } @@ -1055,120 +1052,18 @@ namespace CalamityMod.NPCs { NPCID.WallofFlesh, 0.15f }, }; #endregion - - // Somehow the SetStatic is called few times before SetStaticDefaults - // So We Initialize the Dictionary first. And Push Data later (At SetStaticDefaults) - BossKillTimes = []; } public override void Unload() { DRValues?.Clear(); DRValues = null; - - BossKillTimes?.Clear(); - BossKillTimes = null; } #endregion #region Set Defaults public override void SetStaticDefaults() { - #region Add Entries to BossKillTimes - BossKillTimes.AddRange(new Dictionary(){ - - // - // VANILLA BOSSES - // - { NPCID.KingSlime, 5400 }, // 1:30 (90 seconds) - { NPCID.EyeofCthulhu, 5400 }, // 1:30 (90 seconds) - { NPCID.EaterofWorldsHead, 7200 }, // 2:00 (120 seconds) - { NPCID.EaterofWorldsBody, 7200 }, - { NPCID.EaterofWorldsTail, 7200 }, - { NPCID.BrainofCthulhu, 7200 }, // 2:00 (120 seconds, total length of fight including Creepers phase) - { NPCID.Creeper, 1800 }, // 0:30 (30 seconds, length of Creepers phase) - { NPCID.Deerclops, 5400 }, // 1:30 (90 seconds) - { NPCID.QueenBee, 7200 }, // 2:00 (120 seconds) - { NPCID.SkeletronHead, 7200 }, // 2:00 (120 seconds) - { NPCID.WallofFlesh, 7200 }, // 2:00 (120 seconds) - { NPCID.WallofFleshEye, 7200 }, - { NPCID.QueenSlimeBoss, 7200 }, // 2:00 (120 seconds) - { NPCID.Spazmatism, 10800 }, // 3:00 (180 seconds) - { NPCID.Retinazer, 10800 }, - { NPCID.TheDestroyer, 10800 }, // 3:00 (180 seconds) - { NPCID.TheDestroyerBody, 10800 }, - { NPCID.TheDestroyerTail, 10800 }, - { NPCID.SkeletronPrime, 10800 }, // 3:00 (180 seconds) - { NPCID.Plantera, 10800 }, // 3:00 (180 seconds) - { NPCID.Golem, 9000 }, // 2:30 (150 seconds) - { NPCID.GolemHead, 3600 }, // 1:00 (60 seconds) - { NPCID.DukeFishron, 9000 }, // 2:30 (150 seconds) - { NPCID.HallowBoss, 10800 }, // 3:00 (180 seconds) - { NPCID.CultistBoss, 9000 }, // 2:30 (150 seconds) - { NPCID.MoonLordCore, 14400 }, // 4:00 (240 seconds) - { NPCID.MoonLordHand, 7200 }, // 2:00 (120 seconds) - { NPCID.MoonLordHead, 7200 }, // 2:00 (120 seconds) - - // - // CALAMITY BOSSES - // - { NPCType(), 5400 }, // 1:30 (90 seconds) - { NPCType(), 5400 }, - { NPCType(), 5400 }, - { NPCType(), 5400 }, // 1:30 (90 seconds) - { NPCType(), 7200 }, // 2:00 (120 seconds) - { NPCType(), 7200 }, // 2:00 (120 seconds) - { NPCType(), 9000 }, // 2:30 (150 seconds) -- total length of Slime God fight - { NPCType(), 4500 }, // 1:15 (75 seconds) - { NPCType(), 4500 }, // 1:15 (75 seconds) - { NPCType(), 4500 }, // 1:15 (75 seconds) -- split slimes should spawn at 1:15 and die at around 2:30 - { NPCType(), 4500 }, // 1:15 (75 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 9000 }, // 2:30 (150 seconds) - { NPCType(), 9000 }, - { NPCType(), 9000 }, - { NPCType(), 9000 }, - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 10800 }, - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 7200 }, // 2:00 (120 seconds) -- first phase is 1:00 - { NPCType(), 7200 }, - { NPCType(), 7200 }, - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 7200 }, // 2:00 (120 seconds) - { NPCType(), 7200 }, // 2:00 (120 seconds) - { NPCType(), 14400 }, // 4:00 (240 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 1200 }, // 0:20 (20 seconds) - { NPCType(), 8100 }, // 2:15 (135 seconds) - { NPCType(), 8100 }, - { NPCType(), 8100 }, - { NPCType(), 7200 }, // 2:00 (120 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 14400 }, // 4:00 (240 seconds) - { NPCType(), 14400 }, // DoG Phase 1 is 1:30, DoG Phase 2 is 2:30 - { NPCType(), 14400 }, - { NPCType(), 14400 }, // 4:00 (240 seconds) - { NPCType(), 21600 }, // 6:00 (360 seconds) - { NPCType(), 21600 }, - { NPCType(), 21600 }, // 6:00 (360 seconds) - { NPCType(), 21600 }, - { NPCType(), 21600 }, - { NPCType(), 21600 }, - { NPCType(), 21600 }, - { NPCType(), 21600 }, // 6:00 (360 seconds) - { NPCType(), 21600 }, - { NPCType(), 21600 }, - { NPCType(), 21600 }, - { NPCType(), 18000 }, // 5:00 (300 seconds) - { NPCType(), 18000 } // 5:00 (300 seconds) - }); - #endregion - // Set Plantera to be able to update oldPos[x] // This is only used for her Rev+ AI charge attacks NPCID.Sets.TrailingMode[NPCID.Plantera] = 1; @@ -1195,8 +1090,8 @@ namespace CalamityMod.NPCs } // Aquatic Scourge sets kill time in AI, not here. - if (BossKillTimes.TryGetValue(npc.type, out int revKillTime) && !CalamityNPCTypeSets.AquaticScourge.Contains(npc.type)) - KillTime = revKillTime; + if (!CalamityNPCTypeSets.AquaticScourge.Contains(npc.type)) + KillTime = CalamityNPCSets.BossKillTimes[npc.type]; // Fixing more red mistakes if (npc.type == NPCID.WallofFleshEye) diff --git a/Systems/Collections/CalamityBuffSets.cs b/Systems/Collections/CalamityBuffSets.cs index 6537b0421c..d2b5741368 100644 --- a/Systems/Collections/CalamityBuffSets.cs +++ b/Systems/Collections/CalamityBuffSets.cs @@ -20,8 +20,7 @@ namespace CalamityMod.Systems.Collections [ReinitializeDuringResizeArrays] public static class CalamityBuffSets { - private static SetFactory Factory = new SetFactory(BuffLoader.BuffCount, "CalamityMod/BuffID", Search); - private static IdDictionary Search = IdDictionary.Create(); + private static SetFactory Factory = BuffID.Sets.Factory; /// /// If for a buff type, then that buff will have its duration extended with The Amalgam equipped.
diff --git a/Systems/Collections/CalamityItemSets.cs b/Systems/Collections/CalamityItemSets.cs index 17ac1ea02a..cec913ee4b 100644 --- a/Systems/Collections/CalamityItemSets.cs +++ b/Systems/Collections/CalamityItemSets.cs @@ -24,8 +24,7 @@ namespace CalamityMod.Systems.Collections [ReinitializeDuringResizeArrays] public static class CalamityItemSets { - private static SetFactory Factory = new SetFactory(ItemLoader.ItemCount, "CalamityMod/ItemID", Search); - private static IdDictionary Search = IdDictionary.Create(); + private static SetFactory Factory = ItemID.Sets.Factory; /// /// If for an item type, prevents an item from removing Calamity's summon damage penalty mechanic despite having tool power.
diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs index 502d723b75..a59adcbdd0 100644 --- a/Systems/Collections/CalamityNPCSets.cs +++ b/Systems/Collections/CalamityNPCSets.cs @@ -48,8 +48,7 @@ namespace CalamityMod.Systems.Collections [ReinitializeDuringResizeArrays] public static class CalamityNPCSets { - private static SetFactory Factory = new SetFactory(NPCLoader.NPCCount, "CalamityMod/NPCID", Search); - private static IdDictionary Search = IdDictionary.Create(); + private static SetFactory Factory = NPCID.Sets.Factory; /// /// If for an NPC type, makes this NPC be susceptible to .
@@ -233,6 +232,100 @@ namespace CalamityMod.Systems.Collections .Description("Prevents Calamity's IsAnEnemy method from considering this NPC an enemy.") .RegisterBoolSet(NPCID.TargetDummy, NPCType()); + /// + /// The intended kill times of Calamity bosses, in frames + /// + public static int[] BossKillTimes = Factory.CreateNamedSet("BossKillTimes") + .Description("The intended kill times of Calamity bosses, in frames") + .RegisterIntSet(0, + NPCID.KingSlime, 5400, // 1:30 (90 seconds) + NPCID.EyeofCthulhu, 5400, // 1:30 (90 seconds) + NPCID.EaterofWorldsHead, 7200, // 2:00 (120 seconds) + NPCID.EaterofWorldsBody, 7200, + NPCID.EaterofWorldsTail, 7200, + NPCID.BrainofCthulhu, 7200, // 2:00 (120 seconds, total length of fight including Creepers phase) + NPCID.Creeper, 1800, // 0:30 (30 seconds, length of Creepers phase) + NPCID.Deerclops, 5400, // 1:30 (90 seconds) + NPCID.QueenBee, 7200, // 2:00 (120 seconds) + NPCID.SkeletronHead, 7200, // 2:00 (120 seconds) + NPCID.WallofFlesh, 7200, // 2:00 (120 seconds) + NPCID.WallofFleshEye, 7200, + NPCID.QueenSlimeBoss, 7200, // 2:00 (120 seconds) + NPCID.Spazmatism, 10800, // 3:00 (180 seconds) + NPCID.Retinazer, 10800, + NPCID.TheDestroyer, 10800, // 3:00 (180 seconds) + NPCID.TheDestroyerBody, 10800, + NPCID.TheDestroyerTail, 10800, + NPCID.SkeletronPrime, 10800, // 3:00 (180 seconds) + NPCID.Plantera, 10800, // 3:00 (180 seconds) + NPCID.Golem, 9000, // 2:30 (150 seconds) + NPCID.GolemHead, 3600, // 1:00 (60 seconds) + NPCID.DukeFishron, 9000, // 2:30 (150 seconds) + NPCID.HallowBoss, 10800, // 3:00 (180 seconds) + NPCID.CultistBoss, 9000, // 2:30 (150 seconds) + NPCID.MoonLordCore, 14400, // 4:00 (240 seconds) + NPCID.MoonLordHand, 7200, // 2:00 (120 seconds) + NPCID.MoonLordHead, 7200, // 2:00 (120 seconds) + + // + // CALAMITY BOSSES + // + NPCType(), 5400, // 1:30 (90 seconds) + NPCType(), 5400, + NPCType(), 5400, + NPCType(), 5400, // 1:30 (90 seconds) + NPCType(), 7200, // 2:00 (120 seconds) + NPCType(), 7200, // 2:00 (120 seconds) + NPCType(), 9000, // 2:30 (150 seconds) -- total length of Slime God fight + NPCType(), 4500, // 1:15 (75 seconds) + NPCType(), 4500, // 1:15 (75 seconds) + NPCType(), 4500, // 1:15 (75 seconds) -- split slimes should spawn at 1:15 and die at around 2:30 + NPCType(), 4500, // 1:15 (75 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 9000, // 2:30 (150 seconds) + NPCType(), 9000, + NPCType(), 9000, + NPCType(), 9000, + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 10800, + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 7200, // 2:00 (120 seconds) -- first phase is 1:00 + NPCType(), 7200, + NPCType(), 7200, + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 7200, // 2:00 (120 seconds) + NPCType(), 7200, // 2:00 (120 seconds) + NPCType(), 14400, // 4:00 (240 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 1200, // 0:20 (20 seconds) + NPCType(), 8100, // 2:15 (135 seconds) + NPCType(), 8100, + NPCType(), 8100, + NPCType(), 7200, // 2:00 (120 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 10800, // 3:00 (180 seconds) + NPCType(), 14400, // 4:00 (240 seconds) + NPCType(), 14400, // DoG Phase 1 is 1:30, DoG Phase 2 is 2:30 + NPCType(), 14400, + NPCType(), 14400, // 4:00 (240 seconds) + NPCType(), 21600, // 6:00 (360 seconds) + NPCType(), 21600, + NPCType(), 21600, // 6:00 (360 seconds) + NPCType(), 21600, + NPCType(), 21600, + NPCType(), 21600, + NPCType(), 21600, + NPCType(), 21600, // 6:00 (360 seconds) + NPCType(), 21600, + NPCType(), 21600, + NPCType(), 21600, + NPCType(), 18000, // 5:00 (300 seconds) + NPCType(), 18000 // 5:00 (300 seconds) + ); + /// /// Associates an NPC type with the base value of their max health in Boss Rush.
/// If an NPC type is not a key in this dictionary, then it will use its standard max health value. diff --git a/Systems/Collections/CalamityNPCTypeSets.cs b/Systems/Collections/CalamityNPCTypeSets.cs index 5d8e4a555b..09517fad07 100644 --- a/Systems/Collections/CalamityNPCTypeSets.cs +++ b/Systems/Collections/CalamityNPCTypeSets.cs @@ -20,8 +20,7 @@ namespace CalamityMod.Systems.Collections [ReinitializeDuringResizeArrays] public static class CalamityNPCTypeSets { - private static SetFactory Factory = new SetFactory(NPCLoader.NPCCount, "CalamityMod/NPCType", Search); - private static IdDictionary Search = IdDictionary.Create(); + private static SetFactory Factory = NPCID.Sets.Factory; // Used for dropping Ancient Bone Dust, vanilla has a Skeleton NPCID set which has more unwanted enemies in it public static bool[] Skeleton = Factory.CreateNamedSet("Skeleton") diff --git a/Systems/Collections/CalamityProjectileSets.cs b/Systems/Collections/CalamityProjectileSets.cs index 761ef5f3bb..e16dc062b4 100644 --- a/Systems/Collections/CalamityProjectileSets.cs +++ b/Systems/Collections/CalamityProjectileSets.cs @@ -14,8 +14,7 @@ namespace CalamityMod.Systems.Collections [ReinitializeDuringResizeArrays] public static class CalamityProjectileSets { - private static SetFactory Factory = new SetFactory(ProjectileLoader.ProjectileCount, "CalamityMod/ProjectileID", Search); - private static IdDictionary Search = IdDictionary.Create(); + private static SetFactory Factory = ProjectileID.Sets.Factory; /// /// If for a projectile type, then that minion will completely ignore Calamity's summon damage penalty mechanic with no exceptions.
diff --git a/Systems/Collections/CalamityTileSets.cs b/Systems/Collections/CalamityTileSets.cs index 45d1e37afc..b4336e4360 100644 --- a/Systems/Collections/CalamityTileSets.cs +++ b/Systems/Collections/CalamityTileSets.cs @@ -11,8 +11,7 @@ namespace CalamityMod.Systems.Collections [ReinitializeDuringResizeArrays] public static class CalamityTileSets { - private static SetFactory Factory = new SetFactory(TileLoader.TileCount, "CalamityMod/TileID", Search); - private static IdDictionary Search = IdDictionary.Create(); + private static SetFactory Factory = TileID.Sets.Factory; /// /// Should only contain modded tiles. If for a tile type, then that tile can be replaced by the Abyss during world generation.