diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs new file mode 100644 index 0000000000..24e93888d3 --- /dev/null +++ b/Balancing/BalancingChangesManager.cs @@ -0,0 +1,379 @@ +using CalamityMod; +using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.Crabulon; +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.OldDuke; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Projectiles.DraedonsArsenal; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Balancing +{ + public static class BalancingChangesManager + { + internal static List UniversalBalancingChanges = null; + internal static List NPCSpecificBalancingChanges = null; + + // Balancing changes in this method are sorted based on place in progression, NPC name (from A-Z), and strength of resistance in ascending order, in that level of priority. + // For ease of change, changes that are not exclusive to one specific weapon are not bundled into one line if they share the same resistance factor. + // To give an example of this, Thanatos having a 50% resist to Chicken Cannon and Prismatic Breaker should be two distinct lines with a 0.5x factor instead of hamfisting them all + // into one single resist that may have to be split later. + internal static void Load() + { + // Declare specific filters. + bool DragonRageFilter(Projectile p) => + p.type == ProjectileType() || p.type == ProjectileType() || (p.type == ProjectileType() && p.melee); + + bool MonkStaffT3Filter(Projectile p) => + p.type == ProjectileID.MonkStaffT3_AltShot || (p.type == ProjectileID.Electrosphere && Main.player[p.owner].ActiveItem().type == ItemID.MonkStaffT3); + + bool MushroomSpearFilter(Projectile p) => + p.type == ProjectileID.Mushroom && Main.player[p.owner].ActiveItem().type == ItemID.MushroomSpear; + + UniversalBalancingChanges = new List() + { + // Nerf the T3 Monk Staff by 75% due to its strong primary fire buff. + Do(new ProjectileSpecificRequirementBalancingRule(0.25f, MonkStaffT3Filter)), + + // Nerf Seedler seeds by 66.6%. + Do(new ProjectileResistBalancingRule(0.333f, ProjectileID.SeedlerNut, ProjectileID.SeedlerThorn)), + + // Nerf Cursed Dart flames by 50%. + Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CursedDartFlame)), + + // Nerf Mushroom Spear projectiles by 50%. + Do(new ProjectileSpecificRequirementBalancingRule(0.5f, MushroomSpearFilter)), + }; + + NPCSpecificBalancingChanges = new List(); + + #region Desert Scourge + + // 50% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DesertScourgeIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + #endregion Desert Scourge + + #region Brain of Cthulhu / Creepers + + // 50% resist to true melee. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 50% resist to Demon Scythes. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe)))); + + #endregion Brain of Cthulhu / Creepers + + #region Eater of Worlds + + // 50% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.EaterofWorldsIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 50% resist to Demon Scythes. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.EaterofWorldsIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe)))); + + // 40% resist to Sky Glaze. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.EaterofWorldsIDs, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + + #endregion Eater of Worlds + + #region The Perforators + + // 50% resist to true melee + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.PerforatorIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + #endregion The Perforators + + #region The Aquatic Scourge + + // 50% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AquaticScourgeIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 50% resist to Dormant Brimseekers. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AquaticScourgeIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + #endregion The Aquatic Scourge + + #region The Destroyer + + // 50% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 50% resist to Dormant Brimseekers. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + #endregion The Destroyer + + #region Ravager + + // 50% resist to true melee. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new TrueMeleeResistBalancingRule(0.5f))); + + #endregion Ravager + + #region Duke Fishron + + // 35% vulnerability to Resurrection Butterfly. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.CultistBoss, Do(new ProjectileResistBalancingRule(1.35f, ProjectileType(), ProjectileType())))); + + #endregion Duke Fishron + + #region Cultist + + // 25% resist to Resurrection Butterfly. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.CultistBoss, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + + #endregion Cultist + + #region Astrum Deus + + // 75% resist to Plaguenades. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.25f, ProjectileType(), ProjectileType())))); + + // 50% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 25% resist to Resurrection Butterfly. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + + #endregion Astrum Deus + + #region Ceaseless Void / Dark Energies + + // 50% resist to true melee. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new TrueMeleeResistBalancingRule(0.5f))); + + #endregion Ceaseless Void / Dark Energies + + #region Storm Weaver + + // 50% resist to true melee + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 50% resist to Dazzling Stabbers. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Elemental Axes. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Pristine Fury. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Tactician's Trump Card explosions. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 25% resist to Molten Amputator blobs. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.StormWeaverIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + + #endregion Storm Weaver + + #region Old Duke + + // 60% resist to Last Mourning. + // This will technically catch pumpkins from the Horseman's Blade but that shouldn't really matter. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.4f, ProjectileType(), ProjectileID.FlamingJack))); + + // 20% resist to Time Bolt. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.8f, ProjectileType()))); + + #endregion Old Duke + + #region The Devourer of Gods + + // 15% vulnerability to Time Bolt stealth strikes. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DevourerOfGodsIDs, Do(new StealthStrikeBalancingRule(1.15f, ProjectileType())))); + + #endregion The Devourer of Gods + + #region Ares + + // 75% resist to Dragon Rage projectiles. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.25f, DragonRageFilter)))); + + // 60% resist to Murasama. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.4f, ProjectileType())))); + + // 50% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new TrueMeleeResistBalancingRule(0.5f)))); + + // 50% resist to Enforcer projectiles. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 20% resist to Eclipse's Fall stealth strike. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + + #endregion Ares + + #region Artemis and Apollo + + int[] exoTwins = new int[] { NPCType(), NPCType() }; + + // 10% resist to Eclipse's Fall stealth strike. + NPCSpecificBalancingChanges.AddRange(Bundle(exoTwins, Do(new ProjectileResistBalancingRule(0.9f, ProjectileType())))); + + #endregion Artemis and Apollo + + #region Thanatos + + // 75% resist to Celestus. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.25f, ProjectileType(), ProjectileType())))); + + // 65% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new TrueMeleeResistBalancingRule(0.35f)))); + + // 65% resist to Hadopelagic Echo. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType(), ProjectileType())))); + + // 50% resist to Chicken Cannon. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Prismatic Breaker. (why is this more than BOTH Rancor and Yharim's Crystal?) + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + + // 50% resist to Vehemence skulls. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType(), ProjectileType())))); + + // 40% resist to Rancor. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + + // 40% resist to Wrathwing stealth strike. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + + // 40% resist to Yharim's Crystal. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + + // 35% resist to Seraphim lasers. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + + // 30% resist to Sirius. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + + // 25% resist to Godslayer Slugs. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + + // 25% resist to Luminite Bullets. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.MoonlordBullet)))); + + // 20% resist to Eradicator beams. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + + // 20% resist to Voltaic Climax / Void Vortex hitscan beams. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + + // 20% resist to Blood Boiler fire. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + + // 15% resist to Gruesome Eminence. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + + #endregion Thanatos + + #region Supreme Calamitas / Brimstone Heart + + // 30% resist to Surge Driver's alt click comets. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.7f, ProjectileType()))); + + // 20% resist to Executioner's Blade stealth strikes. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.8f, ProjectileType()))); + + // 15% resist to Seraphim lasers. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.85f, ProjectileType()))); + + #endregion + + #region Supreme Calamitas / Soul Seekers + + // 85% resist to Chicken Cannon. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.15f, ProjectileType()))); + + // 30% resist to Murasama. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.7f, ProjectileType()))); + + // 25% resist to Yharim's Crystal. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.75f, ProjectileType()))); + + // 10% resist to Surge Driver's alt click comets. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType()))); + + // 10% resist to Executioner's Blade stealth strikes. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType()))); + + // 10% resist to Celestus. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.9f, ProjectileType(), ProjectileType()))); + + // 15% vulnerability to The Atom Splitter (Yes, this is kinda weird, but it's what Piky asked for). + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(1.15f, ProjectileType(), ProjectileType()))); + + #endregion Supreme Calamitas / Soul Seekers + } + + internal static void Unload() + { + UniversalBalancingChanges = null; + NPCSpecificBalancingChanges = null; + } + + public static void ApplyFromProjectile(NPC npc, ref int damage, Projectile proj) + { + NPCHitContext hitContext = NPCHitContext.ConstructFromProjectile(proj); + + // Apply universal balancing rules. + foreach (IBalancingRule[] balancingRules in UniversalBalancingChanges) + { + foreach (IBalancingRule balancingRule in balancingRules) + { + if (balancingRule.AppliesTo(npc, hitContext)) + balancingRule.ApplyBalancingChange(npc, ref damage); + } + } + + // As well as rules specific to NPCs. + foreach (NPCBalancingChange balanceChange in NPCSpecificBalancingChanges) + { + if (npc.type != balanceChange.NPCType) + continue; + + foreach (IBalancingRule balancingRule in balanceChange.BalancingRules) + { + if (balancingRule.AppliesTo(npc, hitContext)) + balancingRule.ApplyBalancingChange(npc, ref damage); + } + } + } + + // This function simply concatenates a bunch of balancing rules into an array. + // It looks a lot nicer than constantly typing "new IBalancingRule[]". + internal static IBalancingRule[] Do(params IBalancingRule[] rules) => rules; + + // Shorthand for bundling balancing balancing rules in such a way that it applies to multiple NPCs at once. + // This is useful for preventing having to copy-paste/store the rules and apply it to each NPC individually. + internal static NPCBalancingChange[] Bundle(IEnumerable npcIDs, params IBalancingRule[] rules) + { + NPCBalancingChange[] changes = new NPCBalancingChange[npcIDs.Count()]; + for (int i = 0; i < changes.Length; i++) + changes[i] = new NPCBalancingChange(npcIDs.ElementAt(i), rules); + return changes; + } + } +} diff --git a/Balancing/BalancingRules.cs b/Balancing/BalancingRules.cs new file mode 100644 index 0000000000..8c43e1fa9d --- /dev/null +++ b/Balancing/BalancingRules.cs @@ -0,0 +1,136 @@ +using System.Linq; +using Terraria; + +namespace CalamityMod.Balancing +{ + public class ClassResistBalancingRule : IBalancingRule + { + public float DamageMultiplier; + public ClassType ApplicableClass; + public ClassResistBalancingRule(float damageMultiplier, ClassType classType) + { + DamageMultiplier = damageMultiplier; + ApplicableClass = classType; + } + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) + { + return hitContext.Class == ApplicableClass; + } + + public void ApplyBalancingChange(NPC npc, ref int damage) => damage = (int)(damage * DamageMultiplier); + } + + public class NPCSpecificRequirementBalancingRule : IBalancingRule + { + public NPCApplicationRequirement Requirement; + public delegate bool NPCApplicationRequirement(NPC npc); + public NPCSpecificRequirementBalancingRule(NPCApplicationRequirement npcApplicationRequirement) + { + Requirement = npcApplicationRequirement; + } + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) => Requirement(npc); + + // This "balancing" rule doesn't actually perform any changes. It simply serves as a means of enforcing NPC-specific requirements, and should be used only as a filter. + // As such, this method is empty. + public void ApplyBalancingChange(NPC npc, ref int damage) { } + } + + public class PierceResistBalancingRule : IBalancingRule + { + public float DamageMultiplier; + public PierceResistBalancingRule(float damageMultiplier) => DamageMultiplier = damageMultiplier; + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) => hitContext.Pierce > 1 || hitContext.Pierce == -1; + + public void ApplyBalancingChange(NPC npc, ref int damage) => damage = (int)(damage * DamageMultiplier); + } + + public class ProjectileResistBalancingRule : IBalancingRule + { + public float DamageMultiplier; + public int[] ApplicableProjectileTypes; + public ProjectileResistBalancingRule(float damageMultiplier, params int[] projTypes) + { + DamageMultiplier = damageMultiplier; + ApplicableProjectileTypes = projTypes; + } + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) + { + if (hitContext.DamageSource != DamageSourceType.FriendlyProjectile) + return false; + if (!ApplicableProjectileTypes.Contains(hitContext.ProjectileType ?? -1)) + return false; + + return true; + } + + public void ApplyBalancingChange(NPC npc, ref int damage) => damage = (int)(damage * DamageMultiplier); + } + + public class ProjectileSpecificRequirementBalancingRule : IBalancingRule + { + public float DamageMultiplier; + public ProjectileApplicationRequirement Requirement; + public delegate bool ProjectileApplicationRequirement(Projectile proj); + public ProjectileSpecificRequirementBalancingRule(float damageMultiplier, ProjectileApplicationRequirement projApplicationRequirement) + { + DamageMultiplier = damageMultiplier; + Requirement = projApplicationRequirement; + } + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) + { + if (hitContext.DamageSource != DamageSourceType.FriendlyProjectile) + return false; + + return Requirement(Main.projectile[hitContext.ProjectileIndex.Value]); + } + + public void ApplyBalancingChange(NPC npc, ref int damage) => damage = (int)(damage * DamageMultiplier); + } + + public class StealthStrikeBalancingRule : IBalancingRule + { + public float DamageMultiplier; + public int[] ApplicableProjectileTypes; + public StealthStrikeBalancingRule(float damageMultiplier, params int[] projTypes) + { + DamageMultiplier = damageMultiplier; + ApplicableProjectileTypes = projTypes; + } + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) + { + if (hitContext.DamageSource != DamageSourceType.FriendlyProjectile) + return false; + if (!ApplicableProjectileTypes.Contains(hitContext.ProjectileType ?? -1)) + return false; + + return hitContext.IsStealthStrike; + } + + public void ApplyBalancingChange(NPC npc, ref int damage) => damage = (int)(damage * DamageMultiplier); + } + + public class TrueMeleeResistBalancingRule : IBalancingRule + { + public float DamageMultiplier; + public TrueMeleeResistBalancingRule(float damageMultiplier) + { + DamageMultiplier = damageMultiplier; + } + + public bool AppliesTo(NPC npc, NPCHitContext hitContext) + { + if (hitContext.DamageSource == DamageSourceType.FriendlyProjectile) + return Main.projectile[hitContext.ProjectileIndex.Value].Calamity().trueMelee; + + return hitContext.DamageSource == DamageSourceType.TrueMeleeSwing; + } + + public void ApplyBalancingChange(NPC npc, ref int damage) => damage = (int)(damage * DamageMultiplier); + } +} diff --git a/Balancing/DamageSourceType.cs b/Balancing/DamageSourceType.cs new file mode 100644 index 0000000000..387f27c532 --- /dev/null +++ b/Balancing/DamageSourceType.cs @@ -0,0 +1,8 @@ +namespace CalamityMod.Balancing +{ + public enum DamageSourceType + { + FriendlyProjectile, + TrueMeleeSwing, + } +} diff --git a/Balancing/IBalancingRule.cs b/Balancing/IBalancingRule.cs new file mode 100644 index 0000000000..0c61b1cae3 --- /dev/null +++ b/Balancing/IBalancingRule.cs @@ -0,0 +1,11 @@ +using Terraria; + +namespace CalamityMod.Balancing +{ + public interface IBalancingRule + { + bool AppliesTo(NPC npc, NPCHitContext hitContext); + + void ApplyBalancingChange(NPC npc, ref int damage); + } +} \ No newline at end of file diff --git a/Balancing/NPCBalancingChange.cs b/Balancing/NPCBalancingChange.cs new file mode 100644 index 0000000000..400e6c1a3d --- /dev/null +++ b/Balancing/NPCBalancingChange.cs @@ -0,0 +1,13 @@ +namespace CalamityMod.Balancing +{ + public struct NPCBalancingChange + { + public int NPCType; + public IBalancingRule[] BalancingRules; + public NPCBalancingChange(int npcType, params IBalancingRule[] balancingRules) + { + NPCType = npcType; + BalancingRules = balancingRules; + } + } +} diff --git a/Balancing/NPCHitContext.cs b/Balancing/NPCHitContext.cs new file mode 100644 index 0000000000..9cccc7fc5e --- /dev/null +++ b/Balancing/NPCHitContext.cs @@ -0,0 +1,43 @@ +using Terraria; + +namespace CalamityMod.Balancing +{ + public struct NPCHitContext + { + public int Pierce; + public int Damage; + public int? ProjectileIndex; + public int? ProjectileType => ProjectileIndex.HasValue ? Main.projectile[ProjectileIndex.Value].type : (int?)null; + public bool IsStealthStrike; + public ClassType? Class; + public DamageSourceType DamageSource; + + public static NPCHitContext ConstructFromProjectile(Projectile proj) + { + ClassType? classType = null; + if (proj.active) + { + if (proj.melee) + classType = ClassType.Melee; + if (proj.ranged) + classType = ClassType.Ranged; + if (proj.magic) + classType = ClassType.Magic; + if (proj.minion) + classType = ClassType.Summon; + if (proj.Calamity().rogue) + classType = ClassType.Rogue; + } + + return new NPCHitContext() + { + Pierce = proj.penetrate, + Damage = proj.damage, + ProjectileIndex = proj.whoAmI, + Class = classType, + IsStealthStrike = proj.active && proj.Calamity().stealthStrike, + DamageSource = DamageSourceType.FriendlyProjectile + }; + } + } +} diff --git a/CalamityLists.cs b/CalamityLists.cs index c71f8ab920..da3470cd13 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -1754,7 +1754,7 @@ namespace CalamityMod ItemType(), ItemType(), ItemType(), - ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), @@ -2071,443 +2071,443 @@ namespace CalamityMod ProjectileType(), }; - // Lists of enemies that resist piercing to some extent (mostly worms). - // Could prove useful for other things as well. + // Lists of enemies that resist piercing to some extent (mostly worms). + // Could prove useful for other things as well. - AstrumDeusIDs = new List - { - NPCType(), - NPCType(), - NPCType() - }; + AstrumDeusIDs = new List + { + NPCType(), + NPCType(), + NPCType() + }; - DevourerOfGodsIDs = new List - { - NPCType(), - NPCType(), - NPCType() - }; + DevourerOfGodsIDs = new List + { + NPCType(), + NPCType(), + NPCType() + }; - CosmicGuardianIDs = new List - { - NPCType(), - NPCType(), - NPCType() - }; + CosmicGuardianIDs = new List + { + NPCType(), + NPCType(), + NPCType() + }; - AquaticScourgeIDs = new List - { - NPCType(), - NPCType(), - NPCType(), - NPCType() - }; + AquaticScourgeIDs = new List + { + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; - PerforatorIDs = new List - { - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - }; + PerforatorIDs = new List + { + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; - DesertScourgeIDs = new List - { - NPCType(), - NPCType(), - NPCType() - }; + DesertScourgeIDs = new List + { + NPCType(), + NPCType(), + NPCType() + }; - EaterofWorldsIDs = new List - { - NPCID.EaterofWorldsHead, - NPCID.EaterofWorldsBody, - NPCID.EaterofWorldsTail - }; + EaterofWorldsIDs = new List + { + NPCID.EaterofWorldsHead, + NPCID.EaterofWorldsBody, + NPCID.EaterofWorldsTail + }; - DeathModeSplittingWormIDs = new List - { - NPCID.DuneSplicerHead, - NPCID.DuneSplicerBody, - NPCID.DuneSplicerTail, - NPCID.DiggerHead, - NPCID.DiggerBody, - NPCID.DiggerTail, - NPCID.SeekerHead, - NPCID.SeekerBody, - NPCID.SeekerTail - }; + DeathModeSplittingWormIDs = new List + { + NPCID.DuneSplicerHead, + NPCID.DuneSplicerBody, + NPCID.DuneSplicerTail, + NPCID.DiggerHead, + NPCID.DiggerBody, + NPCID.DiggerTail, + NPCID.SeekerHead, + NPCID.SeekerBody, + NPCID.SeekerTail + }; - DestroyerIDs = new List - { - NPCID.TheDestroyer, - NPCID.TheDestroyerBody, - NPCID.TheDestroyerTail - }; + DestroyerIDs = new List + { + NPCID.TheDestroyer, + NPCID.TheDestroyerBody, + NPCID.TheDestroyerTail + }; - ThanatosIDs = new List - { - NPCType(), - NPCType(), - NPCType(), - NPCType() - }; + ThanatosIDs = new List + { + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; - AresIDs = new List - { - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - }; + AresIDs = new List + { + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; - SkeletronPrimeIDs = new List - { - NPCID.SkeletronPrime, - NPCID.PrimeCannon, - NPCID.PrimeLaser, - NPCID.PrimeSaw, - NPCID.PrimeVice - }; + SkeletronPrimeIDs = new List + { + NPCID.SkeletronPrime, + NPCID.PrimeCannon, + NPCID.PrimeLaser, + NPCID.PrimeSaw, + NPCID.PrimeVice + }; - StormWeaverIDs = new List - { - NPCType(), - NPCType(), - NPCType() - }; + StormWeaverIDs = new List + { + NPCType(), + NPCType(), + NPCType() + }; - GrenadeResistIDs = new List - { - ProjectileID.Grenade, - ProjectileID.StickyGrenade, - ProjectileID.BouncyGrenade, - ProjectileID.Bomb, - ProjectileID.StickyBomb, - ProjectileID.BouncyBomb, - ProjectileID.Dynamite, - ProjectileID.StickyDynamite, - ProjectileID.BouncyDynamite, - ProjectileID.Explosives, - ProjectileID.ExplosiveBunny, - ProjectileID.PartyGirlGrenade, - ProjectileID.BombFish, - ProjectileID.Beenade, - ProjectileID.Bee, - ProjectileID.GiantBee, - ProjectileType() - //ProjectileID.ScarabBomb - }; + GrenadeResistIDs = new List + { + ProjectileID.Grenade, + ProjectileID.StickyGrenade, + ProjectileID.BouncyGrenade, + ProjectileID.Bomb, + ProjectileID.StickyBomb, + ProjectileID.BouncyBomb, + ProjectileID.Dynamite, + ProjectileID.StickyDynamite, + ProjectileID.BouncyDynamite, + ProjectileID.Explosives, + ProjectileID.ExplosiveBunny, + ProjectileID.PartyGirlGrenade, + ProjectileID.BombFish, + ProjectileID.Beenade, + ProjectileID.Bee, + ProjectileID.GiantBee, + ProjectileType() + //ProjectileID.ScarabBomb + }; - ZeroContactDamageNPCList = new List - { - NPCID.DarkCaster, - NPCID.FireImp, - NPCID.Tim, - NPCID.CultistArcherBlue, - NPCID.DesertDjinn, - NPCID.DiabolistRed, - NPCID.DiabolistWhite, - NPCID.Gastropod, - NPCID.IceElemental, - NPCID.IchorSticker, - NPCID.Necromancer, - NPCID.NecromancerArmored, - NPCID.RaggedCaster, - NPCID.RaggedCasterOpenCoat, - NPCID.RuneWizard, - NPCID.SkeletonArcher, - NPCID.SkeletonCommando, - NPCID.SkeletonSniper, - NPCID.TacticalSkeleton, - NPCID.Clown, - NPCID.GoblinArcher, - NPCID.GoblinSorcerer, - NPCID.GoblinSummoner, - NPCID.PirateCrossbower, - NPCID.PirateDeadeye, - NPCID.PirateCaptain, - NPCID.SnowmanGangsta, - NPCID.SnowBalla, - NPCID.DrManFly, - NPCID.Eyezor, - NPCID.Nailhead, - NPCID.MartianWalker, - NPCID.MartianTurret, - NPCID.ElfCopter, - NPCID.ElfArcher, - NPCID.NebulaBrain, - NPCID.StardustJellyfishBig, - NPCID.PirateShipCannon, - NPCID.MartianSaucer, - NPCID.MartianSaucerCannon, - NPCID.MartianSaucerCore, - NPCID.MartianSaucerTurret, - NPCID.Probe, - NPCID.CultistBoss, - NPCID.GolemHeadFree, - NPCID.MoonLordFreeEye, - //NPCID.BloodSquid, - NPCID.PlanterasHook - }; + ZeroContactDamageNPCList = new List + { + NPCID.DarkCaster, + NPCID.FireImp, + NPCID.Tim, + NPCID.CultistArcherBlue, + NPCID.DesertDjinn, + NPCID.DiabolistRed, + NPCID.DiabolistWhite, + NPCID.Gastropod, + NPCID.IceElemental, + NPCID.IchorSticker, + NPCID.Necromancer, + NPCID.NecromancerArmored, + NPCID.RaggedCaster, + NPCID.RaggedCasterOpenCoat, + NPCID.RuneWizard, + NPCID.SkeletonArcher, + NPCID.SkeletonCommando, + NPCID.SkeletonSniper, + NPCID.TacticalSkeleton, + NPCID.Clown, + NPCID.GoblinArcher, + NPCID.GoblinSorcerer, + NPCID.GoblinSummoner, + NPCID.PirateCrossbower, + NPCID.PirateDeadeye, + NPCID.PirateCaptain, + NPCID.SnowmanGangsta, + NPCID.SnowBalla, + NPCID.DrManFly, + NPCID.Eyezor, + NPCID.Nailhead, + NPCID.MartianWalker, + NPCID.MartianTurret, + NPCID.ElfCopter, + NPCID.ElfArcher, + NPCID.NebulaBrain, + NPCID.StardustJellyfishBig, + NPCID.PirateShipCannon, + NPCID.MartianSaucer, + NPCID.MartianSaucerCannon, + NPCID.MartianSaucerCore, + NPCID.MartianSaucerTurret, + NPCID.Probe, + NPCID.CultistBoss, + NPCID.GolemHeadFree, + NPCID.MoonLordFreeEye, + //NPCID.BloodSquid, + NPCID.PlanterasHook + }; - // Reduce contact damage by 25% - HardmodeNPCNerfList = new List - { - NPCID.AnglerFish, - NPCID.AngryTrapper, - NPCID.Arapaima, - NPCID.BlackRecluse, - NPCID.BlackRecluseWall, - NPCID.BloodJelly, - NPCID.FungoFish, - NPCID.GreenJellyfish, - NPCID.Clinger, - NPCID.ArmoredSkeleton, - NPCID.ArmoredViking, - NPCID.Mummy, - NPCID.DarkMummy, - NPCID.LightMummy, - NPCID.BloodFeeder, - NPCID.DesertBeast, - NPCID.ChaosElemental, - //NPCID.BloodMummy, - NPCID.CorruptSlime, - NPCID.Slimeling, - NPCID.Corruptor, - NPCID.Crimslime, - NPCID.BigCrimslime, - NPCID.LittleCrimslime, - NPCID.CrimsonAxe, - NPCID.CursedHammer, - NPCID.Derpling, - NPCID.Herpling, - NPCID.DiggerHead, - NPCID.DiggerBody, - NPCID.DiggerTail, - NPCID.DesertGhoul, - NPCID.DesertGhoulCorruption, - NPCID.DesertGhoulCrimson, - NPCID.DesertGhoulHallow, - NPCID.DuneSplicerHead, - NPCID.DuneSplicerBody, - NPCID.DuneSplicerTail, - NPCID.EnchantedSword, - NPCID.FloatyGross, - NPCID.GiantBat, - NPCID.GiantFlyingFox, - NPCID.GiantFungiBulb, - NPCID.FungiSpore, - NPCID.GiantTortoise, - NPCID.IceTortoise, - NPCID.HoppinJack, - NPCID.Mimic, - NPCID.IchorSticker, - NPCID.IcyMerman, - NPCID.IlluminantBat, - NPCID.IlluminantSlime, - NPCID.JungleCreeper, - NPCID.JungleCreeperWall, - NPCID.DesertLamiaDark, - NPCID.DesertLamiaLight, - NPCID.BigMossHornet, - NPCID.GiantMossHornet, - NPCID.LittleMossHornet, - NPCID.MossHornet, - NPCID.TinyMossHornet, - NPCID.Moth, - NPCID.PigronCorruption, - NPCID.PigronCrimson, - NPCID.PigronHallow, - NPCID.Pixie, - NPCID.PossessedArmor, - //NPCID.RockGolem, - NPCID.DesertScorpionWalk, - NPCID.DesertScorpionWall, - NPCID.Slimer, - NPCID.Slimer2, - NPCID.ToxicSludge, - NPCID.Unicorn, - NPCID.WanderingEye, - NPCID.Werewolf, - NPCID.Wolf, - NPCID.SeekerHead, - NPCID.SeekerBody, - NPCID.SeekerTail, - NPCID.Wraith, - NPCID.ChatteringTeethBomb, - NPCID.Clown, - NPCID.AngryNimbus, - NPCID.IceGolem, - NPCID.RainbowSlime, - NPCID.SandShark, - NPCID.SandsharkCorrupt, - NPCID.SandsharkCrimson, - NPCID.SandsharkHallow, - NPCID.ShadowFlameApparition, - NPCID.Parrot, - NPCID.PirateCorsair, - NPCID.PirateDeckhand, - //NPCID.PiratesCurse, - NPCID.BlueArmoredBonesMace, - NPCID.BlueArmoredBonesSword, - NPCID.BoneLee, - NPCID.DungeonSpirit, - NPCID.FlyingSnake, - NPCID.HellArmoredBones, - NPCID.HellArmoredBonesSpikeShield, - NPCID.HellArmoredBonesSword, - NPCID.MisterStabby, - NPCID.SnowBalla, - NPCID.SnowmanGangsta, - NPCID.Butcher, - NPCID.CreatureFromTheDeep, - NPCID.DeadlySphere, - NPCID.Frankenstein, - NPCID.Fritz, - NPCID.Psycho, - NPCID.Reaper, - NPCID.SwampThing, - NPCID.ThePossessed, - NPCID.Vampire, - NPCID.VampireBat, - NPCID.HeadlessHorseman, - NPCID.Hellhound, - NPCID.Poltergeist, - NPCID.Scarecrow1, - NPCID.Scarecrow2, - NPCID.Scarecrow3, - NPCID.Scarecrow4, - NPCID.Scarecrow5, - NPCID.Scarecrow6, - NPCID.Scarecrow7, - NPCID.Scarecrow8, - NPCID.Scarecrow9, - NPCID.Scarecrow10, - NPCID.Splinterling, - NPCID.Flocko, - NPCID.GingerbreadMan, - NPCID.Krampus, - NPCID.Nutcracker, - NPCID.NutcrackerSpinning, - NPCID.PresentMimic, - NPCID.Yeti, - NPCID.ZombieElf, - NPCID.ZombieElfBeard, - NPCID.ZombieElfGirl - //NPCID.BloodEelHead, - //NPCID.BloodEelBody, - //NPCID.BloodEelTail, - //NPCID.HemogoblinShark, - //NPCID.WanderingEyeFish, - //NPCID.ZombieMerman, - }; + // Reduce contact damage by 25% + HardmodeNPCNerfList = new List + { + NPCID.AnglerFish, + NPCID.AngryTrapper, + NPCID.Arapaima, + NPCID.BlackRecluse, + NPCID.BlackRecluseWall, + NPCID.BloodJelly, + NPCID.FungoFish, + NPCID.GreenJellyfish, + NPCID.Clinger, + NPCID.ArmoredSkeleton, + NPCID.ArmoredViking, + NPCID.Mummy, + NPCID.DarkMummy, + NPCID.LightMummy, + NPCID.BloodFeeder, + NPCID.DesertBeast, + NPCID.ChaosElemental, + //NPCID.BloodMummy, + NPCID.CorruptSlime, + NPCID.Slimeling, + NPCID.Corruptor, + NPCID.Crimslime, + NPCID.BigCrimslime, + NPCID.LittleCrimslime, + NPCID.CrimsonAxe, + NPCID.CursedHammer, + NPCID.Derpling, + NPCID.Herpling, + NPCID.DiggerHead, + NPCID.DiggerBody, + NPCID.DiggerTail, + NPCID.DesertGhoul, + NPCID.DesertGhoulCorruption, + NPCID.DesertGhoulCrimson, + NPCID.DesertGhoulHallow, + NPCID.DuneSplicerHead, + NPCID.DuneSplicerBody, + NPCID.DuneSplicerTail, + NPCID.EnchantedSword, + NPCID.FloatyGross, + NPCID.GiantBat, + NPCID.GiantFlyingFox, + NPCID.GiantFungiBulb, + NPCID.FungiSpore, + NPCID.GiantTortoise, + NPCID.IceTortoise, + NPCID.HoppinJack, + NPCID.Mimic, + NPCID.IchorSticker, + NPCID.IcyMerman, + NPCID.IlluminantBat, + NPCID.IlluminantSlime, + NPCID.JungleCreeper, + NPCID.JungleCreeperWall, + NPCID.DesertLamiaDark, + NPCID.DesertLamiaLight, + NPCID.BigMossHornet, + NPCID.GiantMossHornet, + NPCID.LittleMossHornet, + NPCID.MossHornet, + NPCID.TinyMossHornet, + NPCID.Moth, + NPCID.PigronCorruption, + NPCID.PigronCrimson, + NPCID.PigronHallow, + NPCID.Pixie, + NPCID.PossessedArmor, + //NPCID.RockGolem, + NPCID.DesertScorpionWalk, + NPCID.DesertScorpionWall, + NPCID.Slimer, + NPCID.Slimer2, + NPCID.ToxicSludge, + NPCID.Unicorn, + NPCID.WanderingEye, + NPCID.Werewolf, + NPCID.Wolf, + NPCID.SeekerHead, + NPCID.SeekerBody, + NPCID.SeekerTail, + NPCID.Wraith, + NPCID.ChatteringTeethBomb, + NPCID.Clown, + NPCID.AngryNimbus, + NPCID.IceGolem, + NPCID.RainbowSlime, + NPCID.SandShark, + NPCID.SandsharkCorrupt, + NPCID.SandsharkCrimson, + NPCID.SandsharkHallow, + NPCID.ShadowFlameApparition, + NPCID.Parrot, + NPCID.PirateCorsair, + NPCID.PirateDeckhand, + //NPCID.PiratesCurse, + NPCID.BlueArmoredBonesMace, + NPCID.BlueArmoredBonesSword, + NPCID.BoneLee, + NPCID.DungeonSpirit, + NPCID.FlyingSnake, + NPCID.HellArmoredBones, + NPCID.HellArmoredBonesSpikeShield, + NPCID.HellArmoredBonesSword, + NPCID.MisterStabby, + NPCID.SnowBalla, + NPCID.SnowmanGangsta, + NPCID.Butcher, + NPCID.CreatureFromTheDeep, + NPCID.DeadlySphere, + NPCID.Frankenstein, + NPCID.Fritz, + NPCID.Psycho, + NPCID.Reaper, + NPCID.SwampThing, + NPCID.ThePossessed, + NPCID.Vampire, + NPCID.VampireBat, + NPCID.HeadlessHorseman, + NPCID.Hellhound, + NPCID.Poltergeist, + NPCID.Scarecrow1, + NPCID.Scarecrow2, + NPCID.Scarecrow3, + NPCID.Scarecrow4, + NPCID.Scarecrow5, + NPCID.Scarecrow6, + NPCID.Scarecrow7, + NPCID.Scarecrow8, + NPCID.Scarecrow9, + NPCID.Scarecrow10, + NPCID.Splinterling, + NPCID.Flocko, + NPCID.GingerbreadMan, + NPCID.Krampus, + NPCID.Nutcracker, + NPCID.NutcrackerSpinning, + NPCID.PresentMimic, + NPCID.Yeti, + NPCID.ZombieElf, + NPCID.ZombieElfBeard, + NPCID.ZombieElfGirl + //NPCID.BloodEelHead, + //NPCID.BloodEelBody, + //NPCID.BloodEelTail, + //NPCID.HemogoblinShark, + //NPCID.WanderingEyeFish, + //NPCID.ZombieMerman, + }; - BoundNPCIDs = new List - { - NPCID.BoundGoblin, - NPCID.BoundWizard, - NPCID.BoundMechanic, - NPCID.SleepingAngler, - NPCID.BartenderUnconscious, - NPCID.WebbedStylist, - //NPCID.GolferRescue - }; + BoundNPCIDs = new List + { + NPCID.BoundGoblin, + NPCID.BoundWizard, + NPCID.BoundMechanic, + NPCID.SleepingAngler, + NPCID.BartenderUnconscious, + NPCID.WebbedStylist, + //NPCID.GolferRescue + }; - // Collections - // NOTE - Be sure to reference the NeedsFourLifeBytes list in the IL Editing code if changes are made here. - BossRushHPChanges = new SortedDictionary - { - // Tier 1 - { NPCID.QueenBee, 315000 }, // 30 seconds + // Collections + // NOTE - Be sure to reference the NeedsFourLifeBytes list in the IL Editing code if changes are made here. + BossRushHPChanges = new SortedDictionary + { + // Tier 1 + { NPCID.QueenBee, 315000 }, // 30 seconds - { NPCID.BrainofCthulhu, 100000 }, // 30 seconds with creepers - { NPCID.Creeper, 10000 }, + { NPCID.BrainofCthulhu, 100000 }, // 30 seconds with creepers + { NPCID.Creeper, 10000 }, - { NPCID.KingSlime, 300000 }, // 30 seconds - { NPCID.BlueSlime, 3600 }, - { NPCID.SlimeSpiked, 7200 }, - { NPCID.GreenSlime, 2700 }, - { NPCID.RedSlime, 5400 }, - { NPCID.PurpleSlime, 7200 }, - { NPCID.YellowSlime, 6300 }, - { NPCID.IceSlime, 4500 }, - { NPCID.UmbrellaSlime, 5400 }, - { NPCID.RainbowSlime, 30000 }, - { NPCID.Pinky, 15000 }, + { NPCID.KingSlime, 300000 }, // 30 seconds + { NPCID.BlueSlime, 3600 }, + { NPCID.SlimeSpiked, 7200 }, + { NPCID.GreenSlime, 2700 }, + { NPCID.RedSlime, 5400 }, + { NPCID.PurpleSlime, 7200 }, + { NPCID.YellowSlime, 6300 }, + { NPCID.IceSlime, 4500 }, + { NPCID.UmbrellaSlime, 5400 }, + { NPCID.RainbowSlime, 30000 }, + { NPCID.Pinky, 15000 }, - { NPCID.EyeofCthulhu, 450000 }, // 30 seconds - { NPCID.ServantofCthulhu, 6000 }, + { NPCID.EyeofCthulhu, 450000 }, // 30 seconds + { NPCID.ServantofCthulhu, 6000 }, - { NPCID.SkeletronPrime, 110000 }, // 30 seconds - { NPCID.PrimeVice, 54000 }, - { NPCID.PrimeCannon, 45000 }, - { NPCID.PrimeSaw, 45000 }, - { NPCID.PrimeLaser, 38000 }, + { NPCID.SkeletronPrime, 110000 }, // 30 seconds + { NPCID.PrimeVice, 54000 }, + { NPCID.PrimeCannon, 45000 }, + { NPCID.PrimeSaw, 45000 }, + { NPCID.PrimeLaser, 38000 }, - { NPCID.Golem, 50000 }, // 30 seconds - { NPCID.GolemHead, 30000 }, - { NPCID.GolemHeadFree, 30000 }, - { NPCID.GolemFistLeft, 25000 }, - { NPCID.GolemFistRight, 25000 }, + { NPCID.Golem, 50000 }, // 30 seconds + { NPCID.GolemHead, 30000 }, + { NPCID.GolemHeadFree, 30000 }, + { NPCID.GolemFistLeft, 25000 }, + { NPCID.GolemFistRight, 25000 }, - { NPCID.EaterofWorldsHead, 10000 }, // 30 seconds + immunity timer at start - { NPCID.EaterofWorldsBody, 10000 }, - { NPCID.EaterofWorldsTail, 10000 }, + { NPCID.EaterofWorldsHead, 10000 }, // 30 seconds + immunity timer at start + { NPCID.EaterofWorldsBody, 10000 }, + { NPCID.EaterofWorldsTail, 10000 }, - // Tier 2 - { NPCID.TheDestroyer, 250000 }, // 30 seconds + immunity timer at start - { NPCID.TheDestroyerBody, 250000 }, - { NPCID.TheDestroyerTail, 250000 }, - { NPCID.Probe, 10000 }, + // Tier 2 + { NPCID.TheDestroyer, 250000 }, // 30 seconds + immunity timer at start + { NPCID.TheDestroyerBody, 250000 }, + { NPCID.TheDestroyerTail, 250000 }, + { NPCID.Probe, 10000 }, - { NPCID.Spazmatism, 150000 }, // 30 seconds - { NPCID.Retinazer, 125000 }, + { NPCID.Spazmatism, 150000 }, // 30 seconds + { NPCID.Retinazer, 125000 }, - { NPCID.WallofFlesh, 450000 }, // 30 seconds - { NPCID.WallofFleshEye, 450000 }, + { NPCID.WallofFlesh, 450000 }, // 30 seconds + { NPCID.WallofFleshEye, 450000 }, - { NPCID.SkeletronHead, 160000 }, // 30 seconds - { NPCID.SkeletronHand, 60000 }, + { NPCID.SkeletronHead, 160000 }, // 30 seconds + { NPCID.SkeletronHand, 60000 }, - // Tier 3 - { NPCID.CultistBoss, 220000 }, // 30 seconds - { NPCID.CultistDragonHead, 60000 }, - { NPCID.CultistDragonBody1, 60000 }, - { NPCID.CultistDragonBody2, 60000 }, - { NPCID.CultistDragonBody3, 60000 }, - { NPCID.CultistDragonBody4, 60000 }, - { NPCID.CultistDragonTail, 60000 }, - { NPCID.AncientCultistSquidhead, 50000 }, + // Tier 3 + { NPCID.CultistBoss, 220000 }, // 30 seconds + { NPCID.CultistDragonHead, 60000 }, + { NPCID.CultistDragonBody1, 60000 }, + { NPCID.CultistDragonBody2, 60000 }, + { NPCID.CultistDragonBody3, 60000 }, + { NPCID.CultistDragonBody4, 60000 }, + { NPCID.CultistDragonTail, 60000 }, + { NPCID.AncientCultistSquidhead, 50000 }, - { NPCID.Plantera, 160000 }, // 30 seconds - { NPCID.PlanterasTentacle, 40000 }, + { NPCID.Plantera, 160000 }, // 30 seconds + { NPCID.PlanterasTentacle, 40000 }, - // Tier 4 - { NPCID.DukeFishron, 290000 }, // 30 seconds + // Tier 4 + { NPCID.DukeFishron, 290000 }, // 30 seconds - { NPCID.MoonLordCore, 160000 }, // 1 minute - { NPCID.MoonLordHand, 45000 }, - { NPCID.MoonLordHead, 60000 }, - { NPCID.MoonLordLeechBlob, 800 } + { NPCID.MoonLordCore, 160000 }, // 1 minute + { NPCID.MoonLordHand, 45000 }, + { NPCID.MoonLordHead, 60000 }, + { NPCID.MoonLordLeechBlob, 800 } - // 8 minutes in total for vanilla Boss Rush bosses - }; + // 8 minutes in total for vanilla Boss Rush bosses + }; - BossValues = new SortedDictionary - { - { NPCID.QueenBee, Item.buyPrice(0, 5)}, - { NPCID.SkeletronHead, Item.buyPrice(0, 7) }, - { NPCID.DukeFishron, Item.buyPrice(0, 25) }, - { NPCID.CultistBoss, Item.buyPrice(0, 25) }, - { NPCID.MoonLordCore, Item.buyPrice(0, 30) } - }; + BossValues = new SortedDictionary + { + { NPCID.QueenBee, Item.buyPrice(0, 5)}, + { NPCID.SkeletronHead, Item.buyPrice(0, 7) }, + { NPCID.DukeFishron, Item.buyPrice(0, 25) }, + { NPCID.CultistBoss, Item.buyPrice(0, 25) }, + { NPCID.MoonLordCore, Item.buyPrice(0, 30) } + }; bossTypes = new SortedDictionary() { @@ -2566,7 +2566,7 @@ namespace CalamityMod bossMinionList = new List() { - NPCType(), + NPCType(), NPCType(), NPCType(), NPCID.SlimeSpiked, @@ -2768,7 +2768,7 @@ namespace CalamityMod mossHornetList = null; bossMinionList = null; minibossList = null; - heartDropBlockList = null; + heartDropBlockList = null; pierceResistList = null; pierceResistExceptionList = null; @@ -2780,13 +2780,13 @@ namespace CalamityMod DesertScourgeIDs = null; EaterofWorldsIDs = null; DeathModeSplittingWormIDs = null; - DestroyerIDs = null; + DestroyerIDs = null; ThanatosIDs = null; AresIDs = null; - SkeletronPrimeIDs = null; + SkeletronPrimeIDs = null; StormWeaverIDs = null; BoundNPCIDs = null; - GrenadeResistIDs = null; + GrenadeResistIDs = null; ZeroContactDamageNPCList = null; HardmodeNPCNerfList = null; diff --git a/CalamityMod.cs b/CalamityMod.cs index 7af833963b..f6b39e1f77 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -1,3 +1,4 @@ +using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; @@ -228,6 +229,7 @@ namespace CalamityMod SchematicManager.Load(); CustomLavaManagement.Load(); Attunement.Load(); + BalancingChangesManager.Load(); } private void LoadClient() @@ -378,6 +380,7 @@ namespace CalamityMod bossVelocityDamageScaleValues?.Clear(); bossVelocityDamageScaleValues = null; + BalancingChangesManager.Unload(); Attunement.Unload(); EnchantmentManager.UnloadAllEnchantments(); VanillaArmorChangeManager.Unload(); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index a0fb1a4afc..f034dfd81b 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -72,6 +72,7 @@ using Terraria.Utilities; using static Terraria.ModLoader.ModContent; using CalamityMod.NPCs.ExoMechs; using CalamityMod.NPCs.VanillaNPCOverrides.Bosses; +using CalamityMod.Balancing; namespace CalamityMod.NPCs { @@ -4017,235 +4018,12 @@ namespace CalamityMod.NPCs } } - // Nerfed because the primary fire was buffed a lot. - if (projectile.type == ProjectileID.MonkStaffT3_AltShot || (projectile.type == ProjectileID.Electrosphere && Main.player[projectile.owner].ActiveItem().type == ItemID.MonkStaffT3)) - damage /= 4; - - // Nerfed because these are really overpowered. - if (projectile.type == ProjectileID.CursedDartFlame) - damage /= 2; - - // Nerf Mushroom Spear mushrooms. - if (projectile.type == ProjectileID.Mushroom && Main.player[projectile.owner].ActiveItem().type == ItemID.MushroomSpear) - damage /= 2; - - if (projectile.type == ProjectileID.SeedlerNut || projectile.type == ProjectileID.SeedlerThorn) - damage /= 3; + // Apply balancing resists/vulnerabilities. + BalancingChangesManager.ApplyFromProjectile(npc, ref damage, projectile); if (CalamityLists.pierceResistList.Contains(npc.type)) PierceResistGlobal(projectile, npc, ref damage); - - if (CalamityLists.AresIDs.Contains(npc.type)) - { - // 75% resist to Dragon Rage projectiles. - if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || (projectile.type == ProjectileType() && projectile.melee)) - damage = (int)(damage * 0.25); - - // 60% resist to Murasama. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.4); - - // 50% resist to true melee and Enforcer projectiles. - else if (projectile.Calamity().trueMelee || projectile.type == ProjectileType()) - damage = (int)(damage * 0.5); - - // 20% resist to Eclipse's Fall stealth strike. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.8); - } - else if (npc.type == NPCType() || npc.type == NPCType()) - { - // 10% resist to Eclipse's Fall stealth strike. - if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.9); - } - else if (CalamityLists.ThanatosIDs.Contains(npc.type)) - { - // 75% resist to Celestus and Chicken Cannon. - if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.25); - - // 65% resist to true melee and Hadopelagic Echo. - else if (projectile.Calamity().trueMelee || projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.35); - - // 50% resist to Chicken Cannon, Vehemence skulls and Prismatic Breaker. (why is this more than BOTH Rancor and Yharim's Crystal?) - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.5); - - // 40% resist to Wrathwing stealth strike, Rancor, and Yharim's Crystal. - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.6); - - // 35% resist to Seraphim lasers. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.65); - - // 30% resist to Sirius. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.7); - - // 25% resist to God Slayer Slugs and Luminite Bullets. - else if (projectile.type == ProjectileID.MoonlordBullet || projectile.type == ProjectileType()) - damage = (int)(damage * 0.75); - - // 20% resist to Eradicator beams, Voltaic Climax / Void Vortex hitscan and Blood Boiler fire. - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.8); - - // 15% resist to Gruesome Eminence. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.85); - - } - else if (npc.type == NPCType()) - { - // 50% resist to true melee. - if (projectile.Calamity().trueMelee) - damage = (int)(damage * 0.5); - } - else if (CalamityLists.AstrumDeusIDs.Contains(npc.type)) - { - // 75% resist to Plaguenades. - if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.25); - - // 50% resist to true melee. - else if (projectile.Calamity().trueMelee) - damage = (int)(damage * 0.5); - - // 25% resist to Resurrection Butterfly. - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.75); - } - else if (npc.type == NPCType()) - { - // 30% resist to Surge Driver's alt click comets. - if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.7); - - // 20% resist to Executioner's Blade stealth strikes. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.8); - - // 15% resist to Seraphim lasers. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.85); - } - else if (CalamityLists.DevourerOfGodsIDs.Contains(npc.type)) - { - // 15% increased damage from Time Bolt stealth strikes. - if (projectile.type == ProjectileType()) - { - if (projectile.Calamity().stealthStrike) - damage = (int)(damage * 1.15); - } - } - else if (npc.type == NPCType()) - { - // 50% resist to true melee. - if (projectile.Calamity().trueMelee) - damage = (int)(damage * 0.5); - } - else if (CalamityLists.StormWeaverIDs.Contains(npc.type)) - { - // 25% resist to Molten Amputator blobs. - if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.75); - - // 50% resist to true melee, Elemental Axe, Dazzling Stabber Staff, Pristine Fury, and Tactician's Trump Card explosion. - else if (projectile.Calamity().trueMelee || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.5); - } - else if (CalamityLists.DestroyerIDs.Contains(npc.type)) - { - // 50% resist to true melee and Dormant Brimseekers. - if (projectile.Calamity().trueMelee || projectile.type == ProjectileType()) - damage = (int)(damage * 0.5); - } - else if (CalamityLists.AquaticScourgeIDs.Contains(npc.type)) - { - // 50% resist to true melee and Dormant Brimseekers. - if (projectile.Calamity().trueMelee || projectile.type == ProjectileType()) - damage = (int)(damage * 0.5); - } - else if (CalamityLists.PerforatorIDs.Contains(npc.type)) - { - // 50% resist to true melee. - if (projectile.Calamity().trueMelee) - damage = (int)(damage * 0.5); - } - else if (npc.type == NPCID.Creeper) - { - // 50% resist to true melee and Demon Scythe. - if (projectile.Calamity().trueMelee || projectile.type == ProjectileID.DemonScythe) - damage = (int)(damage * 0.5); - } - else if (CalamityLists.EaterofWorldsIDs.Contains(npc.type)) - { - // 50% resist to true melee and Demon Scythe. - if (projectile.Calamity().trueMelee || projectile.type == ProjectileID.DemonScythe) - damage = (int)(damage * 0.5); - - // 40% resist to Sky Glaze. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.6); - } - else if (CalamityLists.DesertScourgeIDs.Contains(npc.type)) - { - // 50% resist to true melee. - if (projectile.Calamity().trueMelee) - damage = (int)(damage * 0.5); - } - else if (npc.type == NPCType()) - { - // 20% resist to Time Bolt. - if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.8); - - // 60% resist to Last Mourning. - else if (projectile.type == ProjectileType() || projectile.type == ProjectileID.FlamingJack) - damage = (int)(damage * 0.4); - } - else if (npc.type == NPCType()) - { - // 85% resist to Chicken Cannon. - if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.15); - - // 30% resist to Murasama. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.7); - - // 25% resist to Yharim's Crystal. - else if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.75); - - // 10% resist to Surge Driver's alt click comets and Executioner's Blade stealth strikes. - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.9); - - // 10% resist to Celestus. - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.9); - - // 15% vulnerability to the Atom Splitter (Yes, this is kinda weird, but it's what Piky asked for). - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 1.15); - } - else if (npc.type == NPCID.CultistBoss) - { - // 25% resist to Resurrection Butterfly. - if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 0.75); - } - else if (npc.type == NPCID.DukeFishron) - { - // 35% increased damage from Resurrection Butterfly. - if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - damage = (int)(damage * 1.35); - } - + if (modPlayer.camper && !player.StandingStill()) damage = (int)(damage * 0.1); }