From 22c000849e31172fac3a55c088a5adb3b3263b0d Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Wed, 8 Mar 2023 23:16:33 -0600 Subject: [PATCH 1/2] Cal Clone bro despawn edit. --- NPCs/CalamityAI.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index fb19ddbae9..a68cfbfe43 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1961,11 +1961,18 @@ namespace CalamityMod.NPCs if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) npc.rotation = num842; - if (!player.active || player.dead) + bool calCloneActive = false; + if (CalamityGlobalNPC.calamitas != -1) + { + if (Main.npc[CalamityGlobalNPC.calamitas].active) + calCloneActive = true; + } + + if (!player.active || player.dead || !calCloneActive) { npc.TargetClosest(false); player = Main.player[npc.target]; - if (!player.active || player.dead) + if (!player.active || player.dead || !calCloneActive) { if (npc.velocity.Y > 3f) npc.velocity.Y = 3f; @@ -2263,11 +2270,18 @@ namespace CalamityMod.NPCs if (npc.rotation > num842 - num843 && npc.rotation < num842 + num843) npc.rotation = num842; - if (!player.active || player.dead) + bool calCloneActive = false; + if (CalamityGlobalNPC.calamitas != -1) + { + if (Main.npc[CalamityGlobalNPC.calamitas].active) + calCloneActive = true; + } + + if (!player.active || player.dead || !calCloneActive) { npc.TargetClosest(false); player = Main.player[npc.target]; - if (!player.active || player.dead) + if (!player.active || player.dead || !calCloneActive) { if (npc.velocity.Y > 3f) npc.velocity.Y = 3f; From d9ac07dcccbe6e23547caa54928e15c30dbde45d Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Wed, 8 Mar 2023 23:58:15 -0600 Subject: [PATCH 2/2] Put loops inside bool checks, for efficiency, please. --- NPCs/CalamityGlobalNPC.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index cbe8453023..b430fe4818 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -5098,14 +5098,18 @@ namespace CalamityMod.NPCs } // Increase fairy spawn rates while wearing Fairy Boots - if (spawnInfo.Player.Calamity().fairyBoots && NPC.CountNPCS(NPCID.FairyCritterBlue) + NPC.CountNPCS(NPCID.FairyCritterGreen) + NPC.CountNPCS(NPCID.FairyCritterPink) <= 4) + if (spawnInfo.Player.Calamity().fairyBoots) { - if (!NPC.AnyNPCs(NPCID.FairyCritterBlue)) - pool[NPCID.FairyCritterBlue] = SpawnCondition.Overworld.Chance * 5f; - if (!NPC.AnyNPCs(NPCID.FairyCritterGreen)) - pool[NPCID.FairyCritterGreen] = SpawnCondition.Overworld.Chance * 5f; - if (!NPC.AnyNPCs(NPCID.FairyCritterPink)) - pool[NPCID.FairyCritterPink] = SpawnCondition.Overworld.Chance * 5f; + int maxFairies = 5; + if ((NPC.CountNPCS(NPCID.FairyCritterBlue) + NPC.CountNPCS(NPCID.FairyCritterGreen) + NPC.CountNPCS(NPCID.FairyCritterPink)) < maxFairies) + { + if (!NPC.AnyNPCs(NPCID.FairyCritterBlue)) + pool[NPCID.FairyCritterBlue] = SpawnCondition.Overworld.Chance * 5f; + if (!NPC.AnyNPCs(NPCID.FairyCritterGreen)) + pool[NPCID.FairyCritterGreen] = SpawnCondition.Overworld.Chance * 5f; + if (!NPC.AnyNPCs(NPCID.FairyCritterPink)) + pool[NPCID.FairyCritterPink] = SpawnCondition.Overworld.Chance * 5f; + } } if (calamityBiomeZone)