From 8940ff38cd9097ec12fdfbf1df7350c0a38ef37b Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Mon, 20 May 2024 03:43:37 -0500 Subject: [PATCH] I hate how things despawn in this game so much --- NPCs/SlimeGod/CrimulanPaladin.cs | 2 - NPCs/SlimeGod/EbonianPaladin.cs | 2 - NPCs/SlimeGod/SlimeGodCore.cs | 70 ++++++++++++------- NPCs/SlimeGod/SplitCrimulanPaladin.cs | 2 - NPCs/SlimeGod/SplitEbonianPaladin.cs | 2 - .../Bosses/SkeletronAI.cs | 3 - 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index 59c8c721e0..8d7147dc4d 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -742,8 +742,6 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } - public override bool CheckActive() => NPC.ai[0] == 3f; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index f59df6f5f8..fe2ae3f8a7 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -787,8 +787,6 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } - public override bool CheckActive() => NPC.ai[0] == 4f; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 153c0e85ad..d2f4e0bb7c 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -100,6 +100,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(slimesSpawned); writer.Write(buffedSlime); writer.Write(NPC.Opacity); for (int i = 0; i < 4; i++) @@ -108,6 +109,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void ReceiveExtraAI(BinaryReader reader) { + slimesSpawned = reader.ReadBoolean(); buffedSlime = reader.ReadInt32(); NPC.Opacity = reader.ReadSingle(); for (int i = 0; i < 4; i++) @@ -135,11 +137,14 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (Main.netMode != NetmodeID.MultiplayerClient && !slimesSpawned) + if (!slimesSpawned) { slimesSpawned = true; - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + } } // Enrage based on large slimes @@ -188,7 +193,7 @@ namespace CalamityMod.NPCs.SlimeGod bool phase2 = !purpleSlimeAlive || !redSlimeAlive; // Vanish phase - if (!purpleSlimeAlive && !redSlimeAlive) + if ((!purpleSlimeAlive && !redSlimeAlive) || calamityGlobalNPC.newAI[3] == 1f || NPC.ai[3] == 1f) { // Avoid cheap bullshit NPC.damage = 0; @@ -257,40 +262,53 @@ namespace CalamityMod.NPCs.SlimeGod Main.dust[slimyDust2].velocity *= 2f; } - // Let the player know that the Slime God isn't dead fr - if (!DownedBossSystem.downedSlimeGod) + if (calamityGlobalNPC.newAI[3] != 1f) { - string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; - Color messageColor = Color.Magenta; + // Let the player know that the Slime God isn't dead fr + if (!DownedBossSystem.downedSlimeGod) + { + string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; + Color messageColor = Color.Magenta; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + // Set Slime God to have interacted with all players + for (int i = Main.maxPlayers - 1; i >= 0; i--) + NPC.ApplyInteraction(i); + + NPC.active = false; + NPC.HitEffect(); + NPC.NPCLoot(); + NPC.netUpdate = true; } - - // Set Slime God to have interacted with all players - for (int i = Main.maxPlayers - 1; i >= 0; i--) + else { - NPC.ApplyInteraction(i); - } + for (int x = 0; x < Main.maxNPCs; x++) + { + if (Main.npc[x].type == ModContent.NPCType() || Main.npc[x].type == ModContent.NPCType() || + Main.npc[x].type == ModContent.NPCType() || Main.npc[x].type == ModContent.NPCType()) + { + Main.npc[x].active = false; + Main.npc[x].netUpdate = true; + } + } - NPC.active = false; - NPC.HitEffect(); - NPC.NPCLoot(); - NPC.netUpdate = true; + NPC.active = false; + NPC.HitEffect(); + NPC.netUpdate = true; + } } return; } // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > (bossRush ? CalamityGlobalNPC.CatchUpDistance350Tiles : CalamityGlobalNPC.CatchUpDistance200Tiles) || calamityGlobalNPC.newAI[3] == 1f) + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > (bossRush ? CalamityGlobalNPC.CatchUpDistance350Tiles : CalamityGlobalNPC.CatchUpDistance200Tiles)) { - if (calamityGlobalNPC.newAI[3] != 1f) - { - NPC.TargetClosest(false); - player = Main.player[NPC.target]; - } - - if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > (bossRush ? CalamityGlobalNPC.CatchUpDistance350Tiles : CalamityGlobalNPC.CatchUpDistance200Tiles) || calamityGlobalNPC.newAI[3] == 1f) + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > (bossRush ? CalamityGlobalNPC.CatchUpDistance350Tiles : CalamityGlobalNPC.CatchUpDistance200Tiles)) { if (NPC.velocity.Y < -3f) NPC.velocity.Y = -3f; diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index 7ad8a1e363..a51706798a 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -736,8 +736,6 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.Add(ItemID.Gel, 1, 32, 48); } - public override bool CheckActive() => NPC.ai[0] == 3f; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 8dddef1603..fad784a39e 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -780,8 +780,6 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.Add(ItemID.Gel, 1, 32, 48); } - public override bool CheckActive() => NPC.ai[0] == 4f; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index abf2444bac..68e01972b2 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -125,9 +125,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - // Distance from target - float distance = Vector2.Distance(Main.player[npc.target].Center, npc.Center); - // Despawn if (npc.ai[1] != 3f) {