using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.ExoMechs.Apollo; using CalamityMod.NPCs.ExoMechs.Artemis; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Ravager; using CalamityMod.NPCs.SupremeCalamitas; 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.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.CountsAsClass(DamageClass.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; bool AotCThrowCombo(Projectile p) => p.type == ProjectileType() && (p.ai[0] == 2 || p.ai[0] == 3); 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 Crabulon // 50% resist to true melee. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new TrueMeleeResistBalancingRule(0.5f))); #endregion #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 Moon Lord // 30% resist to the shockwave attunement from the True biome blade. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.MoonLordCore, Do(new ProjectileResistBalancingRule(0.1f, ProjectileType(), ProjectileType(), ProjectileType())))); #endregion #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())))); // 30% resist to the Spin Throw part of the Ark of the Cosmos' combo NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AresIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.7f, AotCThrowCombo)))); // 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 // 95% resist to Seraphim lasers (what the actual fuck?). NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.05f, ProjectileType())))); // 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())))); // 30% resist to the Spin Throw part of the Ark of the Cosmos' combo NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileSpecificRequirementBalancingRule(0.7f, AotCThrowCombo)))); // 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.85f, 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; } } }