diff --git a/CalamityMod.cs b/CalamityMod.cs index ff94cb65e9..d51d0fe488 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -3015,6 +3015,19 @@ namespace CalamityMod AstralArcanumUI.UpdateAndDraw(Main.spriteBatch); return true; }, InterfaceScaleType.None)); + + int invasionIndex = layers.FindIndex(layer => layer.Name == "Vanilla: Diagnose Net"); + if (invasionIndex != -1) + { + layers.Insert(invasionIndex, new LegacyGameInterfaceLayer("Acid Rain Invasion UI", () => + { + if (CalamityWorld.rainingAcid) + { + AcidRainUI.Draw(Main.spriteBatch); + } + return true; + }, InterfaceScaleType.None)); + } } public static Color GetNPCColor(NPC npc, Vector2? position = null, bool effects = true, float shadowOverride = 0f) diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index f32a3096b0..267ad87d9e 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -127,7 +127,6 @@ namespace CalamityMod.Events rectangleCheckSize, rectangleCheckSize); if (screen.Intersects(invasionCheckArea)) { - Main.invasionProgressDisplayLeft = 480; return true; } } @@ -152,23 +151,13 @@ namespace CalamityMod.Events } if (playerCount > 0) { - // So that vanilla doesn't shit itself - Main.invasionType = -1; - CalamityWorld.rainingAcid = true; // The E - 1 part is to ensure that we start at 1 as a multiple instead of 0 // At a maximum of 255 players, the max multiplier is 9.98, or 998 enemies that need to be killed. CalamityWorld.acidRainPoints = (int)(180 * Math.Log(playerCount + Math.E - 1)); - Main.invasionProgress = 0; - Main.invasionProgressIcon = -1; - Main.invasionProgressWave = 0; // Make it rain normally Main.raining = true; - - // If abyssSide is true, then the abyss was generated on the left side of the world. - // If false, the right. - Main.invasionX = CalamityWorld.abyssSide ? 0 : Main.maxTilesX; CalamityWorld.triedToSummonOldDuke = false; } UpdateInvasion(); @@ -187,9 +176,6 @@ namespace CalamityMod.Events { CalamityWorld.rainingAcid = false; BroadcastEventText("Mods.CalamityMod.AcidRainEnd"); // The sulphuric skies begin to clear... - Main.invasionType = 0; - Main.invasionDelay = 0; - Main.invasionProgressNearInvasion = false; CalamityWorld.acidRainExtraDrawTime = 40; // Turn off the rain from the event diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index 2adb8dabb9..9eea624895 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -19,232 +19,6 @@ namespace CalamityMod.ILEditing /// public static void Initialize() { - IL.Terraria.Main.DrawInvasionProgress += (il) => - { - var cursor = new ILCursor(il) - { - Index = 1 - }; - cursor.EmitDelegate(() => - { - if (Main.invasionProgressMode == 2 && (Main.invasionProgressNearInvasion || AcidRainEvent.NearInvasionCheck(7500)) && Main.invasionProgressDisplayLeft < 160) - { - Main.invasionProgressDisplayLeft = 160; - } - if (!Main.gamePaused && Main.invasionProgressDisplayLeft > 0) - { - Main.invasionProgressDisplayLeft--; - } - if (Main.invasionProgressDisplayLeft > 0) - { - Main.invasionProgressAlpha += 0.05f; - } - else - { - Main.invasionProgressAlpha -= 0.05f; - } - if (Main.invasionProgressAlpha < 0f) - { - Main.invasionProgressAlpha = 0f; - } - if (Main.invasionProgressAlpha > 1f) - { - Main.invasionProgressAlpha = 1f; - } - if (CalamityWorld.rainingAcid) - { - Main.invasionProgressAlpha = 1f; - } - if (Main.invasionProgressAlpha <= 0f) - { - return; - } - bool draw = CalamityWorld.rainingAcid || CalamityWorld.acidRainExtraDrawTime > 0; - if ((draw && !Main.LocalPlayer.Calamity().ZoneSulphur) || - (!draw && Main.LocalPlayer.Calamity().ZoneSulphur)) - return; - - float progressAlpha = 0.5f + Main.invasionProgressAlpha * 0.5f; - if (CalamityWorld.acidRainExtraDrawTime > 0) - { - progressAlpha = 0.5f + CalamityWorld.acidRainExtraDrawTime / 40f * 0.5f; - CalamityWorld.acidRainExtraDrawTime--; - } - Vector2 screenCoords = new Vector2(Main.screenWidth - 120, Main.screenHeight - 40); - int sizeX = (int)(200f * progressAlpha); - int sizeY = (int)(45f * progressAlpha); - Rectangle screenCoordsRectangle = - new Rectangle((int)screenCoords.X - sizeX / 2, - (int)screenCoords.Y - sizeY / 2, sizeX, sizeY); - Texture2D barTexture = Main.colorBarTexture; - - // If you touch the netcode behind this without a good reason your life will come to an abrupt end -Dominic - if (CalamityWorld.rainingAcid || CalamityWorld.acidRainExtraDrawTime > 0) - { - Utils.DrawInvBG(Main.spriteBatch, screenCoordsRectangle, new Color(63, 65, 151, 255) * 0.785f); - - float progressRatio = 1f - CalamityWorld.AcidRainCompletionRatio; - string progressText = $"{((int)(100 * progressRatio)).ToString()}%"; - progressText = Language.GetTextValue("Game.WaveCleared", progressText); - Main.spriteBatch.Draw(barTexture, screenCoords, null, Color.White * Main.invasionProgressAlpha, 0f, new Vector2(barTexture.Width / 2, 0f), progressAlpha, SpriteEffects.None, 0f); - Vector2 textMeasurement = Main.fontMouseText.MeasureString(progressText); - float adjustedAlpha = progressAlpha; - if (textMeasurement.Y > 22f) - { - adjustedAlpha *= 22f / textMeasurement.Y; - } - float barDrawOffsetX = 169f * progressAlpha; - float scaleY = 8f * progressAlpha; - Vector2 barDrawPosition = screenCoords + Vector2.UnitY * scaleY + Vector2.UnitX * 1f; - Utils.DrawBorderString(Main.spriteBatch, progressText, barDrawPosition + new Vector2(0f, -4f), Color.White * Main.invasionProgressAlpha, adjustedAlpha, 0.5f, 1f, -1); - barDrawPosition += Vector2.UnitX * (progressRatio - 0.5f) * barDrawOffsetX; - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 241, 51) * Main.invasionProgressAlpha, 0f, new Vector2(1f, 0.5f), new Vector2(barDrawOffsetX * progressRatio, scaleY), SpriteEffects.None, 0f); - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 165, 0, 127) * Main.invasionProgressAlpha, 0f, new Vector2(1f, 0.5f), new Vector2(2f, scaleY), SpriteEffects.None, 0f); - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black * Main.invasionProgressAlpha, 0f, new Vector2(0f, 0.5f), new Vector2(barDrawOffsetX * (1f - progressRatio), scaleY), SpriteEffects.None, 0f); - - string invasionNameText = "Acid Rain"; - Vector2 textMeasurement2 = Main.fontMouseText.MeasureString(invasionNameText); - float x = 120f; - if (textMeasurement2.X > 200f) - { - x += textMeasurement2.X - 200f; - } - Texture2D iconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/AcidRainIcon"); - Rectangle iconRectangle = Utils.CenteredRectangle(new Vector2(Main.screenWidth - x, Main.screenHeight - 80), (textMeasurement2 + new Vector2(iconTexture.Width + 12, 6f)) * progressAlpha); - Utils.DrawInvBG(Main.spriteBatch, iconRectangle, AcidRainEvent.TextColor * 0.5f); - Main.spriteBatch.Draw(iconTexture, iconRectangle.Left() + Vector2.UnitX * progressAlpha * 8f, null, Color.White * Main.invasionProgressAlpha, 0f, new Vector2(0f, iconTexture.Height / 2), progressAlpha * 0.8f, SpriteEffects.None, 0f); - Utils.DrawBorderString(Main.spriteBatch, invasionNameText, iconRectangle.Right() + Vector2.UnitX * progressAlpha * -22f, Color.White * Main.invasionProgressAlpha, progressAlpha * 0.9f, 1f, 0.4f, -1); - } - else - { - if (Main.invasionProgress == -1) - { - return; - } - Texture2D iconTexture = Main.extraTexture[9]; - string invasionNameText = ""; - Color drawColor = Color.White; - if (Main.invasionProgressIcon == 1) - { - iconTexture = Main.extraTexture[8]; - invasionNameText = Language.GetTextValue("LegacyInterface.83"); - drawColor = new Color(64, 109, 164) * 0.5f; - } - else if (Main.invasionProgressIcon == 2) - { - iconTexture = Main.extraTexture[12]; - invasionNameText = Language.GetTextValue("LegacyInterface.84"); - drawColor = new Color(112, 86, 114) * 0.5f; - } - else if (Main.invasionProgressIcon == 3) - { - iconTexture = Main.extraTexture[79]; - invasionNameText = Language.GetTextValue("DungeonDefenders2.InvasionProgressTitle"); - drawColor = new Color(88, 0, 160) * 0.5f; - } - else if (Main.invasionProgressIcon == 7) - { - iconTexture = Main.extraTexture[10]; - invasionNameText = Language.GetTextValue("LegacyInterface.85"); - drawColor = new Color(165, 160, 155) * 0.5f; - } - else if (Main.invasionProgressIcon == 6) - { - iconTexture = Main.extraTexture[11]; - invasionNameText = Language.GetTextValue("LegacyInterface.86"); - drawColor = new Color(148, 122, 72) * 0.5f; - } - else if (Main.invasionProgressIcon == 5) - { - iconTexture = Main.extraTexture[7]; - invasionNameText = Language.GetTextValue("LegacyInterface.87"); - drawColor = new Color(173, 135, 140) * 0.5f; - } - else if (Main.invasionProgressIcon == 4) - { - iconTexture = Main.extraTexture[9]; - invasionNameText = Language.GetTextValue("LegacyInterface.88"); - drawColor = new Color(94, 72, 131) * 0.5f; - } - else return; - if (Main.invasionProgressWave > 0) - { - Utils.DrawInvBG(Main.spriteBatch, screenCoordsRectangle, new Color(63, 65, 151, 255) * 0.785f); - string pointsText; - if (Main.invasionProgressMax == 0) - { - pointsText = Language.GetTextValue("Game.InvasionPoints", Main.invasionProgress); - } - else - { - pointsText = ((int)((float)Main.invasionProgress * 100f / (float)Main.invasionProgressMax)).ToString() + "%"; - } - pointsText = Language.GetTextValue("Game.WaveMessage", Main.invasionProgressWave, pointsText); - float progressRatio = MathHelper.Clamp(Main.invasionProgress / (float)Main.invasionProgressMax, 0f, 1f); - if (Main.invasionProgressMax == 0) - { - progressRatio = 1f; - } - float barDrawOffsetX = 169f * progressAlpha; - float scaleY = 8f * progressAlpha; - Vector2 barDrawPosition = screenCoords + Vector2.UnitY * scaleY + Vector2.UnitX * 1f; - Utils.DrawBorderString(Main.spriteBatch, pointsText, barDrawPosition, Color.White * Main.invasionProgressAlpha, progressAlpha, 0.5f, 1f, -1); - Main.spriteBatch.Draw(barTexture, screenCoords, null, Color.White * Main.invasionProgressAlpha, 0f, new Vector2(barTexture.Width / 2, 0f), progressAlpha, SpriteEffects.None, 0f); - barDrawPosition += Vector2.UnitX * (progressRatio - 0.5f) * barDrawOffsetX; - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 241, 51) * Main.invasionProgressAlpha, 0f, new Vector2(1f, 0.5f), new Vector2(barDrawOffsetX * progressRatio, scaleY), SpriteEffects.None, 0f); - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 165, 0, 127) * Main.invasionProgressAlpha, 0f, new Vector2(1f, 0.5f), new Vector2(2f, scaleY), SpriteEffects.None, 0f); - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black * Main.invasionProgressAlpha, 0f, new Vector2(0f, 0.5f), new Vector2(barDrawOffsetX * (1f - progressRatio), scaleY), SpriteEffects.None, 0f); - } - else - { - Vector2 vectorIconRectangle = new Vector2(Main.screenWidth - 120, Main.screenHeight - 40); - Utils.DrawInvBG(Main.spriteBatch, screenCoordsRectangle, new Color(63, 65, 151, 255) * 0.785f); - string progressText; - if (Main.invasionProgressMax == 0) - { - progressText = Main.invasionProgress.ToString(); - } - else - { - progressText = ((int)(Main.invasionProgress * 100f / Main.invasionProgressMax)).ToString() + "%"; - } - progressText = Language.GetTextValue("Game.WaveCleared", progressText); - if (Main.invasionProgressMax != 0) - { - Main.spriteBatch.Draw(barTexture, vectorIconRectangle, null, Color.White * Main.invasionProgressAlpha, 0f, new Vector2((float)(barTexture.Width / 2), 0f), progressAlpha, SpriteEffects.None, 0f); - float progressRatio = MathHelper.Clamp(Main.invasionProgress / (float)Main.invasionProgressMax, 0f, 1f); - Vector2 textMeasurement = Main.fontMouseText.MeasureString(progressText); - float adjustedAlpha = progressAlpha; - if (textMeasurement.Y > 22f) - { - adjustedAlpha *= 22f / textMeasurement.Y; - } - float barDrawOffsetX = 169f * progressAlpha; - float scaleY = 8f * progressAlpha; - Vector2 barDrawPosition = vectorIconRectangle + Vector2.UnitY * scaleY + Vector2.UnitX * 1f; - Utils.DrawBorderString(Main.spriteBatch, progressText, barDrawPosition + new Vector2(0f, -4f), Color.White * Main.invasionProgressAlpha, adjustedAlpha, 0.5f, 1f, -1); - barDrawPosition += Vector2.UnitX * (progressRatio - 0.5f) * barDrawOffsetX; - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 241, 51) * Main.invasionProgressAlpha, 0f, new Vector2(1f, 0.5f), new Vector2(barDrawOffsetX * progressRatio, scaleY), SpriteEffects.None, 0f); - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 165, 0, 127) * Main.invasionProgressAlpha, 0f, new Vector2(1f, 0.5f), new Vector2(2f, scaleY), SpriteEffects.None, 0f); - Main.spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black * Main.invasionProgressAlpha, 0f, new Vector2(0f, 0.5f), new Vector2(barDrawOffsetX * (1f - progressRatio), scaleY), SpriteEffects.None, 0f); - } - } - Vector2 textMeasurement2 = Main.fontMouseText.MeasureString(invasionNameText); - float x = 120f; - if (textMeasurement2.X > 200f) - { - x += textMeasurement2.X - 200f; - } - Rectangle iconRectangle = Utils.CenteredRectangle(new Vector2(Main.screenWidth - x, Main.screenHeight - 80), (textMeasurement2 + new Vector2(iconTexture.Width + 12, 6f)) * progressAlpha); - Utils.DrawInvBG(Main.spriteBatch, iconRectangle, drawColor); - Main.spriteBatch.Draw(iconTexture, iconRectangle.Left() + Vector2.UnitX * progressAlpha * 8f, null, Color.White * Main.invasionProgressAlpha, 0f, new Vector2(0f, iconTexture.Height / 2), progressAlpha * 0.8f, SpriteEffects.None, 0f); - Utils.DrawBorderString(Main.spriteBatch, invasionNameText, iconRectangle.Right() + Vector2.UnitX * progressAlpha * -22f, Color.White * Main.invasionProgressAlpha, progressAlpha * 0.9f, 1f, 0.4f, -1); - } - }); - cursor.Emit(Pop); - cursor.Emit(Ret); - }; - IL.Terraria.WorldGen.MakeDungeon += (il) => { var cursor = new ILCursor(il) diff --git a/NPCs/Abyss/AnthozoanCrab.cs b/NPCs/Abyss/AnthozoanCrab.cs index 75c7bbf7f3..a2b8798561 100644 --- a/NPCs/Abyss/AnthozoanCrab.cs +++ b/NPCs/Abyss/AnthozoanCrab.cs @@ -183,7 +183,7 @@ namespace CalamityMod.NPCs.Abyss public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.Calamity().ZoneSulphur && CalamityWorld.downedAquaticScourge && !spawnInfo.water) + if (spawnInfo.player.Calamity().ZoneSulphur && CalamityWorld.downedAquaticScourge && !spawnInfo.water && Main.raining) { return 0.135f; } diff --git a/NPCs/Abyss/BelchingCoral.cs b/NPCs/Abyss/BelchingCoral.cs index b74e118e6b..dd84a6eb2c 100644 --- a/NPCs/Abyss/BelchingCoral.cs +++ b/NPCs/Abyss/BelchingCoral.cs @@ -54,7 +54,7 @@ namespace CalamityMod.NPCs.Abyss public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.Calamity().ZoneSulphur && CalamityWorld.downedAquaticScourge) + if (spawnInfo.player.Calamity().ZoneSulphur && CalamityWorld.downedAquaticScourge && Main.raining) { return 0.085f; } diff --git a/NPCs/AcidRain/AcidEel.cs b/NPCs/AcidRain/AcidEel.cs index fbe8697660..a34b42db7b 100644 --- a/NPCs/AcidRain/AcidEel.cs +++ b/NPCs/AcidRain/AcidEel.cs @@ -22,8 +22,8 @@ namespace CalamityMod.NPCs.AcidRain npc.width = 72; npc.height = 18; - npc.damage = 40; - npc.lifeMax = 260; + npc.damage = 30; + npc.lifeMax = 140; npc.defense = 4; if (CalamityWorld.downedPolterghast) diff --git a/NPCs/AcidRain/CragmawMire.cs b/NPCs/AcidRain/CragmawMire.cs index c382815ce4..c0e1f9ca38 100644 --- a/NPCs/AcidRain/CragmawMire.cs +++ b/NPCs/AcidRain/CragmawMire.cs @@ -28,13 +28,13 @@ namespace CalamityMod.NPCs.AcidRain npc.aiStyle = aiType = -1; npc.damage = 66; - npc.lifeMax = 11000; + npc.lifeMax = 6000; npc.defense = 25; if (CalamityWorld.downedPolterghast) { npc.damage = 160; - npc.lifeMax = 216600; + npc.lifeMax = 146600; npc.defense = 80; } @@ -65,7 +65,7 @@ namespace CalamityMod.NPCs.AcidRain npc.ai[0]++; - // Summons a spinning diamond of dust and a dust telegraph + // Summons a spinning spiral of dust and a dust telegraph if (npc.ai[0] % 420f > 240f && npc.ai[0] % 420f < 300f) { float vectorRotationAngle = (npc.ai[0] % 420f - 240f) / 60f * MathHelper.Pi * 4f; @@ -121,7 +121,7 @@ namespace CalamityMod.NPCs.AcidRain for (float k = 0f; k < 20f; ++k) { Vector2 randomCirclePointLerped = Vector2.Lerp(circlePointVector, randomCirclePointRotated, k / 20f); - float lerpMultiplier = MathHelper.Lerp(lerpStart, lerpEnd, k / 20f) * 1.4f; + float lerpMultiplier = MathHelper.Lerp(lerpStart, lerpEnd, k / 20f) * 0.9f; int dustIndex = Dust.NewDust(npc.Top + 6f * Vector2.UnitY, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1.3f); @@ -135,41 +135,6 @@ namespace CalamityMod.NPCs.AcidRain } } } - // Near copy-pasta of the Gamma slime's hyper-complex dust code - if (npc.ai[0] % 420f > 300f) - { - float angle = npc.ai[0] / 20f; - float x = (float)Math.Sin(angle * npc.ai[1]) * (float)Math.Cos(angle); - float y = (float)Math.Cos(angle * npc.ai[2]) * (float)Math.Sin(angle); - for (int i = 0; i < 3; i++) - { - Vector2 velocity = new Vector2(x * 7f, y * 4f).RotatedBy(MathHelper.TwoPi / 3f * i); - Dust dust = Dust.NewDustPerfect(npc.Top + 6f * Vector2.UnitY + angle.ToRotationVector2() * 8f, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = velocity; - dust.scale = (float)Math.Cos(angle) + 2.5f; - dust.noGravity = true; - - dust = Dust.NewDustPerfect(npc.Top + 6f * Vector2.UnitY + angle.ToRotationVector2() * 8f, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = -velocity; - dust.scale = (float)Math.Cos(angle) + 2.5f; - dust.noGravity = true; - } - if (npc.ai[0] % 420f < 360f) - { - float length = 1100f - 1100f * (npc.ai[0] % 420f - 300f) / 60f; - float outwardness = 1f - (npc.ai[0] % 420f - 300f) / 60f; - for (float i = npc.Top.Y + 4f; i >= npc.Top.Y + 4f - length; i -= 6f) - { - angle = i / 32f; - float vectorRotationAngle = -(i / 20f) % 0.4f - 0.2f; - Vector2 spawnPosition = new Vector2(npc.Center.X, i); - Dust dust = Dust.NewDustPerfect(spawnPosition, (int)CalamityDusts.SulfurousSeaAcid); - dust.scale = 1.5f; - dust.velocity = (Vector2.UnitX * (float)Math.Cos(angle) * 4f * outwardness).RotatedBy(vectorRotationAngle); - dust.noGravity = true; - } - } - } if (!Phase2) { diff --git a/NPCs/AcidRain/NuclearToad.cs b/NPCs/AcidRain/NuclearToad.cs index a8ef52ed3e..d76f6c81f1 100644 --- a/NPCs/AcidRain/NuclearToad.cs +++ b/NPCs/AcidRain/NuclearToad.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.AcidRain npc.aiStyle = aiType = -1; npc.damage = 20; - npc.lifeMax = 250; + npc.lifeMax = 150; npc.defense = 3; if (CalamityWorld.downedPolterghast) diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 643032eb21..325bfc2acc 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -28,8 +28,8 @@ namespace CalamityMod.NPCs.AcidRain npc.height = 22; npc.aiStyle = aiType = -1; - npc.damage = 40; - npc.lifeMax = 360; + npc.damage = 28; + npc.lifeMax = 210; npc.defense = 6; if (CalamityWorld.downedPolterghast) diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index bbccc0ccc7..b5dca23115 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -22,8 +22,8 @@ namespace CalamityMod.NPCs.AcidRain npc.width = 26; npc.height = 14; - npc.damage = 56; - npc.lifeMax = 130; + npc.damage = 44; + npc.lifeMax = 90; npc.defense = 0; if (CalamityWorld.downedPolterghast) diff --git a/UI/AcidRainUI.cs b/UI/AcidRainUI.cs new file mode 100644 index 0000000000..9882b36085 --- /dev/null +++ b/UI/AcidRainUI.cs @@ -0,0 +1,68 @@ +using CalamityMod.Events; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.UI +{ + public static class AcidRainUI + { + public static void Draw(SpriteBatch spriteBatch) + { + bool draw = CalamityWorld.rainingAcid || CalamityWorld.acidRainExtraDrawTime > 0; + if ((draw && !Main.LocalPlayer.Calamity().ZoneSulphur) || + (!draw && Main.LocalPlayer.Calamity().ZoneSulphur)) + return; + + float progressAlpha = 1f; + Vector2 screenCoords = new Vector2(Main.screenWidth - 120, Main.screenHeight - 40); + int sizeX = (int)(200f * progressAlpha); + int sizeY = (int)(45f * progressAlpha); + Rectangle screenCoordsRectangle = + new Rectangle((int)screenCoords.X - sizeX / 2, + (int)screenCoords.Y - sizeY / 2, sizeX, sizeY); + Texture2D barTexture = Main.colorBarTexture; + + // If you touch the netcode behind this without a good reason your life will come to an abrupt end -Dominic + if (CalamityWorld.rainingAcid || CalamityWorld.acidRainExtraDrawTime > 0) + { + Utils.DrawInvBG(spriteBatch, screenCoordsRectangle, new Color(63, 65, 151, 255) * 0.785f); + + float progressRatio = 1f - CalamityWorld.AcidRainCompletionRatio; + string progressText = $"{((int)(100 * progressRatio)).ToString()}%"; + progressText = Language.GetTextValue("Game.WaveCleared", progressText); + spriteBatch.Draw(barTexture, screenCoords, null, Color.White, 0f, new Vector2(barTexture.Width / 2, 0f), progressAlpha, SpriteEffects.None, 0f); + Vector2 textMeasurement = Main.fontMouseText.MeasureString(progressText); + float adjustedAlpha = progressAlpha; + if (textMeasurement.Y > 22f) + { + adjustedAlpha *= 22f / textMeasurement.Y; + } + float barDrawOffsetX = 169f * progressAlpha; + float scaleY = 8f * progressAlpha; + Vector2 barDrawPosition = screenCoords + Vector2.UnitY * scaleY + Vector2.UnitX * 1f; + Utils.DrawBorderString(spriteBatch, progressText, barDrawPosition + new Vector2(0f, -4f), Color.White, adjustedAlpha, 0.5f, 1f, -1); + barDrawPosition += Vector2.UnitX * (progressRatio - 0.5f) * barDrawOffsetX; + spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 241, 51), 0f, new Vector2(1f, 0.5f), new Vector2(barDrawOffsetX * progressRatio, scaleY), SpriteEffects.None, 0f); + spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), new Color(255, 165, 0, 127), 0f, new Vector2(1f, 0.5f), new Vector2(2f, scaleY), SpriteEffects.None, 0f); + spriteBatch.Draw(Main.magicPixel, barDrawPosition, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black, 0f, new Vector2(0f, 0.5f), new Vector2(barDrawOffsetX * (1f - progressRatio), scaleY), SpriteEffects.None, 0f); + + string invasionNameText = "Acid Rain"; + Vector2 textMeasurement2 = Main.fontMouseText.MeasureString(invasionNameText); + float x = 120f; + if (textMeasurement2.X > 200f) + { + x += textMeasurement2.X - 200f; + } + Texture2D iconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/AcidRainIcon"); + Rectangle iconRectangle = Utils.CenteredRectangle(new Vector2(Main.screenWidth - x, Main.screenHeight - 80), (textMeasurement2 + new Vector2(iconTexture.Width + 12, 6f)) * progressAlpha); + Utils.DrawInvBG(spriteBatch, iconRectangle, AcidRainEvent.TextColor * 0.5f); + spriteBatch.Draw(iconTexture, iconRectangle.Left() + Vector2.UnitX * progressAlpha * 8f, null, Color.White, 0f, new Vector2(0f, iconTexture.Height / 2), progressAlpha * 0.8f, SpriteEffects.None, 0f); + Utils.DrawBorderString(spriteBatch, invasionNameText, iconRectangle.Right() + Vector2.UnitX * progressAlpha * -22f, Color.White, progressAlpha * 0.9f, 1f, 0.4f, -1); + } + } + } +} diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 6f489ffd9c..f3593ba3e0 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -952,27 +952,34 @@ namespace CalamityMod.World Main.invasionProgressNearInvasion = true; // Summon Old Duke tornado post-Polter as needed - if (downedPolterghast && acidRainPoints == 2f && - !NPC.AnyNPCs(ModContent.NPCType()) && - CalamityUtils.CountProjectiles(ModContent.ProjectileType()) <= 0) + if (downedPolterghast && acidRainPoints == 2f) { - if (triedToSummonOldDuke) + if (!NPC.AnyNPCs(ModContent.NPCType()) && + CalamityUtils.CountProjectiles(ModContent.ProjectileType()) <= 0) { - acidRainPoints = 0; - triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - else - { - int playerClosestToAbyss = Player.FindClosest(new Vector2(abyssSide ? 0 : Main.maxTilesX * 16, (int)Main.worldSurface), 0, 0); - Player closestToAbyss = Main.player[playerClosestToAbyss]; - if (Main.netMode != NetmodeID.MultiplayerClient && Math.Abs(closestToAbyss.Center.X - (abyssSide ? 0 : Main.maxTilesX * 16)) <= 12000f) + if (triedToSummonOldDuke) { - Projectile.NewProjectile(closestToAbyss.Center + Vector2.UnitY * 160f, Vector2.Zero, - ModContent.ProjectileType(), 120, 8f, Main.myPlayer); + acidRainPoints = 0; + triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } + else + { + int playerClosestToAbyss = Player.FindClosest(new Vector2(abyssSide ? 0 : Main.maxTilesX * 16, (int)Main.worldSurface), 0, 0); + Player closestToAbyss = Main.player[playerClosestToAbyss]; + if (Main.netMode != NetmodeID.MultiplayerClient && Math.Abs(closestToAbyss.Center.X - (abyssSide ? 0 : Main.maxTilesX * 16)) <= 12000f) + { + Projectile.NewProjectile(closestToAbyss.Center + Vector2.UnitY * 160f, Vector2.Zero, + ModContent.ProjectileType(), 120, 8f, Main.myPlayer); + } } } } + if (Main.invasionProgress != -1) + { + Main.invasionType = 0; + Main.invasionProgress = -1; + } } else {