From d24604cbdc95a9018cfb49c1dc8127828c0dfdcb Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 22 Oct 2021 16:39:21 -0500 Subject: [PATCH] Fixed lab critters not obeying spawn limits --- NPCs/CalamityGlobalNPC.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 7f843141b6..b070b442d1 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3975,6 +3975,11 @@ namespace CalamityMod.NPCs int spawnRate = 400; int maxSpawnCount = (int)MaxSpawnsField.GetValue(null); NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); + + // Enforce a limit on the amount of enemies that can appear. + if (player.activeNPCs >= maxSpawnCount) + return; + for (int i = 0; i < 18; i++) { int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt());