From 3ef36036ef151a529764b1f970d6432b0d49b2a3 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Tue, 8 Aug 2023 16:32:09 -0500 Subject: [PATCH] Adjusted various multiplayer client netmode checks for boss AIs to avoid bugs at all cost. --- CalPlayer/CalamityPlayer.cs | 2 - NPCs/Abyss/BobbitWormSegment.cs | 6 +- NPCs/Bumblebirb/Bumblefuck.cs | 17 +- NPCs/Bumblebirb/Bumblefuck2.cs | 17 +- NPCs/CalamityAI.cs | 756 +++++++++++-------- NPCs/Crabulon/Crabulon.cs | 65 +- NPCs/Cryogen/Cryogen.cs | 118 +-- NPCs/DesertScourge/DesertScourgeHead.cs | 96 +-- NPCs/ExoMechs/Apollo/Apollo.cs | 2 +- NPCs/ExoMechs/Ares/AresBody.cs | 2 +- NPCs/ExoMechs/Ares/AresGaussNuke.cs | 10 +- NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs | 10 +- NPCs/ExoMechs/Ares/AresTeslaCannon.cs | 10 +- NPCs/ExoMechs/Artemis/Artemis.cs | 3 +- NPCs/ExoMechs/Thanatos/ThanatosBody1.cs | 282 ++++--- NPCs/ExoMechs/Thanatos/ThanatosBody2.cs | 269 +++---- NPCs/ExoMechs/Thanatos/ThanatosTail.cs | 269 +++---- Projectiles/Boss/DoGDeath.cs | 1 + 18 files changed, 1023 insertions(+), 912 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index d22c30d001..7abd3083f6 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -2796,9 +2796,7 @@ namespace CalamityMod.CalPlayer { NPC npc = Main.npc[l]; if (npc.active && !npc.friendly && !npc.dontTakeDamage && Vector2.Distance(Player.Center, npc.Center) <= 3000f) - { npc.AddBuff(ModContent.BuffType(), 600, false); - } } } } diff --git a/NPCs/Abyss/BobbitWormSegment.cs b/NPCs/Abyss/BobbitWormSegment.cs index cdbabd7ef4..aad563ed48 100644 --- a/NPCs/Abyss/BobbitWormSegment.cs +++ b/NPCs/Abyss/BobbitWormSegment.cs @@ -47,11 +47,11 @@ namespace CalamityMod.NPCs.Abyss } } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[1] == 0f) { - if (NPC.ai[1] == 0f) + NPC.ai[1] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.ai[1] = 1f; int spawnedNPC = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI, 0f, 0f, 0f, 0f, 255); Main.npc[spawnedNPC].ai[2] = (float)CalamityGlobalNPC.bobbitWormBottom[(int)NPC.ai[0]]; NPC.ai[2] = (float)spawnedNPC; diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 39952c773c..c891406fd3 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -464,18 +464,21 @@ namespace CalamityMod.NPCs.Bumblebirb DownedBossSystem.downedDragonfolly = true; CalamityNetcode.SyncWorld(); - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) + if (Main.zenithWorld) { int spacing = 40; int amt = 7; SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); - for (int i = 0; i < amt; i++) + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); - Vector2 ai0 = NPC.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } } } diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index 467ef7d666..f2549f4800 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -55,16 +55,19 @@ namespace CalamityMod.NPCs.Bumblebirb if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) + if (Main.zenithWorld) { SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); - for (int i = 0; i < 5; i++) + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f); - Vector2 ai0 = NPC.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + for (int i = 0; i < 5; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } } } } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 262bd993c6..1781f01de3 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -150,7 +150,6 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float mistVelocity = death ? 10f : 8f; - Vector2 projectileVelocity = Vector2.Normalize(npc.Center + npc.velocity * 10f - npc.Center); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -979,40 +978,45 @@ namespace CalamityMod.NPCs if (npc.ai[1] % divisor == divisor - 1f) { + float velocity = (death ? 7f : revenge ? 6f : 5f) + (2f * enrageScale) + (expertMode ? 3f * (1f - lifeRatio) : 0f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (brimmy.currentMode == 4) + { + type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item30, player.Center); + } + Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; + if (Main.netMode != NetmodeID.MultiplayerClient) { - float velocity = (death ? 7f : revenge ? 6f : 5f) + (2f * enrageScale) + (expertMode ? 3f * (1f - lifeRatio) : 0f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (brimmy.currentMode == 4) - { - type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item30, player.Center); - } - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(projectileVelocity) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); Main.projectile[proj].timeLeft = 240; if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) Main.projectile[proj].extraUpdates += 1; + } - if (npc.ai[1] % divisor2 == divisor2 - 1f) + if (npc.ai[1] % divisor2 == divisor2 - 1f) + { + velocity = (death ? 5f : 4f) + 2f * enrageScale; + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + if (brimmy.currentMode == 4) + { + type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item21, player.Center); + } + projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; + int numProj = death ? 8 : 4; + int spread = death ? 90 : 45; + if (Main.getGoodWorld) + { + numProj *= 3; + spread *= 2; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) { - velocity = (death ? 5f : 4f) + 2f * enrageScale; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - if (brimmy.currentMode == 4) - { - type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item21, player.Center); - } - projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; - int numProj = death ? 8 : 4; - int spread = death ? 90 : 45; - if (Main.getGoodWorld) - { - numProj *= 3; - spread *= 2; - } float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { @@ -1042,37 +1046,38 @@ namespace CalamityMod.NPCs npc.defense = npc.defDefense * 4; npc.chaseable = false; - if (Main.netMode != NetmodeID.MultiplayerClient) + npc.localAI[0] += 1f; + if (Main.getGoodWorld) + npc.localAI[0] += 2f; + if (expertMode) + npc.localAI[0] += 1f - lifeRatio; + npc.localAI[0] += enrageScale; + + if (npc.localAI[0] >= 120f) { - npc.localAI[0] += 1f; - if (Main.getGoodWorld) - npc.localAI[0] += 2f; - if (expertMode) - npc.localAI[0] += 1f - lifeRatio; - npc.localAI[0] += enrageScale; + npc.localAI[0] = 0f; - if (npc.localAI[0] >= 120f) + float projectileSpeed = death ? 9f : revenge ? 8f : 6f; + projectileSpeed += 2f * enrageScale; + + Vector2 projectileVelocity = player.Center - npc.Center; + + float radialOffset = 0.2f; + float diameter = 80f; + + projectileVelocity = Vector2.Normalize(projectileVelocity) * projectileSpeed; + + Vector2 velocity = projectileVelocity; + velocity.Normalize(); + velocity *= diameter; + + int totalProjectiles = 6; + float offsetAngle = (float)Math.PI * radialOffset; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = 0f; - - float projectileSpeed = death ? 9f : revenge ? 8f : 6f; - projectileSpeed += 2f * enrageScale; - - Vector2 projectileVelocity = player.Center - npc.Center; - - float radialOffset = 0.2f; - float diameter = 80f; - - projectileVelocity = Vector2.Normalize(projectileVelocity) * projectileSpeed; - - Vector2 velocity = projectileVelocity; - velocity.Normalize(); - velocity *= diameter; - - int totalProjectiles = 6; - float offsetAngle = (float)Math.PI * radialOffset; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); for (int j = 0; j < totalProjectiles; j++) { float radians = j - (totalProjectiles - 1f) / 2f; @@ -1083,20 +1088,24 @@ namespace CalamityMod.NPCs if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) Main.projectile[proj].extraUpdates += 1; } + } - totalProjectiles = 12; - float radians2 = MathHelper.TwoPi / totalProjectiles; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - if (brimmy.currentMode == 4) - { - type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item26, player.Center); - } - double angleA = radians2 * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed); + totalProjectiles = 12; + float radians2 = MathHelper.TwoPi / totalProjectiles; + type = ModContent.ProjectileType(); + damage = npc.GetProjectileDamage(type); + if (brimmy.currentMode == 4) + { + type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item26, player.Center); + } + double angleA = radians2 * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); @@ -1116,9 +1125,9 @@ namespace CalamityMod.NPCs Main.projectile[proj].extraUpdates += 1; } } - - npc.localAI[2] += 1f; } + + npc.localAI[2] += 1f; } npc.velocity *= 0.95f; @@ -1199,9 +1208,11 @@ namespace CalamityMod.NPCs laserVelocity2.Normalize(); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.GetSource_FromAI(), source, laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); if (Main.getGoodWorld) Projectile.NewProjectile(npc.GetSource_FromAI(), source, -laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + if (Main.zenithWorld) { Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(-laserVelocity2.X, laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); @@ -1235,9 +1246,9 @@ namespace CalamityMod.NPCs if (npc.ai[1] % playSoundTimer == 0f) SoundEngine.PlaySound(SoundID.Item20, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) { - if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.GetSource_FromAI(), source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); if (Main.getGoodWorld) @@ -1248,18 +1259,23 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(-laserVelocity.X, laserVelocity.Y), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(laserVelocity.X, -laserVelocity.Y), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); } - - calamityGlobalNPC.newAI[0] = 1f; } - else + + calamityGlobalNPC.newAI[0] = 1f; + } + else + { + if (npc.ai[1] == 150f) { - if (npc.ai[1] == 150f) + npc.localAI[0] = laserVelocity.X; + npc.localAI[1] = laserVelocity.Y; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = laserVelocity.X; - npc.localAI[1] = laserVelocity.Y; Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, npc.localAI[0], npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); if (Main.getGoodWorld) Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, -npc.localAI[0], -npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); + if (Main.zenithWorld) { Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, -npc.localAI[0], npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); @@ -1609,9 +1625,8 @@ namespace CalamityMod.NPCs int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); if (Main.zenithWorld) - { type = ModContent.ProjectileType(); - } + float gigaBlastFrequency = (Main.getGoodWorld ? 120f : expertMode ? 180f : 240f) - enrageScale * 15f; float projSpeed = bossRush ? 6.25f : 5f; if (calamityGlobalNPC.newAI[3] <= 300f) @@ -1630,12 +1645,16 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); } } + } - npc.ai[0] += 1f; - float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale; - if (npc.ai[0] >= hellblastGateValue) + npc.ai[0] += 1f; + float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale; + if (npc.ai[0] >= hellblastGateValue) + { + npc.ai[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); float projSpeed = bossRush ? 5f : 4f; @@ -1645,6 +1664,7 @@ namespace CalamityMod.NPCs float velocity = distance == -1000f ? projSpeed : -projSpeed; Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); } + if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above { Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); @@ -1742,13 +1762,14 @@ namespace CalamityMod.NPCs else calamityGlobalNPC.newAI[3] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) + npc.ai[0] += 1f; + float hellblastGateValue = 30f - enrageScale; + if (npc.ai[0] >= hellblastGateValue) { - npc.ai[0] += 1f; - float hellblastGateValue = 30f - enrageScale; - if (npc.ai[0] >= hellblastGateValue) + npc.ai[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); float projSpeed = bossRush ? 5f : 4f; @@ -1758,6 +1779,7 @@ namespace CalamityMod.NPCs float velocity = distance == -1000f ? projSpeed : -projSpeed; Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); } + if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above { Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); @@ -2708,9 +2730,10 @@ namespace CalamityMod.NPCs if (astrumAureus.slimeProjCounter % 180 == 0) { SoundEngine.PlaySound(SoundID.Item33, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + + if (astrumAureus.slimePhase == 1) { - if (astrumAureus.slimePhase == 1) + if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -2723,9 +2746,12 @@ namespace CalamityMod.NPCs Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f); } - astrumAureus.slimePhase = 0; } - else + astrumAureus.slimePhase = 0; + } + else + { + if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -2742,8 +2768,8 @@ namespace CalamityMod.NPCs Vector2 offset = new Vector2(Main.rand.Next(-6, 7), Main.rand.Next(-6, 7)); Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, num1071 + offset.X, num1072 + offset.Y, type, damage, 0f, Main.myPlayer); } - astrumAureus.slimePhase = 1; } + astrumAureus.slimePhase = 1; } } CalamityGlobalAI.BuffedMimicAI(npc, mod); @@ -2799,12 +2825,12 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.Item33, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + if (calamityGlobalNPC.newAI[2] == 0f) { - if (calamityGlobalNPC.newAI[2] == 0f) - { - calamityGlobalNPC.newAI[2] = 1f; + calamityGlobalNPC.newAI[2] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { int maxProjectiles = !phase2 ? (bossRush ? 5 : 3) : (bossRush ? 7 : 5); int spread = !phase2 ? (bossRush ? 11 : 8) : (bossRush ? 12 : 10); @@ -2835,10 +2861,13 @@ namespace CalamityMod.NPCs } } } - else - { - calamityGlobalNPC.newAI[2] = 0f; + } + else + { + calamityGlobalNPC.newAI[2] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 19 : death ? 17 : 15); int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20); @@ -3135,9 +3164,10 @@ namespace CalamityMod.NPCs // Fire lasers or flames on stomp SoundEngine.PlaySound(SoundID.Item33, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + + if (Main.zenithWorld) { - if (Main.zenithWorld) + if (Main.netMode != NetmodeID.MultiplayerClient) { int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -3151,10 +3181,13 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f); } } - else if (calamityGlobalNPC.newAI[2] == 0f && phase2) - { - calamityGlobalNPC.newAI[2] = 1f; + } + else if (calamityGlobalNPC.newAI[2] == 0f && phase2) + { + calamityGlobalNPC.newAI[2] = 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { float flameVelocity = 6f; int maxProjectiles = bossRush ? 4 : death ? 3 : 2; int spread = bossRush ? 36 : death ? 28 : 20; @@ -3171,10 +3204,13 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector + Vector2.Normalize(perturbedSpeed) * 100f, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } - else - { - calamityGlobalNPC.newAI[2] = 0f; + } + else + { + calamityGlobalNPC.newAI[2] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { float laserVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 7f : death ? 6f : 5f; int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 17 : death ? 15 : 13); int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20); @@ -4157,7 +4193,7 @@ namespace CalamityMod.NPCs else { // Shoot lasers - if (npc.type == ModContent.NPCType() && Main.netMode != NetmodeID.MultiplayerClient) + if (npc.type == ModContent.NPCType()) { int shootTime = (doubleWormPhase && expertMode) ? 2 : 1; npc.localAI[0] += 1f; @@ -4172,57 +4208,64 @@ namespace CalamityMod.NPCs { npc.TargetClosest(); - if (deathModeEnragePhase_BodyAndTail) + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 velocity = Vector2.Zero; - if (movingMines) + if (deathModeEnragePhase_BodyAndTail) { - Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= Main.rand.Next(90, 121) * 0.01f; - velocity = vector15; - } + Vector2 velocity = Vector2.Zero; + if (movingMines) + { + Vector2 vector15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + vector15.Normalize(); + vector15 *= Main.rand.Next(90, 121) * 0.01f; + velocity = vector15; + } - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); + } } if (Vector2.Distance(player.Center, npc.Center) > 80f) { SoundEngine.PlaySound(AstrumDeusHead.LaserSound, npc.Center); - float num941 = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; - Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); - float num942 = player.position.X + player.width * 0.5f - vector104.X; - float num943 = player.position.Y + player.height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - Vector2 shootDirection = new Vector2(num942, num943).SafeNormalize(Vector2.UnitY); - Vector2 laserVelocity = shootDirection * num941; - int type = shootGodRays ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (shootGodRays) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - // Waving beams need to start offset so they cross each other neatly. - float waveSideOffset = Main.rand.NextFloat(9f, 14f); - Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset; - - for (int i = -1; i <= 1; i += 2) + float num941 = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; + Vector2 vector104 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + (npc.height / 2)); + float num942 = player.position.X + player.width * 0.5f - vector104.X; + float num943 = player.position.Y + player.height * 0.5f - vector104.Y; + float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); + num944 = num941 / num944; + num942 *= num944; + num943 *= num944; + vector104.X += num942 * 5f; + vector104.Y += num943 * 5f; + Vector2 shootDirection = new Vector2(num942, num943).SafeNormalize(Vector2.UnitY); + Vector2 laserVelocity = shootDirection * num941; + int type = shootGodRays ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (shootGodRays) { - Vector2 laserStartPos = vector104 + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); - Projectile godRay = Projectile.NewProjectileDirect(npc.GetSource_FromAI(), laserStartPos, laserVelocity * 1.1f, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + // Waving beams need to start offset so they cross each other neatly. + float waveSideOffset = Main.rand.NextFloat(9f, 14f); + Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset; - // Tell this Phased God Ray exactly which way it should be waving. - godRay.localAI[1] = i * 0.5f; + for (int i = -1; i <= 1; i += 2) + { + Vector2 laserStartPos = vector104 + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); + Projectile godRay = Projectile.NewProjectileDirect(npc.GetSource_FromAI(), laserStartPos, laserVelocity * 1.1f, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + + // Tell this Phased God Ray exactly which way it should be waving. + godRay.localAI[1] = i * 0.5f; + } } + else + Projectile.NewProjectile(npc.GetSource_FromAI(), vector104, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); } - else - Projectile.NewProjectile(npc.GetSource_FromAI(), vector104, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); } } } @@ -4474,34 +4517,36 @@ namespace CalamityMod.NPCs } } - // Projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) + // Slowly die in final phase and then implode + // This phase lasts 20 seconds + if (theBigSucc && calamityGlobalNPC.newAI[1] % 60f == 0f) { - // Slowly die in final phase and then implode - // This phase lasts 20 seconds - if (theBigSucc && calamityGlobalNPC.newAI[1] % 60f == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient) { int damageAmt = npc.lifeMax / 200; npc.life -= damageAmt; npc.HealEffect(-damageAmt, true); - - if (npc.life <= ((npc.lifeMax / 200) * 5) && !npc.ModNPC().playedbuildsound) - { - SoundEngine.PlaySound(CeaselessVoid.CeaselessVoid.BuildupSound, npc.Center); - npc.ModNPC().playedbuildsound = true; - } - - if (npc.life <= 0) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - } - - npc.netUpdate = true; } - // Beam Portals + if (npc.life <= ((npc.lifeMax / 200) * 5) && !npc.ModNPC().playedbuildsound) + { + SoundEngine.PlaySound(CeaselessVoid.CeaselessVoid.BuildupSound, npc.Center); + npc.ModNPC().playedbuildsound = true; + } + + if (npc.life <= 0) + { + npc.life = 0; + npc.HitEffect(); + npc.checkDead(); + } + + npc.netUpdate = true; + } + + // Beam Portals + if (Main.netMode != NetmodeID.MultiplayerClient) + { if (calamityGlobalNPC.newAI[1] == 0f) { int numBeamPortals = bossRush ? 4 : revenge ? 3 : 2; @@ -4515,24 +4560,28 @@ namespace CalamityMod.NPCs Projectile.NewProjectile(npc.GetSource_FromAI(), player.Center.X + (float)(Math.Sin(i * degrees) * beamPortalDistance), player.Center.Y + (float)(Math.Cos(i * degrees) * beamPortalDistance), 0f, 0f, type, damage, 0f, Main.myPlayer, ai1, 0f); } } + } - // Use this timer to lessen Dark Energy projectile rate of fire while Beam Portals are active - float beamPortalTimeLeft = 600f; - bool summonLessDarkEnergies = false; - if (calamityGlobalNPC.newAI[1] < beamPortalTimeLeft) - { - calamityGlobalNPC.newAI[1] += 1f; - summonLessDarkEnergies = true; - } - else if (theBigSucc) - calamityGlobalNPC.newAI[1] += 1f; + // Use this timer to lessen Dark Energy projectile rate of fire while Beam Portals are active + float beamPortalTimeLeft = 600f; + bool summonLessDarkEnergies = false; + if (calamityGlobalNPC.newAI[1] < beamPortalTimeLeft) + { + calamityGlobalNPC.newAI[1] += 1f; + summonLessDarkEnergies = true; + } + else if (theBigSucc) + calamityGlobalNPC.newAI[1] += 1f; - // Suck in Dark Energy projectiles from far away - calamityGlobalNPC.newAI[3] += 1f; - float darkEnergySpiralGateValue = (summonLessDarkEnergies ? 24f : 12f) * projectileFireRateMultiplier; - if (calamityGlobalNPC.newAI[3] >= darkEnergySpiralGateValue) + // Suck in Dark Energy projectiles from far away + calamityGlobalNPC.newAI[3] += 1f; + float darkEnergySpiralGateValue = (summonLessDarkEnergies ? 24f : 12f) * projectileFireRateMultiplier; + if (calamityGlobalNPC.newAI[3] >= darkEnergySpiralGateValue) + { + calamityGlobalNPC.newAI[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - calamityGlobalNPC.newAI[3] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); bool normalSpread = npc.localAI[0] % 2f == 0f; @@ -4550,16 +4599,21 @@ namespace CalamityMod.NPCs Vector2 velocity = Vector2.Normalize(npc.Center - spawnVector) * speed; Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); } - npc.localAI[1] += 10f; } - // Summon some extra projectiles in Expert Mode - if (phase2 && expertMode) + npc.localAI[1] += 10f; + } + + // Summon some extra projectiles in Expert Mode + if (phase2 && expertMode) + { + npc.localAI[2] += 1f; + if (npc.localAI[2] >= 60f * projectileFireRateMultiplier) { - npc.localAI[2] += 1f; - if (npc.localAI[2] >= 60f * projectileFireRateMultiplier) + npc.localAI[2] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[2] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); bool normalSpread = npc.localAI[0] % 2f != 0f; @@ -4579,14 +4633,18 @@ namespace CalamityMod.NPCs } } } + } - // Summon some extra projectiles in Revengeance Mode - if (phase4 && revenge) + // Summon some extra projectiles in Revengeance Mode + if (phase4 && revenge) + { + npc.localAI[3] += 1f; + if (npc.localAI[3] >= 90f * projectileFireRateMultiplier) { - npc.localAI[3] += 1f; - if (npc.localAI[3] >= 90f * projectileFireRateMultiplier) + npc.localAI[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[3] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); bool normalSpread = npc.localAI[0] % 2f == 0f; @@ -4763,22 +4821,22 @@ namespace CalamityMod.NPCs if (npc.life > 0) { - if (Main.netMode != NetmodeID.MultiplayerClient) + int healthGateValue = (int)(npc.lifeMax * 0.3); + if ((npc.life + healthGateValue) < calamityGlobalNPC.newAI[0]) { - int healthGateValue = (int)(npc.lifeMax * 0.3); - if ((npc.life + healthGateValue) < calamityGlobalNPC.newAI[0]) - { - npc.TargetClosest(); - calamityGlobalNPC.newAI[0] = npc.life; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] += 1f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - npc.localAI[3] = 0f; + npc.TargetClosest(); + calamityGlobalNPC.newAI[0] = npc.life; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.ai[3] = 0f; + npc.localAI[0] += 1f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + npc.localAI[3] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { if (phase4) { for (int i = 0; i < darkEnergyAmt; i++) @@ -4812,19 +4870,19 @@ namespace CalamityMod.NPCs NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2.5f, 0f, 0f); } + } - // Despawn potentially hazardous projectiles when entering a new phase - for (int i = 0; i < Main.maxProjectiles; i++) + // Despawn potentially hazardous projectiles when entering a new phase + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile projectile = Main.projectile[i]; + if (projectile.active) { - Projectile projectile = Main.projectile[i]; - if (projectile.active) + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 30) - projectile.timeLeft = 30; - } + if (projectile.timeLeft > 30) + projectile.timeLeft = 30; } } } @@ -4966,18 +5024,22 @@ namespace CalamityMod.NPCs float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) + if (Main.zenithWorld) { int spacing = 20; int amt = 5; SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - for (int i = 0; i < amt; i++) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); + Vector2 ai0 = npc.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } } } } @@ -5004,18 +5066,22 @@ namespace CalamityMod.NPCs float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) + if (Main.zenithWorld) { int spacing = 20; int amt = 3; SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - for (int i = 0; i < amt; i++) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); + Vector2 ai0 = npc.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } } } } @@ -5089,7 +5155,7 @@ namespace CalamityMod.NPCs // Phase switch npc.ai[1] += 1f; - if (npc.ai[1] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) + if (npc.ai[1] >= 30f) { npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -5160,30 +5226,16 @@ namespace CalamityMod.NPCs { npc.ai[3] = 3f; SoundEngine.PlaySound(SoundID.Item102, player.Center); - int totalProjectiles = 40; - float radians = MathHelper.TwoPi / totalProjectiles; - int distance = 800; - bool spawnRight = player.velocity.X > 0f; - for (int i = 0; i < totalProjectiles; i++) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.getGoodWorld) + int totalProjectiles = 40; + float radians = MathHelper.TwoPi / totalProjectiles; + int distance = 800; + bool spawnRight = player.velocity.X > 0f; + for (int i = 0; i < totalProjectiles; i++) { - if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - else - { - if (spawnRight) + if (Main.getGoodWorld) { if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) { @@ -5191,14 +5243,32 @@ namespace CalamityMod.NPCs Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); } + if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } } else { - if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) + if (spawnRight) { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); + if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } + else + { + if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } } } } @@ -5227,37 +5297,41 @@ namespace CalamityMod.NPCs { npc.ai[3] = 3f; SoundEngine.PlaySound(SoundID.Item102, player.Center); - int totalProjectiles = phase2 ? 40 : 48; - if (Main.getGoodWorld) - totalProjectiles *= 2; - - float radians = MathHelper.TwoPi / totalProjectiles; - int distance = phase2 ? 1200 : 1320; - - if (Main.getGoodWorld) - distance *= 2; - - bool spawnRight = player.velocity.X > 0f; - for (int i = 0; i < totalProjectiles; i++) + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (spawnRight) - { - if (i >= totalProjectiles / 2) - break; + int totalProjectiles = phase2 ? 40 : 48; - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - else + if (Main.getGoodWorld) + totalProjectiles *= 2; + + float radians = MathHelper.TwoPi / totalProjectiles; + int distance = phase2 ? 1200 : 1320; + + if (Main.getGoodWorld) + distance *= 2; + + bool spawnRight = player.velocity.X > 0f; + for (int i = 0; i < totalProjectiles; i++) { - if (i >= totalProjectiles / 2) + if (spawnRight) { + if (i >= totalProjectiles / 2) + break; + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); } + else + { + if (i >= totalProjectiles / 2) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); + } + } } } } @@ -5502,18 +5576,22 @@ namespace CalamityMod.NPCs float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) + if (Main.zenithWorld) { int spacing = 30; int amt = 3; SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - for (int i = 0; i < amt; i++) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); + Vector2 ai0 = npc.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } } } } @@ -5568,18 +5646,22 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) + if (Main.zenithWorld) { int spacing = 30; int amt = 3; SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - for (int i = 0; i < amt; i++) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); + Vector2 ai0 = npc.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } } } } @@ -6531,16 +6613,20 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num9 - 90) { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + if (npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 100f; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 900f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 900f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - if (Main.getGoodWorld) + if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 1800f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 1800f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 900f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 900f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 1800f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 1800f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + } } } } @@ -6571,16 +6657,20 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num10 - 60) { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + if (npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 150f; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); - if (Main.getGoodWorld) + if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + } } } } @@ -6800,9 +6890,7 @@ namespace CalamityMod.NPCs int damage = npc.GetProjectileDamage(type); Vector2 vortexSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; if (Main.netMode != NetmodeID.MultiplayerClient) - { Projectile.NewProjectile(npc.GetSource_FromAI(), vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); - } } if (npc.ai[2] % toothBallSpinPhaseDivisor == 0f) @@ -6906,12 +6994,16 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num9 - 90) { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + if (npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 100f; - float x = 900f - calamityGlobalNPC.newAI[2]; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float x = 900f - calamityGlobalNPC.newAI[2]; + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + } } } @@ -6941,16 +7033,20 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num10 - 60) { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + if (npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 200f; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, sharkronVelocity, 255); - if (Main.getGoodWorld) + if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, sharkronVelocity, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, sharkronVelocity, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + } } } } @@ -7271,17 +7367,21 @@ namespace CalamityMod.NPCs if (npc.ai[2] >= num9 - 90) { - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 18f == 0f) + if (npc.ai[2] % 18f == 0f) { calamityGlobalNPC.newAI[2] += 150f; - float x = 900f - calamityGlobalNPC.newAI[2]; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - if (Main.getGoodWorld) + if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + float x = 900f - calamityGlobalNPC.newAI[2]; + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); + } } } } @@ -7311,9 +7411,7 @@ namespace CalamityMod.NPCs int damage = npc.GetProjectileDamage(type); Vector2 vortexSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; if (Main.netMode != NetmodeID.MultiplayerClient) - { Projectile.NewProjectile(npc.GetSource_FromAI(), vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); - } } if (npc.ai[2] % toothBallSpinPhaseDivisor == 0f) diff --git a/NPCs/Crabulon/Crabulon.cs b/NPCs/Crabulon/Crabulon.cs index dcb02eba48..7973ed421d 100644 --- a/NPCs/Crabulon/Crabulon.cs +++ b/NPCs/Crabulon/Crabulon.cs @@ -191,47 +191,44 @@ namespace CalamityMod.NPCs.Crabulon if (NPC.ai[0] < 2f) { Vector2 vector34 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - if (Main.netMode != NetmodeID.MultiplayerClient) + int num352 = 1; + NPC.localAI[3] += 2f; + if (phase2) + { + NPC.localAI[3] += 1f; + num352 += 2; + } + if (phase3) { - int num352 = 1; NPC.localAI[3] += 2f; - if (phase2) - { - NPC.localAI[3] += 1f; - num352 += 2; - } - if (phase3) - { - NPC.localAI[3] += 2f; - num352 += 3; - } - if (NPC.ai[3] == 0f) - { - if (NPC.localAI[3] > 600f) - { - NPC.ai[3] = 1f; - NPC.localAI[3] = 0f; - } - } - else if (NPC.localAI[3] > 45f) + num352 += 3; + } + if (NPC.ai[3] == 0f) + { + if (NPC.localAI[3] > 600f) { + NPC.ai[3] = 1f; NPC.localAI[3] = 0f; - NPC.ai[3] += 1f; - if (NPC.ai[3] >= num352) - { - NPC.ai[3] = 0f; - } - float num353 = 10f; - int type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item42, NPC.Center); + } + } + else if (NPC.localAI[3] > 45f) + { + NPC.localAI[3] = 0f; + NPC.ai[3] += 1f; + if (NPC.ai[3] >= num352) + NPC.ai[3] = 0f; + + float num353 = 10f; + int type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item42, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { if (phase2) - { num353 += 1f; - } if (phase3) - { num353 += 1f; - } + vector34 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); float num349 = player.position.X + player.width * 0.5f - vector34.X; float num350 = player.position.Y + player.height * 0.5f - vector34.Y; @@ -873,9 +870,7 @@ namespace CalamityMod.NPCs.Crabulon if (Main.zenithWorld && Main.netMode != NetmodeID.MultiplayerClient) { for (int i = 0; i < Main.rand.Next(10, 23); i++) - { NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + Main.rand.Next(-NPC.width / 2, NPC.width / 2), (int)NPC.Center.Y + Main.rand.Next(-NPC.height / 2, NPC.height / 2), NPCID.Crab); - } } } diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index b1849ed247..53c6904ddc 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -331,26 +331,30 @@ namespace CalamityMod.NPCs.Cryogen float chargeSlownDownPhaseGateValue = chargeGateValue + chargeSlowDownTime; bool chargePhase = NPC.ai[1] >= chargePhaseGateValue; - if (Main.netMode != NetmodeID.MultiplayerClient && expertMode && (NPC.ai[0] < 5f || !phase6) && !chargePhase) + if (expertMode && (NPC.ai[0] < 5f || !phase6) && !chargePhase) { calamityGlobalNPC.newAI[3] += 1f; if (calamityGlobalNPC.newAI[3] >= (bossRush ? 660f : 900f)) { calamityGlobalNPC.newAI[3] = 0f; SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); - int totalProjectiles = 3; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = iceBomb; - int damage = NPC.GetProjectileDamage(type); - float velocity = 2f + NPC.ai[0]; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + int totalProjectiles = 3; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = iceBomb; + int damage = NPC.GetProjectileDamage(type); + float velocity = 2f + NPC.ai[0]; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(vector255) * 30f, vector255, type, damage, 0f, Main.myPlayer); + } } } } @@ -359,16 +363,17 @@ namespace CalamityMod.NPCs.Cryogen { NPC.rotation = NPC.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 120f) { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 120f) + NPC.localAI[0] = 0f; + NPC.TargetClosest(); + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - NPC.localAI[0] = 0f; - NPC.TargetClosest(); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 24 : 16; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -419,16 +424,17 @@ namespace CalamityMod.NPCs.Cryogen NPC.rotation = NPC.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 120f) { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 120f) + NPC.localAI[0] = 0f; + NPC.TargetClosest(); + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - NPC.localAI[0] = 0f; - NPC.TargetClosest(); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -498,11 +504,12 @@ namespace CalamityMod.NPCs.Cryogen float totalSpreads = 3f; if ((NPC.ai[1] - chargePhaseGateValue) % (chargeTelegraphTime / totalSpreads) == 0f) { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceRain; int damage = NPC.GetProjectileDamage(type); float maxVelocity = 9f + enrageScale; @@ -593,16 +600,17 @@ namespace CalamityMod.NPCs.Cryogen NPC.rotation = NPC.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 120f) { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 120f) + NPC.localAI[0] = 0f; + NPC.TargetClosest(); + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - NPC.localAI[0] = 0f; - NPC.TargetClosest(); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -644,11 +652,12 @@ namespace CalamityMod.NPCs.Cryogen float totalSpreads = 2f; if ((NPC.ai[1] - chargePhaseGateValue) % (chargeTelegraphTime / totalSpreads) == 0f) { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceRain; int damage = NPC.GetProjectileDamage(type); float maxVelocity = 9f + enrageScale; @@ -742,15 +751,16 @@ namespace CalamityMod.NPCs.Cryogen { NPC.rotation = NPC.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 90f && NPC.Opacity == 1f) { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 90f && NPC.Opacity == 1f) + NPC.localAI[0] = 0f; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - NPC.localAI[0] = 0f; - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = bossRush ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; @@ -855,12 +865,13 @@ namespace CalamityMod.NPCs.Cryogen Main.dust[num39].noGravity = true; } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + NPC.localAI[0] = 0f; + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.localAI[0] = 0f; - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceRain; int damage = NPC.GetProjectileDamage(type); float velocity = 9f + enrageScale; @@ -939,11 +950,12 @@ namespace CalamityMod.NPCs.Cryogen { NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (18f + enrageScale * 2f); - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int type = iceBlast; int damage = NPC.GetProjectileDamage(type); float velocity = 1.5f + enrageScale * 0.5f; diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index a3fe1e9b0e..6d1e60f8a8 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -252,47 +252,51 @@ namespace CalamityMod.NPCs.DesertScourge } TailSpawned = true; } + } - if (expertMode) + if (expertMode) + { + if (NPC.Calamity().newAI[2] < 300f) + NPC.Calamity().newAI[2] += 1f; + + if (NPC.SafeDirectionTo(player.Center).AngleBetween((NPC.rotation - MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(18f) && + NPC.Calamity().newAI[2] >= 300f && Vector2.Distance(NPC.Center, player.Center) > 320f && + Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - if (NPC.Calamity().newAI[2] < 300f) - NPC.Calamity().newAI[2] += 1f; - - if (NPC.SafeDirectionTo(player.Center).AngleBetween((NPC.rotation - MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(18f) && - NPC.Calamity().newAI[2] >= 300f && Vector2.Distance(NPC.Center, player.Center) > 320f && - Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + if (NPC.Calamity().newAI[2] % 30f == 0f) { - if (NPC.Calamity().newAI[2] % 30f == 0f) + SoundEngine.PlaySound(SoundID.Item21, NPC.Center); + + float velocity = bossRush ? 6f : death ? 5.5f : 5f; + int type = ModContent.ProjectileType(); + int type2 = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * velocity; + int baseProjectileAmt = bossRush ? 6 : death ? 4 : revenge ? 3 : 2; + int numProj = NPC.Calamity().newAI[2] % 60f == 0f ? (int)(baseProjectileAmt * 1.5) : baseProjectileAmt; + int spread = bossRush ? 18 : death ? 14 : revenge ? 12 : 10; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < numProj; i++) { - SoundEngine.PlaySound(SoundID.Item21, NPC.Center); - float velocity = bossRush ? 6f : death ? 5.5f : 5f; - int type = ModContent.ProjectileType(); - int type2 = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * velocity; - int baseProjectileAmt = bossRush ? 6 : death ? 4 : revenge ? 3 : 2; - int numProj = NPC.Calamity().newAI[2] % 60f == 0f ? (int)(baseProjectileAmt * 1.5) : baseProjectileAmt; - int spread = bossRush ? 18 : death ? 14 : revenge ? 12 : 10; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + perturbedSpeed *= Main.rand.NextFloat() + 0.5f; + + for (int k = 0; k < 10; k++) + Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, 85, perturbedSpeed.X, perturbedSpeed.Y); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - perturbedSpeed *= Main.rand.NextFloat() + 0.5f; - - for (int k = 0; k < 10; k++) - Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, 85, perturbedSpeed.X, perturbedSpeed.Y); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); if (Main.zenithWorld) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 3f, perturbedSpeed, type2, damage, 0f, Main.myPlayer); } } - - NPC.Calamity().newAI[2] += 1f; - if (NPC.Calamity().newAI[2] > 360f) - NPC.Calamity().newAI[2] = 0f; } + + NPC.Calamity().newAI[2] += 1f; + if (NPC.Calamity().newAI[2] > 360f) + NPC.Calamity().newAI[2] = 0f; } } @@ -431,27 +435,25 @@ namespace CalamityMod.NPCs.DesertScourge { // Spit a huge spread of sand upwards that falls down SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 16f : bossRush ? 9f : death ? 7f : 6f; + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 projectileVelocity = Vector2.Normalize(NPC.Center + NPC.velocity * 10f - NPC.Center) * velocity; + int numProj = bossRush ? 24 : death ? 20 : revenge ? 18 : expertMode ? 16 : 12; + if (Main.getGoodWorld) + numProj *= 2; + + int spread = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 120 : 90; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < numProj; i++) { - float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 16f : bossRush ? 9f : death ? 7f : 6f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 projectileVelocity = Vector2.Normalize(NPC.Center + NPC.velocity * 10f - NPC.Center) * velocity; - int numProj = bossRush ? 24 : death ? 20 : revenge ? 18 : expertMode ? 16 : 12; - if (Main.getGoodWorld) - numProj *= 2; + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int spread = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 120 : 90; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - - for (int k = 0; k < 10; k++) - Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, 85, perturbedSpeed.X, perturbedSpeed.Y); + for (int k = 0; k < 10; k++) + Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, 85, perturbedSpeed.X, perturbedSpeed.Y); + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } } NPC.TargetClosest(); diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index f4b73c55f6..bb9512608c 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -978,11 +978,11 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo { pickNewLocation = true; NPC.ai[2] += 1f; + SoundEngine.PlaySound(CommonCalamitySounds.ExoPlasmaShootSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - SoundEngine.PlaySound(CommonCalamitySounds.ExoPlasmaShootSound, NPC.Center); Vector2 plasmaVelocity = Vector2.Normalize(aimedVector) * projectileVelocity; Vector2 offset = Vector2.Normalize(plasmaVelocity) * 70f; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index cef9013d2c..119f295493 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -904,9 +904,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Create a bunch of lightning bolts in the sky ExoMechsSky.CreateLightningBolt(12); + SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound, NPC.Center); int type = ModContent.ProjectileType(); Vector2 spawnPoint = NPC.Center + new Vector2(-1f, 23f); for (int k = 0; k < totalProjectiles; k++) diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index df32c7f2b8..5fe548bc0b 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -411,18 +411,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { calamityGlobalNPC.newAI[1] = 1f; + SoundEngine.PlaySound(CommonCalamitySounds.LargeWeaponFireSound, NPC.Center); + Vector2 gaussNukeVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(CommonCalamitySounds.LargeWeaponFireSound, NPC.Center); - Vector2 gaussNukeVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); float offset = 40f; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(gaussNukeVelocity) * offset, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - - // Recoil - NPC.velocity -= gaussNukeVelocity * 2f; } + + // Recoil + NPC.velocity -= gaussNukeVelocity * 2f; } EnergyDrawer.ParticleSpawnRate = AresBody.telegraphParticlesSpawnRate; diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index f8a2a7bcf5..74ecb23f97 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -433,10 +433,10 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((calamityGlobalNPC.newAI[2] - plasmaBoltTelegraphDuration) % divisor == 0f && canFire) { NPC.ai[3] += 1f; + SoundEngine.PlaySound(CommonCalamitySounds.ExoPlasmaShootSound, NPC.Center); + Vector2 plasmaBoltVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(CommonCalamitySounds.ExoPlasmaShootSound, NPC.Center); - Vector2 plasmaBoltVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); Vector2 offset = Vector2.Normalize(plasmaBoltVelocity) * 40f + Vector2.UnitY * 16f; @@ -445,10 +445,10 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, -1f); else Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - - // Recoil - NPC.velocity -= plasmaBoltVelocity; } + + // Recoil + NPC.velocity -= plasmaBoltVelocity; } } diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index c2dc869544..499af0c23c 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -430,19 +430,19 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) % divisor == 0f && canFire) { + SoundEngine.PlaySound(TeslaOrbShootSound, NPC.Center); + Vector2 teslaOrbVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(TeslaOrbShootSound, NPC.Center); - Vector2 teslaOrbVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); Vector2 offset = Vector2.Normalize(teslaOrbVelocity) * 40f + Vector2.UnitY * 8f; float identity = fireMoreOrbs ? -2f : calamityGlobalNPC.newAI[3] + (calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) / divisor; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, teslaOrbVelocity, type, damage, 0f, Main.myPlayer, identity); - - // Recoil - NPC.velocity -= teslaOrbVelocity; } + + // Recoil + NPC.velocity -= teslaOrbVelocity; } } diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index e3e7667801..05cf161c29 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -1071,10 +1071,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis ExoMechsSky.CreateLightningBolt(12); // Fire deathray + DeathraySoundSlot = SoundEngine.PlaySound(SpinLaserbeamSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - DeathraySoundSlot = SoundEngine.PlaySound(SpinLaserbeamSound, NPC.Center); - int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); int laser = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, NPC.whoAmI); diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index 1dd286842e..faf9306e96 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -47,7 +47,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos private const float timeToOpenAndFireLasers = 36f; private const float segmentCloseTimerDecrement = 0.2f; + public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.ThanatosHead.DisplayName"); + public override void SetStaticDefaults() { this.HideFromBestiary(); @@ -249,164 +251,165 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; if (shootLasers && !invisiblePhase) { - if (Main.netMode != NetmodeID.MultiplayerClient) + // Only charge up lasers if not venting or firing lasers + if (NPC.Calamity().newAI[0] == 0f) + NPC.ai[3] += 1f; + + double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; + if (shouldGetBuffedByBerserkPhase) + numSegmentsAbleToFire *= 1.25; + + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) { - // Only charge up lasers if not venting or firing lasers - if (NPC.Calamity().newAI[0] == 0f) - NPC.ai[3] += 1f; - - double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; - if (shouldGetBuffedByBerserkPhase) - numSegmentsAbleToFire *= 1.25; - - float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); - - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 75f; + if ((NPC.ai[3] % divisor == 0f && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) { - float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 75f; - if ((NPC.ai[3] % divisor == 0f && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + // Body is vulnerable while firing lasers + vulnerable = true; + + if (NPC.Calamity().newAI[1] == 0f) { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (NPC.Calamity().newAI[1] == 0f) + NPC.Calamity().newAI[0] += 1f; + if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) { - NPC.Calamity().newAI[0] += 1f; - if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + NPC.ai[3] = 0f; + NPC.Calamity().newAI[1] = 1f; + + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) { - NPC.ai[3] = 0f; - NPC.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, NPC.Center); + if (distance < maxDistance) { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, NPC.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound with { Volume = 0.1f * CommonCalamitySounds.ExoLaserShootSound.Volume}, NPC.Center); - - for (int i = 0; i < numProjectiles; i++) - { - // Normal laser - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; } } - } - else - { - NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (NPC.Calamity().newAI[0] <= 0f) + + SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound with { Volume = 0.1f * CommonCalamitySounds.ExoLaserShootSound.Volume }, NPC.Center); + + for (int i = 0; i < numProjectiles; i++) { - NPC.Calamity().newAI[0] = 0f; - NPC.Calamity().newAI[1] = 0f; + // Normal laser + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } - } - else - { - float divisor = NPC.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 - if ((NPC.ai[3] == divisor && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + else { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (NPC.Calamity().newAI[1] == 0f) + NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (NPC.Calamity().newAI[0] <= 0f) { - NPC.Calamity().newAI[0] += 1f; - if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + float divisor = NPC.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 + if ((NPC.ai[3] == divisor && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (NPC.Calamity().newAI[1] == 0f) + { + NPC.Calamity().newAI[0] += 1f; + if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + NPC.ai[3] = 0f; + NPC.Calamity().newAI[1] = 1f; + + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) { - NPC.ai[3] = 0f; - NPC.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, NPC.Center); + if (distance < maxDistance) { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } - for (int i = 0; i < Main.maxPlayers; i++) + float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + if (NPC.ai[0] % 3f == 0f) + predictionAmt *= 0.5f; + + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); + for (int i = 0; i < numProjectiles; i++) + { + // Fire normal lasers if head is in passive state + if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) + { + // Normal laser + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + } + else + { + // Normal laser + if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, NPC.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; - if (NPC.ai[0] % 3f == 0f) - predictionAmt *= 0.5f; - - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); - for (int i = 0; i < numProjectiles; i++) - { - // Fire normal lasers if head is in passive state - if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) - { - // Normal laser + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } - else - { - // Normal laser - if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - - // Predictive laser - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - - // Opposite laser - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } } + + // Predictive laser + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + + // Opposite laser + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } - else + } + else + { + NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (NPC.Calamity().newAI[0] <= 0f) { - NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (NPC.Calamity().newAI[0] <= 0f) - { - NPC.Calamity().newAI[0] = 0f; - NPC.Calamity().newAI[1] = 0f; - } + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; } } } @@ -451,9 +454,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Noise float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; if (NPC.localAI[0] == 0f) - { SoundEngine.PlaySound(ThanatosHead.VentSound with { Volume = volume * ThanatosHead.VentSound.Volume }, NPC.Center); - } // Steam NPC.localAI[0] += 1f; @@ -489,9 +490,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X; targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y; - } catch - { } + catch { } NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2; distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY); @@ -599,13 +599,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int index = (int)NPC.ai[2]; if (index < 0 || index >= Main.maxNPCs || Main.npc[index] is null) return; + if (Main.npc[index].type != ModContent.NPCType()) return; if (Main.npc[index].ModNPC().exoMechdusa) - { typeName = CalamityUtils.GetTextValue("NPCs.ThanatosHead.HekateName"); - } } public override void HitEffect(NPC.HitInfo hit) @@ -631,9 +630,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.life <= 0) { for (int num193 = 0; num193 < 2; num193++) - { Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - } + for (int num194 = 0; num194 < 20; num194++) { int num195 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index d935e46c16..8bc54a62e2 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -249,164 +249,165 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; if (shootLasers && !invisiblePhase) { - if (Main.netMode != NetmodeID.MultiplayerClient) + // Only charge up lasers if not venting or firing lasers + if (NPC.Calamity().newAI[0] == 0f) + NPC.ai[3] += 1f; + + double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; + if (shouldGetBuffedByBerserkPhase) + numSegmentsAbleToFire *= 1.25; + + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) { - // Only charge up lasers if not venting or firing lasers - if (NPC.Calamity().newAI[0] == 0f) - NPC.ai[3] += 1f; - - double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; - if (shouldGetBuffedByBerserkPhase) - numSegmentsAbleToFire *= 1.25; - - float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); - - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 75f; + if ((NPC.ai[3] % divisor == 0f && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) { - float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 75f; - if ((NPC.ai[3] % divisor == 0f && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + // Body is vulnerable while firing lasers + vulnerable = true; + + if (NPC.Calamity().newAI[1] == 0f) { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (NPC.Calamity().newAI[1] == 0f) + NPC.Calamity().newAI[0] += 1f; + if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) { - NPC.Calamity().newAI[0] += 1f; - if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + NPC.ai[3] = 0f; + NPC.Calamity().newAI[1] = 1f; + + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) { - NPC.ai[3] = 0f; - NPC.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, NPC.Center); + if (distance < maxDistance) { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, NPC.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound with { Volume = 0.1f * CommonCalamitySounds.ExoLaserShootSound.Volume }, NPC.Center); - - for (int i = 0; i < numProjectiles; i++) - { - // Normal laser - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; } } - } - else - { - NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (NPC.Calamity().newAI[0] <= 0f) + + SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound with { Volume = 0.1f * CommonCalamitySounds.ExoLaserShootSound.Volume }, NPC.Center); + + for (int i = 0; i < numProjectiles; i++) { - NPC.Calamity().newAI[0] = 0f; - NPC.Calamity().newAI[1] = 0f; + // Normal laser + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } - } - else - { - float divisor = NPC.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 - if ((NPC.ai[3] == divisor && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + else { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (NPC.Calamity().newAI[1] == 0f) + NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (NPC.Calamity().newAI[0] <= 0f) { - NPC.Calamity().newAI[0] += 1f; - if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + float divisor = NPC.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 + if ((NPC.ai[3] == divisor && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (NPC.Calamity().newAI[1] == 0f) + { + NPC.Calamity().newAI[0] += 1f; + if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + NPC.ai[3] = 0f; + NPC.Calamity().newAI[1] = 1f; + + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) { - NPC.ai[3] = 0f; - NPC.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, NPC.Center); + if (distance < maxDistance) { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } - for (int i = 0; i < Main.maxPlayers; i++) + float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + if (NPC.ai[0] % 3f == 0f) + predictionAmt *= 0.5f; + + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); + for (int i = 0; i < numProjectiles; i++) + { + // Fire normal lasers if head is in passive state + if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) + { + // Normal laser + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + } + else + { + // Normal laser + if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, NPC.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; - if (NPC.ai[0] % 3f == 0f) - predictionAmt *= 0.5f; - - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); - for (int i = 0; i < numProjectiles; i++) - { - // Fire normal lasers if head is in passive state - if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) - { - // Normal laser + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } - else - { - // Normal laser - if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - - // Predictive laser - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - - // Opposite laser - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } } + + // Predictive laser + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + + // Opposite laser + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } - else + } + else + { + NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (NPC.Calamity().newAI[0] <= 0f) { - NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (NPC.Calamity().newAI[0] <= 0f) - { - NPC.Calamity().newAI[0] = 0f; - NPC.Calamity().newAI[1] = 0f; - } + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index 9cd480a97f..851cc27a9d 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -249,164 +249,165 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; if (shootLasers && !invisiblePhase) { - if (Main.netMode != NetmodeID.MultiplayerClient) + // Only charge up lasers if not venting or firing lasers + if (NPC.Calamity().newAI[0] == 0f) + NPC.ai[3] += 1f; + + double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; + if (shouldGetBuffedByBerserkPhase) + numSegmentsAbleToFire *= 1.25; + + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) { - // Only charge up lasers if not venting or firing lasers - if (NPC.Calamity().newAI[0] == 0f) - NPC.ai[3] += 1f; - - double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; - if (shouldGetBuffedByBerserkPhase) - numSegmentsAbleToFire *= 1.25; - - float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); - - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 75f; + if ((NPC.ai[3] % divisor == 0f && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) { - float divisor = lastMechAlive ? 45f : shouldGetBuffedByBerserkPhase ? 60f : 75f; - if ((NPC.ai[3] % divisor == 0f && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + // Body is vulnerable while firing lasers + vulnerable = true; + + if (NPC.Calamity().newAI[1] == 0f) { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (NPC.Calamity().newAI[1] == 0f) + NPC.Calamity().newAI[0] += 1f; + if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) { - NPC.Calamity().newAI[0] += 1f; - if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + NPC.ai[3] = 0f; + NPC.Calamity().newAI[1] = 1f; + + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) { - NPC.ai[3] = 0f; - NPC.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, NPC.Center); + if (distance < maxDistance) { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; - - for (int i = 0; i < Main.maxPlayers; i++) - { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, NPC.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound with { Volume = 0.1f * CommonCalamitySounds.ExoLaserShootSound.Volume }, NPC.Center); - - for (int i = 0; i < numProjectiles; i++) - { - // Normal laser - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; } } - } - else - { - NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (NPC.Calamity().newAI[0] <= 0f) + + SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound with { Volume = 0.1f * CommonCalamitySounds.ExoLaserShootSound.Volume }, NPC.Center); + + for (int i = 0; i < numProjectiles; i++) { - NPC.Calamity().newAI[0] = 0f; - NPC.Calamity().newAI[1] = 0f; + // Normal laser + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } - } - else - { - float divisor = NPC.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 - if ((NPC.ai[3] == divisor && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + else { - // Body is vulnerable while firing lasers - vulnerable = true; - - if (NPC.Calamity().newAI[1] == 0f) + NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (NPC.Calamity().newAI[0] <= 0f) { - NPC.Calamity().newAI[0] += 1f; - if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + float divisor = NPC.ai[0] * (lastMechAlive ? 1f : shouldGetBuffedByBerserkPhase ? 2f : 3f); // Ranges from 3 to 300 + if ((NPC.ai[3] == divisor && NPC.ai[0] % segmentDivisor == 0f) || NPC.Calamity().newAI[0] > 0f) + { + // Body is vulnerable while firing lasers + vulnerable = true; + + if (NPC.Calamity().newAI[1] == 0f) + { + NPC.Calamity().newAI[0] += 1f; + if (NPC.Calamity().newAI[0] >= timeToOpenAndFireLasers) + { + NPC.ai[3] = 0f; + NPC.Calamity().newAI[1] = 1f; + + int maxTargets = 3; + int[] whoAmIArray = new int[maxTargets]; + Vector2[] targetCenterArray = new Vector2[maxTargets]; + int numProjectiles = 0; + float maxDistance = 2400f; + + for (int i = 0; i < Main.maxPlayers; i++) { - NPC.ai[3] = 0f; - NPC.Calamity().newAI[1] = 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (!Main.player[i].active || Main.player[i].dead) + continue; + + Vector2 playerCenter = Main.player[i].Center; + float distance = Vector2.Distance(playerCenter, NPC.Center); + if (distance < maxDistance) { - int maxTargets = 3; - int[] whoAmIArray = new int[maxTargets]; - Vector2[] targetCenterArray = new Vector2[maxTargets]; - int numProjectiles = 0; - float maxDistance = 2400f; + whoAmIArray[numProjectiles] = i; + targetCenterArray[numProjectiles] = playerCenter; + int projectileLimit = numProjectiles + 1; + numProjectiles = projectileLimit; + if (projectileLimit >= targetCenterArray.Length) + break; + } + } - for (int i = 0; i < Main.maxPlayers; i++) + float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + if (NPC.ai[0] % 3f == 0f) + predictionAmt *= 0.5f; + + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); + for (int i = 0; i < numProjectiles; i++) + { + // Fire normal lasers if head is in passive state + if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) + { + // Normal laser + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + } + else + { + // Normal laser + if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) { - if (!Main.player[i].active || Main.player[i].dead) - continue; - - Vector2 playerCenter = Main.player[i].Center; - float distance = Vector2.Distance(playerCenter, NPC.Center); - if (distance < maxDistance) - { - whoAmIArray[numProjectiles] = i; - targetCenterArray[numProjectiles] = playerCenter; - int projectileLimit = numProjectiles + 1; - numProjectiles = projectileLimit; - if (projectileLimit >= targetCenterArray.Length) - break; - } - } - - float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; - if (NPC.ai[0] % 3f == 0f) - predictionAmt *= 0.5f; - - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); - for (int i = 0; i < numProjectiles; i++) - { - // Fire normal lasers if head is in passive state - if (calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive) - { - // Normal laser + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } - else - { - // Normal laser - if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - - // Predictive laser - Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - - // Opposite laser - projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); - } } + + // Predictive laser + Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + + // Opposite laser + projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } - else + } + else + { + NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; + if (NPC.Calamity().newAI[0] <= 0f) { - NPC.Calamity().newAI[0] -= segmentCloseTimerDecrement + fasterSegmentClosingVar; - if (NPC.Calamity().newAI[0] <= 0f) - { - NPC.Calamity().newAI[0] = 0f; - NPC.Calamity().newAI[1] = 0f; - } + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; } } } diff --git a/Projectiles/Boss/DoGDeath.cs b/Projectiles/Boss/DoGDeath.cs index ab76d2e5a0..d865fa4e2b 100644 --- a/Projectiles/Boss/DoGDeath.cs +++ b/Projectiles/Boss/DoGDeath.cs @@ -13,6 +13,7 @@ namespace CalamityMod.Projectiles.Boss public class DoGDeath : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public float TelegraphDelay { get => Projectile.ai[0];