diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 98a8c33dca..8f3de47ca5 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -58,6 +58,14 @@ internal static readonly int RageFadeTime = CalamityUtils.SecondsToFrames(30); internal static readonly float DefaultRageDamageBoost = 0.35f; // +35% + // Proximity Rage + // These variables should be used in general to classify "enemies" vs "non-enemies" as well. + // See NPCUtils.IsAnEnemy + internal const int TinyHealthThreshold = 5; + internal const int TinyDamageThreshold = 5; + internal const int NoContactDamageHealthThreshold = 3000; + internal const int UnreasonableHealthThreshold = 25000000; // 25 million + // Adrenaline internal static readonly float AdrenalineDamageBoost = 2f; // +200% internal static readonly float AdrenalineDamagePerBooster = 0.15f; // +15% diff --git a/NPCs/HiveMind/HiveCyst.cs b/NPCs/HiveMind/HiveCyst.cs index 13e9a6bbd8..865c16b17e 100644 --- a/NPCs/HiveMind/HiveCyst.cs +++ b/NPCs/HiveMind/HiveCyst.cs @@ -32,6 +32,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().ProvidesProximityRage = false; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index 6d37fe414a..ba877fbbd2 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -49,6 +49,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; + NPC.Calamity().ProvidesProximityRage = false; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Perforator/PerforatorCyst.cs b/NPCs/Perforator/PerforatorCyst.cs index eec3c125cc..a5c83fe2de 100644 --- a/NPCs/Perforator/PerforatorCyst.cs +++ b/NPCs/Perforator/PerforatorCyst.cs @@ -36,6 +36,7 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().ProvidesProximityRage = false; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 1f5aad5a24..ff2c89b83e 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -1,26 +1,24 @@ -using CalamityMod.Buffs.DamageOverTime; +using System.Linq; +using System.Reflection; +using CalamityMod.Balancing; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.DataStructures; using CalamityMod.Events; using CalamityMod.NPCs; -using CalamityMod.NPCs.HiveMind; -using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.Perforator; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SlimeGod; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; -using System.Linq; -using System.Reflection; using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Localization; -using static Terraria.ModLoader.ModContent; using Terraria.Chat; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod { @@ -130,17 +128,33 @@ namespace CalamityMod npc.Calamity().customDR = true; } - public static bool IsAnEnemy(this NPC npc) + // This function controls the behavior of Proximity Rage. + // + // TODO -- In multiplayer, with more than one player, all enemies are listed as statue spawned. + // This sounds like packet corruption or something, but it's impossible to know. + // Even stranger, this bug only affects players who aren't player slot 0. + // As such, statue enemies are currently allowed by default for Proximity Rage. + // This is not the intent. Ideally, they would not count. + // + // TODO -- Use this function EVERYWHERE that target validity is checked, not just for Proximity Rage. + // The easiest way to find locations this should be used is checks for whether something is statue spawned. + public static bool IsAnEnemy(this NPC npc, bool allowStatues = true) { - // Null, inactive, town NPCs, friendlies, statue spawns, "non-enemies" (e.g. butterflies or projectile enemies), - // or anything else with no contact damage (exception: Providence and Celestial Pillars) don't count for rage. - if (npc is null || !npc.active || npc.townNPC || npc.friendly || npc.SpawnedFromStatue || npc.lifeMax <= 5 || (npc.damage <= 5 && npc.lifeMax <= 2000)) + // Null, inactive, town NPCs, and friendlies are right out. + if (npc is null || !npc.active || npc.townNPC || npc.friendly) + return false; + + // Unless allowed, statue spawns don't count for rage. + if (!allowStatues && npc.SpawnedFromStatue) + return false; + + // "Non-enemies" (e.g. butterflies or projectile enemies) with near zero max health, + // or anything but the strongest enemies with no contact damage (e.g. Celestial Pillars, Providence) + // do not generate rage. + if (npc.lifeMax <= BalancingConstants.TinyHealthThreshold || (npc.damage <= BalancingConstants.TinyDamageThreshold && npc.lifeMax <= BalancingConstants.NoContactDamageHealthThreshold)) return false; // Also explicitly exclude dummies and anything with a ridiculous health pool (dummies from Fargo's for example). - if (npc.type == NPCID.TargetDummy || npc.type == NPCType() || npc.lifeMax > 100000000) - return false; - // Finally, exclude boss spawners. - if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) + if (npc.type == NPCID.TargetDummy || npc.type == NPCType() || npc.lifeMax > BalancingConstants.UnreasonableHealthThreshold) return false; // Anything else is considered a valid enemy target.