diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index c16b1308ca..83ce481280 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -73,9 +73,21 @@ namespace CalamityMod.NPCs public partial class CalamityGlobalNPC : GlobalNPC { #region Variables - public float DR { get; set; } = 0f; + /// + /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. + /// + public bool unbreakableDR = false; + + /// + /// Overrides the normal DR math and uses custom DR reductions for each debuff, registered separately.

+ /// Used primarily by post-Moon Lord bosses. + ///
+ public bool customDR = false; + public Dictionary flatDRReductions = new Dictionary(); + public Dictionary multDRReductions = new Dictionary(); + public int KillTime { get; set; } = 0; public const int DoGPhase1KillTime = 5400; @@ -103,19 +115,6 @@ namespace CalamityMod.NPCs public bool ShouldFallThroughPlatforms; - /// - /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. - /// - public bool unbreakableDR = false; - - /// - /// Overrides the normal DR math and uses custom DR reductions for each debuff, registered separately.

- /// Used primarily by post-Moon Lord bosses. - ///
- public bool customDR = false; - public Dictionary flatDRReductions = new Dictionary(); - public Dictionary multDRReductions = new Dictionary(); - /// /// Allows hostile NPCs to deal damage to the player's defense stat, used mostly for hard-hitting bosses. /// @@ -292,8 +291,128 @@ namespace CalamityMod.NPCs public bool DoesNotDisappearInBossRush; #endregion - #region Instance Per Entity + #region Instance Per Entity and TML 1.4 Cloning public override bool InstancePerEntity => true; + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityGlobalNPC myClone = (CalamityGlobalNPC)base.Clone(npc, npcClone); + + // Manually copy everything because I don't trust the base clone behavior after seeing the bugs + // Ozzatron 25APR2022 + myClone.DR = DR; + myClone.unbreakableDR = unbreakableDR; + myClone.flatDRReductions = new Dictionary(); + foreach (var flatDR in flatDRReductions) + myClone.flatDRReductions.Add(flatDR.Key, flatDR.Value); + myClone.multDRReductions = new Dictionary(); + foreach (var multDR in multDRReductions) + myClone.multDRReductions.Add(multDR.Key, multDR.Value); + + myClone.KillTime = KillTime; + + myClone.VulnerableToHeat = VulnerableToHeat; + myClone.VulnerableToCold = VulnerableToCold; + myClone.VulnerableToSickness = VulnerableToSickness; + myClone.VulnerableToElectricity = VulnerableToElectricity; + myClone.VulnerableToWater = VulnerableToWater; + + myClone.IncreasedColdEffects = IncreasedColdEffects; + myClone.IncreasedHeatEffects = IncreasedHeatEffects; + myClone.IncreasedSicknessAndWaterEffects = IncreasedSicknessAndWaterEffects; + + myClone.ShouldFallThroughPlatforms = ShouldFallThroughPlatforms; + + myClone.canBreakPlayerDefense = canBreakPlayerDefense; + + myClone.miscDefenseLoss = miscDefenseLoss; + + myClone.maxVelocity = maxVelocity; + + myClone.dashImmunityTime = new int[maxPlayerImmunities]; + for (int i = 0; i < maxPlayerImmunities; ++i) + myClone.dashImmunityTime[i] = dashImmunityTime[i]; + + myClone.shopAlertAnimTimer = shopAlertAnimTimer; + myClone.shopAlertAnimFrame = shopAlertAnimFrame; + + myClone.DoesNotGenerateRage = DoesNotGenerateRage; + + myClone.newAI = new float[maxAIMod]; + for (int i = 0; i < maxAIMod; ++i) + myClone.newAI[i] = newAI[i]; + myClone.AITimer = AITimer; + + myClone.setNewName = setNewName; + + myClone.SplittingWorm = SplittingWorm; + myClone.CanHaveBossHealthBar = CanHaveBossHealthBar; + myClone.ShouldCloseHPBar = ShouldCloseHPBar; + + myClone.debuffResistanceTimer = debuffResistanceTimer; + + myClone.bossCanBeKnockedBack = bossCanBeKnockedBack; + myClone.knockbackResistanceTimer = knockbackResistanceTimer; + + myClone.vaporfied = vaporfied; + myClone.timeSlow = timeSlow; + myClone.gState = gState; + myClone.tesla = tesla; + myClone.tSad = tSad; + myClone.eFreeze = eFreeze; + myClone.eutrophication = eutrophication; + myClone.webbed = webbed; + myClone.slowed = slowed; + myClone.electrified = electrified; + myClone.yellowCandle = yellowCandle; + myClone.pearlAura = pearlAura; + myClone.wCleave = wCleave; + myClone.bBlood = bBlood; + myClone.dFlames = dFlames; + myClone.marked = marked; + myClone.irradiated = irradiated; + myClone.bFlames = bFlames; + myClone.hFlames = hFlames; + myClone.pFlames = pFlames; + myClone.aCrunch = aCrunch; + + myClone.somaShredStacks = somaShredStacks; + myClone.somaShredApplicator = somaShredApplicator; + myClone.somaShredFalloff = somaShredFalloff; + + myClone.cDepth = cDepth; + myClone.gsInferno = gsInferno; + myClone.astralInfection = astralInfection; + myClone.aFlames = aFlames; + myClone.wDeath = wDeath; + myClone.nightwither = nightwither; + myClone.enraged = enraged; + myClone.shellfishVore = shellfishVore; + myClone.clamDebuff = clamDebuff; + myClone.sulphurPoison = sulphurPoison; + myClone.ladHearts = ladHearts; + myClone.kamiFlu = kamiFlu; + myClone.relicOfResilienceCooldown = relicOfResilienceCooldown; + myClone.relicOfResilienceWeakness = relicOfResilienceWeakness; + myClone.GaussFluxTimer = GaussFluxTimer; + myClone.sagePoisonTime = sagePoisonTime; + myClone.sagePoisonDamage = sagePoisonDamage; + myClone.vulnerabilityHex = vulnerabilityHex; + myClone.banishingFire = banishingFire; + myClone.wither = wither; + myClone.RancorBurnTime = RancorBurnTime; + + // This gets set up as needed. + myClone.VulnerabilityHexFireDrawer = null; + + myClone.CurrentlyEnraged = CurrentlyEnraged; + + myClone.CurrentlyIncreasingDefenseOrDR = CurrentlyIncreasingDefenseOrDR; + + myClone.DoesNotDisappearInBossRush = DoesNotDisappearInBossRush; + + return myClone; + } #endregion #region Reset Effects