From 198f1646bb6330bd141e4aec010cbf641076e9a4 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 11 Mar 2020 15:00:59 -0400 Subject: [PATCH] bandit and drunk princess spawn if they've spawned in the world previously --- NPCs/TownNPCs/FAP.cs | 12 ++++++++++-- NPCs/TownNPCs/THIEF.cs | 12 ++++++++++-- World/CalamityWorld.cs | 30 +++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 051bbd8b92..a9f35568f4 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -44,9 +44,17 @@ namespace CalamityMod.NPCs.TownNPCs animationType = NPCID.Guide; } + public override void AI() + { + if (!CalamityWorld.spawnedCirrus) + { + CalamityWorld.spawnedCirrus = true; + } + } + public override bool CanTownNPCSpawn(int numTownNPCs, int money) { - for (int k = 0; k < 255; k++) + for (int k = 0; k < Main.maxPlayers; k++) { Player player = Main.player[k]; if (player.active) @@ -60,7 +68,7 @@ namespace CalamityMod.NPCs.TownNPCs } } } - return false; + return CalamityWorld.spawnedCirrus; } public override string TownNPCName() diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index c837920688..c8ddf8ff8c 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -55,9 +55,17 @@ namespace CalamityMod.NPCs.TownNPCs animationType = NPCID.PartyGirl; } + public override void AI() + { + if (!CalamityWorld.spawnedBandit) + { + CalamityWorld.spawnedBandit = true; + } + } + public override bool CanTownNPCSpawn(int numTownNPCs, int money) { - for (int k = 0; k < 255; k++) + for (int k = 0; k < Main.maxPlayers; k++) { Player player = Main.player[k]; if (player.active && player.InventoryHas(ItemID.PlatinumCoin)) @@ -65,7 +73,7 @@ namespace CalamityMod.NPCs.TownNPCs return NPC.downedBoss3; } } - return false; + return CalamityWorld.spawnedBandit; } public override string TownNPCName() diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 435512ba79..3071f8f414 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -116,6 +116,10 @@ namespace CalamityMod.World public static int[] SChestY = new int[10]; public static bool roxShrinePlaced = false; + //Spawned NPCs + public static bool spawnedBandit = false; + public static bool spawnedCirrus = false; + #region Downed Bools public static bool downedBossAny = false; //Any boss public static bool downedDesertScourge = false; @@ -189,6 +193,8 @@ namespace CalamityMod.World newAltarY = 0; abyssChasmBottom = 0; abyssSide = false; + spawnedBandit = false; + spawnedCirrus = false; downedDesertScourge = false; downedAquaticScourge = false; downedHiveMind = false; @@ -323,6 +329,10 @@ namespace CalamityMod.World downed.Add("scales"); if (rainingAcid) downed.Add("acidRain"); + if (spawnedBandit) + downed.Add("bandit"); + if (spawnedCirrus) + downed.Add("drunkPrincess"); return new TagCompound { @@ -383,6 +393,8 @@ namespace CalamityMod.World downedCLAM = downed.Contains("clam"); dragonScalesBought = downed.Contains("scales"); rainingAcid = downed.Contains("acidRain"); + spawnedBandit = downed.Contains("bandit"); + spawnedCirrus = downed.Contains("drunkPrincess"); abyssChasmBottom = tag.GetInt("abyssChasmBottom"); } @@ -437,11 +449,11 @@ namespace CalamityMod.World onionMode = flags4[6]; revenge = flags4[7]; - // These 3 bits are currently unused, they used to be astral meteor drops + // 1 bit is currently unused, it used to be astral meteor drops BitsByte flags5 = reader.ReadByte(); downedStarGod = flags5[0]; - _ = flags5[1]; - _ = flags5[2]; + spawnedBandit = flags5[1]; + spawnedCirrus = flags5[2]; _ = flags5[3]; spawnedHardBoss = flags5[4]; downedPolterghast = flags5[5]; @@ -516,11 +528,11 @@ namespace CalamityMod.World flags4[6] = onionMode; flags4[7] = revenge; - // These 3 bits are currently unused, they used to be astral meteor drops + // 1 bits is currently unused, it used to be astral meteor drops BitsByte flags5 = new BitsByte(); flags5[0] = downedStarGod; - flags5[1] = false; - flags5[2] = false; + flags5[1] = spawnedBandit; + flags5[2] = spawnedCirrus; flags5[3] = false; flags5[4] = spawnedHardBoss; flags5[5] = downedPolterghast; @@ -599,11 +611,11 @@ namespace CalamityMod.World onionMode = flags4[6]; revenge = flags4[7]; - // These 3 bits are currently unused, they used to be astral meteor drops + // 1 bits is currently unused, it used to be astral meteor drops BitsByte flags5 = reader.ReadByte(); downedStarGod = flags5[0]; - _ = flags5[1]; - _ = flags5[2]; + spawnedBandit = flags5[1]; + spawnedCirrus = flags5[2]; _ = flags5[3]; spawnedHardBoss = flags5[4]; downedPolterghast = flags5[5];