From 92a41babd14b55dfd92e5e00e4f95fa53503f803 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Mon, 16 Oct 2023 06:51:45 -0500 Subject: [PATCH] 1 - Hive Mind net spam block prevention. 2 - Destroyer now shoots weak purple lasers from broken segments. 3 - Safe Normalize for SCal/Cirrus. --- DataStructures/NPCStats.cs | 1 + NPCs/HiveMind/HiveMind.cs | 12 +++++++ NPCs/SupremeCalamitas/SupremeCalamitas.cs | 34 +++++++++---------- .../VanillaNPCOverrides/Bosses/DestroyerAI.cs | 14 ++++---- 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index fedd792c34..3c60759aab 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -627,6 +627,7 @@ namespace CalamityMod { new Tuple(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 72, 116, 128, 174 } }, // 108 in non-rev master mode { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 46, 76, 128, 140, 186 } }, { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 48, 80, 136, 152, 210 } }, + { new Tuple(NPCID.TheDestroyerBody, ProjectileID.EyeLaser), new int[] { 40, 68, 100, 112, 144 } }, { new Tuple(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 144 } }, // 132 in non-rev master mode { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 176, 234 } }, diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index b104be88d7..d4f7e75840 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -605,6 +605,7 @@ namespace CalamityMod.NPCs.HiveMind } } NPC.netUpdate = true; + NPC.netSpam = 0; } else if (burrowTimer < 0) { @@ -714,6 +715,7 @@ namespace CalamityMod.NPCs.HiveMind rotation = MathHelper.ToRadians(Main.rand.Next(360)); NPC.netUpdate = true; + NPC.netSpam = 0; } if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 5000f) @@ -751,6 +753,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity *= 2f / 255f * (reelbackFade + 2 * (int)enrageScale); ReelBack(); NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -782,6 +785,7 @@ namespace CalamityMod.NPCs.HiveMind phase2timer = minimumDriftTime + Main.rand.Next(121); NPC.netUpdate = true; + NPC.netSpam = 0; } else if (NPC.ai[1] == 0f && NPC.ai[2] == 0f) { @@ -794,6 +798,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.ai[1] = posX; NPC.ai[2] = posY; NPC.netUpdate = true; + NPC.netSpam = 0; break; } } @@ -834,6 +839,7 @@ namespace CalamityMod.NPCs.HiveMind case 3: // Lunge NPC.netUpdate = true; + NPC.netSpam = 0; if (NPC.alpha > 0) { NPC.alpha -= lungeFade; @@ -890,6 +896,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.Y += teleportRadius; } NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -900,6 +907,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity.X = MathHelper.Pi * teleportRadius / arcTime; NPC.velocity *= rotationDirection; NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -947,6 +955,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.X += teleportRadius * rotationDirection; } NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -957,6 +966,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity.X = teleportRadius / arcTime * 3; NPC.velocity *= -rotationDirection; NPC.netUpdate = true; + NPC.netSpam = 0; } else { @@ -995,6 +1005,7 @@ namespace CalamityMod.NPCs.HiveMind phase2timer = minimumDriftTime + Main.rand.Next(121); state = 0; NPC.netUpdate = true; + NPC.netSpam = 0; } break; @@ -1033,6 +1044,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity *= -4f; ReelBack(); NPC.netUpdate = true; + NPC.netSpam = 0; } } diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 6d67fa6a21..a065b545d6 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -227,7 +227,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Main.npcFrameCount[NPC.type] = 21; NPCID.Sets.TrailingMode[NPC.type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(0) + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { SpriteDirection = 1 }; @@ -872,7 +872,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; - Vector2 bottleVelocity = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * bottleSpeed; + Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 350, 0f, Main.myPlayer); } } @@ -967,7 +967,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Vector2 destination = player.Center; Vector2 distanceFromDestination = destination - NPC.Center; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * CirrusPhotonRipperDashVelocity; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * CirrusPhotonRipperDashVelocity; if (Vector2.Distance(NPC.Center, destination) > CirrusPhotonRipperMinDistanceFromTarget) NPC.SimpleFlyMovement(desiredVelocity * uDieLul, CirrusPhotonRipperDashAcceleration * uDieLul); @@ -1070,7 +1070,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; - Vector2 bottleVelocity = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * bottleSpeed; + Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer); } } @@ -1164,7 +1164,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Vector2 destination = player.Center; Vector2 distanceFromDestination = destination - NPC.Center; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * CirrusPhotonRipperDashVelocity; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * CirrusPhotonRipperDashVelocity; if (Vector2.Distance(NPC.Center, destination) > CirrusPhotonRipperMinDistanceFromTarget) NPC.SimpleFlyMovement(desiredVelocity * uDieLul, CirrusPhotonRipperDashAcceleration * uDieLul); @@ -1186,7 +1186,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; - Vector2 bottleVelocity = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * bottleSpeed; + Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer); } } @@ -1303,7 +1303,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int k = 0; k < totalProjectiles; k++) { Vector2 rayVelocity = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(rayVelocity) * 16f, rayVelocity, ModContent.ProjectileType(), 250, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + (rayVelocity).SafeNormalize(Vector2.UnitY) * 16f, rayVelocity, ModContent.ProjectileType(), 250, 0f, Main.myPlayer); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].DamageType = DamageClass.Default; @@ -1830,7 +1830,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + projectileVelocity.SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 10f * uDieLul; @@ -1930,7 +1930,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) { - Vector2 vector = Vector2.Normalize(player.Center - NPC.Center); + Vector2 vector = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); NPC.velocity = vector * chargeVelocity; shieldRotation = NPC.velocity.ToRotation(); @@ -1945,13 +1945,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas float velocity = 8; int type = ModContent.ProjectileType(); int damage = (int)(NPC.damage / 3); - Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * velocity; + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; float rotation = MathHelper.ToRadians(22); for (int i = 0; i < 3; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(2))); - int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 3f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + (perturbedSpeed).SafeNormalize(Vector2.UnitY) * 3f, perturbedSpeed, type, damage, 0f, Main.myPlayer); if (p.WithinBounds(Main.maxProjectiles)) { Main.projectile[p].DamageType = DamageClass.Default; @@ -2075,7 +2075,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + projectileVelocity.SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 4f; projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; @@ -2154,7 +2154,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + projectileVelocity.SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 5f * uDieLul; int projectileType = gigablast; @@ -2396,7 +2396,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + projectileVelocity.SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 10f * uDieLul; @@ -2494,7 +2494,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) { - Vector2 vector = Vector2.Normalize(player.Center - NPC.Center); + Vector2 vector = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); NPC.velocity = vector * chargeVelocity; shieldRotation = NPC.velocity.ToRotation(); @@ -2612,7 +2612,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + projectileVelocity.SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 4f; projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; @@ -2695,7 +2695,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); Vector2 projectileVelocity = player.Center - NPC.Center; - projectileVelocity.Normalize(); + projectileVelocity.SafeNormalize(Vector2.UnitY); Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 5f * uDieLul; int projectileType = gigablast; diff --git a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs index b15361f677..e8b1f4f4cf 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs @@ -267,11 +267,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses laserSpawnDistance = 20f; } - bool scrap = false; + bool weakLaser = false; if (probeLaunched) { - scrap = true; - projectileType = ProjectileID.SaucerScrap; + weakLaser = true; + projectileType = ProjectileID.EyeLaser; laserSpawnDistance = 0f; } @@ -279,10 +279,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; Vector2 projectileSpawn = npc.Center + projectileVelocity * laserSpawnDistance; - // Shoot projectile and set timeLeft if not a homing laser/metal scrap so lasers don't last for too long - int damage = scrap ? 0 : npc.GetProjectileDamage(projectileType); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, scrap ? 0f : 1f, 0f); - Main.projectile[proj].timeLeft = scrap ? 150 : 900; + // Shoot projectile + int damage = npc.GetProjectileDamage(projectileType); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, weakLaser ? 0f : 1f, 0f); + Main.projectile[proj].timeLeft = weakLaser ? 600 : 900; npc.netUpdate = true; }