From 4cf38b4cb71f1b5d7919ff058a72a58a2bdc0bbf Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Wed, 29 May 2024 17:34:29 -0500 Subject: [PATCH] More Hive Mind and Blob adjustments and fixes. --- NPCs/HiveMind/HiveBlob.cs | 30 +++++++++--------- NPCs/HiveMind/HiveBlob2.cs | 30 +++++++++--------- NPCs/HiveMind/HiveMind.cs | 65 +++++++++++++++++++++++++++++++++----- 3 files changed, 87 insertions(+), 38 deletions(-) diff --git a/NPCs/HiveMind/HiveBlob.cs b/NPCs/HiveMind/HiveBlob.cs index 38bec7c7e6..14d3a860b5 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -91,11 +91,10 @@ namespace CalamityMod.NPCs.HiveMind NPC.TargetClosest(); float hiveMindVelocity = Main.npc[hiveMind].velocity.Length(); - float relocateSpeed = (getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f) + hiveMindVelocity * 0.0625f; - Vector2 randomLocationVector = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float targetX = Main.player[NPC.target].Center.X - (NPC.width / 2) - randomLocationVector.X; - float targetY = Main.player[NPC.target].Center.Y - (NPC.height / 2) - randomLocationVector.Y; - float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; + float acceleration = 0.8f; + float distanceFromMind = Main.getGoodWorld ? 256f : 128f; + float hiveMindX = Main.npc[hiveMind].Center.X; float hiveMindY = Main.npc[hiveMind].Center.Y; Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); @@ -104,32 +103,33 @@ namespace CalamityMod.NPCs.HiveMind float finalRandPosX = randomPosX - hiveMindPos.X; float finalRandPosY = randomPosY - hiveMindPos.Y; float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); - finalRandDistance = (Main.getGoodWorld ? 256f : 128f) / finalRandDistance; + finalRandDistance = distanceFromMind / finalRandDistance; finalRandPosX *= finalRandDistance; finalRandPosY *= finalRandDistance; + if (NPC.position.X < hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X + relocateSpeed; + NPC.velocity.X += relocateSpeed; if (NPC.velocity.X < 0f && finalRandPosX > 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } else if (NPC.position.X > hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X - relocateSpeed; + NPC.velocity.X -= relocateSpeed; if (NPC.velocity.X > 0f && finalRandPosX < 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } if (NPC.position.Y < hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y + relocateSpeed; + NPC.velocity.Y += relocateSpeed; if (NPC.velocity.Y < 0f && finalRandPosY > 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } else if (NPC.position.Y > hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y - relocateSpeed; + NPC.velocity.Y -= relocateSpeed; if (NPC.velocity.Y > 0f && finalRandPosY < 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } float velocityLimit = relocateSpeed * 16f; @@ -209,7 +209,7 @@ namespace CalamityMod.NPCs.HiveMind Color color = NPC.GetAlpha(drawColor); if (NPC.localAI[1] > 240f) - color = Color.Lerp(color, Color.Green, MathHelper.Clamp((NPC.localAI[1] - 240f) / 120f, 0f, 1f)); + color = Color.Lerp(color, Color.Green * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - 240f) / 120f, 0f, 1f)); spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index 4b860e61aa..7774a4db71 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -94,11 +94,10 @@ namespace CalamityMod.NPCs.HiveMind NPC.TargetClosest(); float hiveMindVelocity = Main.npc[hiveMind].velocity.Length(); - float relocateSpeed = (getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f) + hiveMindVelocity * 0.0625f; - Vector2 randomRelocateVector = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float targetX = Main.player[NPC.target].Center.X - (NPC.width / 2) - randomRelocateVector.X; - float targetY = Main.player[NPC.target].Center.Y - (NPC.height / 2) - randomRelocateVector.Y; - float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; + float acceleration = 0.8f; + float distanceFromMind = Main.getGoodWorld ? 192f : 96f; + float hiveMindX = Main.npc[hiveMind].Center.X; float hiveMindY = Main.npc[hiveMind].Center.Y; Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); @@ -107,32 +106,33 @@ namespace CalamityMod.NPCs.HiveMind float finalRandPosX = randomPosX - hiveMindPos.X; float finalRandPosY = randomPosY - hiveMindPos.Y; float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); - finalRandDistance = (Main.getGoodWorld ? 192f : 96f) / finalRandDistance; + finalRandDistance = distanceFromMind / finalRandDistance; finalRandPosX *= finalRandDistance; finalRandPosY *= finalRandDistance; + if (NPC.position.X < hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X + relocateSpeed; + NPC.velocity.X += relocateSpeed; if (NPC.velocity.X < 0f && finalRandPosX > 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } else if (NPC.position.X > hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X - relocateSpeed; + NPC.velocity.X -= relocateSpeed; if (NPC.velocity.X > 0f && finalRandPosX < 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } if (NPC.position.Y < hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y + relocateSpeed; + NPC.velocity.Y += relocateSpeed; if (NPC.velocity.Y < 0f && finalRandPosY > 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } else if (NPC.position.Y > hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y - relocateSpeed; + NPC.velocity.Y -= relocateSpeed; if (NPC.velocity.Y > 0f && finalRandPosY < 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } float velocityLimit = relocateSpeed * 16f; @@ -212,7 +212,7 @@ namespace CalamityMod.NPCs.HiveMind Color color = NPC.GetAlpha(drawColor); if (NPC.localAI[1] > 240f) - color = Color.Lerp(color, Color.Green, MathHelper.Clamp((NPC.localAI[1] - 240f) / 120f, 0f, 1f)); + color = Color.Lerp(color, Color.Green * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - 240f) / 120f, 0f, 1f)); spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 8972d8a532..0b98d73ab0 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -572,7 +572,7 @@ namespace CalamityMod.NPCs.HiveMind int fivePercentMinions = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, type); Main.npc[fivePercentMinions].SetDefaults(type); if (Main.netMode == NetmodeID.Server && fivePercentMinions < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, fivePercentMinions, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, fivePercentMinions); } return; @@ -830,15 +830,15 @@ namespace CalamityMod.NPCs.HiveMind { NPC.position.X = NPC.ai[1] * 16 - NPC.width / 2; NPC.position.Y = NPC.ai[2] * 16 - height_Phase2 / 2; + } - for (int i = 0; i < Main.maxNPCs; i++) + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hiveBlob = Main.npc[i]; + if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) { - NPC hiveBlob = Main.npc[i]; - if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) - { - hiveBlob.position.X = NPC.position.X; - hiveBlob.position.Y = NPC.position.Y; - } + hiveBlob.position.X = NPC.position.X; + hiveBlob.position.Y = NPC.position.Y; } } @@ -879,6 +879,16 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity = Vector2.Zero; dashStarted = false; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hiveBlob = Main.npc[i]; + if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) + { + hiveBlob.position.X = NPC.position.X; + hiveBlob.position.Y = NPC.position.Y; + } + } + if (revenge && lifeRatio < 0.53f) { state = nextState; @@ -914,6 +924,19 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); + if (NPC.alpha == 255 - lungeFade) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hiveBlob = Main.npc[i]; + if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) + { + hiveBlob.position.X = NPC.position.X; + hiveBlob.position.Y = NPC.position.Y; + } + } + } + rotation += rotationIncrement * rotationDirection; phase2timer = lungeDelay; } @@ -978,6 +1001,19 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.Y += teleportRadius; } + if (NPC.alpha == 255 - (masterMode ? 10 : 5)) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hiveBlob = Main.npc[i]; + if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) + { + hiveBlob.position.X = NPC.position.X; + hiveBlob.position.Y = NPC.position.Y; + } + } + } + NPC.netUpdate = true; NPC.netSpam = 0; } @@ -1051,6 +1087,19 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.X += teleportRadius * rotationDirection; } + if (NPC.alpha == 255 - (masterMode ? 10 : 5)) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hiveBlob = Main.npc[i]; + if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) + { + hiveBlob.position.X = NPC.position.X; + hiveBlob.position.Y = NPC.position.Y; + } + } + } + NPC.netUpdate = true; NPC.netSpam = 0; }