From 22fb3230084eaaec6a4c08430cc4b0abfa95997d Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Wed, 15 May 2024 14:54:31 -0500 Subject: [PATCH] 1 - Fixed Desert Scourge body and tail not showing up in mp. 2 - Fixed certain worms having despawn issues in mp. --- NPCs/Abyss/EidolonWyrmHead.cs | 37 +++++++----------- NPCs/Abyss/GulperEelHead.cs | 39 +++++++------------ NPCs/Abyss/OarfishHead.cs | 6 ++- NPCs/DesertScourge/DesertNuisanceBody.cs | 29 ++------------ NPCs/DesertScourge/DesertNuisanceBodyYoung.cs | 29 ++------------ NPCs/DesertScourge/DesertScourgeBody.cs | 23 ++--------- NPCs/SunkenSea/SeaSerpent1.cs | 36 +++++++---------- 7 files changed, 58 insertions(+), 141 deletions(-) diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 8b23bec9cf..b7b311396f 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -118,19 +118,18 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { - NPC.TargetClosest(true); - } + NPC.TargetClosest(); + if (NPC.justHit || detectsPlayer || Main.player[NPC.target].chaosState || adultWyrmAlive || (Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f)) { detectsPlayer = true; NPC.damage = Main.expertMode ? 340 : 170; } else - { NPC.damage = 0; - } + NPC.chaseable = detectsPlayer; + if (detectsPlayer) { if (NPC.soundDelay <= 0) @@ -142,14 +141,12 @@ namespace CalamityMod.NPCs.Abyss else { if (Main.rand.NextBool(900)) - { SoundEngine.PlaySound(roar, NPC.Center); - } } + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -161,18 +158,13 @@ namespace CalamityMod.NPCs.Abyss if (segments >= 0 && segments < minLength) { if (segments % 2 == 0) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -180,17 +172,16 @@ namespace CalamityMod.NPCs.Abyss NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = -1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = 1; - } + if (Main.player[NPC.target].dead) { NPC.TargetClosest(false); @@ -208,14 +199,16 @@ namespace CalamityMod.NPCs.Abyss } } } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f) + NPC.active = false; } float currentSpeed = speed; diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index 1d09fd334f..395fc3d696 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -115,19 +115,16 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { - NPC.TargetClosest(true); - } - if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || - NPC.justHit) - { + NPC.TargetClosest(); + + if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || NPC.justHit) detectsPlayer = true; - } + NPC.chaseable = detectsPlayer; + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -139,18 +136,13 @@ namespace CalamityMod.NPCs.Abyss if (segments >= 0 && segments < minLength) { if (segments == 0) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -158,29 +150,28 @@ namespace CalamityMod.NPCs.Abyss NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = 1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = -1; - } + if (Main.player[NPC.target].dead) - { NPC.TargetClosest(false); - } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; } float currentSpeed = speed; diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 5945215fc8..9459276e5a 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -155,7 +155,11 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) - NPC.active = false; + { + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; + } float currentSpeed = speed; float currentTurnSpeed = turnSpeed; diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index e666fc7b04..d61794d229 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -69,23 +69,6 @@ namespace CalamityMod.NPCs.DesertScourge public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; - public override void SendExtraAI(BinaryWriter writer) - { - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; - } - public override void AI() { bool bossRush = BossRushEvent.BossRushActive; @@ -104,10 +87,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -121,10 +102,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -138,10 +117,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; diff --git a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs index 86b3514232..c1086817cc 100644 --- a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs @@ -69,23 +69,6 @@ namespace CalamityMod.NPCs.DesertScourge public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; - public override void SendExtraAI(BinaryWriter writer) - { - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; - } - public override void AI() { bool bossRush = BossRushEvent.BossRushActive; @@ -104,10 +87,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -121,10 +102,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -138,10 +117,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index daa0b54eae..1d30f4e6ce 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -80,23 +80,12 @@ namespace CalamityMod.NPCs.DesertScourge { writer.Write(NPC.alpha); writer.Write(NPC.dontTakeDamage); - - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); } public override void ReceiveExtraAI(BinaryReader reader) { NPC.alpha = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); - - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; } public override void AI() @@ -117,10 +106,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -134,10 +121,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -151,10 +136,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index 7a678cddb8..2cb2cdab19 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -84,15 +84,14 @@ namespace CalamityMod.NPCs.SunkenSea } } - Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f); + Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 0.3f / 255f, (255 - NPC.alpha) * 0.3f / 255f); + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { NPC.TargetClosest(true); - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -102,21 +101,14 @@ namespace CalamityMod.NPCs.SunkenSea { int lol = 0; if (segment == 0 || segment == 1 || segment == 4 || segment == 5) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 2 || segment == 3 || segment == 6) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 7) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 8) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -124,30 +116,30 @@ namespace CalamityMod.NPCs.SunkenSea NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = -1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = 1; - } + if (Main.player[NPC.target].dead) - { NPC.TargetClosest(false); - } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; } + float currentSpeed = speed; float currentTurnSpeed = turnSpeed; Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);