From 2154d0a131a6ca23b16640b85e27d5bd5832666c Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Thu, 20 Feb 2020 01:32:58 -0600 Subject: [PATCH] Signus headcrab effect, darkness changes, Plaguebringer lines up her charges slower, Multiple Bobbit Worms can spawn, Ravager parts don't despawn unless the body is gone, Dark Energies don't despawn unless Void is gone. --- CalPlayer/CalamityPlayerMiscEffects.cs | 117 +++++++++++++----- CalamityMod.cs | 63 ++++++++-- NPCs/Abyss/BobbitWormHead.cs | 23 ++-- NPCs/Abyss/BobbitWormSegment.cs | 36 ++++-- NPCs/CalamityGlobalNPC.cs | 8 +- NPCs/CeaselessVoid/DarkEnergy.cs | 11 +- NPCs/CeaselessVoid/DarkEnergy2.cs | 11 +- NPCs/CeaselessVoid/DarkEnergy3.cs | 11 +- .../PlaguebringerGoliath.cs | 95 +++++++------- NPCs/Ravager/FlamePillar.cs | 11 +- NPCs/Ravager/RavagerClawLeft.cs | 11 +- NPCs/Ravager/RavagerClawRight.cs | 11 +- NPCs/Ravager/RavagerHead.cs | 11 +- NPCs/Ravager/RavagerHead2.cs | 11 +- NPCs/Ravager/RavagerLegLeft.cs | 11 +- NPCs/Ravager/RavagerLegRight.cs | 11 +- NPCs/Ravager/RockPillar.cs | 11 +- NPCs/Signus/CosmicLantern.cs | 7 ++ NPCs/Signus/Signus.cs | 13 +- NPCs/Signus/SignusBomb.cs | 7 ++ World/CalamityWorld.cs | 6 +- 21 files changed, 341 insertions(+), 155 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 7a69b30621..6ef2b73796 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -26,6 +26,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.GameContent.Events; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -99,6 +100,56 @@ namespace CalamityMod.CalPlayer { if (CalamityWorld.revenge) { + // Signus headcrab effect + if (CalamityGlobalNPC.signus != -1) + { + if (Main.npc[CalamityGlobalNPC.signus].active) + { + if (Vector2.Distance(player.Center, Main.npc[CalamityGlobalNPC.signus].Center) <= 5200f) + { + float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax); + + // Reduce the power of Signus darkness based on your light level. + float multiplier = 1f; + switch (modPlayer.GetTotalLightStrength()) + { + case 0: + break; + case 1: + case 2: + multiplier = 0.75f; + break; + case 3: + case 4: + multiplier = 0.5f; + break; + case 5: + case 6: + multiplier = 0.25f; + break; + default: + multiplier = 0f; + break; + } + + // Increased darkness in Death Mode + if (CalamityWorld.death) + multiplier += (1f - multiplier) * 0.1f; + + // Total darkness + float signusDarkness = signusLifeRatio * multiplier; + + // Headcrab effect + if (!modPlayer.ZoneAbyss && !player.headcovered) + { + float screenObstructionAmt = MathHelper.Clamp(signusDarkness, 0f, 0.63f); + float targetValue = MathHelper.Clamp(screenObstructionAmt * 0.45f, 0.1f, 0.2f); + ScreenObstruction.screenObstruction = MathHelper.Lerp(ScreenObstruction.screenObstruction, screenObstructionAmt, targetValue); + } + } + } + } + // Life Steal nerf if (player.lifeSteal > (CalamityWorld.death ? 50f : 60f)) player.lifeSteal = CalamityWorld.death ? 50f : 60f; @@ -1651,8 +1702,16 @@ namespace CalamityMod.CalPlayer // Modify darkness variable modPlayer.caveDarkness = darknessStrength * multiplier; + // Nebula Headcrab darkness effect + if (!player.headcovered) + { + float screenObstructionAmt = MathHelper.Clamp(modPlayer.caveDarkness, 0f, 0.95f); + float targetValue = MathHelper.Clamp(screenObstructionAmt * 0.7f, 0.1f, 0.3f); + ScreenObstruction.screenObstruction = MathHelper.Lerp(ScreenObstruction.screenObstruction, screenObstructionAmt, targetValue); + } + // Breath lost while at zero breath - int breathLoss = (int)(60 * depthRatio); + double breathLoss = 50D * depthRatio; // Breath Loss Multiplier, depending on gear double breathLossMult = 1D - @@ -1670,13 +1729,13 @@ namespace CalamityMod.CalPlayer breathLossMult = 0.05; // Reduce breath lost while at zero breath, depending on gear - breathLoss = (int)(breathLoss * breathLossMult); + breathLoss *= breathLossMult; // Stat Meter stat - modPlayer.abyssBreathLossStat = breathLoss; + modPlayer.abyssBreathLossStat = (int)breathLoss; // Defense loss - int defenseLoss = (int)(120 * depthRatio); + int defenseLoss = (int)(120D * depthRatio); // Anechoic Plating reduces defense loss by 66% if (modPlayer.anechoicPlating) @@ -1705,11 +1764,11 @@ namespace CalamityMod.CalPlayer } // Ticks (frames) until breath is deducted from the breath meter - int tick = (int)(12D * (1D - depthRatio)); + double tick = 12D * (1D - depthRatio); - // Prevent awful shit from happening - if (tick < 1) - tick = 1; + // Prevent 0 + if (tick < 1D) + tick = 1D; // Tick (frame) multiplier, depending on gear double tickMult = 1D + @@ -1728,21 +1787,21 @@ namespace CalamityMod.CalPlayer tickMult = 50D; // Increase ticks (frames) until breath is deducted, depending on gear - tick = (int)(tick * tickMult); + tick *= tickMult; // Stat Meter stat - modPlayer.abyssBreathLossRateStat = tick; + modPlayer.abyssBreathLossRateStat = (int)tick; // Reduce breath over ticks (frames) modPlayer.abyssBreathCD++; - if (modPlayer.abyssBreathCD >= tick) + if (modPlayer.abyssBreathCD >= (int)tick) { // Reset modded breath variable modPlayer.abyssBreathCD = 0; // Reduce breath if (player.breath > 0) - player.breath -= (modPlayer.cDepth ? breathLoss + 1 : breathLoss); + player.breath -= (int)(modPlayer.cDepth ? breathLoss + 1D : breathLoss); } // If breath is greater than 0 and player has gills or is merfolk, balance out the effects by reducing breath @@ -1752,35 +1811,27 @@ namespace CalamityMod.CalPlayer player.breath -= 3; } - // Life loss will at zero breath - int lifeLossAtZeroBreath = (int)(30 * depthRatio); + // Life loss at zero breath + int lifeLossAtZeroBreath = (int)(12D * depthRatio); // Resistance to life loss at zero breath - int lifeLossAtZeroBreathResist = 0; - if (modPlayer.depthCharm) - { - lifeLossAtZeroBreathResist += 3; - if (modPlayer.abyssalDivingSuit) - lifeLossAtZeroBreathResist += 6; - } + int lifeLossAtZeroBreathResist = 0 + + (modPlayer.depthCharm ? 3 : 0) + + (modPlayer.abyssalDivingSuit ? 6 : 0); + + // Reduce life loss, depending on gear + lifeLossAtZeroBreath -= lifeLossAtZeroBreathResist; + + // Prevent negatives + if (lifeLossAtZeroBreath < 0) + lifeLossAtZeroBreath = 0; // Stat Meter stat - modPlayer.abyssLifeLostAtZeroBreathStat = lifeLossAtZeroBreath - lifeLossAtZeroBreathResist; - - // Can't be negative - if (modPlayer.abyssLifeLostAtZeroBreathStat < 0) - modPlayer.abyssLifeLostAtZeroBreathStat = 0; + modPlayer.abyssLifeLostAtZeroBreathStat = lifeLossAtZeroBreath; // Check breath value if (player.breath <= 0) { - // Reduce life loss, depending on gear - lifeLossAtZeroBreath -= lifeLossAtZeroBreathResist; - - // Prevent awful shit again - if (lifeLossAtZeroBreath < 0) - lifeLossAtZeroBreath = 0; - // Reduce life player.statLife -= lifeLossAtZeroBreath; diff --git a/CalamityMod.cs b/CalamityMod.cs index be4a2180da..9d26692861 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -82,6 +82,7 @@ using System.IO; using System.Reflection; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Events; using Terraria.Graphics; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; @@ -3402,16 +3403,64 @@ namespace CalamityMod #region Lighting const float MaxCaveDarkness = -0.3f; + const float MaxSignusDarkness = -0.5f; + const float MaxAbyssDarkness = -0.7f; public override void ModifyLightingBrightness(ref float scale) { - // Apply the calculated cave darkness value for the local player. - // It should always be zero outside of death mode, but just to be safe, make sure it doesn't apply. + // Apply the calculated darkness value for the local player. CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); - if (CalamityWorld.death || modPlayer.ZoneAbyss) - { - float darkRatio = MathHelper.Clamp(modPlayer.caveDarkness, 0f, 1f); - scale += MaxCaveDarkness * darkRatio; - } + float darkRatio = MathHelper.Clamp(modPlayer.caveDarkness, 0f, 1f); + + if (modPlayer.ZoneAbyss) + scale += MaxAbyssDarkness * darkRatio; + else if (CalamityWorld.death) + scale += MaxCaveDarkness * darkRatio; + + if (CalamityWorld.revenge) + { + if (CalamityGlobalNPC.signus != -1) + { + if (Main.npc[CalamityGlobalNPC.signus].active) + { + if (Vector2.Distance(Main.LocalPlayer.Center, Main.npc[CalamityGlobalNPC.signus].Center) <= 5200f) + { + float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax); + + // Reduce the power of Signus darkness based on your light level. + float multiplier = 1f; + switch (modPlayer.GetTotalLightStrength()) + { + case 0: + break; + case 1: + case 2: + multiplier = 0.75f; + break; + case 3: + case 4: + multiplier = 0.5f; + break; + case 5: + case 6: + multiplier = 0.25f; + break; + default: + multiplier = 0f; + break; + } + + // Increased darkness in Death Mode + if (CalamityWorld.death) + multiplier += (1f - multiplier) * 0.1f; + + // Total darkness + float signusDarkness = signusLifeRatio * multiplier; + darkRatio = MathHelper.Clamp(signusDarkness, 0f, 1f); + scale += MaxSignusDarkness * darkRatio; + } + } + } + } } #endregion diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index 5f2b9cc34a..6ad3e72445 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -26,8 +26,8 @@ namespace CalamityMod.NPCs.Abyss npc.lavaImmune = true; npc.aiStyle = -1; npc.damage = 150; - npc.width = 80; //324 - npc.height = 40; //216 + npc.width = 80; + npc.height = 40; npc.defense = 50; npc.Calamity().RevPlusDR(0.25f); npc.lifeMax = 10000; @@ -44,19 +44,20 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - if (CalamityGlobalNPC.bobbitWormBottom < 0 || !Main.npc[CalamityGlobalNPC.bobbitWormBottom].active) + if (!Main.npc[(int)npc.ai[2]].active || (int)npc.ai[2] < 0) { npc.active = false; npc.netUpdate = true; return; } + if (npc.ai[0] == 0f) { npc.noTileCollide = true; float num659 = 14f; Vector2 vector79 = new Vector2(npc.Center.X, npc.Center.Y); - float num660 = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.X - vector79.X; - float num661 = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.Y - vector79.Y; + float num660 = Main.npc[(int)npc.ai[2]].Center.X - vector79.X; + float num661 = Main.npc[(int)npc.ai[2]].Center.Y - vector79.Y; float num662 = (float)Math.Sqrt((double)(num660 * num660 + num661 * num661)); if (num662 < 11f + num659) { @@ -129,8 +130,8 @@ namespace CalamityMod.NPCs.Abyss } } Vector2 vector81 = new Vector2(npc.Center.X, npc.Center.Y); - float num667 = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.X - vector81.X; - float num668 = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.Y - vector81.Y; + float num667 = Main.npc[(int)npc.ai[2]].Center.X - vector81.X; + float num668 = Main.npc[(int)npc.ai[2]].Center.Y - vector81.Y; float num669 = (float)Math.Sqrt((double)(num667 * num667 + num668 * num668)); if (num669 > 700f || npc.collideX || npc.collideY) { @@ -198,8 +199,8 @@ namespace CalamityMod.NPCs.Abyss public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - float drawPositionX = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.X - center.X; - float drawPositionY = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.Y - center.Y; + float drawPositionX = Main.npc[(int)npc.ai[2]].Center.X - center.X; + float drawPositionY = Main.npc[(int)npc.ai[2]].Center.Y - center.Y; float rotation = (float)Math.Atan2((double)drawPositionY, (double)drawPositionX) - 1.57f; bool draw = true; while (draw) @@ -216,8 +217,8 @@ namespace CalamityMod.NPCs.Abyss drawPositionY *= totalDrawDistance; center.X += drawPositionX; center.Y += drawPositionY; - drawPositionX = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.X - center.X; - drawPositionY = Main.npc[CalamityGlobalNPC.bobbitWormBottom].Center.Y - center.Y; + drawPositionX = Main.npc[(int)npc.ai[2]].Center.X - center.X; + drawPositionY = Main.npc[(int)npc.ai[2]].Center.Y - center.Y; drawPositionY += 4f; Color color = Lighting.GetColor((int)center.X / 16, (int)(center.Y / 16f)); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/BobbitWormSegment"), new Vector2(center.X - Main.screenPosition.X, center.Y - Main.screenPosition.Y), diff --git a/NPCs/Abyss/BobbitWormSegment.cs b/NPCs/Abyss/BobbitWormSegment.cs index 3806120197..223736b0b6 100644 --- a/NPCs/Abyss/BobbitWormSegment.cs +++ b/NPCs/Abyss/BobbitWormSegment.cs @@ -1,4 +1,5 @@ -using Terraria; +using System.Linq; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,8 +18,8 @@ namespace CalamityMod.NPCs.Abyss npc.aiStyle = -1; npc.damage = 0; npc.alpha = 255; - npc.width = 26; //324 - npc.height = 26; //216 + npc.width = 26; + npc.height = 26; npc.defense = 0; npc.lifeMax = 100; npc.knockBackResist = 0f; @@ -30,16 +31,31 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - CalamityGlobalNPC.bobbitWormBottom = npc.whoAmI; + if (npc.ai[0] == 0f) + { + for (int i = 0; i < CalamityGlobalNPC.bobbitWormBottom.Length; i++) + { + if (CalamityGlobalNPC.bobbitWormBottom[i] == -1) + { + CalamityGlobalNPC.bobbitWormBottom[i] = npc.whoAmI; + npc.ai[0] = (float)i; + break; + } + } + } + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.localAI[0] == 0f) + if (npc.ai[1] == 0f) { - npc.localAI[0] = 1f; - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI, 0f, 0f, 0f, 0f, 255); - } + npc.ai[1] = 1f; + int spawnedNPC = NPC.NewNPC((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; + } } - if (!NPC.AnyNPCs(ModContent.NPCType())) + + if (!Main.npc[(int)npc.ai[2]].active || Main.npc[(int)npc.ai[2]].life <= 0) { npc.active = false; npc.netUpdate = true; @@ -50,7 +66,7 @@ namespace CalamityMod.NPCs.Abyss { if (spawnInfo.player.Calamity().ZoneAbyssLayer4 && spawnInfo.water) { - if (!NPC.AnyNPCs(ModContent.NPCType())) + if (CalamityGlobalNPC.bobbitWormBottom.Contains(-1)) return SpawnCondition.CaveJellyfish.Chance * 0.3f; } return 0f; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index c638b7b312..2253e74186 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -131,7 +131,7 @@ namespace CalamityMod.NPCs public int sulphurPoison = 0; // whoAmI Variables - public static int bobbitWormBottom = -1; + public static int[] bobbitWormBottom = new int[5]; public static int hiveMind = -1; public static int perfHive = -1; public static int slimeGodPurple = -1; @@ -158,6 +158,7 @@ namespace CalamityMod.NPCs public static int holyBossHealer = -1; public static int holyBoss = -1; public static int voidBoss = -1; + public static int signus = -1; public static int ghostBossClone = -1; public static int ghostBoss = -1; public static int DoGHead = -1; @@ -313,7 +314,9 @@ namespace CalamityMod.NPCs } } - ResetSavedIndex(ref bobbitWormBottom); + for (int i = 0; i < bobbitWormBottom.Length; i++) + ResetSavedIndex(ref bobbitWormBottom[i]); + ResetSavedIndex(ref hiveMind); ResetSavedIndex(ref perfHive); ResetSavedIndex(ref slimeGodPurple); @@ -340,6 +343,7 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref holyBossHealer); ResetSavedIndex(ref holyBoss); ResetSavedIndex(ref voidBoss); + ResetSavedIndex(ref signus); ResetSavedIndex(ref ghostBossClone); ResetSavedIndex(ref ghostBoss); ResetSavedIndex(ref DoGHead); diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index e64046cb7c..a26f765724 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -133,9 +133,9 @@ namespace CalamityMod.NPCs.CeaselessVoid return; } } - else if (npc.timeLeft < 2400) + else if (npc.timeLeft < 1800) { - npc.timeLeft = 2400; + npc.timeLeft = 1800; } if (npc.ai[0] == 0f) { @@ -190,7 +190,12 @@ namespace CalamityMod.NPCs.CeaselessVoid } } - public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) + public override bool CheckActive() + { + return false; + } + + public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) { if (CalamityWorld.DoGSecondStageCountdown <= 0) { diff --git a/NPCs/CeaselessVoid/DarkEnergy2.cs b/NPCs/CeaselessVoid/DarkEnergy2.cs index 05fc434565..9ddb6cfd38 100644 --- a/NPCs/CeaselessVoid/DarkEnergy2.cs +++ b/NPCs/CeaselessVoid/DarkEnergy2.cs @@ -132,9 +132,9 @@ namespace CalamityMod.NPCs.CeaselessVoid return; } } - else if (npc.timeLeft < 2400) + else if (npc.timeLeft < 1800) { - npc.timeLeft = 2400; + npc.timeLeft = 1800; } Vector2 vector145 = new Vector2(npc.Center.X, npc.Center.Y); float num1258 = Main.player[npc.target].Center.X - vector145.X; @@ -154,7 +154,12 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.velocity.Y = (npc.velocity.Y * 100f + num1259) / 101f; } - public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) + public override bool CheckActive() + { + return false; + } + + public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) { if (CalamityWorld.DoGSecondStageCountdown <= 0) { diff --git a/NPCs/CeaselessVoid/DarkEnergy3.cs b/NPCs/CeaselessVoid/DarkEnergy3.cs index cc90262e42..02128d4e4b 100644 --- a/NPCs/CeaselessVoid/DarkEnergy3.cs +++ b/NPCs/CeaselessVoid/DarkEnergy3.cs @@ -133,9 +133,9 @@ namespace CalamityMod.NPCs.CeaselessVoid return; } } - else if (npc.timeLeft < 2400) + else if (npc.timeLeft < 1800) { - npc.timeLeft = 2400; + npc.timeLeft = 1800; } float num1372 = expertMode ? 10f : 8f; @@ -182,7 +182,12 @@ namespace CalamityMod.NPCs.CeaselessVoid } } - public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) + public override bool CheckActive() + { + return false; + } + + public override void OnHitByProjectile(Projectile projectile, int damage, float knockback, bool crit) { if (CalamityWorld.DoGSecondStageCountdown <= 0) { diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 4c349f1c88..ec2f315d52 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -144,11 +144,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (MissileCountdown > 1) MissileCountdown--; + Vector2 vectorCenter = npc.Center; + // Count nearby players int num1038 = 0; for (int num1039 = 0; num1039 < 255; num1039++) { - if (Main.player[num1039].active && !Main.player[num1039].dead && (npc.Center - Main.player[num1039].Center).Length() < 1000f) + if (Main.player[num1039].active && !Main.player[num1039].dead && (vectorCenter - Main.player[num1039].Center).Length() < 1000f) num1038++; } @@ -166,7 +168,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Player player = Main.player[npc.target]; // Distance from target - Vector2 distFromPlayer = player.Center - npc.Center; + Vector2 distFromPlayer = player.Center - vectorCenter; // Enrage bool aboveGroundEnrage = ((double)player.position.Y < Main.worldSurface * 16.0 || player.position.Y > (float)((Main.maxTilesY - 200) * 16)) && !CalamityWorld.bossRushActive; @@ -178,11 +180,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath bool diagonalDash = revenge && ((double)npc.life <= (double)npc.lifeMax * 0.8 || death); // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) { npc.TargetClosest(false); player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 5600f) { if (despawnTimer > 0) despawnTimer--; @@ -273,9 +275,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { npc.TargetClosest(true); - float playerLocation = npc.Center.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; - if (Math.Abs(npc.position.Y + (float)(npc.height / 2) - (player.position.Y + (float)(player.height / 2) - (float)chargeDistance)) < 20f) + if (Math.Abs(npc.Center.Y - (player.Center.Y - (float)chargeDistance)) < 20f) { if (diagonalDash) { @@ -308,9 +310,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) num1044 += 2f; - Vector2 vector117 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num1045 = player.position.X + (float)(player.width / 2) - vector117.X; - float num1046 = player.position.Y + (float)(player.height / 2) - vector117.Y; + float num1045 = player.position.X + (float)(player.width / 2) - vectorCenter.X; + float num1046 = player.position.Y + (float)(player.height / 2) - vectorCenter.Y; float num1047 = (float)Math.Sqrt((double)(num1045 * num1045 + num1046 * num1046)); num1047 = num1044 / num1047; @@ -326,16 +327,16 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath charging = false; - float num1048 = revenge ? 18f : 16f; - float num1049 = revenge ? 0.35f : 0.32f; + float num1048 = revenge ? 14f : 12f; + float num1049 = revenge ? 0.25f : 0.22f; if ((double)npc.life < (double)npc.lifeMax * 0.66 || death) { - num1048 += 2f; + num1048 += 1f; num1049 += 0.05f; } if ((double)npc.life < (double)npc.lifeMax * 0.33 || death) { - num1048 += 2f; + num1048 += 1f; num1049 += 0.05f; } if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) @@ -344,7 +345,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1049 += 0.1f; } - if (npc.position.Y + (float)(npc.height / 2) < (player.position.Y + (float)(player.height / 2) - (float)chargeDistance)) + if (vectorCenter.Y < (player.Center.Y - (float)chargeDistance)) npc.velocity.Y += num1049; else npc.velocity.Y -= num1049; @@ -354,9 +355,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (npc.velocity.Y > num1048) npc.velocity.Y = num1048; - if (Math.Abs(npc.position.X + (float)(npc.width / 2) - (player.position.X + (float)(player.width / 2))) > 650f) + if (Math.Abs(vectorCenter.X - player.Center.X) > 650f) npc.velocity.X += num1049 * (float)npc.direction; - else if (Math.Abs(npc.position.X + (float)(npc.width / 2) - (player.position.X + (float)(player.width / 2))) < 500f) + else if (Math.Abs(vectorCenter.X - player.Center.X) < 500f) npc.velocity.X -= num1049 * (float)npc.direction; else npc.velocity.X *= 0.8f; @@ -387,19 +388,21 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath int num1050 = revenge ? 525 : 550; if (npc.Calamity().enraged > 0 || (CalamityMod.CalamityConfig.BossRushXerocCurse && CalamityWorld.bossRushActive)) - num1050 = 250; + num1050 = 300; else if (aboveGroundEnrage || CalamityWorld.bossRushActive) - num1050 = 350; + num1050 = 400; else if ((double)npc.life < (double)npc.lifeMax * 0.33 || death) - num1050 = revenge ? 425 : 450; + num1050 = revenge ? 450 : 475; else if ((double)npc.life < (double)npc.lifeMax * 0.66) num1050 = revenge ? 475 : 500; int num1051 = 1; - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)(player.width / 2)) + if (vectorCenter.X < player.Center.X) num1051 = -1; - if (npc.direction == num1051 && Math.Abs(npc.position.X + (float)(npc.width / 2) - (player.position.X + (float)(player.width / 2))) > (float)num1050) - npc.ai[2] = 1f; + if (npc.direction == num1051 && (Math.Abs(vectorCenter.X - player.Center.X) > (float)num1050 || Math.Abs(vectorCenter.Y - player.Center.Y) > (float)num1050)) + { + npc.ai[2] = 1f; + } if (npc.ai[2] != 1f) { @@ -449,13 +452,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { npc.TargetClosest(true); - float playerLocation = npc.Center.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - Vector2 vector118 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num1055 = player.position.X + (float)(player.width / 2) - vector118.X; - float num1056 = player.position.Y + (float)(player.height / 2) - 200f - vector118.Y; + float num1055 = player.position.X + (float)(player.width / 2) - vectorCenter.X; + float num1056 = player.position.Y + (float)(player.height / 2) - 200f - vectorCenter.Y; float num1057 = (float)Math.Sqrt((double)(num1055 * num1055 + num1056 * num1056)); if (num1057 < 600f) { @@ -477,9 +479,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.TargetClosest(true); Vector2 vector119 = new Vector2(npc.position.X + (float)(npc.width / 2) + (float)(80 * npc.direction), npc.position.Y + (float)npc.height * 1.2f); - Vector2 vector120 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num1058 = player.position.X + (float)(player.width / 2) - vector120.X; - float num1059 = player.position.Y + (float)(player.height / 2) - vector120.Y; + float num1058 = player.position.X + (float)(player.width / 2) - vectorCenter.X; + float num1059 = player.position.Y + (float)(player.height / 2) - vectorCenter.Y; float num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059)); npc.ai[1] += 1f; @@ -532,7 +533,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else npc.velocity *= 0.9f; - float playerLocation = npc.Center.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -552,9 +553,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.TargetClosest(true); Vector2 vector119 = new Vector2(npc.position.X + (float)(npc.width / 2) + (float)(80 * npc.direction), npc.position.Y + (float)npc.height * 1.2f); - Vector2 vector120 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num1058 = player.position.X + (float)(player.width / 2) - vector120.X; - float num1059 = player.position.Y + (float)(player.height / 2) - vector120.Y; + float num1058 = player.position.X + (float)(player.width / 2) - vectorCenter.X; + float num1059 = player.position.Y + (float)(player.height / 2) - vectorCenter.Y; float num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059)); npc.ai[1] += 1f; @@ -609,7 +609,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else npc.velocity *= 0.9f; - float playerLocation = npc.Center.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -646,7 +646,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else if (npc.ai[1] % 30f == 29f) flag104 = true; - if (flag104 && npc.position.Y + (float)npc.height < player.position.Y) + if (flag104 && vectorCenter.Y < player.position.Y) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 42); @@ -693,7 +693,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Movement(100f, 400f, 500f, player); - float playerLocation = npc.Center.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -724,9 +724,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { npc.TargetClosest(true); - float playerLocation = npc.Center.X - player.Center.X; + float playerLocation = vectorCenter.X - player.Center.X; - if (Math.Abs(npc.position.Y + (float)(npc.height / 2) - (player.position.Y + (float)(player.height / 2) - 500f)) < 20f) + if (Math.Abs(vectorCenter.Y - (player.Center.Y - 500f)) < 20f) { if (MissileCountdown == 1) { @@ -741,13 +741,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath speed = 12; int damage = expertMode ? 48 : 60; - Vector2 baseVelocity = player.Center - npc.Center; + Vector2 baseVelocity = player.Center - vectorCenter; baseVelocity.Normalize(); baseVelocity *= speed; for (int i = 0; i < MissileProjectiles; i++) { - Vector2 spawn = npc.Center; + Vector2 spawn = vectorCenter; spawn.X += i * 27 - (MissileProjectiles * 12); // -96 to 93 Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-MissileAngleSpread / 2 + (MissileAngleSpread * i / (float)MissileProjectiles))); Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, player.position.Y); @@ -764,9 +764,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (CalamityWorld.bossRushActive) num1044 = 32f; - Vector2 vector117 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num1045 = player.position.X + (float)(player.width / 2) - vector117.X; - float num1046 = player.position.Y - 500f + (float)(player.height / 2) - vector117.Y; + float num1045 = player.position.X + (float)(player.width / 2) - vectorCenter.X; + float num1046 = player.position.Y - 500f + (float)(player.height / 2) - vectorCenter.Y; float num1047 = (float)Math.Sqrt((double)(num1045 * num1045 + num1046 * num1046)); num1047 = num1044 / num1047; @@ -788,7 +787,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1049 *= 1.5f; } - if (npc.position.Y + (float)(npc.height / 2) < (player.position.Y + (float)(player.height / 2) - 500f)) + if (vectorCenter.Y < player.Center.Y - 500f) npc.velocity.Y += num1049; else npc.velocity.Y -= num1049; @@ -798,9 +797,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (npc.velocity.Y > num1048) npc.velocity.Y = num1048; - if (Math.Abs(npc.position.X + (float)(npc.width / 2) - (player.position.X + (float)(player.width / 2))) > 600f) + if (Math.Abs(vectorCenter.X - player.Center.X) > 600f) npc.velocity.X += 0.15f * (float)npc.direction; - else if (Math.Abs(npc.position.X + (float)(npc.width / 2) - (player.position.X + (float)(player.width / 2))) < 300f) + else if (Math.Abs(vectorCenter.X - player.Center.X) < 300f) npc.velocity.X -= 0.15f * (float)npc.direction; else npc.velocity.X *= 0.8f; @@ -832,9 +831,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath int num1050 = 600; int num1051 = 1; - if (npc.position.X + (float)(npc.width / 2) < player.position.X + (float)(player.width / 2)) + if (vectorCenter.X < player.Center.X) num1051 = -1; - if (npc.direction == num1051 && Math.Abs(npc.position.X + (float)(npc.width / 2) - (player.position.X + (float)(player.width / 2))) > (float)num1050) + if (npc.direction == num1051 && Math.Abs(vectorCenter.X - player.Center.X) > (float)num1050) npc.ai[2] = 1f; if (npc.ai[2] != 1f) diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index 957d55db8f..3720f054e5 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -54,9 +54,9 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } if (npc.alpha > 0) { @@ -115,7 +115,12 @@ namespace CalamityMod.NPCs.Ravager } } - public override void HitEffect(int hitDirection, double damage) + public override bool CheckActive() + { + return false; + } + + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index e82d01dafb..5dbf0b8dda 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -80,9 +80,9 @@ namespace CalamityMod.NPCs.Ravager return; } bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } if (npc.alpha > 0) { @@ -304,7 +304,12 @@ namespace CalamityMod.NPCs.Ravager return true; } - public override bool PreNPCLoot() + public override bool CheckActive() + { + return false; + } + + public override bool PreNPCLoot() { return false; } diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index 35aa844e2b..b00f5a813e 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -81,9 +81,9 @@ namespace CalamityMod.NPCs.Ravager return; } bool death = CalamityWorld.death || CalamityWorld.bossRushActive; - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } if (npc.alpha > 0) { @@ -305,7 +305,12 @@ namespace CalamityMod.NPCs.Ravager return true; } - public override bool PreNPCLoot() + public override bool CheckActive() + { + return false; + } + + public override bool PreNPCLoot() { return false; } diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index e6f01d8b04..8334960d29 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -82,9 +82,9 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } float speed = 12f; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); @@ -140,7 +140,12 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool PreNPCLoot() + public override bool CheckActive() + { + return false; + } + + public override bool PreNPCLoot() { return false; } diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs index 4f600ba438..dc6da13f62 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -51,9 +51,9 @@ namespace CalamityMod.NPCs.Ravager { npc.TargetClosest(true); } - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } float num = 5f; float num2 = 0.1f; @@ -274,7 +274,12 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool PreNPCLoot() + public override bool CheckActive() + { + return false; + } + + public override bool PreNPCLoot() { return false; } diff --git a/NPCs/Ravager/RavagerLegLeft.cs b/NPCs/Ravager/RavagerLegLeft.cs index 940be39a7a..6cad414234 100644 --- a/NPCs/Ravager/RavagerLegLeft.cs +++ b/NPCs/Ravager/RavagerLegLeft.cs @@ -78,9 +78,9 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } if (npc.alpha > 0) { @@ -127,7 +127,12 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool PreNPCLoot() + public override bool CheckActive() + { + return false; + } + + public override bool PreNPCLoot() { return false; } diff --git a/NPCs/Ravager/RavagerLegRight.cs b/NPCs/Ravager/RavagerLegRight.cs index debc0991cf..9f84d4d5d0 100644 --- a/NPCs/Ravager/RavagerLegRight.cs +++ b/NPCs/Ravager/RavagerLegRight.cs @@ -78,9 +78,9 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } if (npc.alpha > 0) { @@ -127,7 +127,12 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool PreNPCLoot() + public override bool CheckActive() + { + return false; + } + + public override bool PreNPCLoot() { return false; } diff --git a/NPCs/Ravager/RockPillar.cs b/NPCs/Ravager/RockPillar.cs index e9d390ead8..2fb055fb57 100644 --- a/NPCs/Ravager/RockPillar.cs +++ b/NPCs/Ravager/RockPillar.cs @@ -45,9 +45,9 @@ namespace CalamityMod.NPCs.Ravager npc.netUpdate = true; return; } - if (npc.timeLeft < 3000) + if (npc.timeLeft < 1800) { - npc.timeLeft = 3000; + npc.timeLeft = 1800; } if (npc.alpha > 0) { @@ -152,7 +152,12 @@ namespace CalamityMod.NPCs.Ravager } } - public override void HitEffect(int hitDirection, double damage) + public override bool CheckActive() + { + return false; + } + + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index c6f69d537b..babbc87b92 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -60,6 +60,13 @@ namespace CalamityMod.NPCs.Signus public override void AI() { + if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } + Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.75f, 0.75f, 0.75f); npc.alpha -= 3; diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index bc0d39278e..3104d9ec74 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -112,6 +112,8 @@ namespace CalamityMod.NPCs.Signus public override void AI() { + CalamityGlobalNPC.signus = npc.whoAmI; + bool death = CalamityWorld.death || CalamityWorld.bossRushActive; bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; @@ -134,15 +136,6 @@ namespace CalamityMod.NPCs.Signus Player player = Main.player[npc.target]; - int targetLightStrength = player.Calamity().GetTotalLightStrength() * 15; - if (revenge) - { - int fadeIn = (int)((double)lifeToAlpha * 1.5) - targetLightStrength; - if (fadeIn < 0) - fadeIn = 0; - Main.BlackFadeIn = fadeIn; - } - if (!player.active || player.dead || Vector2.Distance(player.Center, vectorCenter) > 6400f) { npc.TargetClosest(false); @@ -217,7 +210,7 @@ namespace CalamityMod.NPCs.Signus { npc.knockBackResist *= Main.expertKnockBack; } - if (cosmicSpeed) + if (speedBoost) { npc.knockBackResist = 0f; } diff --git a/NPCs/Signus/SignusBomb.cs b/NPCs/Signus/SignusBomb.cs index 5b8e63374c..5844d095ba 100644 --- a/NPCs/Signus/SignusBomb.cs +++ b/NPCs/Signus/SignusBomb.cs @@ -41,6 +41,13 @@ namespace CalamityMod.NPCs.Signus public override void AI() { + if (CalamityGlobalNPC.signus < 0 || !Main.npc[CalamityGlobalNPC.signus].active) + { + npc.active = false; + npc.netUpdate = true; + return; + } + Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.7f, 0.2f, 1.1f); npc.rotation = npc.velocity.X * 0.04f; if (npc.ai[1] == 0f) diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 491cf89d32..5a61865508 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -164,13 +164,17 @@ namespace CalamityMod.World CalamityGlobalNPC.energyFlame = -1; CalamityGlobalNPC.hiveMind = -1; CalamityGlobalNPC.scavenger = -1; - CalamityGlobalNPC.bobbitWormBottom = -1; + + for (int i = 0; i < CalamityGlobalNPC.bobbitWormBottom.Length; i++) + CalamityGlobalNPC.bobbitWormBottom[i] = -1; + CalamityGlobalNPC.DoGHead = -1; CalamityGlobalNPC.SCal = -1; CalamityGlobalNPC.ghostBoss = -1; CalamityGlobalNPC.laserEye = -1; CalamityGlobalNPC.fireEye = -1; CalamityGlobalNPC.brimstoneElemental = -1; + CalamityGlobalNPC.signus = -1; bossRushStage = 0; DoGSecondStageCountdown = 0; ArmoredDiggerSpawnCooldown = 0;