diff --git a/Backgrounds/AstralDesertSurfaceBGStyle.cs b/Backgrounds/AstralDesertSurfaceBGStyle.cs index 51d1c01ef7..181f0d7222 100644 --- a/Backgrounds/AstralDesertSurfaceBGStyle.cs +++ b/Backgrounds/AstralDesertSurfaceBGStyle.cs @@ -1,22 +1,23 @@ -using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using System.Reflection; +using System; +using Terraria.Graphics.Effects; +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; namespace CalamityMod.Backgrounds { public class AstralDesertSurfaceBGStyle : ModSurfaceBackgroundStyle { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) - { - b -= 75f; - return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - } + internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic); + internal static readonly FieldInfo scAdjField = typeof(Main).GetField("scAdj", BindingFlags.Instance | BindingFlags.NonPublic); + internal static readonly FieldInfo COSBMAplhaField = typeof(Main).GetField("ColorOfSurfaceBackgroundsModified", BindingFlags.Static | BindingFlags.NonPublic); + readonly int CloseBGYOffset = 475; + readonly int MiddleBGYOffset = 475; public override void ModifyFarFades(float[] fades, float transitionSpeed) { - // This just fades in the background and fades out other backgrounds. for (int i = 0; i < fades.Length; i++) { if (i == Slot) @@ -33,5 +34,90 @@ namespace CalamityMod.Backgrounds } } } + + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceHorizon"); + + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralDesertSurfaceFar"); + + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Skies/AstralDesertSurfaceMiddle"); + + public override bool PreDrawCloseBackground(SpriteBatch spriteBatch) + { + //Please see AstralSurfaceBGStyle for comments, code is pretty much identical here + float screenOff = (float)screenOffField.GetValue(Main.instance); + float scAdj = (float)scAdjField.GetValue(Main.instance); + Color COSBMAplha = (Color)COSBMAplhaField.GetValue(null); + Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A); + bool canBGDraw = false; + if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen)) + canBGDraw = true; + if (Main.mapFullscreen) + canBGDraw = false; + int offset = 30; + if (Main.gameMenu) + offset = 0; + if (WorldGen.drunkWorldGen) + offset = -180; + float surfacePosition = (float)Main.worldSurface; + if (surfacePosition == 0f) + surfacePosition = 1f; + float screenPosition = Main.screenPosition.Y + (float)(Main.screenHeight / 2) - 600f; + double backgroundTopMagicNumber = (0f - screenPosition + screenOff / 2f) / (surfacePosition * 16f); + float bgGlobalScaleMultiplier = 2f; + int pushBGTopHack; + int offset2 = -180; + int menuOffset = 0; + if (Main.gameMenu) + { + menuOffset -= offset2; + } + pushBGTopHack = menuOffset; + pushBGTopHack += offset; + pushBGTopHack += offset2; + if (canBGDraw) + { + var bgScale = 1.25f; + var bgParallax = 0.4; + var bgTopY = (int)(backgroundTopMagicNumber * 1800.0 + 1500.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + var bgWidthScaled = (int)((float)CalamityMod.AstralDesertSurfaceMiddle.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1.2f / (float)bgParallax); + var bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + bgTopY = 320 + pushBGTopHack; + + var bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralDesertSurfaceMiddle, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + MiddleBGYOffset), new Rectangle(0, 0, CalamityMod.AstralDesertSurfaceMiddle.Width, CalamityMod.AstralDesertSurfaceMiddle.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + + bgScale = 1.31f; + bgParallax = 0.43; + bgTopY = (int)(backgroundTopMagicNumber * 1950.0 + 1750.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + bgWidthScaled = (int)((float)CalamityMod.AstralDesertSurfaceClose.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)bgParallax); + bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + { + bgTopY = 400 + pushBGTopHack; + bgStartX -= 80; + } + + bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralDesertSurfaceClose, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + CloseBGYOffset), new Rectangle(0, 0, CalamityMod.AstralDesertSurfaceClose.Width, CalamityMod.AstralDesertSurfaceClose.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + } + return false; + } } } diff --git a/Backgrounds/AstralDesertSurfaceFar.png b/Backgrounds/AstralDesertSurfaceFar.png index a2337a7d8f..e8b7a01e29 100644 Binary files a/Backgrounds/AstralDesertSurfaceFar.png and b/Backgrounds/AstralDesertSurfaceFar.png differ diff --git a/Backgrounds/AstralSnowSurfaceBGStyle.cs b/Backgrounds/AstralSnowSurfaceBGStyle.cs index 993decd710..239fc427b3 100644 --- a/Backgrounds/AstralSnowSurfaceBGStyle.cs +++ b/Backgrounds/AstralSnowSurfaceBGStyle.cs @@ -1,18 +1,25 @@ -using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using System.Reflection; +using System; +using Terraria.Graphics.Effects; +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Terraria.GameContent.UI.States; namespace CalamityMod.Backgrounds { public class AstralSnowSurfaceBGStyle : ModSurfaceBackgroundStyle { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic); + internal static readonly FieldInfo scAdjField = typeof(Main).GetField("scAdj", BindingFlags.Instance | BindingFlags.NonPublic); + internal static readonly FieldInfo COSBMAplhaField = typeof(Main).GetField("ColorOfSurfaceBackgroundsModified", BindingFlags.Static | BindingFlags.NonPublic); + readonly int FrontBGYOffset = 275; + readonly int CloseBGYOffset = 175; + readonly int MiddleBGYOffset = 475; public override void ModifyFarFades(float[] fades, float transitionSpeed) { - // This just fades in the background and fades out other backgrounds. for (int i = 0; i < fades.Length; i++) { if (i == Slot) @@ -29,5 +36,113 @@ namespace CalamityMod.Backgrounds } } } + + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceHorizon"); + + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceFar"); + + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Skies/AstralSnowSurfaceMiddle"); + + public override bool PreDrawCloseBackground(SpriteBatch spriteBatch) + { + //Please see AstralSurfaceBGStyle for comments, code is pretty much identical here + float screenOff = (float)screenOffField.GetValue(Main.instance); + float scAdj = (float)scAdjField.GetValue(Main.instance); + Color COSBMAplha = (Color)COSBMAplhaField.GetValue(null); + Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A); + bool canBGDraw = false; + if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen)) + canBGDraw = true; + if (Main.mapFullscreen) + canBGDraw = false; + int offset = 30; + if (Main.gameMenu) + offset = 0; + if (WorldGen.drunkWorldGen) + offset = -180; + float surfacePosition = (float)Main.worldSurface; + if (surfacePosition == 0f) + surfacePosition = 1f; + float screenPosition = Main.screenPosition.Y + (float)(Main.screenHeight / 2) - 600f; + double backgroundTopMagicNumber = (0f - screenPosition + screenOff / 2f) / (surfacePosition * 16f); + float bgGlobalScaleMultiplier = 2f; + int pushBGTopHack; + int offset2 = -180; + int menuOffset = 0; + if (Main.gameMenu) + { + menuOffset -= offset2; + } + pushBGTopHack = menuOffset; + pushBGTopHack += offset; + pushBGTopHack += offset2; + if (canBGDraw) + { + var bgScale = 1.25f; + var bgParallax = 0.4; + var bgTopY = (int)(backgroundTopMagicNumber * 1800.0 + 1500.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + var bgWidthScaled = (int)((float)CalamityMod.AstralSnowSurfaceMiddle.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1.2f / (float)bgParallax); + var bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + bgTopY = 320 + pushBGTopHack; + + var bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralSnowSurfaceMiddle, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + MiddleBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSnowSurfaceMiddle.Width, CalamityMod.AstralSnowSurfaceMiddle.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + + bgScale = 1.31f; + bgParallax = 0.43; + bgTopY = (int)(backgroundTopMagicNumber * 1950.0 + 1750.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + bgWidthScaled = (int)((float)CalamityMod.AstralSurfaceClose.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)bgParallax); + bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + { + bgTopY = 400 + pushBGTopHack; + bgStartX -= 80; + } + + bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceClose, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + CloseBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceClose.Width, CalamityMod.AstralSurfaceClose.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceCloseGlow, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + CloseBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceCloseGlow.Width, CalamityMod.AstralSurfaceCloseGlow.Height), new Color(Color.White.R * 0.7f, Color.White.G * 0.7f, Color.White.B * 0.7f, COSBMAplha.A), 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + bgScale = 1.34f; + bgParallax = 0.49; + bgTopY = (int)(backgroundTopMagicNumber * 2100.0 + 2000.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + bgWidthScaled = (int)(CalamityMod.AstralSurfaceFront.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)bgParallax); + bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + { + bgTopY = 480 + pushBGTopHack; + bgStartX -= 120; + } + + bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceFront, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + FrontBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceFront.Width, CalamityMod.AstralSurfaceFront.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceFrontGlow, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + FrontBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceFrontGlow.Width, CalamityMod.AstralSurfaceFrontGlow.Height), new Color(Color.White.R * 0.9f, Color.White.G * 0.9f, Color.White.B * 0.9f, COSBMAplha.A), 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + } + return false; + } } } diff --git a/Backgrounds/AstralSnowSurfaceFar.png b/Backgrounds/AstralSnowSurfaceFar.png deleted file mode 100644 index e1b3614aa8..0000000000 Binary files a/Backgrounds/AstralSnowSurfaceFar.png and /dev/null differ diff --git a/Backgrounds/AstralSnowSurfaceMiddle.png b/Backgrounds/AstralSnowSurfaceMiddle.png index fc7c678756..ff4e5fc236 100644 Binary files a/Backgrounds/AstralSnowSurfaceMiddle.png and b/Backgrounds/AstralSnowSurfaceMiddle.png differ diff --git a/Backgrounds/AstralSurfaceBGStyle.cs b/Backgrounds/AstralSurfaceBGStyle.cs index 8c8a7ee21c..c89092d701 100644 --- a/Backgrounds/AstralSurfaceBGStyle.cs +++ b/Backgrounds/AstralSurfaceBGStyle.cs @@ -1,22 +1,24 @@ -using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using System.Reflection; +using System; +using Terraria.Graphics.Effects; +using Terraria; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { public class AstralSurfaceBGStyle : ModSurfaceBackgroundStyle { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) - { - scale *= 0.75f; - return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - } + internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic); + internal static readonly FieldInfo scAdjField = typeof(Main).GetField("scAdj", BindingFlags.Instance | BindingFlags.NonPublic); + internal static readonly FieldInfo COSBMAplhaField = typeof(Main).GetField("ColorOfSurfaceBackgroundsModified", BindingFlags.Static | BindingFlags.NonPublic); + readonly int FrontBGYOffset = 275; //Offsets for the height positioning. Make these 0 for backgrounds that want to be the same as treeline backgrounds (backgrounds that have the front 3 layers as trees) + readonly int CloseBGYOffset = 175; + readonly int MiddleBGYOffset = 475; public override void ModifyFarFades(float[] fades, float transitionSpeed) { - // This just fades in the background and fades out other backgrounds. for (int i = 0; i < fades.Length; i++) { if (i == Slot) @@ -33,5 +35,120 @@ namespace CalamityMod.Backgrounds } } } + + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceHorizon"); //5th layer (Horizon) + + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceFar"); //4th layer (Far) + + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Skies/AstralSurfaceMiddle"); //Fallback texture, not nessesarily needed since predraw returns false + + public override bool PreDrawCloseBackground(SpriteBatch spriteBatch) //Taken from vanilla to draw the front 3 layers, edited to fit tmod and astral background needs + { + float screenOff = (float)screenOffField.GetValue(Main.instance); + float scAdj = (float)scAdjField.GetValue(Main.instance); + Color COSBMAplha = (Color)COSBMAplhaField.GetValue(null); + Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A); //Astral Biome Coloration with the alpha as the background fade + bool canBGDraw = false; + if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen)) + canBGDraw = true; + if (Main.mapFullscreen) + canBGDraw = false; + int offset = 30; + if (Main.gameMenu) + offset = 0; + if (WorldGen.drunkWorldGen) + offset = -180; + float surfacePosition = (float)Main.worldSurface; + if (surfacePosition == 0f) + surfacePosition = 1f; + float screenPosition = Main.screenPosition.Y + (float)(Main.screenHeight / 2) - 600f; + double backgroundTopMagicNumber = (0f - screenPosition + screenOff / 2f) / (surfacePosition * 16f); + float bgGlobalScaleMultiplier = 2f; + int pushBGTopHack; + int offset2 = -180; + int menuOffset = 0; + if (Main.gameMenu) + { + menuOffset -= offset2; + } + pushBGTopHack = menuOffset; + pushBGTopHack += offset; + pushBGTopHack += offset2; //Offsets to the background placement + if (canBGDraw) //If the background can draw (player is not in a remix world or is not in a map). This can probably be removed since backgrounds already go through these checks + { + //3rd layer (Middle) + var bgScale = 1.25f; //Scale of the furthest of the closest background layers (3rd layer) + var bgParallax = 0.4; //The parallax of the background layer + var bgTopY = (int)(backgroundTopMagicNumber * 1800.0 + 1500.0) + (int)scAdj + pushBGTopHack; //the Y position of the background + bgScale *= bgGlobalScaleMultiplier; //Scale of the background + var bgWidthScaled = (int)((float)CalamityMod.AstralSurfaceMiddle.Width * bgScale); //The Width of the bg texture scaled to the correct size + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1.2f / (float)bgParallax); + var bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); //The starting position of the background layer + if (Main.gameMenu) + bgTopY = 320 + pushBGTopHack; //increases the height in the main menu + + var bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + //Draw the texture and its glowmask to each loop of the texture + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceMiddle, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + MiddleBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceMiddle.Width, CalamityMod.AstralSurfaceMiddle.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceMiddleGlow, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + MiddleBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceMiddleGlow.Width, CalamityMod.AstralSurfaceMiddleGlow.Height), new Color(Color.White.R * 0.5f, Color.White.G * 0.5f, Color.White.B * 0.5f, COSBMAplha.A), 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + + //2nd layer (Close) + //Repeat of above with slight changes to variables + bgScale = 1.31f; + bgParallax = 0.43; + bgTopY = (int)(backgroundTopMagicNumber * 1950.0 + 1750.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + bgWidthScaled = (int)((float)CalamityMod.AstralSurfaceClose.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)bgParallax); + bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + { + bgTopY = 400 + pushBGTopHack; + bgStartX -= 80; //the initial postion of where the background starts in the main menu is pushed back to not be directly ontop, mostly for tree bgs that use the same treeline texture but faded + } + + bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceClose, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + CloseBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceClose.Width, CalamityMod.AstralSurfaceClose.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceCloseGlow, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + CloseBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceCloseGlow.Width, CalamityMod.AstralSurfaceCloseGlow.Height), new Color(Color.White.R * 0.7f, Color.White.G * 0.7f, Color.White.B * 0.7f, COSBMAplha.A), 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + + //1st layer (Front) + //Repeat of above with slight changes to variables + bgScale = 1.34f; + bgParallax = 0.49; + bgTopY = (int)(backgroundTopMagicNumber * 2100.0 + 2000.0) + (int)scAdj + pushBGTopHack; + bgScale *= bgGlobalScaleMultiplier; + bgWidthScaled = (int)(CalamityMod.AstralSurfaceFront.Width * bgScale); + SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)bgParallax); + bgStartX = (int)(0.0 - Math.IEEERemainder((double)Main.screenPosition.X * bgParallax, bgWidthScaled) - (double)(bgWidthScaled / 2)); + if (Main.gameMenu) + { + bgTopY = 480 + pushBGTopHack; + bgStartX -= 120; + } + + bgLoops = Main.screenWidth / bgWidthScaled + 2; + if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) + { + for (int i = 0; i < bgLoops; i++) + { + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceFront, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + FrontBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceFront.Width, CalamityMod.AstralSurfaceFront.Height), ColorOfSurfaceBackgroundsModified, 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(CalamityMod.AstralSurfaceFrontGlow, new Vector2(bgStartX + bgWidthScaled * i, bgTopY + FrontBGYOffset), new Rectangle(0, 0, CalamityMod.AstralSurfaceFrontGlow.Width, CalamityMod.AstralSurfaceFrontGlow.Height), new Color(Color.White.R * 0.9f, Color.White.G * 0.9f, Color.White.B * 0.9f, COSBMAplha.A), 0f, default(Vector2), bgScale, SpriteEffects.None, 0f); + } + } + } + return false; //Stop the drawing of the base close background texture (note: does NOT stop the drawing of the Middle and Far textures because tmodloader is slight stupid :blushing:) + } } } diff --git a/Backgrounds/AstralSurfaceClose.png b/Backgrounds/AstralSurfaceClose.png index 6701b9a71c..166e8bc48d 100644 Binary files a/Backgrounds/AstralSurfaceClose.png and b/Backgrounds/AstralSurfaceClose.png differ diff --git a/Skies/AstralSurfaceCloseGlow.png b/Backgrounds/AstralSurfaceCloseGlow.png similarity index 100% rename from Skies/AstralSurfaceCloseGlow.png rename to Backgrounds/AstralSurfaceCloseGlow.png diff --git a/Backgrounds/AstralSurfaceFar.png b/Backgrounds/AstralSurfaceFar.png index 9285cefdae..6e90155b16 100644 Binary files a/Backgrounds/AstralSurfaceFar.png and b/Backgrounds/AstralSurfaceFar.png differ diff --git a/Backgrounds/AstralSurfaceFogBGStyle.cs b/Backgrounds/AstralSurfaceFogBGStyle.cs deleted file mode 100644 index aab1ea3fba..0000000000 --- a/Backgrounds/AstralSurfaceFogBGStyle.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Terraria.ModLoader; - -namespace CalamityMod.Backgrounds -{ - public class AstralSurfaceFogBGStyle : ModSurfaceBackgroundStyle - { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - - public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) - { - scale *= 0.75f; - return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - } - - public override void ModifyFarFades(float[] fades, float transitionSpeed) - { - // This just fades in the background and fades out other backgrounds. - for (int i = 0; i < fades.Length; i++) - { - if (i == Slot) - { - fades[i] += transitionSpeed; - if (fades[i] > 1f) - fades[i] = 1f; - } - else - { - fades[i] -= transitionSpeed; - if (fades[i] < 0f) - fades[i] = 0f; - } - } - } - } -} diff --git a/Backgrounds/AstralSurfaceFront.png b/Backgrounds/AstralSurfaceFront.png new file mode 100644 index 0000000000..5d603a737b Binary files /dev/null and b/Backgrounds/AstralSurfaceFront.png differ diff --git a/Skies/AstralSurfaceFrontGlow.png b/Backgrounds/AstralSurfaceFrontGlow.png similarity index 100% rename from Skies/AstralSurfaceFrontGlow.png rename to Backgrounds/AstralSurfaceFrontGlow.png diff --git a/Backgrounds/AstralSurfaceHorizon.png b/Backgrounds/AstralSurfaceHorizon.png new file mode 100644 index 0000000000..fa58141a90 Binary files /dev/null and b/Backgrounds/AstralSurfaceHorizon.png differ diff --git a/Backgrounds/AstralSurfaceMiddle.png b/Backgrounds/AstralSurfaceMiddle.png index 89b568c3be..d3f984c001 100644 Binary files a/Backgrounds/AstralSurfaceMiddle.png and b/Backgrounds/AstralSurfaceMiddle.png differ diff --git a/Skies/AstralSurfaceMiddleGlow.png b/Backgrounds/AstralSurfaceMiddleGlow.png similarity index 100% rename from Skies/AstralSurfaceMiddleGlow.png rename to Backgrounds/AstralSurfaceMiddleGlow.png diff --git a/Backgrounds/AstralUG4_0.png b/Backgrounds/AstralUG4_0.png new file mode 100644 index 0000000000..73f3bad550 Binary files /dev/null and b/Backgrounds/AstralUG4_0.png differ diff --git a/Backgrounds/AstralUG4_1.png b/Backgrounds/AstralUG4_1.png new file mode 100644 index 0000000000..bf9978ceeb Binary files /dev/null and b/Backgrounds/AstralUG4_1.png differ diff --git a/Backgrounds/AstralUG4_2.png b/Backgrounds/AstralUG4_2.png new file mode 100644 index 0000000000..b36e95b213 Binary files /dev/null and b/Backgrounds/AstralUG4_2.png differ diff --git a/Backgrounds/AstralUndergroundBGStyle.cs b/Backgrounds/AstralUndergroundBGStyle.cs index 71f1ec2c50..f3c9455798 100644 --- a/Backgrounds/AstralUndergroundBGStyle.cs +++ b/Backgrounds/AstralUndergroundBGStyle.cs @@ -1,4 +1,5 @@ -using Terraria.ModLoader; +using Terraria; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { @@ -6,8 +7,8 @@ namespace CalamityMod.Backgrounds { public override void FillTextureArray(int[] textureSlots) { - for (int i = 0; i <= 3; i++) - textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralUG" + i.ToString()); + for (int i = 0; i <= 4; i++) + textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot(i == 4 ? "CalamityMod/Backgrounds/AstralUG" + i.ToString() + "_" + Main.hellBackStyle : "CalamityMod/Backgrounds/AstralUG" + i.ToString()); } } } diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 8bd7f64dfe..3daca26a39 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -321,10 +321,6 @@ namespace CalamityMod.Balancing #endregion #region Old Duke - // 60% resist to The Last Mourning's projectiles. - // This will technically catch pumpkins from The Horseman's Blade but that shouldn't really matter. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.4f, ProjectileType(), ProjectileID.FlamingJack))); - // 20% resist to Time Bolt. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.8f, ProjectileType()))); #endregion @@ -414,6 +410,9 @@ namespace CalamityMod.Balancing // 50% resist to Tarragon Throwing Dart's thorns. (LOL) NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + // 50% resist to Omicron's beam. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + // 50% resist to Vehemence's skulls. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 2bc76824c8..5087a7a6cf 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -16,6 +16,17 @@ // Altered jump speed boost provided by Shiny Red Balloon via IL edit // This is a const because it replaces a hardcoded value in vanilla internal const float BalloonJumpSpeedBoost = 0.75f; + + // Altered movement stats provided by Shadow Armor via IL edit + // This item is modified to not stack with Magiluminescence if on the ground. If in the air, it still functions. + internal static readonly float ShadowArmorRunAccelerationMultiplier = 1.25f; // Vanilla and Magi = 1.75f + internal static readonly float ShadowArmorMaxRunSpeedMultiplier = 1.05f; // Vanilla and Magi = 1.15f + internal static readonly float ShadowArmorAccRunSpeedMultiplier = 1.05f; // Vanilla and Magi = 1.15f + internal static readonly float ShadowArmorRunSlowdownMultiplier = 1.5f; // Vanilla and Magi = 1.75f + + // Altered run acceleration multiplier provided by Soaring Insignia via IL edit + // This is a const because it replaces a hardcoded value in vanilla + internal const float SoaringInsigniaRunAccelerationMultiplier = 1.1f; // Vanilla = 1.75f #endregion #region Immunity Frames @@ -218,7 +229,7 @@ internal static readonly float AdrenalineDRPerBooster = 0.05f; // +5% per booster internal static readonly int AdrenalinePauseAfterDamage = CalamityUtils.SecondsToFrames(1); - internal static readonly float MinimumAdrenalineLoss = 0.1f; // No matter how small a hit, you will always lose at least 10% current Adrenaline + internal static readonly float MinimumAdrenalineLoss = 0.25f; // No matter how small a hit, you will always lose at least 25% current Adrenaline internal static readonly float AdrenalineFalloffTinyHitHealthRatio = 0.05f; // Hits for 5% max HP or less result in less Adrenaline loss internal static readonly float TrueMeleeRipperReductionFactor = 0.5f; // True melee benefits less from rippers to prevent excessive melting. diff --git a/BiomeManagers/AbovegroundAstralBiome.cs b/BiomeManagers/AbovegroundAstralBiome.cs deleted file mode 100644 index aea59f5567..0000000000 --- a/BiomeManagers/AbovegroundAstralBiome.cs +++ /dev/null @@ -1,34 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Systems; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.BiomeManagers -{ - public class AbovegroundAstralBiome : ModBiome - { - public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/AstralWater"); - public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle => ModContent.Find("CalamityMod/AstralSurfaceFogBGStyle"); - public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/AstralUndergroundBGStyle"); - public override int BiomeTorchItemType => ModContent.ItemType(); - public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; - public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbovegroundAstralBiomeIcon"; - public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - - public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("AstralInfection") ?? MusicID.Space; - - public override bool IsBiomeActive(Player player) - { - return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950; - } - - public override void SpecialVisuals(Player player, bool isActive) - { - player.ManageSpecialBiomeVisuals("CalamityMod:Astral", isActive); - - } - } -} diff --git a/BiomeManagers/AbovegroundAstralBiomeSurface.cs b/BiomeManagers/AbovegroundAstralBiomeSurface.cs deleted file mode 100644 index d68e9ed700..0000000000 --- a/BiomeManagers/AbovegroundAstralBiomeSurface.cs +++ /dev/null @@ -1,41 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Systems; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.BiomeManagers -{ - public class AbovegroundAstralBiomeSurface : ModBiome - { - public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/AstralWater"); - public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle => ModContent.Find("CalamityMod/AstralSurfaceBGStyle"); - public override int BiomeTorchItemType => ModContent.ItemType(); - public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; - public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - - public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("AstralInfection") ?? MusicID.Space; - - public override bool IsBiomeActive(Player player) - { - return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && !player.ZoneSnow && !player.ZoneDesert; - } - - public override void SpecialVisuals(Player player, bool isActive) - { - if (SkyManager.Instance["CalamityMod:AstralSurface"] != null && isActive != SkyManager.Instance["CalamityMod:AstralSurface"].IsActive()) - { - if (isActive) - { - SkyManager.Instance.Activate("CalamityMod:AstralSurface"); - } - else - { - SkyManager.Instance.Deactivate("CalamityMod:AstralSurface"); - } - } - } - - } -} diff --git a/BiomeManagers/AbovegroundAstralDesertBiome.cs b/BiomeManagers/AbovegroundAstralDesertBiome.cs deleted file mode 100644 index 37058fdce9..0000000000 --- a/BiomeManagers/AbovegroundAstralDesertBiome.cs +++ /dev/null @@ -1,43 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Systems; -using Terraria; -using Terraria.GameContent.Events; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.BiomeManagers -{ - public class AbovegroundAstralDesertBiome : ModBiome - { - public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/AstralWater"); - public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle => ModContent.Find("CalamityMod/AstralDesertSurfaceBGStyle"); - public override int BiomeTorchItemType => ModContent.ItemType(); - public override SceneEffectPriority Priority => Sandstorm.Happening && !(Main.slimeRain || Main.eclipse) ? SceneEffectPriority.Environment : SceneEffectPriority.BiomeHigh; - public override string BestiaryIcon => "CalamityMod/BiomeManagers/AstralDesertIcon"; - // Could use its own unique background - public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("AstralInfection") ?? MusicID.Space; - - public override bool IsBiomeActive(Player player) - { - return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && player.ZoneDesert && !player.ZoneSnow; - } - - public override void SpecialVisuals(Player player, bool isActive) - { - if (SkyManager.Instance["CalamityMod:AstralDesert"] != null && isActive != SkyManager.Instance["CalamityMod:AstralDesert"].IsActive()) - { - if (isActive) - { - SkyManager.Instance.Activate("CalamityMod:AstralDesert"); - } - else - { - SkyManager.Instance.Deactivate("CalamityMod:AstralDesert"); - } - } - } - } -} diff --git a/BiomeManagers/AbovegroundAstralSnowBiome.cs b/BiomeManagers/AbovegroundAstralSnowBiome.cs deleted file mode 100644 index 029513ce91..0000000000 --- a/BiomeManagers/AbovegroundAstralSnowBiome.cs +++ /dev/null @@ -1,41 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Systems; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.BiomeManagers -{ - public class AbovegroundAstralSnowBiome : ModBiome - { - public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/AstralWater"); - public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle => ModContent.Find("CalamityMod/AstralSnowSurfaceBGStyle"); - public override int BiomeTorchItemType => ModContent.ItemType(); - public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; - public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - - public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("AstralInfection") ?? MusicID.Space; - - public override bool IsBiomeActive(Player player) - { - return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && player.ZoneSnow; - } - - public override void SpecialVisuals(Player player, bool isActive) - { - if (SkyManager.Instance["CalamityMod:AstralSnow"] != null && isActive != SkyManager.Instance["CalamityMod:AstralSnow"].IsActive()) - { - if (isActive) - { - SkyManager.Instance.Activate("CalamityMod:AstralSnow"); - } - else - { - SkyManager.Instance.Deactivate("CalamityMod:AstralSnow"); - } - } - } - - } -} diff --git a/BiomeManagers/AstralInfectionBiome.cs b/BiomeManagers/AstralInfectionBiome.cs new file mode 100644 index 0000000000..980d34e0da --- /dev/null +++ b/BiomeManagers/AstralInfectionBiome.cs @@ -0,0 +1,112 @@ +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; +using Terraria; +using Terraria.GameContent.Events; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class AstralInfectionBiome : ModBiome + { + public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/AstralWater"); + + public override ModSurfaceBackgroundStyle SurfaceBackgroundStyle + { + get + { + if (Main.LocalPlayer.ZoneSnow) //Snow + { + return ModContent.Find("CalamityMod/AstralSnowSurfaceBGStyle"); + } + else if (Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow) //Desert + { + return ModContent.Find("CalamityMod/AstralDesertSurfaceBGStyle"); + } + else //surface + { + return ModContent.Find("CalamityMod/AstralSurfaceBGStyle"); + } + } + } + + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle + { + get + { + if (Main.LocalPlayer.ZoneSnow) + { + return ModContent.Find("CalamityMod/AstralUndergroundBGStyle"); // Could use its own unique background + } + return ModContent.Find("CalamityMod/AstralUndergroundBGStyle"); + } + } + + public override int BiomeTorchItemType => ModContent.ItemType(); + + public override SceneEffectPriority Priority + { + get + { + if (Main.LocalPlayer.ZoneDesert && Sandstorm.Happening && !(Main.LocalPlayer.ZoneSnow || Main.slimeRain || Main.eclipse)) + { + return SceneEffectPriority.Environment; + } + else + { + return SceneEffectPriority.BiomeHigh; + } + } + } + + public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbovegroundAstralBiomeIcon"; + + public override string BackgroundPath + { + get + { + if (Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow) + { + //desert + return "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; // Could use its own unique background + } + else if (Main.LocalPlayer.ZoneDirtLayerHeight || Main.LocalPlayer.ZoneRockLayerHeight || Main.LocalPlayer.ZoneUnderworldHeight) + { + //underground + return "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; // Could use its own unique background + } + else + { + return "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + } + } + } + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + + public override int Music + { + get + { + if (Main.LocalPlayer.ZoneDirtLayerHeight || Main.LocalPlayer.ZoneRockLayerHeight || Main.LocalPlayer.ZoneUnderworldHeight) + { + return CalamityMod.Instance.GetMusicFromMusicMod("AstralInfectionUnderground") ?? MusicID.Space; + } + return CalamityMod.Instance.GetMusicFromMusicMod("AstralInfection") ?? MusicID.Space; + } + } + + public override bool IsBiomeActive(Player player) + { + return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950; + } + + public override void SpecialVisuals(Player player, bool isActive) + { + player.ManageSpecialBiomeVisuals("CalamityMod:Astral", isActive); + if (Main.LocalPlayer.ZoneDirtLayerHeight || Main.LocalPlayer.ZoneRockLayerHeight || Main.LocalPlayer.ZoneUnderworldHeight) + { + player.ManageSpecialBiomeVisuals("CalamityMod:Astral", isActive); //underground + } + } + } +} diff --git a/BiomeManagers/AcidRainBiome.cs b/BiomeManagers/BestiaryCategories/AcidRainBiome.cs similarity index 100% rename from BiomeManagers/AcidRainBiome.cs rename to BiomeManagers/BestiaryCategories/AcidRainBiome.cs diff --git a/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs b/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs new file mode 100644 index 0000000000..8f7d2a9a30 --- /dev/null +++ b/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs @@ -0,0 +1,11 @@ +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers.BestiaryCategories +{ + public class AstralCaveDesert : ModBiome //Unused, currently + { + public override string BestiaryIcon => "CalamityMod/BiomeManagers/AstralCaveDesertIcon"; + + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + } +} diff --git a/BiomeManagers/BestiaryCategories/AstralDesert.cs b/BiomeManagers/BestiaryCategories/AstralDesert.cs new file mode 100644 index 0000000000..29b0a3f907 --- /dev/null +++ b/BiomeManagers/BestiaryCategories/AstralDesert.cs @@ -0,0 +1,11 @@ +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers.BestiaryCategories +{ + public class AstralDesert : ModBiome + { + public override string BestiaryIcon => "CalamityMod/BiomeManagers/AstralDesertIcon"; + + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + } +} diff --git a/BiomeManagers/BestiaryCategories/AstralIce.cs b/BiomeManagers/BestiaryCategories/AstralIce.cs new file mode 100644 index 0000000000..f478ae1ee9 --- /dev/null +++ b/BiomeManagers/BestiaryCategories/AstralIce.cs @@ -0,0 +1,11 @@ +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers.BestiaryCategories +{ + public class AstralIce : ModBiome //Unused, currently + { + public override string BestiaryIcon => "CalamityMod/BiomeManagers/AstralIceIcon"; + + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + } +} diff --git a/BiomeManagers/BestiaryCategories/AstralUnderground.cs b/BiomeManagers/BestiaryCategories/AstralUnderground.cs new file mode 100644 index 0000000000..42d924fd5b --- /dev/null +++ b/BiomeManagers/BestiaryCategories/AstralUnderground.cs @@ -0,0 +1,11 @@ +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers.BestiaryCategories +{ + public class AstralUnderground : ModBiome + { + public override string BestiaryIcon => "CalamityMod/BiomeManagers/UndergroundAstralIcon"; + + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + } +} diff --git a/BiomeManagers/UndergroundAstralBiome.cs b/BiomeManagers/UndergroundAstralBiome.cs deleted file mode 100644 index f83a02d83f..0000000000 --- a/BiomeManagers/UndergroundAstralBiome.cs +++ /dev/null @@ -1,33 +0,0 @@ -using CalamityMod.Systems; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.BiomeManagers -{ - public class UndergroundAstralBiome : ModBiome - { - public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/AstralWater"); - public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/AstralUndergroundBGStyle"); - public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; - public override string BestiaryIcon => "CalamityMod/BiomeManagers/UndergroundAstralIcon"; - // Could use its own unique background - public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; - - public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("AstralInfectionUnderground") ?? MusicID.Space; - - public override bool IsBiomeActive(Player player) - { - return !player.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && (player.ZoneDirtLayerHeight || player.ZoneRockLayerHeight || player.ZoneUnderworldHeight); - } - - public override void SpecialVisuals(Player player, bool isActive) - { - player.ManageSpecialBiomeVisuals("CalamityMod:Astral", isActive); - } - - // Just slightly above the above-ground astral biomes. - public override float GetWeight(Player player) => 0.51f; - } -} diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 127d379201..fbafda6416 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -190,6 +190,7 @@ namespace CalamityMod.CalPlayer public int PHAThammer = 0; public int StellarHammer = 0; public int GalaxyHammer = 0; + public int NorfleetCounter = 0; public int hideOfDeusMeleeBoostTimer = 0; public int alcoholPoisonLevel = 0; public int modStealthTimer; @@ -574,10 +575,13 @@ namespace CalamityMod.CalPlayer public bool bloodPactBoost = false; public bool bloodflareCore = false; public int bloodflareCoreRemainingHealOverTime = 0; + public bool chaliceOfTheBloodGod = false; public double chaliceBleedoutBuffer = 0D; public double chaliceDamagePointPartialProgress = 0D; + public int chaliceBleedoutToApplyOnHurt = 0; public int chaliceHitOriginalDamage = 0; + public bool elementalHeart = false; public bool crownJewel = false; public bool infectedJewel = false; @@ -593,6 +597,8 @@ namespace CalamityMod.CalPlayer public bool anechoicPlating = false; public bool jellyfishNecklace = false; public bool fairyBoots = false; + public bool flameWakerBoots = false; + public int bootLevel = 0; //Used to prevent Flame Waker and Hellfire Treads stacking public bool hellfireTreads = false; public bool abyssalAmulet = false; public bool lumenousAmulet = false; @@ -1087,10 +1093,7 @@ namespace CalamityMod.CalPlayer #region Biome public bool ZoneCalamity => Player.InModBiome(ModContent.GetInstance()); - public bool ZoneAstral => (Player.InModBiome(ModContent.GetInstance()) || - Player.InModBiome(ModContent.GetInstance()) || - Player.InModBiome(ModContent.GetInstance()) || - Player.InModBiome(ModContent.GetInstance())) && !ZoneAbyss; + public bool ZoneAstral => Player.InModBiome(ModContent.GetInstance()) && !ZoneAbyss; public bool ZoneSunkenSea => Player.InModBiome(ModContent.GetInstance()); public bool ZoneSulphur => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyss => ZoneAbyssLayer1 || ZoneAbyssLayer2 || ZoneAbyssLayer3 || ZoneAbyssLayer4; @@ -1722,6 +1725,7 @@ namespace CalamityMod.CalPlayer bloodPact = false; bloodflareCore = false; chaliceOfTheBloodGod = false; + chaliceBleedoutToApplyOnHurt = 0; // Resets every frame so it doesn't improperly carry over between hits elementalHeart = false; crownJewel = false; infectedJewel = false; @@ -1816,6 +1820,7 @@ namespace CalamityMod.CalPlayer anechoicPlating = false; jellyfishNecklace = false; fairyBoots = false; + flameWakerBoots = false; hellfireTreads = false; abyssalAmulet = false; lumenousAmulet = false; @@ -2148,11 +2153,13 @@ namespace CalamityMod.CalPlayer StellarTorus = false; LiliesOfFinalityBool = false; + /* disableVoodooSpawns = false; disablePerfCystSpawns = false; disableHiveCystSpawns = false; disableNaturalScourgeSpawns = false; disableAnahitaSpawns = false; + */ abyssalDivingSuitPrevious = abyssalDivingSuit; abyssalDivingSuit = abyssalDivingSuitHide = abyssalDivingSuitForce = abyssalDivingSuitPower = false; @@ -2975,10 +2982,9 @@ namespace CalamityMod.CalPlayer } if (Main.netMode != NetmodeID.MultiplayerClient) { - for (int l = 0; l < Main.maxNPCs; l++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[l]; - if (npc.active && !npc.friendly && !npc.dontTakeDamage && Vector2.Distance(Player.Center, npc.Center) <= 3000f) + if (!npc.friendly && !npc.dontTakeDamage && Vector2.Distance(Player.Center, npc.Center) <= 3000f) npc.AddBuff(ModContent.BuffType(), 600, false); } } @@ -4765,22 +4771,22 @@ namespace CalamityMod.CalPlayer { int spearsFired = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { if (spearsFired == 2) break; - if (Main.projectile[i].owner == Player.whoAmI && Main.projectile[i].friendly) + if (p.owner == Player.whoAmI && p.friendly) { - bool attack = Main.projectile[i].owner == Player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType(); + bool attack = p.type == ModContent.ProjectileType(); if (attack) { int numSpears = profanedCrystalBuffs ? 12 : 6; - int dam = (int)(Main.projectile[i].originalDamage * (profanedCrystalBuffs ? 1f : 0.25f)); + int dam = (int)(p.originalDamage * (profanedCrystalBuffs ? 1f : 0.25f)); for (int x = 0; x < numSpears; x++) { float angle = MathHelper.TwoPi / numSpears * x; - int proj = Projectile.NewProjectile(source, Main.projectile[i].Center, angle.ToRotationVector2().RotatedBy(Math.Atan(-45f)) * 8f, ModContent.ProjectileType(), dam, 0f, Player.whoAmI, pscState, 0f); + int proj = Projectile.NewProjectile(source, p.Center, angle.ToRotationVector2().RotatedBy(Math.Atan(-45f)) * 8f, ModContent.ProjectileType(), dam, 0f, Player.whoAmI, pscState, 0f); Main.projectile[proj].originalDamage = dam; } spearsFired++; @@ -4869,7 +4875,7 @@ namespace CalamityMod.CalPlayer // Set a random delay between 12 and 20 seconds. When this delay hits zero, startup messages display bool plushieMessage = true; - if (plushieMessage || (CalamityMod.Instance.musicMod is null && CalamityConfig.Instance.MusicModReminderMessage) || CalamityConfig.Instance.WikiStatusMessage) + if (plushieMessage || CalamityConfig.Instance.WikiStatusMessage) { startMessageDisplayDelay = Main.rand.Next(CalamityUtils.SecondsToFrames(12), CalamityUtils.SecondsToFrames(20) + 1); } diff --git a/CalPlayer/CalamityPlayerDashEffects.cs b/CalPlayer/CalamityPlayerDashEffects.cs index 302f69fc37..279dff0a6d 100644 --- a/CalPlayer/CalamityPlayerDashEffects.cs +++ b/CalPlayer/CalamityPlayerDashEffects.cs @@ -72,15 +72,13 @@ namespace CalamityMod.CalPlayer if (HasCustomDash && Player.dashDelay < 0) { Rectangle hitArea = new Rectangle((int)(Player.position.X + Player.velocity.X * 0.5 - 4f), (int)(Player.position.Y + Player.velocity.Y * 0.5 - 4), Player.width + 8, Player.height + 8); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - NPC n = Main.npc[i]; - // Ignore critters with the Guide to Critter Companionship if (Player.dontHurtCritters && NPCID.Sets.CountsAsCritter[n.type]) continue; - if (n.active && !n.dontTakeDamage && !n.friendly && n.Calamity().dashImmunityTime[Player.whoAmI] <= 0) + if (!n.dontTakeDamage && !n.friendly && n.Calamity().dashImmunityTime[Player.whoAmI] <= 0) { if (hitArea.Intersects(n.getRect()) && (n.noTileCollide || Player.CanHit(n))) { @@ -543,15 +541,13 @@ namespace CalamityMod.CalPlayer public int DoMountDashDamage(Rectangle myRect, float Damage, float Knockback, int NPCImmuneTime, int PlayerImmuneTime) { int totalHurtNPCs = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - NPC n = Main.npc[i]; - // Ignore critters with the Guide to Critter Companionship if (Player.dontHurtCritters && NPCID.Sets.CountsAsCritter[n.type]) continue; - if (n.active && !n.dontTakeDamage && !n.friendly && n.Calamity().dashImmunityTime[Player.whoAmI] <= 0) + if (!n.dontTakeDamage && !n.friendly && n.Calamity().dashImmunityTime[Player.whoAmI] <= 0) { Rectangle npcHitbox = n.getRect(); if (myRect.Intersects(npcHitbox) && (n.noTileCollide || Collision.CanHit(Player.position, Player.width, Player.height, n.position, n.width, n.height))) diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index eed9b2b6ea..d5326f5e54 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -471,8 +471,14 @@ namespace CalamityMod.CalPlayer SpriteEffects spriteEffects = Player.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + int xOffset = 9; + // Photoviscerator's tank is extended a bit more out + if (thingToDraw == ModContent.Request("CalamityMod/CalPlayer/DrawLayers/Backpack_Photoviscerator").Value) + { + xOffset = 16; + } DrawData howDoIDrawThings = new DrawData(thingToDraw, - new Vector2((int)(drawPlayer.position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (9 * drawPlayer.direction)) - 4f * drawPlayer.direction, (int)(drawPlayer.position.Y - Main.screenPosition.Y + (drawPlayer.height / 2) + 2f * drawPlayer.gravDir - 8f * drawPlayer.gravDir)), + new Vector2((int)(drawPlayer.position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (xOffset * drawPlayer.direction)) - 4f * drawPlayer.direction, (int)(drawPlayer.position.Y - Main.screenPosition.Y + (drawPlayer.height / 2) + 2f * drawPlayer.gravDir - 8f * drawPlayer.gravDir + drawPlayer.gfxOffY)), new Rectangle(0, 0, thingToDraw.Width, thingToDraw.Height), drawInfo.colorArmorBody, drawPlayer.bodyRotation, diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 367f3910e9..7dad272e20 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -250,10 +250,10 @@ namespace CalamityMod.CalPlayer if (hInferno) { - for (int x = 0; x < Main.maxNPCs; x++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[x].active && Main.npc[x].type == ModContent.NPCType()) - Main.npc[x].active = false; + if (n.type == ModContent.NPCType()) + n.active = false; } } @@ -490,6 +490,10 @@ namespace CalamityMod.CalPlayer if (Main.zenithWorld) SoundEngine.PlaySound(LeonDeathNoiseRE4_ForGFB, Player.Center); + if (NorfleetCounter >= 3 && NorfleetCounter < 1000) + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Norfleet").Format(Player.name)); + NorfleetCounter = 0; + if (NPC.AnyNPCs(ModContent.NPCType())) { if (sCalDeathCount < 51) @@ -1469,15 +1473,13 @@ namespace CalamityMod.CalPlayer // This also strikes the NPCs as a side effect if (gSabatonFalling) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - NPC n = Main.npc[i]; - // Ignore critters with the Guide to Critter Companionship if (Player.dontHurtCritters && NPCID.Sets.CountsAsCritter[n.type]) continue; - if (n.active && !n.dontTakeDamage && !n.friendly && n.Calamity().dashImmunityTime[Player.whoAmI] <= 0) + if (!n.dontTakeDamage && !n.friendly && n.Calamity().dashImmunityTime[Player.whoAmI] <= 0) { Rectangle npcHitbox = n.getRect(); if ((Player.getRect()).Intersects(npcHitbox) && (n.noTileCollide || Collision.CanHit(Player.position, Player.width, Player.height, n.position, n.width, n.height))) @@ -1507,7 +1509,12 @@ namespace CalamityMod.CalPlayer // The dodges will only trigger if the player has taken greater than or equal to 5% of their max HP in damage double dodgeDamageGateValuePercent = 0.05; int dodgeDamageGateValue = (int)Math.Round(Player.statLifeMax2 * dodgeDamageGateValuePercent); - if (!Player.HasCooldown(GlobalDodge.ID) && info.Damage >= dodgeDamageGateValue) + + // 14MAY2024: Ozzatron: Chalice of the Blood God now works with dodges + int actualDamageTaken = chaliceOfTheBloodGod ? chaliceHitOriginalDamage : info.Damage; + bool sufficientDamageForDodging = actualDamageTaken >= dodgeDamageGateValue; + + if (!Player.HasCooldown(GlobalDodge.ID) && sufficientDamageForDodging) { double maxCooldownDurationDamagePercent = 0.5; int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); @@ -1516,7 +1523,7 @@ namespace CalamityMod.CalPlayer if (maxCooldownDurationDamageValue <= 0) maxCooldownDurationDamageValue = 1; - float cooldownDurationScalar = MathHelper.Clamp((info.Damage - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); + float cooldownDurationScalar = MathHelper.Clamp((actualDamageTaken - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); // Re-implementation of vanilla item Black Belt as a consumable dodge if (Player.whoAmI == Main.myPlayer && Player.blackBelt) @@ -1621,7 +1628,7 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(SoundID.NPCHit4, Player.Center); //metal hit noise hurtSoundTimer = 10; } - else if ((aquaticHeartPower || aquaticHeartForce) && !aquaticHeartHide) + else if (((aquaticHeartPower || aquaticHeartForce) && !aquaticHeartHide) || Player.GetModPlayer().vanityEquipped) { modifiers.DisableSound(); SoundEngine.PlaySound(SoundID.FemaleHit, Player.Center); //female hit noise @@ -1967,22 +1974,14 @@ namespace CalamityMod.CalPlayer // // Chalice of the Blood God does nothing to a hit that was just fully blocked by shields. // Otherwise, it reduces the damage of any hit to 5, which allows for full iframes. - // It then applies the full hit (minus that 5 damage) to its own bleedout buffer. + // It then applies the full hit (minus that 5 damage) to its own bleedout buffer in OnHurt (see below). // Hits for less than 5 damage are ignored entirely and allowed to strike the player as normal. if (chaliceOfTheBloodGod && !shieldsFullyAbsorbedHit && info.Damage > ChaliceOfTheBloodGod.MinAllowedDamage) { - int bleedoutToApply = info.Damage - ChaliceOfTheBloodGod.MinAllowedDamage; - chaliceBleedoutBuffer += bleedoutToApply; + chaliceBleedoutToApplyOnHurt = info.Damage - ChaliceOfTheBloodGod.MinAllowedDamage; + chaliceHitOriginalDamage = info.Damage; info.Damage = ChaliceOfTheBloodGod.MinAllowedDamage; - - // Defense damage is applied here. - DealDefenseDamage(info, bleedoutToApply); - - // Display text indicating that damage was transferred to bleedout. - string text = $"({-bleedoutToApply})"; - Rectangle location = new Rectangle((int)Player.position.X + 4, (int)Player.position.Y - 3, Player.width - 4, Player.height - 4); - CombatText.NewText(location, ChaliceOfTheBloodGod.BleedoutBufferDamageTextColor, Language.GetTextValue(text), dot: true); } } #endregion @@ -2004,7 +2003,7 @@ namespace CalamityMod.CalPlayer // This function will be ignored if the player is wearing Chalice, as it handles its defense damage elsewhere. bool hitCanApplyDefenseDamage = nextHitDealsDefenseDamage || bloodflareCore; - if (hitCanApplyDefenseDamage && !chaliceOfTheBloodGod && !hasIFrames && !Player.creativeGodMode) + if (hitCanApplyDefenseDamage && !hasIFrames && !Player.creativeGodMode) { double halfDefense = Player.statDefense / 2.0; int netMitigation = hurtInfo.SourceDamage - hurtInfo.Damage; @@ -2035,6 +2034,12 @@ namespace CalamityMod.CalPlayer Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi * 1.5f); } } + + // Chalice of the Blood God has to compensate for the "mitigation" provided by its bleedout buffer + else if (chaliceOfTheBloodGod) + DealDefenseDamage(hurtInfo, chaliceBleedoutToApplyOnHurt); + + // Otherwise, just deal regular defense damage. else DealDefenseDamage(hurtInfo); } @@ -2042,6 +2047,24 @@ namespace CalamityMod.CalPlayer nextHitDealsDefenseDamage = false; #endregion + #region Chalice of the Blood God Bleed Application + // This is handled in OnHurt so that Chalice hits can still be dodged based on their appropriate normal damage + // Defense damage based on the "total lethality of the hit" is applied immediately prior to this + // + // 1 - Actually apply bleedout to the player based on the damage they would have taken + // 2 - Display an indicator of how much damage was dealt as bleedout instead of regular damage + if (chaliceOfTheBloodGod) + { + int bleedoutToApply = chaliceBleedoutToApplyOnHurt; + chaliceBleedoutBuffer += bleedoutToApply; + + // Display text indicating that damage was transferred to bleedout. + string text = $"({-bleedoutToApply})"; + Rectangle location = new Rectangle((int)Player.position.X + 4, (int)Player.position.Y - 3, Player.width - 4, Player.height - 4); + CombatText.NewText(location, ChaliceOfTheBloodGod.BleedoutBufferDamageTextColor, Language.GetTextValue(text), dot: true); + } + #endregion + #region Shattered Community Rage Gain // Shattered Community makes the player gain rage based on the amount of damage taken. // Also set the Rage gain cooldown to prevent bizarre abuse cases. @@ -2265,10 +2288,9 @@ namespace CalamityMod.CalPlayer if (fBarrier || (aquaticHeart && NPC.downedBoss3)) { SoundEngine.PlaySound(SoundID.Item27, Player.Center); - for (int m = 0; m < Main.maxNPCs; m++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[m]; - if (!npc.active || npc.friendly || npc.dontTakeDamage) + if (npc.friendly || npc.dontTakeDamage) continue; float npcDist = (npc.Center - Player.Center).Length(); @@ -2292,10 +2314,9 @@ namespace CalamityMod.CalPlayer // and also doesn't have random chance (why does Brain of Confusion not guarantee confusion on hit) if (aBrain || amalgam) { - for (int m = 0; m < Main.maxNPCs; m++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[m]; - if (!npc.active || npc.friendly || npc.dontTakeDamage) + if (npc.friendly || npc.dontTakeDamage) continue; float npcDist = (npc.Center - Player.Center).Length(); @@ -2330,11 +2351,11 @@ namespace CalamityMod.CalPlayer if (Player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach(Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == Player.whoAmI) + if (p.type == ModContent.ProjectileType() && p.owner == Player.whoAmI) { - Main.projectile[i].Kill(); + p.Kill(); break; } } @@ -2760,9 +2781,8 @@ namespace CalamityMod.CalPlayer // Under typical circumstances, defense damage scales with "net mitigation", aka how much damage the player DIDN'T take. // Thematically, this means it scales with how much damage the player's defense took instead of them. - - CalamityPlayer modPlayer = Player.Calamity(); - + // Chalice of the Blood God makes you take much less direct damage than you should, which would catastrophically inflate defense damage. + // // Subtract the bleedout applied on this hit from the net mitigation. // This prevents Chalice from making the player take much more defense damage than intended. int netMitigation = hurtInfo.SourceDamage - (hurtInfo.Damage + bleedoutApplied); @@ -2808,6 +2828,10 @@ namespace CalamityMod.CalPlayer // Actually applies defense damage. Cannot be called externally. private void ApplyDefenseDamageInternal(int defenseDamage, bool showVisuals = true) { + // If zero defense damage is being dealt, don't waste your time or display a grey 0. + if (defenseDamage <= 0) + return; + // Can be dynamically reduced by Adamantite set bonus and maybe other future effects. int defenseDamageTaken = defenseDamage; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index eff4574d77..f72d05e4eb 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -452,10 +452,9 @@ namespace CalamityMod.CalPlayer float enemyDistance = maxProxRageDistance + 1f; float bossDistance = maxProxRageDistance + 1f; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc is null || npc.type == NPCID.None || !npc.IsAnEnemy() || !npc.Calamity().ProvidesProximityRage) + if (npc.type == NPCID.None || !npc.IsAnEnemy() || !npc.Calamity().ProvidesProximityRage) continue; // Take the longer of the two directions for the NPC's hitbox to be generous. @@ -719,10 +718,9 @@ namespace CalamityMod.CalPlayer sigilDamage = Player.ApplyArmorAccDamageBonusesTo(sigilDamage); bool brightenedSigil = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; - if (!target.active || !target.Hitbox.Intersects(sigilHitbox) || target.immortal || target.dontTakeDamage || target.townNPC || NPCID.Sets.ActsLikeTownNPC[target.type] || NPCID.Sets.CountsAsCritter[target.type]) + if (!target.Hitbox.Intersects(sigilHitbox) || target.immortal || target.dontTakeDamage || target.townNPC || NPCID.Sets.ActsLikeTownNPC[target.type] || NPCID.Sets.CountsAsCritter[target.type]) continue; // Brighten the sigil because it is dealing damage. This can only happen once per hit event. @@ -734,7 +732,7 @@ namespace CalamityMod.CalPlayer // Create a direct strike to hit this specific NPC. var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - Projectile sigilStrike = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sigilDamage, 0f, Player.whoAmI, i); + Projectile sigilStrike = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sigilDamage, 0f, Player.whoAmI, target.whoAmI); // Enable crits by setting the sigil's damage class to be whatever the player's strongest damage class is. sigilStrike.DamageType = Player.GetBestClass(); @@ -863,24 +861,23 @@ namespace CalamityMod.CalPlayer { int bullseyeType = ModContent.ProjectileType(); List alreadyTargetedNPCs = new List(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != bullseyeType || !Main.projectile[i].active || Main.projectile[i].owner != Player.whoAmI) + if (p.type != bullseyeType || p.owner != Player.whoAmI) continue; - alreadyTargetedNPCs.Add((int)Main.projectile[i].ai[0]); + alreadyTargetedNPCs.Add((int)p.ai[0]); } - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; - if (!target.active || target.friendly || target.lifeMax < 5 || alreadyTargetedNPCs.Contains(i) || target.realLife >= 0 || + if (target.friendly || target.lifeMax < 5 || alreadyTargetedNPCs.Contains(target.whoAmI) || target.realLife >= 0 || target.dontTakeDamage || target.immortal || target.townNPC || NPCID.Sets.ActsLikeTownNPC[target.type] || NPCID.Sets.CountsAsCritter[target.type]) continue; var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - if (Main.myPlayer == Player.whoAmI && Main.npc[i].WithinRange(Player.Center, 2000f)) - Projectile.NewProjectile(source, Main.npc[i].Center, Vector2.Zero, bullseyeType, 0, 0f, Player.whoAmI, i); + if (Main.myPlayer == Player.whoAmI && target.WithinRange(Player.Center, 2000f)) + Projectile.NewProjectile(source, target.Center, Vector2.Zero, bullseyeType, 0, 0f, Player.whoAmI, target.whoAmI); if (spiritOriginBullseyeShootCountdown <= 0) spiritOriginBullseyeShootCountdown = 45; } @@ -1142,10 +1139,9 @@ namespace CalamityMod.CalPlayer if (Player.ownedProjectileCounts[ModContent.ProjectileType()] < 6 && Main.myPlayer == Player.whoAmI) { bool[] tentaclesPresent = new bool[6]; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - Projectile projectile = Main.projectile[i]; - if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.owner == Main.myPlayer && projectile.ai[1] >= 0f && projectile.ai[1] < 6f) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Main.myPlayer && projectile.ai[1] >= 0f && projectile.ai[1] < 6f) tentaclesPresent[(int)projectile.ai[1]] = true; } @@ -1250,14 +1246,13 @@ namespace CalamityMod.CalPlayer { float maxDistance = 300f; int target = -1; - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[npcIndex]; float targetDist = Vector2.Distance(npc.Center, Player.Center); if (targetDist < maxDistance && npc.Calamity().arcZapCooldown == 0 && npc.CanBeChasedBy()) { maxDistance = targetDist; - target = npcIndex; + target = npc.whoAmI; } } @@ -1853,10 +1848,9 @@ namespace CalamityMod.CalPlayer { if (Main.rand.NextBool(5)) { - for (int l = 0; l < Main.maxNPCs; l++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[l]; - if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) + if (npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) continue; if (!npc.buffImmune[buffType] && Vector2.Distance(Player.Center, npc.Center) <= freezeDist) @@ -1902,10 +1896,9 @@ namespace CalamityMod.CalPlayer // Ceaseless Hunger Potion buff if (ceaselessHunger) { - for (int j = 0; j < Main.maxItems; j++) + foreach (Item item in Main.ActiveItems) { - Item item = Main.item[j]; - if (item.active && item.noGrabDelay == 0 && item.playerIndexTheItemIsReservedFor == Player.whoAmI) + if (item.noGrabDelay == 0 && item.playerIndexTheItemIsReservedFor == Player.whoAmI) { item.beingGrabbed = true; if (Player.Center.X > item.Center.X) @@ -2783,10 +2776,9 @@ namespace CalamityMod.CalPlayer { if (Main.netMode != NetmodeID.MultiplayerClient && !areThereAnyDamnBosses) { - for (int m = 0; m < Main.maxNPCs; m++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[m]; - if (!npc.active || npc.friendly || npc.dontTakeDamage) + if (npc.friendly || npc.dontTakeDamage) continue; float distance = (npc.Center - Player.Center).Length(); if (distance < 120f) @@ -3146,14 +3138,13 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_FromThis(TarragonHeadSummon.LifeAuraEntitySourceContext); float range = 300f; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.dontTakeDamage) + if (npc.friendly || npc.dontTakeDamage) continue; if (Vector2.Distance(Player.Center, npc.Center) <= range) - Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, i); + Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, npc.whoAmI); } } } @@ -3174,14 +3165,13 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_ItemUse(Player.ActiveItem()); float range = 200f; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) + if (npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) continue; if (Vector2.Distance(Player.Center, npc.Center) <= range) - Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, i); + Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, npc.whoAmI); // Occasionally spawn cute sparks so it looks like an electrical aura if (Main.rand.NextBool(10)) @@ -3217,17 +3207,16 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_FromThis(HydrothermicArmor.InfernoPotionEntitySourceContext); float range = 300f; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) + if (npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) continue; if (Vector2.Distance(Player.Center, npc.Center) <= range) { npc.AddBuff(ModContent.BuffType(), 120); if (brimLoreInfernoTimer == 0) - Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, i); + Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, npc.whoAmI); } } } @@ -3387,11 +3376,11 @@ namespace CalamityMod.CalPlayer { if (Player.whoAmI == Main.myPlayer) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == Player.whoAmI) + if (p.type == ModContent.ProjectileType() && p.owner == Player.whoAmI) { - Main.projectile[i].Kill(); + p.Kill(); break; } } @@ -3444,12 +3433,12 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) { int auraType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != auraType || !Main.projectile[i].active || Main.projectile[i].owner != Player.whoAmI) + if (p.type != auraType || p.owner != Player.whoAmI) continue; - Main.projectile[i].Kill(); + p.Kill(); break; } } @@ -3467,12 +3456,12 @@ namespace CalamityMod.CalPlayer else if (Player.whoAmI == Main.myPlayer) { int shieldType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != shieldType || !Main.projectile[i].active || Main.projectile[i].owner != Player.whoAmI) + if (p.type != shieldType || p.owner != Player.whoAmI) continue; - Main.projectile[i].Kill(); + p.Kill(); break; } } @@ -3958,62 +3947,51 @@ namespace CalamityMod.CalPlayer // Defense damage does not heal during iframes, and has a delay after they end before it starts recovering. if (totalDefenseDamage > 0) { - // If a Full Cleanse is in effect, then cleanse all defense damage and don't do anything else. - if (CleansingEffect == 1) - { - totalDefenseDamage = 0; - defenseDamageRecoveryFrames = 0; - totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; - defenseDamageDelayFrames = 0; - CleansingEffect = 0; - } - else - { - // Defense damage is capped at your maximum defense, except in GFB. - if (!Main.getGoodWorld && totalDefenseDamage > Player.statDefense) - totalDefenseDamage = Player.statDefense; + // Defense damage is capped at your maximum defense, except in GFB. + if (!Main.getGoodWorld && totalDefenseDamage > Player.statDefense) + totalDefenseDamage = Player.statDefense; - // You cannot begin recovering from defense damage until your iframes wear off. - if (!Player.HasIFrames()) + // You cannot begin recovering from defense damage until your iframes wear off. + if (!Player.HasIFrames()) + { + // Delay before defense damage recovery can start. While this delay is ticking down, defense damage doesn't recover at all. + if (defenseDamageDelayFrames > 0) + --defenseDamageDelayFrames; + + // Once the delay is up, defense damage recovery actually occurs. + else if (defenseDamageDelayFrames <= 0) { - // Delay before defense damage recovery can start. While this delay is ticking down, defense damage doesn't recover at all. - if (defenseDamageDelayFrames > 0) - --defenseDamageDelayFrames; + // Make one frame's worth of progress towards recovery. + --defenseDamageRecoveryFrames; - // Once the delay is up, defense damage recovery actually occurs. - else if (defenseDamageDelayFrames <= 0) + // If completely recovered, reset defense damage to nothing. + if (defenseDamageRecoveryFrames <= 0) { - // Make one frame's worth of progress towards recovery. - --defenseDamageRecoveryFrames; - - // If completely recovered, reset defense damage to nothing. - if (defenseDamageRecoveryFrames <= 0) - { - totalDefenseDamage = 0; - defenseDamageRecoveryFrames = 0; - totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; - defenseDamageDelayFrames = 0; - } + totalDefenseDamage = 0; + defenseDamageRecoveryFrames = 0; + totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; + defenseDamageDelayFrames = 0; } } - - // Get current amount of defense damage to apply this frame. - int currentDefenseDamage = CurrentDefenseDamage; - - // Apply DR Damage. - // - // DR Damage is applied at exactly the same ratio as defense damage; - // if you lose half your defense to defense damage, you also lose half your DR. - // This is applied first because the math would be wrong if the player's defense was already reduced by defense damage. - if (Player.statDefense > 0 && Player.endurance > 0f) - { - float drDamageRatio = currentDefenseDamage / (float)Player.statDefense; - Player.endurance *= 1f - drDamageRatio; - } - - // Apply defense damage - Player.statDefense -= currentDefenseDamage; } + + // Get current amount of defense damage to apply this frame. + int currentDefenseDamage = CurrentDefenseDamage; + + // Apply DR Damage. + // + // DR Damage is applied at exactly the same ratio as defense damage; + // if you lose half your defense to defense damage, you also lose half your DR. + // This is applied first because the math would be wrong if the player's defense was already reduced by defense damage. + if (Player.statDefense > 0 && Player.endurance > 0f) + { + float drDamageRatio = currentDefenseDamage / (float)Player.statDefense; + Player.endurance *= 1f - drDamageRatio; + } + + // Apply defense damage + Player.statDefense -= currentDefenseDamage; + } // Defense can never be reduced below zero, no matter what @@ -4171,11 +4149,6 @@ namespace CalamityMod.CalPlayer CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.WikiStatus2"); } - if (CalamityMod.Instance.musicMod is null && CalamityConfig.Instance.MusicModReminderMessage) - { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.MusicModReminder"); - } - // 04JAN2024: Ozzatron: Plushie message always appears. CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.GimmeSwagPlushieCampaign"); } @@ -4239,10 +4212,9 @@ namespace CalamityMod.CalPlayer if (Main.myPlayer != Player.whoAmI) return; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc is null || !npc.active || npc.type != ModContent.NPCType()) + if (npc.type != ModContent.NPCType()) continue; bool holdingsol = ((Player.HeldItem.type >= ItemID.GreenSolution && Player.HeldItem.type <= ItemID.RedSolution) || (Player.HeldItem.type >= ItemID.SandSolution && Player.HeldItem.type <= ItemID.DirtSolution) || Player.HeldItem.type == ModContent.ItemType()); @@ -4338,7 +4310,7 @@ namespace CalamityMod.CalPlayer } } if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); } } } diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 8545129723..42a6b1c2af 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -77,6 +77,7 @@ namespace CalamityMod.CalPlayer target.Calamity().IncreasedHeatEffects_Fireball = fireball; target.Calamity().IncreasedHeatEffects_CinnamonRoll = cinnamonRoll; + target.Calamity().IncreasedHeatEffects_FlameWakerBoots = flameWakerBoots; target.Calamity().IncreasedHeatEffects_HellfireTreads = hellfireTreads; target.Calamity().IncreasedSicknessEffects_ToxicHeart = toxicHeart; @@ -86,8 +87,7 @@ namespace CalamityMod.CalPlayer switch (item.type) { case ItemID.CobaltSword: - target.Calamity().miscDefenseLoss = (int)(target.defense * 0.25); - target.Calamity().isNerfedByCobalt = true; + target.Calamity().cobaltNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime; break; case ItemID.PalladiumSword: @@ -97,8 +97,7 @@ namespace CalamityMod.CalPlayer break; case ItemID.MythrilSword: - target.damage = (int)(target.defDamage * 0.9); - target.Calamity().isNerfedByMythril = true; + target.Calamity().mythrilNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime; break; case ItemID.OrichalcumSword: @@ -155,6 +154,9 @@ namespace CalamityMod.CalPlayer break; } + if (flameWakerBoots) + target.AddBuff(BuffID.OnFire, 120); + if (hellfireTreads) { if (Main.rand.NextBool(4)) @@ -217,8 +219,7 @@ namespace CalamityMod.CalPlayer switch (proj.type) { case ProjectileID.CobaltNaginata: - target.Calamity().miscDefenseLoss = (int)(target.defense * 0.25); - target.Calamity().isNerfedByCobalt = true; + target.Calamity().cobaltNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime; break; case ProjectileID.PalladiumPike: @@ -228,8 +229,7 @@ namespace CalamityMod.CalPlayer break; case ProjectileID.MythrilHalberd: - target.damage = (int)(target.defDamage * 0.9); - target.Calamity().isNerfedByMythril = true; + target.Calamity().mythrilNerfTimer = CalamityGlobalNPC.cobaltAndMythrilNerfTime; break; case ProjectileID.OrichalcumHalberd: @@ -305,6 +305,9 @@ namespace CalamityMod.CalPlayer break; } + if (flameWakerBoots) + target.AddBuff(BuffID.OnFire, 120); + if ((proj.arrow && Player.hasMoltenQuiver) || hellfireTreads) { if (Main.rand.NextBool(4)) @@ -1448,16 +1451,15 @@ namespace CalamityMod.CalPlayer float lowestHealthCheck = 0f; int healTarget = Player.whoAmI; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player otherPlayer in Main.ActivePlayers) { - Player otherPlayer = Main.player[i]; - if (otherPlayer.active && !otherPlayer.dead && ((!Player.hostile && !otherPlayer.hostile) || Player.team == otherPlayer.team)) + if (!otherPlayer.dead && ((!Player.hostile && !otherPlayer.hostile) || Player.team == otherPlayer.team)) { float playerDist = Vector2.Distance(target.Center, otherPlayer.Center); if (playerDist < BalancingConstants.LifeStealRange && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) { lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; - healTarget = i; + healTarget = otherPlayer.whoAmI; } } } @@ -1499,7 +1501,7 @@ namespace CalamityMod.CalPlayer if (playerDist < BalancingConstants.LifeStealRange && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) { lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; - healTarget = i; + healTarget = otherPlayer.whoAmI; } } } diff --git a/CalPlayer/DrawLayers/AndromedaMechLayer.cs b/CalPlayer/DrawLayers/AndromedaMechLayer.cs index 49ec26064a..cbf5c7c409 100644 --- a/CalPlayer/DrawLayers/AndromedaMechLayer.cs +++ b/CalPlayer/DrawLayers/AndromedaMechLayer.cs @@ -34,11 +34,11 @@ namespace CalamityMod.CalPlayer.DrawLayers int robot = -1; int andromedaMechID = ModContent.ProjectileType(); - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == andromedaMechID && Main.projectile[i].owner == drawPlayer.whoAmI) + if (p.type == andromedaMechID && p.owner == drawPlayer.whoAmI) { - robot = i; + robot = p.whoAmI; break; } } diff --git a/CalPlayer/DrawLayers/Backpack_Photoviscerator.png b/CalPlayer/DrawLayers/Backpack_Photoviscerator.png index aa94ab14fd..5eb58e0d3e 100644 Binary files a/CalPlayer/DrawLayers/Backpack_Photoviscerator.png and b/CalPlayer/DrawLayers/Backpack_Photoviscerator.png differ diff --git a/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs b/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs index cb9e490ba8..6e956ede84 100644 --- a/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs +++ b/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using CalamityMod.Items.SummonItems; +using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -47,6 +48,8 @@ namespace CalamityMod.CalPlayer.DrawLayers glowMask = ModContent.Request("CalamityMod/Items/Weapons/Ranged/AuroraBlazerGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Ranged/CleansingBlazeGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/Summon/CosmicImmaterializerGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/DeathhailStaffGlow").Value; else if (itemType == ModContent.ItemType()) @@ -77,6 +80,8 @@ namespace CalamityMod.CalPlayer.DrawLayers glowMask = ModContent.Request("CalamityMod/Items/Weapons/Summon/PlantationStaffGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/PrismaticBreakerGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PulseRifleGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/SoulPiercerGlow").Value; else if (itemType == ModContent.ItemType()) @@ -87,6 +92,8 @@ namespace CalamityMod.CalPlayer.DrawLayers glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/TheEnforcerGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Ranged/VernalBolterGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/VividClarityGlow").Value; if (glowMask == default) return; diff --git a/CalamityConditions.cs b/CalamityConditions.cs new file mode 100644 index 0000000000..8cce78968e --- /dev/null +++ b/CalamityConditions.cs @@ -0,0 +1,105 @@ +using System; +using CalamityMod.World; +using Terraria; +using Terraria.Localization; + +namespace CalamityMod +{ + public static class CalamityConditions + { + private static Condition Create(string key, Func predicate) + { + return new Condition( + Language.GetText($"Mods.CalamityMod.Condition.{key}"), + predicate + ); + } + + // + // Config based conditions + // + + public static readonly Condition PotionSellingConfig = Create("PotionConfig", () => CalamityConfig.Instance.PotionSelling); + + // + // Player conditions + // + + public static readonly Condition PlayerHasRogueArmor = Create("HasRogueArmor", () => Main.LocalPlayer.Calamity().rogueStealthMax > 0f && Main.LocalPlayer.Calamity().wearingRogueArmor); + public static readonly Condition PlayerHasWings = Create("HasWings", () => Main.LocalPlayer.wingTimeMax > 0); + public static readonly Condition PlayerAlcoholPoisoned = Create("AlcoholPoison", () => Main.LocalPlayer.Calamity().alcoholPoisoning); + + // + // NPC conditions + // + + /// Don't use this. It's always `true`. + public static readonly Condition TrasherTextCondition = Create("Drops.TrasherKill", () => true); + + // + // Calamity Event Flag conditions + // + + public static readonly Condition DownedAcidRainT1 = Create("Drops.DownedT1AR", () => DownedBossSystem.downedEoCAcidRain); + public static readonly Condition DownedAcidRainT2 = Create("Drops.DownedT2AR", () => DownedBossSystem.downedAquaticScourgeAcidRain); + + // + // Calamity Boss Flag conditions + // + + public static readonly Condition DownedDesertScourge = Create("Drops.DownedDS", () => DownedBossSystem.downedDesertScourge); + public static readonly Condition DownedCrabulon = Create("Drops.DownedCrabulon", () => DownedBossSystem.downedDesertScourge); + public static readonly Condition DownedHiveMind = Create("Drops.DownedHM", () => DownedBossSystem.downedHiveMind); + public static readonly Condition DownedPerforator = Create("Drops.DownedPerfs", () => DownedBossSystem.downedPerforator); + public static readonly Condition DownedSlimeGod = Create("Drops.DownedSG", () => DownedBossSystem.downedSlimeGod); + public static readonly Condition DownedCryogen = Create("Drops.DownedCryo", () => DownedBossSystem.downedCryogen); + public static readonly Condition DownedAquaticScourge = Create("Drops.DownedAS", () => DownedBossSystem.downedAquaticScourge); + public static readonly Condition DownedBrimstoneElemental = Create("Drops.DownedBrim", () => DownedBossSystem.downedBrimstoneElemental); + public static readonly Condition DownedCalamitasClone = Create("Drops.DownedCal", () => DownedBossSystem.downedCalamitasClone); + public static readonly Condition DownedLeviathan = Create("Drops.DownedLebi", () => DownedBossSystem.downedLeviathan); + public static readonly Condition DownedAstrumAureus = Create("Drops.DownedAureus", () => DownedBossSystem.downedAstrumAureus); + public static readonly Condition DownedPlaguebringer = Create("Drops.DownedPBG", () => DownedBossSystem.downedPlaguebringer); + public static readonly Condition DownedRavager = Create("Drops.DownedRav", () => DownedBossSystem.downedRavager); + public static readonly Condition DownedAstrumDeus = Create("Drops.DownedAD", () => DownedBossSystem.downedAstrumDeus); + public static readonly Condition DownedGuardians = Create("Drops.DownedGuard", () => DownedBossSystem.downedGuardians); + public static readonly Condition DownedBumblebird = Create("Drops.DownedBirb", () => DownedBossSystem.downedDragonfolly); + public static readonly Condition DownedProvidence = Create("Drops.DownedProv", () => DownedBossSystem.downedProvidence); + public static readonly Condition DownedSignus = Create("Drops.DownedSig", () => DownedBossSystem.downedSignus); + public static readonly Condition DownedStormWeaver = Create("Drops.DownedSW", () => DownedBossSystem.downedStormWeaver); + public static readonly Condition DownedCeaselessVoid = Create("Drops.DownedCV", () => DownedBossSystem.downedCeaselessVoid); + public static readonly Condition DownedPolterghast = Create("Drops.DownedPolter", () => DownedBossSystem.downedPolterghast); + public static readonly Condition DownedOldDuke = Create("Drops.DownedOD", () => DownedBossSystem.downedBoomerDuke); + public static readonly Condition DownedDevourerOfGods = Create("Drops.DownedDoG", () => DownedBossSystem.downedDoG); + public static readonly Condition DownedYharon = Create("Drops.DownedYharon", () => DownedBossSystem.downedYharon); + public static readonly Condition DownedExoMechs = Create("Drops.DownedExos", () => DownedBossSystem.downedExoMechs); + public static readonly Condition DownedSupremeCalamitas = Create("Drops.DownedSCal", () => DownedBossSystem.downedCalamitas); + public static readonly Condition DownedPrimordialWyrm = Create("Drops.DownedAEW", () => DownedBossSystem.downedPrimordialWyrm); + public static readonly Condition DownedClam = Create("Drops.DownedClam", () => DownedBossSystem.downedCLAM); + public static readonly Condition DownedBuffedClam = Create("Drops.DownedClamHM", () => DownedBossSystem.downedCLAMHardMode); + public static readonly Condition DownedGreatSandShark = Create("Drops.DownedGSS", () => DownedBossSystem.downedGSS); + + // Mixed + public static readonly Condition DownedHiveMindOrPerforator = Create("Drops.DownedHMOrPerfs",() => DownedBossSystem.downedHiveMind || DownedBossSystem.downedPerforator); + public static readonly Condition DownedCalamitasCloneOrPlantera = Create("Drops.DownedCalPlant", () => DownedBossSystem.downedCalamitasClone || Condition.DownedPlantera.IsMet()); + + // Vanilla + public static readonly Condition DownedBetsy = Create("Drops.DownedBetsy", () => DownedBossSystem.downedBetsy); + + // + // Calamity Biome conditions + // + + public static readonly Condition InAstral = Create("InAstral", () => Main.LocalPlayer.Calamity().ZoneAstral); + public static readonly Condition InCrag = Create("InCrag", () => Main.LocalPlayer.Calamity().ZoneCalamity); + public static readonly Condition InSulph = Create("InSulph", () => Main.LocalPlayer.Calamity().ZoneSulphur); + public static readonly Condition InSunken = Create("InSunken", () => Main.LocalPlayer.Calamity().ZoneSunkenSea); + + // + // World based conditions + // + + public static readonly Condition InRevengeanceMode = Create("InRev", () => CalamityWorld.revenge); + public static readonly Condition InRevengeanceModeNotMasterMode = Create("InRev", () => !Main.masterMode && CalamityWorld.revenge); + public static readonly Condition InRevengeanceModeOrMasterMode = Create("InRevOrMM", () => Main.masterMode || CalamityWorld.revenge); + } +} diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 371af0690c..eedd4de7ed 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -66,10 +66,6 @@ namespace CalamityMod #region UI Changes [Header("UI")] - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - public bool MusicModReminderMessage { get; set; } - [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] public bool WikiStatusMessage { get; set; } diff --git a/CalamityMod.cs b/CalamityMod.cs index db4492d4f8..62b15634c1 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -92,13 +92,10 @@ namespace CalamityMod public static Texture2D AstralSurfaceCloseGlow; public static Texture2D AstralSurfaceMiddle; public static Texture2D AstralSurfaceMiddleGlow; - public static Texture2D AstralSurfaceFar; - public static Texture2D AstralSurfaceHorizon; // Astral Desert Sky/BG public static Texture2D AstralDesertSurfaceClose; public static Texture2D AstralDesertSurfaceMiddle; - public static Texture2D AstralDesertSurfaceFar; // Astral Snow Sky/BG public static Texture2D AstralSnowSurfaceMiddle; @@ -278,22 +275,19 @@ namespace CalamityMod { // Astral Sky/BG AstralSky = ModContent.Request("CalamityMod/Skies/AstralSky", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceFront = ModContent.Request("CalamityMod/Skies/AstralSurfaceFront", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceFrontGlow = ModContent.Request("CalamityMod/Skies/AstralSurfaceFrontGlow", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceClose = ModContent.Request("CalamityMod/Skies/AstralSurfaceClose", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceCloseGlow = ModContent.Request("CalamityMod/Skies/AstralSurfaceCloseGlow", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceMiddle = ModContent.Request("CalamityMod/Skies/AstralSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceMiddleGlow = ModContent.Request("CalamityMod/Skies/AstralSurfaceMiddleGlow", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceFar = ModContent.Request("CalamityMod/Skies/AstralSurfaceFar", AssetRequestMode.ImmediateLoad).Value; - AstralSurfaceHorizon = ModContent.Request("CalamityMod/Skies/AstralSurfaceHorizon", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceFront = ModContent.Request("CalamityMod/Backgrounds/AstralSurfaceFront", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceFrontGlow = ModContent.Request("CalamityMod/Backgrounds/AstralSurfaceFrontGlow", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceClose = ModContent.Request("CalamityMod/Backgrounds/AstralSurfaceClose", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceCloseGlow = ModContent.Request("CalamityMod/Backgrounds/AstralSurfaceCloseGlow", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceMiddle = ModContent.Request("CalamityMod/Backgrounds/AstralSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceMiddleGlow = ModContent.Request("CalamityMod/Backgrounds/AstralSurfaceMiddleGlow", AssetRequestMode.ImmediateLoad).Value; - // Astral Desert Sky/BG - AstralDesertSurfaceClose = ModContent.Request("CalamityMod/Skies/AstralDesertSurfaceClose", AssetRequestMode.ImmediateLoad).Value; - AstralDesertSurfaceMiddle = ModContent.Request("CalamityMod/Skies/AstralDesertSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; - AstralDesertSurfaceFar = ModContent.Request("CalamityMod/Skies/AstralDesertSurfaceFar", AssetRequestMode.ImmediateLoad).Value; + //Astral Desert Sky/BG + AstralDesertSurfaceClose = ModContent.Request("CalamityMod/Backgrounds/AstralDesertSurfaceClose", AssetRequestMode.ImmediateLoad).Value; + AstralDesertSurfaceMiddle = ModContent.Request("CalamityMod/Backgrounds/AstralDesertSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; - // Astral Snow Sky/BG - AstralSnowSurfaceMiddle = ModContent.Request("CalamityMod/Skies/AstralSnowSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; + //Astral Snow Sky/BG + AstralSnowSurfaceMiddle = ModContent.Request("CalamityMod/Backgrounds/AstralSnowSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; // Sulpher Sea Sky/BG SulphurSeaSky = ModContent.Request("CalamityMod/Skies/SulphurSeaSky", AssetRequestMode.ImmediateLoad).Value; @@ -352,10 +346,6 @@ namespace CalamityMod SkyManager.Instance["CalamityMod:BrimstoneCrag"] = new BrimstoneCragSky(); SkyManager.Instance["CalamityMod:Astral"] = new AstralSky(); - SkyManager.Instance["CalamityMod:AstralSurface"] = new AstralSkySurface(); - SkyManager.Instance["CalamityMod:AstralDesert"] = new AstralSkyDesert(); - SkyManager.Instance["CalamityMod:AstralSnow"] = new AstralSkySnow(); - SkyManager.Instance["CalamityMod:MonolithAstral"] = new AstralMonolithSky(); SkyManager.Instance["CalamityMod:SulphurSea"] = new SulphurSeaSky(); SkyManager.Instance["CalamityMod:Cryogen"] = new CryogenSky(); SkyManager.Instance["CalamityMod:StormWeaverFlash"] = new StormWeaverFlashSky(); diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 15d755c415..4c0a22518d 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -294,16 +294,16 @@ namespace CalamityMod EnemyStats.ContactDamageValues = new SortedDictionary { - { NPCID.KingSlime, new int[] { 40, 64, 80, 96, 120 } }, - { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 90 } }, + { NPCID.KingSlime, new int[] { 40, 64, 80, 96, 144 } }, + { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, - { ModContent.NPCType(), new int[] { 45, 66, 88, 110, 132 } }, + { ModContent.NPCType(), new int[] { 45, 66, 88, 110, 165 } }, { ModContent.NPCType(), new int[] { 24, 32, 40, 48, 72 } }, { ModContent.NPCType(), new int[] { 18, 24, 30, 36, 54 } }, - { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 90 } }, + { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, { ModContent.NPCType(), new int[] { 21, 28, 32, 36, 63 } }, { ModContent.NPCType(), new int[] { 12, 16, 20, 24, 36 } }, - { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 90 } }, + { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, { ModContent.NPCType(), new int[] { 21, 28, 32, 36, 63 } }, { ModContent.NPCType(), new int[] { 12, 16, 20, 24, 36 } }, @@ -312,73 +312,73 @@ namespace CalamityMod 30, // 45 in phase 2 40, // 48 in phase 2, 56 in phase 3 50, // 60 in phase 2, 70 in phase 3 - 72 } }, // Vanilla: 108 in phase 2; Rev+: 86 in phase 2, 101 in phase 3 + 75 } }, // Vanilla: 113 in phase 2; Rev+: 90 in phase 2, 105 in phase 3 { NPCID.ServantofCthulhu, new int[] { 18, 24, 30, 36, 54 } }, - { ModContent.NPCType(), new int[] { 20, 26, 34, 42, 60 } }, // In phase 2: 26, 34, 44, 55, 78 + { ModContent.NPCType(), new int[] { 20, 26, 34, 42, 63 } }, // In phase 2: 26, 34, 44, 55, 82 - { ModContent.NPCType(), new int[] { 40, 64, 80, 96, 120 } }, - { ModContent.NPCType(), new int[] { 25, 50, 62, 74, 75 } }, + { ModContent.NPCType(), new int[] { 40, 64, 80, 96, 144 } }, + { ModContent.NPCType(), new int[] { 25, 50, 62, 74, 111 } }, - { NPCID.EaterofWorldsHead, new int[] { 38, 55, 77, 99, 132 } }, + { NPCID.EaterofWorldsHead, new int[] { 38, 55, 77, 99, 165 } }, { NPCID.EaterofWorldsBody, new int[] { 18, 24, 32, 40, 60 } }, - { NPCID.EaterofWorldsTail, new int[] { 12, 16, 24, 32, 36 } }, + { NPCID.EaterofWorldsTail, new int[] { 12, 16, 24, 32, 48 } }, { NPCID.VileSpitEaterOfWorlds, new int[] { -1, 64, 64, 64, 96 } }, - { NPCID.BrainofCthulhu, new int[] { 36, 54, 81, 108, 135 } }, - { NPCID.Creeper, new int[] { 24, 36, 66, 96, 120 } }, + { NPCID.BrainofCthulhu, new int[] { 36, 54, 81, 108, 162 } }, + { NPCID.Creeper, new int[] { 24, 36, 66, 96, 144 } }, - { ModContent.NPCType(), new int[] { 42, 63, 81, 99, 135 } }, - { ModContent.NPCType(), new int[] { 30, 50, 62, 74, 90 } }, + { ModContent.NPCType(), new int[] { 42, 63, 81, 99, 162 } }, + { ModContent.NPCType(), new int[] { 30, 50, 62, 74, 111 } }, { ModContent.NPCType(), new int[] { 36, 54, 63, 72, 108 } }, - { ModContent.NPCType(), new int[] { 54, 90, 108, 126, 162 } }, - { ModContent.NPCType(), new int[] { 28, 48, 56, 64, 84 } }, - { ModContent.NPCType(), new int[] { 22, 36, 42, 48, 66 } }, - { ModContent.NPCType(), new int[] { 42, 70, 84, 98, 126 } }, - { ModContent.NPCType(), new int[] { 24, 42, 50, 58, 72 } }, - { ModContent.NPCType(), new int[] { 18, 28, 34, 40, 54 } }, - { ModContent.NPCType(), new int[] { 36, 60, 72, 84, 108 } }, - { ModContent.NPCType(), new int[] { 20, 36, 42, 48, 60 } }, - { ModContent.NPCType(), new int[] { 14, 20, 26, 32, 42 } }, + { ModContent.NPCType(), new int[] { 54, 90, 108, 126, 189 } }, + { ModContent.NPCType(), new int[] { 28, 48, 56, 64, 96 } }, + { ModContent.NPCType(), new int[] { 22, 36, 42, 48, 72 } }, + { ModContent.NPCType(), new int[] { 42, 70, 84, 98, 147 } }, + { ModContent.NPCType(), new int[] { 24, 42, 50, 58, 87 } }, + { ModContent.NPCType(), new int[] { 18, 28, 34, 40, 60 } }, + { ModContent.NPCType(), new int[] { 36, 60, 72, 84, 126 } }, + { ModContent.NPCType(), new int[] { 20, 36, 42, 48, 72 } }, + { ModContent.NPCType(), new int[] { 14, 20, 26, 32, 48 } }, - { NPCID.QueenBee, new int[] { 36, 54, 81, 108, 135 } }, - { NPCID.Bee, new int[] { 20, 24, 48, 72, 90 } }, - { NPCID.BeeSmall, new int[] { 15, 18, 36, 54, 72 } }, + { NPCID.QueenBee, new int[] { 36, 54, 81, 108, 162 } }, + { NPCID.Bee, new int[] { 20, 24, 48, 72, 108 } }, + { NPCID.BeeSmall, new int[] { 15, 18, 36, 54, 81 } }, { NPCID.SkeletronHead, new int[] { 42, // 55 while spinning 77, // 100 while spinning 88, // 114 while spinning 99, // 128 while spinning - 132 } }, // 171 while spinning - { NPCID.SkeletronHand, new int[] { 32, 44, 77, 110, 132 } }, + 165 } }, // 215 while spinning + { NPCID.SkeletronHand, new int[] { 32, 44, 77, 110, 165 } }, - { NPCID.Deerclops, new int[] { 20, 40, 50, 60, 81 } }, + { NPCID.Deerclops, new int[] { 20, 40, 50, 60, 90 } }, - { ModContent.NPCType(), new int[] { 48, 80, 96, 112, 144 } }, - { ModContent.NPCType(), new int[] { 54, 90, 108, 126, 162 } }, - { ModContent.NPCType(), new int[] { 48, 80, 96, 112, 144 } }, - { ModContent.NPCType(), new int[] { 60, 100, 120, 140, 180 } }, - { ModContent.NPCType(), new int[] { 54, 90, 108, 126, 162 } }, - { ModContent.NPCType(), new int[] { 36, 60, 72, 84, 108 } }, - { ModContent.NPCType(), new int[] { 24, 40, 48, 56, 72 } }, - { ModContent.NPCType(), new int[] { 42, 70, 84, 98, 126 } }, - { ModContent.NPCType(), new int[] { 30, 50, 60, 70, 90 } }, + { ModContent.NPCType(), new int[] { 48, 80, 96, 112, 168 } }, + { ModContent.NPCType(), new int[] { 54, 90, 108, 126, 189 } }, + { ModContent.NPCType(), new int[] { 48, 80, 96, 112, 168 } }, + { ModContent.NPCType(), new int[] { 60, 100, 120, 140, 210 } }, + { ModContent.NPCType(), new int[] { 54, 90, 108, 126, 189 } }, + { ModContent.NPCType(), new int[] { 36, 60, 72, 84, 126 } }, + { ModContent.NPCType(), new int[] { 24, 40, 48, 56, 84 } }, + { ModContent.NPCType(), new int[] { 42, 70, 84, 98, 147 } }, + { ModContent.NPCType(), new int[] { 30, 50, 60, 70, 105 } }, - { NPCID.WallofFlesh, new int[] { 100, 150, 180, 210, 270 } }, - { NPCID.WallofFleshEye, new int[] { 100, 150, 180, 210, 270 } }, + { NPCID.WallofFlesh, new int[] { 100, 150, 180, 210, 315 } }, + { NPCID.WallofFleshEye, new int[] { 100, 150, 180, 210, 315 } }, { NPCID.TheHungry, new int[] { 30, // Ranges from 30 to 75 depending on WoF life 60, // Ranges from 60 to 150 depending on WoF life 60, // Ranges from 60 to 150 depending on WoF life 60, // Ranges from 60 to 150 depending on WoF life 90 } }, // Ranges from 90 to 225 depending on WoF life - { NPCID.TheHungryII, new int[] { 30, 60, 74, 88, 108 } }, - { NPCID.LeechHead, new int[] { 26, 52, 62, 72, 90 } }, - { NPCID.LeechBody, new int[] { 22, 44, 52, 60, 78 } }, - { NPCID.LeechTail, new int[] { 18, 36, 42, 48, 66 } }, + { NPCID.TheHungryII, new int[] { 30, 60, 74, 88, 132 } }, + { NPCID.LeechHead, new int[] { 26, 52, 62, 72, 108 } }, + { NPCID.LeechBody, new int[] { 22, 44, 52, 60, 90 } }, + { NPCID.LeechTail, new int[] { 18, 36, 42, 48, 72 } }, - { NPCID.QueenSlimeBoss, new int[] { 80, 120, 150, 180, 240 } }, + { NPCID.QueenSlimeBoss, new int[] { 80, 120, 150, 180, 270 } }, { NPCID.QueenSlimeMinionBlue, new int[] { 60, 80, 100, 120, 180 } }, { NPCID.QueenSlimeMinionPink, new int[] { 60, 80, 100, 120, 180 } }, { NPCID.QueenSlimeMinionPurple, new int[] { 70, 100, 120, 140, 210 } }, @@ -400,15 +400,15 @@ namespace CalamityMod 153 } }, // 229 in phase 2 { ModContent.NPCType(), new int[] { 110, 176, 187, 198, 330 } }, - { ModContent.NPCType(), new int[] { 75, 112, 136, 160, 216 } }, + { ModContent.NPCType(), new int[] { 75, 112, 136, 160, 240 } }, { ModContent.NPCType(), new int[] { 70, 104, 112, 120, 192 } }, { ModContent.NPCType(), new int[] { 65, 96, 104, 112, 168 } }, - { NPCID.TheDestroyer, new int[] { 140, 280, 300, 320, 420 } }, + { NPCID.TheDestroyer, new int[] { 140, 280, 300, 320, 480 } }, { NPCID.TheDestroyerBody, new int[] { 70, 102, 136, 170, 255 } }, { NPCID.TheDestroyerTail, new int[] { 45, 68, 102, 136, 204 } }, - { ModContent.NPCType(), new int[] { 75, 112, 136, 160, 216 } }, + { ModContent.NPCType(), new int[] { 75, 112, 136, 160, 240 } }, { NPCID.SkeletronPrime, new int[] { 50, // 100 while spinning @@ -427,7 +427,7 @@ namespace CalamityMod { NPCID.PrimeCannon, new int[] { 30, 51, 68, 85, 102 } }, { NPCID.PrimeLaser, new int[] { 30, 51, 68, 85, 102 } }, - { ModContent.NPCType(), new int[] { 95, 144, 168, 192, 276 } }, + { ModContent.NPCType(), new int[] { 95, 144, 168, 192, 288 } }, { ModContent.NPCType(), new int[] { 80, 120, 138, 156, 240 } }, { ModContent.NPCType(), new int[] { 85, 130, 150, 170, 255 } }, @@ -436,7 +436,7 @@ namespace CalamityMod 100, // 140 in phase 2 138, // 193 in phase 2 176, // 246 in phase 2 - 207 } }, // 290 in phase 2 + 276 } }, // 386 in phase 2 { NPCID.PlanterasTentacle, new int[] { 90, 138, 161, 184, 276 } }, { ModContent.NPCType(), new int[] { 90, 138, 161, 184, 276 } }, { NPCID.Spore, new int[] { 90, 140, 160, 180, 270 } }, @@ -445,7 +445,7 @@ namespace CalamityMod 110, // 165 during charge 143, // 215 during charge 176, // 264 during charge - 231 } }, // 347 during charge + 264 } }, // 396 during charge { ModContent.NPCType(), new int[] { 140, 216, 240, 264, 414 } }, { ModContent.NPCType(), new int[] { @@ -453,37 +453,37 @@ namespace CalamityMod 112, // 168 during charge 136, // 204 during charge 160, // 240 during charge - 216 } }, // 324 during charge + 240 } }, // 360 during charge { ModContent.NPCType(), new int[] { 70, 110, 126, 142, 210 } }, - { NPCID.DetonatingBubble, new int[] { 100, 150, 180, 210, 270 } }, + { NPCID.DetonatingBubble, new int[] { 100, 150, 180, 210, 315 } }, { ModContent.NPCType(), new int[] { 90, 140, 160, 180, 270 } }, { ModContent.NPCType(), new int[] { 145, 220, 242, 264, 429 } }, { ModContent.NPCType(), new int[] { 75, 112, 128, 144, 225 } }, - { NPCID.Golem, new int[] { 95, 144, 176, 208, 264 } }, - { NPCID.GolemHead, new int[] { 85, 128, 144, 160, 228 } }, - { NPCID.GolemFistLeft, new int[] { 75, 112, 144, 176, 240 } }, - { NPCID.GolemFistRight, new int[] { 75, 112, 144, 176, 240 } }, + { NPCID.Golem, new int[] { 95, 144, 176, 208, 312 } }, + { NPCID.GolemHead, new int[] { 85, 128, 144, 160, 240 } }, + { NPCID.GolemFistLeft, new int[] { 75, 112, 144, 176, 264 } }, + { NPCID.GolemFistRight, new int[] { 75, 112, 144, 176, 264 } }, - { ModContent.NPCType(), new int[] { 120, 180, 216, 252, 351 } }, + { ModContent.NPCType(), new int[] { 120, 180, 216, 252, 378 } }, { ModContent.NPCType(), new int[] { 120, 180, 210, 240, 360 } }, - { ModContent.NPCType(), new int[] { 130, 200, 240, 280, 390 } }, + { ModContent.NPCType(), new int[] { 130, 200, 240, 280, 420 } }, { NPCID.DukeFishron, new int[] { 100, // 120 in phase 2 140, // 202 in phase 2, 185 in phase 3 168, // 242 in phase 2, 222 in phase 3 196, // 282 in phase 2, 259 in phase 3 - 252 } }, // 363 in phase 2, 333 in phase 3 - { NPCID.Sharkron, new int[] { 100, 150, 180, 210, 270 } }, - { NPCID.Sharkron2, new int[] { 120, 180, 210, 240, 315 } }, + 294 } }, // 423 in phase 2, 388 in phase 3 + { NPCID.Sharkron, new int[] { 100, 150, 180, 210, 315 } }, + { NPCID.Sharkron2, new int[] { 120, 180, 210, 240, 360 } }, { ModContent.NPCType(), new int[] { 130, 192, 224, 256, 384 } }, { ModContent.NPCType(), new int[] { 105, 160, 180, 200, 315 } }, { ModContent.NPCType(), new int[] { 105, 160, 180, 200, 315 } }, { ModContent.NPCType(), new int[] { 130, 192, 224, 256, 390 } }, - { ModContent.NPCType(), new int[] { 105, 160, 192, 224, 315 } }, + { ModContent.NPCType(), new int[] { 105, 160, 192, 224, 336 } }, { NPCID.CultistDragonHead, new int[] { 120, 180, 210, 240, 360 } }, { NPCID.CultistDragonBody1, new int[] { 60, 90, 105, 120, 180 } }, @@ -495,8 +495,8 @@ namespace CalamityMod { NPCID.AncientLight, new int[] { 120, 180, 210, 240, 360 } }, { ModContent.NPCType(), new int[] { 160, 240, 268, 296, 480 } }, - { ModContent.NPCType(), new int[] { 105, 160, 192, 224, 312 } }, - { ModContent.NPCType(), new int[] { 85, 128, 160, 192, 252 } }, + { ModContent.NPCType(), new int[] { 105, 160, 192, 224, 336 } }, + { ModContent.NPCType(), new int[] { 85, 128, 160, 192, 288 } }, { ModContent.NPCType(), new int[] { 150, 224, 256, 288, 444 } }, { ModContent.NPCType(), new int[] { 160, 240, 264, 288, 405 } }, @@ -566,181 +566,181 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, - { new Tuple(NPCID.EyeofCthulhu, ProjectileID.BloodNautilusShot), new int[] { 26, 44, 60, 76, 108 } }, + { new Tuple(NPCID.EyeofCthulhu, ProjectileID.BloodNautilusShot), new int[] { 26, 44, 60, 76, 114 } }, { new Tuple(ModContent.NPCType(), ProjectileID.BloodShot), new int[] { 26, 36, 44, 52, 84 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 72, 96 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 72, 96 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 72, 108 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 72, 108 } }, - { new Tuple(NPCID.EaterofWorldsHead, ProjectileID.CursedFlameHostile), new int[] { 26, 44, 60, 76, 108 } }, + { new Tuple(NPCID.EaterofWorldsHead, ProjectileID.CursedFlameHostile), new int[] { 26, 44, 60, 76, 114 } }, { new Tuple(NPCID.EaterofWorldsHead, ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, - { new Tuple(NPCID.BrainofCthulhu, ProjectileID.BloodNautilusShot), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(NPCID.BrainofCthulhu, ProjectileID.BloodShot), new int[] { 26, 44, 60, 76, 108 } }, - { new Tuple(NPCID.Creeper, ProjectileID.BloodShot), new int[] { 26, 44, 60, 76, 108 } }, + { new Tuple(NPCID.BrainofCthulhu, ProjectileID.BloodNautilusShot), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(NPCID.BrainofCthulhu, ProjectileID.BloodShot), new int[] { 26, 44, 60, 76, 114 } }, + { new Tuple(NPCID.Creeper, ProjectileID.BloodShot), new int[] { 26, 44, 60, 76, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 72, 96 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 72, 96 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 72, 108 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 30, 48, 60, 72, 108 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 22, 36, 44, 52, 84 } }, - { new Tuple(NPCID.QueenBee, ProjectileID.QueenBeeStinger), new int[] { 22, 44, 64, 84, 120 } }, + { new Tuple(NPCID.QueenBee, ProjectileID.QueenBeeStinger), new int[] { 22, 44, 64, 84, 126 } }, - { new Tuple(NPCID.SkeletronHead, ProjectileID.Skull), new int[] { 46, 72, 84, 96, 138 } }, - { new Tuple(NPCID.SkeletronHead, ProjectileID.Shadowflames), new int[] { 36, 72, 88, 104, 150 } }, - { new Tuple(NPCID.SkeletronHand, ProjectileID.Skull), new int[] { 36, 56, 68, 80, 114 } }, + { new Tuple(NPCID.SkeletronHead, ProjectileID.Skull), new int[] { 46, 72, 84, 96, 144 } }, + { new Tuple(NPCID.SkeletronHead, ProjectileID.Shadowflames), new int[] { 36, 72, 88, 104, 156 } }, + { new Tuple(NPCID.SkeletronHand, ProjectileID.Skull), new int[] { 36, 56, 68, 80, 120 } }, - { new Tuple(NPCID.Deerclops, ProjectileID.DeerclopsIceSpike), new int[] { 26, 52, 76, 100, 138 } }, - { new Tuple(NPCID.Deerclops, ProjectileID.DeerclopsRangedProjectile), new int[] { 36, 72, 88, 104, 150 } }, - { new Tuple(NPCID.Deerclops, ProjectileID.InsanityShadowHostile), new int[] { 20, 40, 60, 80, 114 } }, + { new Tuple(NPCID.Deerclops, ProjectileID.DeerclopsIceSpike), new int[] { 26, 52, 76, 100, 150 } }, + { new Tuple(NPCID.Deerclops, ProjectileID.DeerclopsRangedProjectile), new int[] { 36, 72, 88, 104, 156 } }, + { new Tuple(NPCID.Deerclops, ProjectileID.InsanityShadowHostile), new int[] { 20, 40, 60, 80, 120 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 100, 138 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 92, 126 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 100, 138 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 92, 126 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 92, 126 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 34, 52, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 114 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 24, 48, 60, 72, 96 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 100, 150 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 92, 138 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 42, 68, 84, 100, 150 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 92, 138 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 38, 60, 76, 92, 138 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 34, 52, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 36, 56, 68, 80, 120 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 24, 48, 60, 72, 108 } }, - { new Tuple(NPCID.WallofFleshEye, ProjectileID.EyeLaser), new int[] { 36, 72, 88, 104, 150 } }, - { new Tuple(NPCID.WallofFlesh, ProjectileID.DemonSickle), new int[] { 52, 92, 112, 132, 168 } }, - { new Tuple(NPCID.WallofFlesh, ProjectileID.Fireball), new int[] { 36, 72, 88, 104, 150 } }, + { new Tuple(NPCID.WallofFleshEye, ProjectileID.EyeLaser), new int[] { 36, 72, 88, 104, 156 } }, + { new Tuple(NPCID.WallofFlesh, ProjectileID.DemonSickle), new int[] { 52, 92, 112, 132, 198 } }, + { new Tuple(NPCID.WallofFlesh, ProjectileID.Fireball), new int[] { 36, 72, 88, 104, 156 } }, - { new Tuple(NPCID.QueenSlimeBoss, ProjectileID.QueenSlimeGelAttack), new int[] { 60, 120, 136, 152, 210 } }, - { new Tuple(NPCID.QueenSlimeBoss, ProjectileID.QueenSlimeSmash), new int[] { 80, 160, 188, 216, 270 } }, - { new Tuple(NPCID.QueenSlimeBoss, ProjectileID.QueenSlimeMinionBlueSpike), new int[] { 52, 92, 112, 132, 168 } }, - { new Tuple(NPCID.QueenSlimeMinionBlue, ProjectileID.QueenSlimeMinionBlueSpike), new int[] { 52, 92, 112, 132, 168 } }, - { new Tuple(NPCID.QueenSlimeMinionPink, ProjectileID.QueenSlimeMinionPinkBall), new int[] { 52, 92, 112, 132, 168 } }, + { new Tuple(NPCID.QueenSlimeBoss, ProjectileID.QueenSlimeGelAttack), new int[] { 60, 120, 136, 152, 228 } }, + { new Tuple(NPCID.QueenSlimeBoss, ProjectileID.QueenSlimeSmash), new int[] { 80, 160, 188, 216, 324 } }, + { new Tuple(NPCID.QueenSlimeBoss, ProjectileID.QueenSlimeMinionBlueSpike), new int[] { 52, 92, 112, 132, 198 } }, + { new Tuple(NPCID.QueenSlimeMinionBlue, ProjectileID.QueenSlimeMinionBlueSpike), new int[] { 52, 92, 112, 132, 198 } }, + { new Tuple(NPCID.QueenSlimeMinionPink, ProjectileID.QueenSlimeMinionPinkBall), new int[] { 52, 92, 112, 132, 198 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 132, 168 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 140, 180 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 132, 168 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 132, 198 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 228 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 140, 210 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 52, 92, 112, 132, 198 } }, - { new Tuple(NPCID.Retinazer, ProjectileID.EyeLaser), new int[] { 40, 92, 116, 140, 174 } }, + { new Tuple(NPCID.Retinazer, ProjectileID.EyeLaser), new int[] { 40, 92, 116, 140, 210 } }, { new Tuple(NPCID.Retinazer, ProjectileID.DeathLaser), new int[] { 50, // 38 in rapid fire 108, // 81 in rapid fire 132, // 99 in rapid fire 156, // 117 in rapid fire - 186 } }, // 139 in rapid fire - { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 100, 120, 140, 180 } }, - { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 120, 148, 176, 222 } }, - { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 222 } }, - { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 128, 156, 192 } }, + 234 } }, // 176 in rapid fire + { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 228 } }, + { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 100, 120, 140, 210 } }, + { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 120, 148, 176, 264 } }, + { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, + { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 128, 156, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 140, 180 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 66, 112, 128, 144, 198 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 140, 210 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 228 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 66, 112, 128, 144, 216 } }, - { new Tuple(NPCID.TheDestroyer, ProjectileID.DeathLaser), new int[] { 44, 96, 116, 136, 174 } }, - { new Tuple(NPCID.TheDestroyer, ModContent.ProjectileType()), new int[] { 46, 108, 128, 148, 192 } }, - { new Tuple(NPCID.TheDestroyer, ModContent.ProjectileType()), new int[] { 48, 116, 136, 156, 210 } }, - { new Tuple(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 96, 116, 136, 174 } }, - { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 46, 108, 128, 148, 192 } }, - { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 48, 116, 136, 156, 210 } }, - { new Tuple(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 162 } }, + { new Tuple(NPCID.TheDestroyer, ProjectileID.DeathLaser), new int[] { 44, 96, 116, 136, 204 } }, + { new Tuple(NPCID.TheDestroyer, ModContent.ProjectileType()), new int[] { 46, 108, 128, 148, 222 } }, + { new Tuple(NPCID.TheDestroyer, ModContent.ProjectileType()), new int[] { 48, 116, 136, 156, 234 } }, + { new Tuple(NPCID.TheDestroyerBody, ProjectileID.DeathLaser), new int[] { 44, 96, 116, 136, 204 } }, + { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 46, 108, 128, 148, 222 } }, + { new Tuple(NPCID.TheDestroyerBody, ModContent.ProjectileType()), new int[] { 48, 116, 136, 156, 234 } }, + { new Tuple(NPCID.Probe, ProjectileID.PinkLaser), new int[] { 50, 88, 100, 112, 168 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 280, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 210 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 280, 420 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, - { new Tuple(NPCID.SkeletronPrime, ProjectileID.Skull), new int[] { 50, 108, 124, 140, 186 } }, - { new Tuple(NPCID.SkeletronPrime, ProjectileID.DeathLaser), new int[] { 50, 108, 124, 140, 186 } }, - { new Tuple(NPCID.SkeletronPrime, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 176, 222 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.Skull), new int[] { 50, 108, 124, 140, 186 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 180, 200, 240 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.FrostBeam), new int[] { 50, 108, 124, 140, 186 } }, - { new Tuple(NPCID.PrimeCannon, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 176, 222 } }, - { new Tuple(NPCID.PrimeCannon, ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 0, 0, 240 } }, - { new Tuple(NPCID.PrimeLaser, ProjectileID.DeathLaser), new int[] { 50, 108, 124, 140, 186 } }, + { new Tuple(NPCID.SkeletronPrime, ProjectileID.Skull), new int[] { 50, 108, 124, 140, 210 } }, + { new Tuple(NPCID.SkeletronPrime, ProjectileID.DeathLaser), new int[] { 50, 108, 124, 140, 210 } }, + { new Tuple(NPCID.SkeletronPrime, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 176, 264 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.Skull), new int[] { 50, 108, 124, 140, 210 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 180, 200, 300 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.FrostBeam), new int[] { 50, 108, 124, 140, 210 } }, + { new Tuple(NPCID.PrimeCannon, ProjectileID.RocketSkeleton), new int[] { 60, 120, 148, 176, 264 } }, + { new Tuple(NPCID.PrimeCannon, ProjectileID.BombSkeletronPrime), new int[] { 80, 160, 0, 0, 300 } }, + { new Tuple(NPCID.PrimeLaser, ProjectileID.DeathLaser), new int[] { 50, 108, 124, 140, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 210 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 210 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, - { new Tuple(NPCID.Plantera, ProjectileID.SeedPlantera), new int[] { 52, 96, 128, 160, 210 } }, - { new Tuple(NPCID.Plantera, ProjectileID.PoisonSeedPlantera), new int[] { 62, 116, 144, 172, 222 } }, - { new Tuple(NPCID.Plantera, ProjectileID.ThornBall), new int[] { 72, 132, 160, 188, 240 } }, - { new Tuple(NPCID.Plantera, ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(NPCID.Plantera, ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, + { new Tuple(NPCID.Plantera, ProjectileID.SeedPlantera), new int[] { 52, 96, 128, 160, 240 } }, + { new Tuple(NPCID.Plantera, ProjectileID.PoisonSeedPlantera), new int[] { 62, 116, 144, 172, 258 } }, + { new Tuple(NPCID.Plantera, ProjectileID.ThornBall), new int[] { 72, 132, 160, 188, 282 } }, + { new Tuple(NPCID.Plantera, ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(NPCID.Plantera, ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, { new Tuple(NPCID.HallowBoss, ProjectileID.HallowBossRainbowStreak), new int[] { 100, 152, 172, 192, 300 } }, { new Tuple(NPCID.HallowBoss, ProjectileID.FairyQueenSunDance), new int[] { 120, 180, 204, 228, 360 } }, { new Tuple(NPCID.HallowBoss, ProjectileID.HallowBossLastingRainbow), new int[] { 100, 152, 172, 192, 300 } }, { new Tuple(NPCID.HallowBoss, ProjectileID.FairyQueenLance), new int[] { 130, 196, 216, 236, 390 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 244, 300 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 240 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 84, 148, 172, 196, 252 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 264 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 244, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 84, 148, 172, 196, 294 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 318 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 264 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 244, 300 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 264 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 318 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 208, 244, 366 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 318 } }, - { new Tuple(NPCID.Golem, ProjectileID.Fireball), new int[] { 72, 132, 160, 188, 234 } }, - { new Tuple(NPCID.Golem, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 246 } }, - { new Tuple(NPCID.GolemHead, ProjectileID.Fireball), new int[] { 60, 120, 160, 200, 240 } }, - { new Tuple(NPCID.GolemHead, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 246 } }, - { new Tuple(NPCID.GolemFistLeft, ProjectileID.InfernoHostileBolt), new int[] { 88, 156, 184, 212, 264 } }, - { new Tuple(NPCID.GolemFistRight, ProjectileID.InfernoHostileBolt), new int[] { 88, 156, 184, 212, 264 } }, - { new Tuple(NPCID.GolemHeadFree, ProjectileID.Fireball), new int[] { 60, 120, 160, 200, 240 } }, - { new Tuple(NPCID.GolemHeadFree, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 246 } }, - { new Tuple(NPCID.GolemHeadFree, ProjectileID.InfernoHostileBolt), new int[] { 88, 156, 184, 212, 264 } }, + { new Tuple(NPCID.Golem, ProjectileID.Fireball), new int[] { 72, 132, 160, 188, 282 } }, + { new Tuple(NPCID.Golem, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 306 } }, + { new Tuple(NPCID.GolemHead, ProjectileID.Fireball), new int[] { 60, 120, 160, 200, 300 } }, + { new Tuple(NPCID.GolemHead, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 306 } }, + { new Tuple(NPCID.GolemFistLeft, ProjectileID.InfernoHostileBolt), new int[] { 88, 156, 184, 212, 318 } }, + { new Tuple(NPCID.GolemFistRight, ProjectileID.InfernoHostileBolt), new int[] { 88, 156, 184, 212, 318 } }, + { new Tuple(NPCID.GolemHeadFree, ProjectileID.Fireball), new int[] { 60, 120, 160, 200, 300 } }, + { new Tuple(NPCID.GolemHeadFree, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 306 } }, + { new Tuple(NPCID.GolemHeadFree, ProjectileID.InfernoHostileBolt), new int[] { 88, 156, 184, 212, 318 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 264 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 264 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 360 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 318 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 88, 156, 184, 212, 318 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 372 } }, - { new Tuple(NPCID.DukeFishron, ProjectileID.Sharknado), new int[] { 80, 100, 150, 200, 240 } }, + { new Tuple(NPCID.DukeFishron, ProjectileID.Sharknado), new int[] { 80, 100, 150, 200, 300 } }, { new Tuple(NPCID.DukeFishron, ProjectileID.Cthulunado), new int[] { 160, 200, 232, 264, 480 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 300 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 300 } }, - { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossFireBall), new int[] { 88, 156, 184, 212, 264 } }, + { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossFireBall), new int[] { 88, 156, 184, 212, 318 } }, { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossIceMist), new int[] { 120, 180, 208, 236, 360 } }, - { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossLightningOrb), new int[] { 120, 192, 220, 248, 360 } }, - { new Tuple(NPCID.CultistBossClone, ProjectileID.CultistBossFireBallClone), new int[] { 90, 144, 172, 200, 270 } }, - { new Tuple(NPCID.AncientDoom, ProjectileID.AncientDoomProjectile), new int[] { 88, 156, 184, 212, 264 } }, + { new Tuple(NPCID.CultistBoss, ProjectileID.CultistBossLightningOrb), new int[] { 120, 192, 220, 248, 372 } }, + { new Tuple(NPCID.CultistBossClone, ProjectileID.CultistBossFireBallClone), new int[] { 90, 144, 172, 200, 300 } }, + { new Tuple(NPCID.AncientDoom, ProjectileID.AncientDoomProjectile), new int[] { 88, 156, 184, 212, 318 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 152, 176, 200, 270 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 152, 176, 200, 300 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 192, 212, 300 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 100, 172, 192, 212, 318 } }, - { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalDeathray), new int[] { 200, 300, 380, 460, 600 } }, - { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalBolt), new int[] { 90, 120, 160, 200, 270 } }, - { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalEye), new int[] { 90, 120, 160, 200, 270 } }, - { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalSphere), new int[] { 120, 160, 220, 280, 360 } }, - { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalBolt), new int[] { 90, 120, 160, 200, 270 } }, - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalBolt), new int[] { 100, 140, 180, 220, 300 } }, - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalEye), new int[] { 100, 140, 180, 220, 300 } }, + { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalDeathray), new int[] { 200, 300, 380, 460, 690 } }, + { new Tuple(NPCID.MoonLordHead, ProjectileID.PhantasmalBolt), new int[] { 90, 120, 160, 200, 300 } }, + { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalEye), new int[] { 90, 120, 160, 200, 300 } }, + { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalSphere), new int[] { 120, 160, 220, 280, 420 } }, + { new Tuple(NPCID.MoonLordHand, ProjectileID.PhantasmalBolt), new int[] { 90, 120, 160, 200, 300 } }, + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalBolt), new int[] { 100, 140, 180, 220, 330 } }, + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalEye), new int[] { 100, 140, 180, 220, 330 } }, { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalSphere), new int[] { 132, 176, 220, 264, 396 } }, - { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalDeathray), new int[] { 150, 200, 260, 320, 450 } }, + { new Tuple(NPCID.MoonLordFreeEye, ProjectileID.PhantasmalDeathray), new int[] { 150, 200, 260, 320, 480 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index 0536f96f59..a56fbe8ce2 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -65,10 +65,10 @@ namespace CalamityMod.Events { get { - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - if (Main.npc[i].active && (PossibleMinibossesAS.Select(miniboss => miniboss.Key).Contains(Main.npc[i].type) || - PossibleMinibossesPolter.Select(miniboss => miniboss.Key).Contains(Main.npc[i].type))) + if ((PossibleMinibossesAS.Select(miniboss => miniboss.Key).Contains(npc.type) || + PossibleMinibossesPolter.Select(miniboss => miniboss.Key).Contains(npc.type))) { return true; } @@ -107,14 +107,8 @@ namespace CalamityMod.Events { get { - int playerCount = 0; - for (int i = 0; i < Main.player.Length; i++) - { - if (Main.player[i].active) - { - playerCount++; - } - } + int playerCount = Main.CurrentFrameFlags.ActivePlayersCount; + if (DownedBossSystem.downedPolterghast) return (int)(Math.Log(playerCount + Math.E - 1) * 170f); else if (DownedBossSystem.downedAquaticScourge) @@ -189,12 +183,7 @@ namespace CalamityMod.Events if (AcidRainEventIsOngoing || (!NPC.downedBoss1 && !Main.hardMode && !DownedBossSystem.downedAquaticScourge) || BossRushEvent.BossRushActive) return; - int playerCount = 0; - for (int i = 0; i < Main.player.Length; i++) - { - if (Main.player[i].active) - playerCount++; - } + int playerCount = Main.CurrentFrameFlags.ActivePlayersCount; if (playerCount > 0) { @@ -243,12 +232,8 @@ namespace CalamityMod.Events if (!HasStartedAcidicDownpour) { int sulphSeaWidth = SulphurousSea.BiomeWidth; - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[playerIndex]; - if (!player.active) - continue; - // An artificial biome can be made, and therefore, the event could be started by an artificial biome. // While fighting the event in an artificial biome is not bad, having it be started by a patch of Sulphurous Sand // would definitely be strange. @@ -387,11 +372,9 @@ namespace CalamityMod.Events if ((int)Main.time == (int)(Main.nightLength - 1f) && !Main.dayTime && Main.rand.NextBool(increasedEventChance ? 3 : 300)) { bool shouldNotStartEvent = false; - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player player in Main.ActivePlayers) { - if (!Main.player[playerIndex].active) - continue; - if (Main.player[playerIndex].Calamity().noStupidNaturalARSpawns) + if (player.Calamity().noStupidNaturalARSpawns) { shouldNotStartEvent = true; break; @@ -407,9 +390,9 @@ namespace CalamityMod.Events // Attempt to force an Acid Rain immediately after the EoC is dead when someone wanders to the sea. if (NPC.downedBoss1 && !DownedBossSystem.downedEoCAcidRain && !HasBeenForceStartedByEoCDefeat) { - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[playerIndex].active && Main.player[playerIndex].Calamity().ZoneSulphur) + if (player.Calamity().ZoneSulphur) { HasBeenForceStartedByEoCDefeat = true; TryStartEvent(); diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 07e1b805da..6da1815a4d 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -320,14 +320,10 @@ namespace CalamityMod.Events new Boss(ModContent.NPCType(), spawnContext: type => { - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[playerIndex]; - if (p is not null && p.active) - { - if (p.FindBuffIndex(ModContent.BuffType()) > -1) - p.ClearBuff(ModContent.BuffType()); - } + if (p.FindBuffIndex(ModContent.BuffType()) > -1) + p.ClearBuff(ModContent.BuffType()); } Player player = Main.player[ClosestPlayerToWorldCenter]; @@ -415,19 +411,15 @@ namespace CalamityMod.Events BossRushDialogueSystem.StartDialogue(BossRushDialoguePhase.TierOneComplete); // Teleport players to where they came from - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[playerIndex]; - if (p is not null && p.active) + if (p.Calamity().BossRushReturnPosition.HasValue) { - if (p.Calamity().BossRushReturnPosition.HasValue) - { - CalamityPlayer.ModTeleport(p, p.Calamity().BossRushReturnPosition.Value, false, TeleportationStyleID.TeleportationPotion); - p.Calamity().BossRushReturnPosition = null; - } + CalamityPlayer.ModTeleport(p, p.Calamity().BossRushReturnPosition.Value, false, TeleportationStyleID.TeleportationPotion); p.Calamity().BossRushReturnPosition = null; - SoundEngine.PlaySound(TeleportSound with { Volume = 1.6f }, p.Center); } + p.Calamity().BossRushReturnPosition = null; + SoundEngine.PlaySound(TeleportSound with { Volume = 1.6f }, p.Center); } }, // Plantera: End of Tier 2 @@ -489,6 +481,10 @@ namespace CalamityMod.Events { get { + if (!BossRushActive) + { + return -1; + } int tier = CurrentTier; if (CalamityMod.Instance.musicMod != null) { @@ -589,7 +585,7 @@ namespace CalamityMod.Events // Increase cooldown post-Moon Lord. if (BossRushStage >= Bosses.FindIndex(boss => boss.EntityID == NPCID.MoonLordCore)) - BossRushSpawnCountdown += 300; + BossRushSpawnCountdown += 180; // Override the spawn countdown if specified. if (BossRushStage < Bosses.Count - 1 && Bosses[BossRushStage + 1].SpecialSpawnCountdown != -1) @@ -624,13 +620,9 @@ namespace CalamityMod.Events public static void End() { // Reset BossRushReturnPosition - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[playerIndex]; - if (p is not null && p.active) - { - p.Calamity().BossRushReturnPosition = null; - } + p.Calamity().BossRushReturnPosition = null; } if (Main.netMode == NetmodeID.SinglePlayer) @@ -731,18 +723,14 @@ namespace CalamityMod.Events CalamityUtils.KillAllHostileProjectiles(); HostileProjectileKillCounter = 3; - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[playerIndex]; - if (p is not null && p.active) - { - p.Calamity().BossRushReturnPosition = p.Center; - Vector2? underworld = CalamityPlayer.GetUnderworldPosition(p); - if (!underworld.HasValue) - break; - CalamityPlayer.ModTeleport(p, underworld.Value, false, TeleportationStyleID.TeleportationPotion); - SoundEngine.PlaySound(TeleportSound with { Volume = 1.6f }, p.Center); - } + p.Calamity().BossRushReturnPosition = p.Center; + Vector2? underworld = CalamityPlayer.GetUnderworldPosition(p); + if (!underworld.HasValue) + break; + CalamityPlayer.ModTeleport(p, underworld.Value, false, TeleportationStyleID.TeleportationPotion); + SoundEngine.PlaySound(TeleportSound with { Volume = 1.6f }, p.Center); } } @@ -790,12 +778,12 @@ namespace CalamityMod.Events { if (Main.netMode != NetmodeID.MultiplayerClient) { - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player p in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (p.dead) continue; - int animation = Projectile.NewProjectile(new EntitySource_WorldEvent(), Main.player[i].Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, i); + int animation = Projectile.NewProjectile(new EntitySource_WorldEvent(), p.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, p.whoAmI); if (Main.projectile.IndexInRange(animation)) Main.projectile[animation].ai[0] = tier; } diff --git a/Graphics/Metaballs/GruesomeMetaball.cs b/Graphics/Metaballs/GruesomeMetaball.cs index f1d273a344..3a67d24c7c 100644 --- a/Graphics/Metaballs/GruesomeMetaball.cs +++ b/Graphics/Metaballs/GruesomeMetaball.cs @@ -136,8 +136,12 @@ namespace CalamityMod.Graphics.Metaballs } // Draw gruesome eminence ghost heads. - foreach (Projectile eminence in CalamityUtils.AllProjectilesByID(ModContent.ProjectileType())) - eminence.ModProjectile().DrawHeadForMetaball(); + int eminenceType = ModContent.ProjectileType(); + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == eminenceType) + p.ModProjectile().DrawHeadForMetaball(); + } } } } diff --git a/Graphics/Primitives/PrimitivePixelationSystem.cs b/Graphics/Primitives/PrimitivePixelationSystem.cs index 27a40a1efd..19d5fb1b5c 100644 --- a/Graphics/Primitives/PrimitivePixelationSystem.cs +++ b/Graphics/Primitives/PrimitivePixelationSystem.cs @@ -65,12 +65,10 @@ namespace CalamityMod.Graphics.Primitives var afterProjectiles = new List(); // Check every active projectile. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - // If the projectile is active, a mod projectile, and uses the interface, add it to the list of primitives to draw this frame. - if (projectile.active && projectile.ModProjectile != null && projectile.ModProjectile is IPixelatedPrimitiveRenderer pixelPrimitiveProjectile) + if (projectile.ModProjectile != null && projectile.ModProjectile is IPixelatedPrimitiveRenderer pixelPrimitiveProjectile) { var listToUse = pixelPrimitiveProjectile.LayerToRenderTo switch { @@ -84,12 +82,10 @@ namespace CalamityMod.Graphics.Primitives } // Check every active NPC. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - var npc = Main.npc[i]; - // If the NPC is active, a mod NPC, and uses the interface, add it to the list of primitives to draw this frame. - if (npc.active && npc.ModNPC != null && npc.ModNPC is IPixelatedPrimitiveRenderer pixelPrimitiveNPC) + if (npc.ModNPC != null && npc.ModNPC is IPixelatedPrimitiveRenderer pixelPrimitiveNPC) { var listToUse = pixelPrimitiveNPC.LayerToRenderTo switch { diff --git a/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs b/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs index 2f6ee9af3f..9fdab1f84a 100644 --- a/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs @@ -89,14 +89,12 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers ActuallyDoPreDraw = true; // Draw every npc to a single target that should have the miracle blight visual. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { // Extra check to ensure that index errors will not occur. If not in range, something has gone wrong and the loop should terminate. - if (!Main.npc.IndexInRange(i)) + if (!Main.npc.IndexInRange(npc.whoAmI)) break; - NPC npc = Main.npc[i]; - if (ValidToDraw(npc)) Main.instance.DrawNPC(npc.whoAmI, npc.behindTiles); } diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 0d4956e672..ef06ec1d55 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -27,7 +27,7 @@ namespace CalamityMod.ILEditing #endregion - #region Soaring Insignia Changes + #region Remove Soaring Insignia Infinite Flight private static void RemoveSoaringInsigniaInfiniteWingTime(ILContext il) { // Prevent the infinite flight effect. @@ -42,34 +42,6 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_I4_0); cursor.Emit(OpCodes.And); } - - private static void NerfSoaringInsigniaRunAcceleration(ILContext il) - { - // Nerf the run acceleration boost from 1.75x to 1.1x. - var cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) - { - LogFailure("Soaring Insignia Mobility Nerf", "Could not locate the Soaring Insignia bool."); - return; - } - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.75f))) - { - LogFailure("Soaring Insignia Mobility Nerf", "Could not locate the Soaring Insignia run acceleration multiplier."); - return; - } - cursor.Next.Operand = 1.1f; - - // Prevent the rocket boots infinite flight effect. - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) - { - LogFailure("Soaring Insignia Mobility Nerf", "Could not locate the Soaring Insignia bool."); - return; - } - - // AND with 0 (false) so that the Soaring Insignia is never considered equipped and thus infinite rocket boots never triggers. - cursor.Emit(OpCodes.Ldc_I4_0); - cursor.Emit(OpCodes.And); - } #endregion #region Jump Height Changes @@ -258,6 +230,78 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_R4, iceSkateTopSpeed); } } + + private static void NerfOverpoweredRunAccelerationSources(ILContext il) + { + // First: Soaring Insignia. Find the check for whether it's equipped for run speeds. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Soaring Insignia bool."); + return; + } + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.75f))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Soaring Insignia run acceleration multiplier."); + return; + } + cursor.Next.Operand = BalancingConstants.SoaringInsigniaRunAccelerationMultiplier; + + // Second: Magiluminescence. Find the check for whether it's equipped for run speeds. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("hasMagiluminescence"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Magiluminescence bool."); + return; + } + + // + // Don't actually do anything. Magiluminescence is not intended to be nerfed by Calamity. + // + + // Third: Shadow Armor. Find the check for whether it's equipped for run speeds. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("shadowArmor"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Shadow Armor bool."); + return; + } + + // Load the player onto the stack as an argument to the following delegate. + // Emit a delegate which consumes the Shadow Armor bool, performs Calamity effects, then always returns false. + // Returning false ensures vanilla Shadow Armor code never runs. + cursor.Emit(OpCodes.Ldarg_0); + + cursor.EmitDelegate((bool shadowArmor, Player p) => { + // If you don't even have Shadow Armor equipped, do nothing. + if (!shadowArmor) + return 0; + + // Shadow Armor does not stack with Magiluminescence if you are on the ground. + if (p.hasMagiluminescence && p.velocity.Y == 0) + return 0; + + // Shadow Armor grants reduced movement bonuses if in the air, or on the ground WITHOUT Magiluminescence. + p.runAcceleration *= BalancingConstants.ShadowArmorRunAccelerationMultiplier; + p.maxRunSpeed *= BalancingConstants.ShadowArmorMaxRunSpeedMultiplier; + p.accRunSpeed *= BalancingConstants.ShadowArmorAccRunSpeedMultiplier; + p.runSlowdown *= BalancingConstants.ShadowArmorRunSlowdownMultiplier; + + // Vanilla Shadow Armor behavior should still always be skipped. + return 0; + }); + + + // Finally: Back to Soaring Insignia. Prevent the rocket boots infinite flight effect, since it's in the same function. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Soaring Insignia bool."); + return; + } + + // AND with 0 (false) so that the Soaring Insignia is never considered equipped and thus infinite rocket boots never triggers. + cursor.Emit(OpCodes.Ldc_I4_0); + cursor.Emit(OpCodes.And); + } #endregion #region Life Regen Changes diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 04892f9102..c2ea95f2b1 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -13,6 +13,7 @@ using Terraria.GameContent.Liquid; using Terraria.GameContent.UI.Elements; using Terraria.GameContent.UI.States; using Terraria.Graphics.Light; +using Terraria.Map; using Terraria.ModLoader; namespace CalamityMod.ILEditing @@ -106,7 +107,7 @@ namespace CalamityMod.ILEditing IL_Player.UpdateJumpHeight += FixJumpHeightBoosts; IL_Player.Update += BaseJumpHeightAdjustment; IL_Player.Update += RunSpeedAdjustments; - IL_Player.Update += NerfSoaringInsigniaRunAcceleration; + IL_Player.Update += NerfOverpoweredRunAccelerationSources; // Soaring Insignia, Magiluminescence, and Shadow Armor IL_Player.WingMovement += RemoveSoaringInsigniaInfiniteWingTime; // Life regen balance @@ -160,6 +161,9 @@ namespace CalamityMod.ILEditing // Fix vanilla not accounting for multiple bobbers when fishing with truffle worm IL_Player.ItemCheck_CheckFishingBobbers += FixTruffleWormFishing; + + // Allow specified walls to be visible through water on the map + IL_MapHelper.CreateMapTile += UseVisibleThroughWaterMapTile; //Additional detours that are in their own item files given they are only relevant to these specific items: //Rover drive detours on Player.DrawInfernoRings to draw its shield diff --git a/ILEditing/ILHelperMethods.cs b/ILEditing/ILHelperMethods.cs index bd8175fb1f..01f2379f0e 100644 --- a/ILEditing/ILHelperMethods.cs +++ b/ILEditing/ILHelperMethods.cs @@ -64,7 +64,7 @@ namespace CalamityMod.ILEditing SoundEngine.PlaySound(SoundID.DoorClosed, new Vector2(doorX * 16, doorY * 16)); return true; } - + private static Texture2D SelectLavaTexture(Texture2D initialTexture, LiquidTileType type) { // Use the initial texture if it isn't lava. diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 37bdeebdbd..fb4fe1510e 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -736,22 +736,16 @@ namespace CalamityMod.ILEditing Main.spriteBatch.SetBlendState(BlendState.Additive); // Draw Projectiles. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!Main.projectile[i].active) - continue; - - if (Main.projectile[i].ModProjectile is IAdditiveDrawer d) + if (p.ModProjectile is IAdditiveDrawer d) d.AdditiveDraw(Main.spriteBatch); } // Draw NPCs. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].active) - continue; - - if (Main.npc[i].ModNPC is IAdditiveDrawer d) + if (n.ModNPC is IAdditiveDrawer d) d.AdditiveDraw(Main.spriteBatch); } diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index 379e93326d..9a430ec383 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -7,12 +7,14 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Walls; using Microsoft.Xna.Framework; using Mono.Cecil.Cil; using MonoMod.Cil; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Map; using Terraria.ModLoader; namespace CalamityMod.ILEditing @@ -269,7 +271,7 @@ namespace CalamityMod.ILEditing // Sync the color changes. if (colorWasChanged) - NetMessage.SendData(MessageID.ItemTweaker, -1, -1, null, itemID, 1f); + NetMessage.SendData(MessageID.ItemTweaker, -1, -1, null, itemIndex, 1f); } #endregion Color Blighted Gel @@ -898,5 +900,62 @@ namespace CalamityMod.ILEditing } } #endregion + + #region Render Special Map Colors + private static void UseVisibleThroughWaterMapTile(ILContext il) + { + var c = new ILCursor(il); + + if (!c.TryGotoNext(x => x.MatchCall("get_Item"))) + { + LogFailure("Use VisibleThroughWater Map Tile", "Could not locate call to Terraria.Map.TileMap::get_Item."); + return; + } + + int tileIndex = -1; + if (!c.TryGotoNext(x => x.MatchStloc(out tileIndex)) || tileIndex == -1) + { + LogFailure("Use VisibleThroughWater Map Tile", "Could not determine the local variable index tile is pushed to."); + return; + } + + if (!c.TryGotoNext(x => x.MatchCall("liquidType"))) + { + LogFailure("Use VisibleThroughWater Map Tile", "Could not locate call to Terraria.Tile::liquidType."); + return; + } + + int liquidTypeIndex = -1; + if (!c.TryGotoNext(x => x.MatchStloc(out liquidTypeIndex)) || liquidTypeIndex == -1) + { + LogFailure("Use VisibleThroughWater Map Tile", "Could not determine the local variable index liquidType is pushed to."); + return; + } + + int relativeMapTypeIndex = -1; + if (!c.TryGotoNext(MoveType.After, x => x.MatchStloc(out relativeMapTypeIndex)) || relativeMapTypeIndex == -1) + { + LogFailure("Use VisibleThroughWater Map Tile", "Could not determine the local variable index of the relative map type."); + return; + } + + c.Emit(OpCodes.Ldloc_0); + c.Emit(OpCodes.Ldloc, relativeMapTypeIndex); + c.Emit(OpCodes.Ldloc, liquidTypeIndex); + c.EmitDelegate( + (Tile tile, int relativeMapType, int liquidType) => + { + if (liquidType != LiquidID.Water) + return relativeMapType; + + if (WallLoader.GetWall(tile.WallType) is IVisibleThroughWater visibleThroughWater) + return visibleThroughWater.WaterMapEntry; + + return relativeMapType; + } + ); + c.Emit(OpCodes.Stloc, relativeMapTypeIndex); + } + #endregion } } diff --git a/Items/Accessories/DaawnlightSpiritOrigin.cs b/Items/Accessories/DaawnlightSpiritOrigin.cs index e6a42c5c25..e37ec2dcc2 100644 --- a/Items/Accessories/DaawnlightSpiritOrigin.cs +++ b/Items/Accessories/DaawnlightSpiritOrigin.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Accessories // Regular crits are intentionally weak, especially because they rarely happen (your crit chance gets murdered). // Bullseyes should be doing all the work. private const float OriginBullseyeCritRatio = 3.5f; // Bullseye crits deal x3.5 damage instead of x2. - private const float RicoshotBullseyeCritRatio = 2.4f; // If you use Ricoshot mechanics to "force" a bullseye, you get less of a reward. + private const float ForcedCritBullseyeCritRatio = 2.4f; // If your projectile is forced to crit, you get less of a reward. private const float StoredCritConversionRatio = 0.01f; // Add +1% more damage to crits for every 1% critical chance the player would have had. private const float MinUseTimeForSlowBonus = 11f; @@ -39,8 +39,8 @@ namespace CalamityMod.Items.Accessories if (hitBullseye) { // Bullseye crits are weaker if the projectile was already a forced crit. - // This currently only occurs due to ULTRAKILL-style ricoshots. - baseCritMult = wasForcedCrit ? RicoshotBullseyeCritRatio : OriginBullseyeCritRatio; + // This is currently implemented for ULTRAKILL-style ricoshots and for Heavenly Gale's lightning. + baseCritMult = wasForcedCrit ? ForcedCritBullseyeCritRatio : OriginBullseyeCritRatio; } // Factor in the critical strike chance the player isn't getting to use. diff --git a/Items/Accessories/InfectedJewel.cs b/Items/Accessories/InfectedJewel.cs index 86c11199ca..c5c18c08f6 100644 --- a/Items/Accessories/InfectedJewel.cs +++ b/Items/Accessories/InfectedJewel.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Accessories CreateRecipe(). AddIngredient(). AddIngredient(10). - AddIngredient(25). + AddIngredient(25). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index fcbb9e69d8..a9ead56f4f 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -39,9 +39,9 @@ namespace CalamityMod.Items.Accessories if (Main.rand.NextBool(15)) { int numProj = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType()) + if (p.owner == player.whoAmI && p.type == ModContent.ProjectileType()) { numProj++; } diff --git a/Items/Accessories/ProfanedSoulArtifact.cs b/Items/Accessories/ProfanedSoulArtifact.cs index 1823d0a29b..21905aa701 100644 --- a/Items/Accessories/ProfanedSoulArtifact.cs +++ b/Items/Accessories/ProfanedSoulArtifact.cs @@ -38,10 +38,9 @@ namespace CalamityMod.Items.Accessories get { bool result = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -118,10 +117,9 @@ namespace CalamityMod.Items.Accessories // Visibility is not net synced, for example. bool alreadyDrawnShieldForPlayer = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -135,6 +133,7 @@ namespace CalamityMod.Items.Accessories // Scale the shield is drawn at. // The "i" parameter is to make different player's shields not be perfectly synced. + int i = player.whoAmI; float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f)); if (!alreadyDrawnShieldForPlayer) diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index e04ec73a75..926771a180 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -42,10 +42,9 @@ namespace CalamityMod.Items.Accessories get { bool result = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/Purity.cs b/Items/Accessories/Radiance.cs similarity index 95% rename from Items/Accessories/Purity.cs rename to Items/Accessories/Radiance.cs index 4bdeeaa82d..b8f71335c4 100644 --- a/Items/Accessories/Purity.cs +++ b/Items/Accessories/Radiance.cs @@ -10,8 +10,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - [LegacyName("AstralArcanum")] - public class Purity : ModItem, ILocalizedModType + [LegacyName("AstralArcanum", "Purity")] + public class Radiance : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; public override void SetStaticDefaults() diff --git a/Items/Accessories/Purity.png b/Items/Accessories/Radiance.png similarity index 100% rename from Items/Accessories/Purity.png rename to Items/Accessories/Radiance.png diff --git a/Items/Accessories/RoverDrive.cs b/Items/Accessories/RoverDrive.cs index 92b08066ed..f2669eef54 100644 --- a/Items/Accessories/RoverDrive.cs +++ b/Items/Accessories/RoverDrive.cs @@ -38,11 +38,10 @@ namespace CalamityMod.Items.Accessories get { bool result = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) - continue; + if (player.outOfRange || player.dead) + continue; CalamityPlayer modPlayer = player.Calamity(); @@ -112,10 +111,9 @@ namespace CalamityMod.Items.Accessories // Visibility is not net synced, for example. bool alreadyDrawnShieldForPlayer = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -127,7 +125,7 @@ namespace CalamityMod.Items.Accessories continue; // The shield very gently grows and shrinks - float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f)); + float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + player.whoAmI * 0.2f)); if (!alreadyDrawnShieldForPlayer) { diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index 430535724a..1d77244faf 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -58,13 +58,12 @@ namespace CalamityMod.Items.Accessories if (auraCounter == 9) { auraCounter = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.IsAnEnemy() && !npc.dontTakeDamage && Vector2.Distance(player.Center, npc.Center) <= range) { int campingFireDamage = (int)player.GetBestClassDamage().ApplyTo(Main.rand.Next(20, 41)); - Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), campingFireDamage, 0f, player.whoAmI, i); + Projectile.NewProjectileDirect(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), campingFireDamage, 0f, player.whoAmI, npc.whoAmI); } } } diff --git a/Items/Accessories/TheSponge.cs b/Items/Accessories/TheSponge.cs index 16fe75addd..a58d372c0b 100644 --- a/Items/Accessories/TheSponge.cs +++ b/Items/Accessories/TheSponge.cs @@ -47,10 +47,9 @@ namespace CalamityMod.Items.Accessories get { bool result = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -178,10 +177,9 @@ namespace CalamityMod.Items.Accessories // Visibility is not net synced, for example. bool alreadyDrawnShieldForPlayer = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -194,6 +192,7 @@ namespace CalamityMod.Items.Accessories // Scale the shield is drawn at. The Sponge shield gently grows and shrinks; it should be largely imperceptible. // The "i" parameter is to make different player's shields not be perfectly synced. + int i = player.whoAmI; float baseScale = 0.155f; float maxExtraScale = 0.025f; float extraScalePulseInterpolant = MathF.Pow(4f, MathF.Sin(Main.GlobalTimeWrappedHourly * 0.791f + i) - 1); diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index b5cbd57c43..ee4b89c267 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -40,9 +40,8 @@ namespace CalamityMod.Items.Accessories { if (random == 0) { - for (int l = 0; l < Main.maxNPCs; l++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[l]; if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[plagueDebuff] && Vector2.Distance(player.Center, nPC.Center) <= 300f) { if (nPC.FindBuffIndex(plagueDebuff) == -1) @@ -53,7 +52,7 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectileDirect(source, nPC.Center, Vector2.Zero, ModContent.ProjectileType(), auraDamage, 0f, player.whoAmI, l); + Projectile.NewProjectileDirect(source, nPC.Center, Vector2.Zero, ModContent.ProjectileType(), auraDamage, 0f, player.whoAmI, nPC.whoAmI); } } } diff --git a/Items/Accessories/WarbanneroftheSun.cs b/Items/Accessories/WarbanneroftheSun.cs index 3b16c87ca2..ff2003d17f 100644 --- a/Items/Accessories/WarbanneroftheSun.cs +++ b/Items/Accessories/WarbanneroftheSun.cs @@ -49,26 +49,24 @@ namespace CalamityMod.Items.Accessories float bonus = 0f; int closestNPC = -1; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; if (nPC.IsAnEnemy() && !nPC.dontTakeDamage) { - closestNPC = i; + closestNPC = nPC.whoAmI; break; } } float distance = -1f; - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[j]; if (nPC.IsAnEnemy() && !nPC.dontTakeDamage) { float distance2 = Math.Abs(nPC.position.X + (float)(nPC.width / 2) - (player.position.X + (float)(player.width / 2))) + Math.Abs(nPC.position.Y + (float)(nPC.height / 2) - (player.position.Y + (float)(player.height / 2))); if (distance == -1f || distance2 < distance) { distance = distance2; - closestNPC = j; + closestNPC = nPC.whoAmI; } } } diff --git a/Items/Accessories/WulfrumAcrobaticsPack.cs b/Items/Accessories/WulfrumAcrobaticsPack.cs index 0558fdda00..78fc5d2339 100644 --- a/Items/Accessories/WulfrumAcrobaticsPack.cs +++ b/Items/Accessories/WulfrumAcrobaticsPack.cs @@ -361,10 +361,9 @@ namespace CalamityMod.Items.Accessories if (bestGrapplePos != Point.Zero) { //Clear any hooks that might have been flying before then. - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (!p.active || p.owner != Player.whoAmI || p.type != ProjectileType()) + if (p.owner != Player.whoAmI || p.type != ProjectileType()) continue; if (p.ModProjectile is WulfrumHook) @@ -412,10 +411,9 @@ namespace CalamityMod.Items.Accessories if (triggersSet.Grapple && Player.releaseHook) { //Clear any previous non-wulfrum hooks / Any hooks that just got shot (should already be handled by the global proj - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (!p.active || p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType()) + if (p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType()) continue; p.Kill(); @@ -443,10 +441,9 @@ namespace CalamityMod.Items.Accessories //Jumping out of the hook if (triggersSet.Jump && Player.releaseJump) { - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (!p.active || p.owner != Player.whoAmI || p.type != ProjectileType()) + if (p.owner != Player.whoAmI || p.type != ProjectileType()) continue; //Only clear hooks that are attached to stuff diff --git a/Items/AlicornonaStick.cs b/Items/AlicornonaStick.cs index 9c3ce74d19..4f30a42f0b 100644 --- a/Items/AlicornonaStick.cs +++ b/Items/AlicornonaStick.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Items { int offset = player.direction == 1 ? 5 : -Item.width - 5; Rectangle itemRect = new Rectangle((int)player.Center.X + offset, (int)player.position.Y - 10, Item.width, Item.height); - foreach (NPC npc in Main.npc) + foreach (NPC npc in Main.ActiveNPCs) { - if (npc.active && npc != null && !npc.dontTakeDamage && npc.type != ModContent.NPCType()) + if (!npc.dontTakeDamage && npc.type != ModContent.NPCType()) { if (itemRect.Intersects(npc.getRect())) { diff --git a/Items/AntiCystOintment.cs b/Items/AntiCystOintment.cs index 464176fd38..c109169272 100644 --- a/Items/AntiCystOintment.cs +++ b/Items/AntiCystOintment.cs @@ -1,11 +1,16 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { public class AntiCystOintment : ModItem, ILocalizedModType { + public static bool state = false; public new string LocalizationCategory => "Items.Misc"; public override void SetDefaults() { @@ -20,12 +25,71 @@ namespace CalamityMod.Items itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; } - public override void UpdateInventory(Player player) + public override bool CanRightClick() => true; + + public override void RightClick(Player player) { - if (Item.favorited) + if (player.Calamity().disablePerfCystSpawns == true) + player.Calamity().disablePerfCystSpawns = false; + else player.Calamity().disablePerfCystSpawns = true; + Item.NetStateChanged(); + state = player.Calamity().disablePerfCystSpawns; + + bool favorited = Item.favorited; + Item.SetDefaults(ModContent.ItemType()); + Item.stack++; + Item.favorited = favorited; } + /* + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/AntiCystOintment").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/AntiCystOintment").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/AntiCystOintment").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/AntiCystOintment").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return false; + } + */ + + public override void ModifyTooltips(List tooltips) + { + string text; + if (state == true) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } public override void AddRecipes() { CreateRecipe(). diff --git a/Items/AntiTumorOintment.cs b/Items/AntiTumorOintment.cs index 0c356725ec..1ee5b62e48 100644 --- a/Items/AntiTumorOintment.cs +++ b/Items/AntiTumorOintment.cs @@ -1,11 +1,16 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { public class AntiTumorOintment : ModItem, ILocalizedModType { + public static bool state = false; public new string LocalizationCategory => "Items.Misc"; public override void SetDefaults() { @@ -20,10 +25,69 @@ namespace CalamityMod.Items itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; } - public override void UpdateInventory(Player player) + public override bool CanRightClick() => true; + + public override void RightClick(Player player) { - if (Item.favorited) + if (player.Calamity().disableHiveCystSpawns == true) + player.Calamity().disableHiveCystSpawns = false; + else player.Calamity().disableHiveCystSpawns = true; + Item.NetStateChanged(); + state = player.Calamity().disableHiveCystSpawns; + + bool favorited = Item.favorited; + Item.SetDefaults(ModContent.ItemType()); + Item.stack++; + Item.favorited = favorited; + } + /* + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/AntiTumorOintment").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/AntiTumorOintment").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/AntiTumorOintment").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/AntiTumorOintment").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return false; + } + */ + + public override void ModifyTooltips(List tooltips) + { + string text; + if (state == true) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); } public override void AddRecipes() diff --git a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs index f8c38f6f04..9333121be6 100644 --- a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs +++ b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs @@ -42,10 +42,9 @@ namespace CalamityMod.Items.Armor.LunicCorps get { bool result = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -116,10 +115,9 @@ namespace CalamityMod.Items.Armor.LunicCorps // Visibility is not net synced, for example. bool alreadyDrawnShieldForPlayer = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active || player.outOfRange || player.dead) + if (player.outOfRange || player.dead) continue; CalamityPlayer modPlayer = player.Calamity(); @@ -130,6 +128,7 @@ namespace CalamityMod.Items.Armor.LunicCorps // Scale the shield is drawn at. The Lunic Corps shield sticks very close to the body to mimic Halo and occasionally pulses. // The "i" parameter is to make different player's shields not be perfectly synced. + int i = player.whoAmI; float baseScale = 0.11f; float maxExtraScale = 0.013f; float extraScalePulseInterpolant = MathF.Pow(12f, MathF.Sin(Main.GlobalTimeWrappedHourly * 1.6f + i) - 1); diff --git a/Items/BleachBall.cs b/Items/BleachBall.cs index 697b0860b1..72c06d37a5 100644 --- a/Items/BleachBall.cs +++ b/Items/BleachBall.cs @@ -1,12 +1,17 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { public class BleachBall : ModItem, ILocalizedModType { + public static bool state = false; public new string LocalizationCategory => "Items.Misc"; public override void SetDefaults() { @@ -21,10 +26,70 @@ namespace CalamityMod.Items itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; } - public override void UpdateInventory(Player player) + public override bool CanRightClick() => true; + + public override void RightClick(Player player) { - if (Item.favorited) + if (player.Calamity().disableNaturalScourgeSpawns == true) + player.Calamity().disableNaturalScourgeSpawns = false; + else player.Calamity().disableNaturalScourgeSpawns = true; + Item.NetStateChanged(); + state = player.Calamity().disableNaturalScourgeSpawns; + + bool favorited = Item.favorited; + Item.SetDefaults(ModContent.ItemType()); + Item.stack++; + Item.favorited = favorited; + } + + /* + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/BleachBall").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/BleachBall").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/BleachBall").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/BleachBall").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return false; + } + */ + + public override void ModifyTooltips(List tooltips) + { + string text; + if (state == true) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); } public override void AddRecipes() diff --git a/Items/BrokenWaterFilter.cs b/Items/BrokenWaterFilter.cs index 208a8a0a43..c4fe0204bc 100644 --- a/Items/BrokenWaterFilter.cs +++ b/Items/BrokenWaterFilter.cs @@ -2,11 +2,16 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { public class BrokenWaterFilter : ModItem, ILocalizedModType { + public static bool state = false; public new string LocalizationCategory => "Items.Misc"; public override void SetDefaults() { @@ -21,10 +26,70 @@ namespace CalamityMod.Items itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; } - public override void UpdateInventory(Player player) + public override bool CanRightClick() => true; + + public override void RightClick(Player player) { - if (Item.favorited) + if (player.Calamity().noStupidNaturalARSpawns == true) + player.Calamity().noStupidNaturalARSpawns = false; + else player.Calamity().noStupidNaturalARSpawns = true; + Item.NetStateChanged(); + state = player.Calamity().noStupidNaturalARSpawns; + + bool favorited = Item.favorited; + Item.SetDefaults(ModContent.ItemType()); + Item.stack++; + Item.favorited = favorited; + } + + /* + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/BrokenWaterFilter").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/BrokenWaterFilter").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/BrokenWaterFilter").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/BrokenWaterFilter").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return false; + } + */ + + public override void ModifyTooltips(List tooltips) + { + string text; + if (state == true) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); } public override void AddRecipes() diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 6c0d570a95..8c6efe6774 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -160,6 +160,10 @@ namespace CalamityMod.Items if (item.type == ItemID.PearlwoodBow || item.type == ItemID.PearlwoodHammer || item.type == ItemID.PearlwoodSword) item.rare = ItemRarityID.LightRed; + //Flame Waker Boots are no longer just vanity and therefore lose the vanity tooltip. + if (item.type == ItemID.FlameWakerBoots) + item.vanity = false; + // Volatile Gelatin is pre-mech post-WoF so it should use the pink rarity. if (item.type == ItemID.VolatileGelatin) item.rare = ItemRarityID.Pink; @@ -509,11 +513,11 @@ namespace CalamityMod.Items } if (item.type == ItemID.PearlwoodBow) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && (Main.projectile[i].type == ModContent.ProjectileType() || Main.projectile[i].type == ModContent.ProjectileType()) && Main.projectile[i].owner == player.whoAmI) + if ((p.type == ModContent.ProjectileType() || p.type == ModContent.ProjectileType()) && p.owner == player.whoAmI) { - Main.projectile[i].Kill(); + p.Kill(); } } for (int i = -8; i <= 8; i += 8) @@ -674,9 +678,9 @@ namespace CalamityMod.Items if (player.ActiveItem().type == ModContent.ItemType()) { bool hasBlades = false; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) + if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI && p.localAI[1] == 0f) { hasBlades = true; break; @@ -684,22 +688,22 @@ namespace CalamityMod.Items } if (hasBlades) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].ModProjectile is IgneousBlade) + if (p.ModProjectile is IgneousBlade) { - if (Main.projectile[i].ModProjectile().Firing) + if (p.ModProjectile().Firing) continue; } - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) + if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI && p.localAI[1] == 0f) { - Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4; - Main.projectile[i].velocity = Main.projectile[i].SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * 22f; - Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation(); - Main.projectile[i].ai[0] = 180f; - Main.projectile[i].ModProjectile().Firing = true; - Main.projectile[i].tileCollide = true; - Main.projectile[i].netUpdate = true; + p.rotation = MathHelper.PiOver2 + MathHelper.PiOver4; + p.velocity = p.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * 22f; + p.rotation += p.velocity.ToRotation(); + p.ai[0] = 180f; + p.ModProjectile().Firing = true; + p.tileCollide = true; + p.netUpdate = true; } } } @@ -707,13 +711,13 @@ namespace CalamityMod.Items } if (player.ActiveItem().type == ModContent.ItemType() && player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].ModProjectile is VoidConcentrationAura) + if (p.ModProjectile is VoidConcentrationAura) { - if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (p.owner == player.whoAmI) { - Main.projectile[i].ModProjectile().HandleRightClick(); + p.ModProjectile().HandleRightClick(); break; } } @@ -724,18 +728,18 @@ namespace CalamityMod.Items { bool canContinue = true; int count = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI) + if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI) { - if (Main.projectile[i].ai[1] > 1f) + if (p.ai[1] > 1f) { canContinue = false; break; } - else if (Main.projectile[i].ai[1] == 0f) + else if (p.ai[1] == 0f) { - if (((GlacialEmbracePointyThing)Main.projectile[i].ModProjectile).circlingPlayer) + if (((GlacialEmbracePointyThing)p.ModProjectile).circlingPlayer) count++; } } @@ -1179,9 +1183,18 @@ namespace CalamityMod.Items if (item.type == ItemID.AnkhShield) player.buffImmune[BuffID.WindPushed] = true; + if (item.type == ItemID.FlameWakerBoots) + { + modPlayer.flameWakerBoots = true; + if (modPlayer.bootLevel < 1) + modPlayer.bootLevel = 1; + } + if (item.type == ItemID.HellfireTreads) { modPlayer.hellfireTreads = true; + if (modPlayer.bootLevel < 2) + modPlayer.bootLevel = 2; player.buffImmune[BuffID.OnFire] = true; } @@ -1443,7 +1456,7 @@ namespace CalamityMod.Items player.AddBuff(BuffID.DryadsWard, 5, true); // Dryad's Blessing } } - else if (item.type == ItemID.FestiveWings) // Drop powerful homing christmas tree bulbs while in flight + else if (item.type == ItemID.FestiveWings) // Drop homing christmas tree bulbs while in flight { player.noFallDmg = true; player.statLifeMax2 += 40; @@ -1452,13 +1465,13 @@ namespace CalamityMod.Items var source = player.GetSource_Accessory(item); if (player.controlJump && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) { - int ornamentDamage = (int)player.GetBestClassDamage().ApplyTo(100); + int ornamentDamage = (int)player.GetBestClassDamage().ApplyTo(50); int p = Projectile.NewProjectile(source, player.Center, Vector2.UnitY * 2f, ProjectileID.OrnamentFriendly, ornamentDamage, 5f, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) { Main.projectile[p].DamageType = DamageClass.Generic; Main.projectile[p].Calamity().lineColor = 1; - modPlayer.icicleCooldown = 10; + modPlayer.icicleCooldown = 15; } } } diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index c0ae5fd933..d2fa8e249d 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -326,7 +326,7 @@ namespace CalamityMod.Items // There are no item sets for tombstones wtf if (item.type == ItemID.Tombstone || item.type == ItemID.GraveMarker || item.type == ItemID.CrossGraveMarker || item.type == ItemID.Headstone || item.type == ItemID.Gravestone || item.type == ItemID.Obelisk || item.type == ItemID.RichGravestone1 || item.type == ItemID.RichGravestone2 || item.type == ItemID.RichGravestone3 || item.type == ItemID.RichGravestone4 || item.type == ItemID.RichGravestone5) - EditTooltipByName("Material", (line) => line.Text += "\n20 of any tombstone turns the surrounding area into a graveyard" + EditTooltipByName("Material", (line) => line.Text += "\n13 of any tombstone turns the surrounding area into a graveyard" + "\nGraveyards have various new item sales and recipes"); // Eternity Crystal notifies the player that they can accelerate the invasion @@ -429,7 +429,7 @@ namespace CalamityMod.Items // Cobalt if (item.type == ItemID.CobaltSword || item.type == ItemID.CobaltNaginata) - EditTooltipByName("Knockback", (line) => line.Text += "\nPermanently decreases enemy defense by 25% on hit"); + EditTooltipByName("Knockback", (line) => line.Text += "\nDecreases enemy defense by 25% on hit\nThis effect lasts for 10 seconds"); // Palladium if (item.type == ItemID.PalladiumSword || item.type == ItemID.PalladiumPike) @@ -437,7 +437,7 @@ namespace CalamityMod.Items // Mythril if (item.type == ItemID.MythrilSword || item.type == ItemID.MythrilHalberd) - EditTooltipByName("Knockback", (line) => line.Text += "\nPermanently decreases enemy contact damage by 10% on hit"); + EditTooltipByName("Knockback", (line) => line.Text += "\nDecreases enemy contact damage by 10% on hit\nThis effect lasts for 10 seconds"); // Orichalcum if (item.type == ItemID.OrichalcumSword || item.type == ItemID.OrichalcumHalberd) @@ -583,11 +583,19 @@ namespace CalamityMod.Items "Drinking more than 3 different alcohols might not end well with your liver"); } + //Flame Waker Boots buff. + if (item.type == ItemID.FlameWakerBoots) + { + EditTooltipByNum(0, (line) => line.Text = "Multiplies all fire-based debuff damage by 1.25\n" + + "All attacks light enemies on fire\n" + + "'Never get cold feet again'\n"); + } + // Hellfire Treads buff. if (item.type == ItemID.HellfireTreads) { EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("fire blocks", "the Burning and On Fire! debuffs")); - EditTooltipByNum(2, (line) => line.Text += "\nMultiplies all fire-based debuff damage by 1.5\n" + + EditTooltipByNum(2, (line) => line.Text += "\nMultiplies all fire-based debuff damage by 1.5, does not stack with downgrades\n" + "All attacks inflict Hellfire"); } @@ -820,7 +828,7 @@ namespace CalamityMod.Items if (item.type == ItemID.PlatinumHelmet) AddTooltip("6% increased damage"); if (item.type == ItemID.PlatinumChainmail) - AddTooltip("5% increased critical strike chance"); + AddTooltip("3% increased critical strike chance"); if (item.type == ItemID.PlatinumGreaves) AddTooltip("10% increased movement speed"); @@ -833,17 +841,14 @@ namespace CalamityMod.Items if (item.type == ItemID.JunglePants || item.type == ItemID.AncientCobaltLeggings) EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("6%", "3%")); - // Shadow - if (item.type == ItemID.ShadowHelmet || item.type == ItemID.AncientShadowHelmet || item.type == ItemID.ShadowScalemail || item.type == ItemID.AncientShadowScalemail || item.type == ItemID.ShadowGreaves || item.type == ItemID.AncientShadowGreaves) - EditTooltipByNum(0, (line) => line.Text = "5% increased damage and 7% increased jump speed"); - // Crimson if (item.type == ItemID.CrimsonHelmet || item.type == ItemID.CrimsonScalemail || item.type == ItemID.CrimsonGreaves) { EditTooltipByNum(0, (line) => { - string newTooltip = line.Text.Replace("3%", "5%"); - newTooltip += "\n+0.5 HP/s life regen"; + string newTooltip = line.Text.Replace("3%", "6%"); + // Chest piece has 2 regen instead of 1 + newTooltip += item.type == ItemID.CrimsonScalemail ? "\n+1 HP/s life regen" : "\n+0.5 HP/s life regen"; line.Text = newTooltip; }); } diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 877fc5ffeb..4b73cceaba 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -601,6 +601,7 @@ namespace CalamityMod.Items { ItemID.SpicyPepper, Do(Value(Item.sellPrice(copper: 40))) }, { ItemID.Starfruit, Do(Value(Item.sellPrice(copper: 40))) }, { ItemID.PortableStool, Do(Value(Item.sellPrice(copper: 20))) }, // Step Stool + { ItemID.UncumberingStone, Do(Worthless) }, { ItemID.ViciousMushroom, Do(Worthless) }, { ItemID.VileMushroom, Do(Worthless) }, #endregion diff --git a/Items/Dyes/DefiledFlameDye.cs b/Items/Dyes/DefiledFlameDye.cs index 5f8543ddf1..1e8fe79c46 100644 --- a/Items/Dyes/DefiledFlameDye.cs +++ b/Items/Dyes/DefiledFlameDye.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { Item.rare = ItemRarityID.LightRed; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; + //Light red is 12 gold, and this is purchased with 10 gold, this would make it sell for 6 gold, still far more expensive than vanilla dyes + Item.value = CalamityGlobalItem.RarityLightRedBuyPrice/2; } } } diff --git a/Items/Dyes/NecroplasmicDye.cs b/Items/Dyes/NecroplasmicDye.cs index 7591885281..8c9c1dd00d 100644 --- a/Items/Dyes/NecroplasmicDye.cs +++ b/Items/Dyes/NecroplasmicDye.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { - [LegacyName("PhantoplasmDye")] + [LegacyName("PhantoplasmDye", "PolterplasmDye")] public class NecroplasmicDye : BaseDye { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(Mod.Assets.Request("Effects/Dyes/NecroplasmicDyeShader"), "DyePass"). diff --git a/Items/Fishing/AstralCatches/AstralCrate.cs b/Items/Fishing/AstralCatches/AstralCrate.cs index 9c5c6ec6db..690c4c8e8b 100644 --- a/Items/Fishing/AstralCatches/AstralCrate.cs +++ b/Items/Fishing/AstralCatches/AstralCrate.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Fishing.AstralCatches var postAstrumDeus = itemLoot.DefineConditionalDropSet(() => DownedBossSystem.downedAstrumDeus); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 5, 10); + itemLoot.Add(ModContent.ItemType(), 1, 5, 10); itemLoot.Add(ItemID.FallenStar, 1, 5, 10); itemLoot.Add(ItemID.Meteorite, 5, 10, 20); itemLoot.Add(ItemID.MeteoriteBar, 10, 1, 3); diff --git a/Items/Materials/AstralBar.cs b/Items/Materials/AstralBar.cs index 2bf49e1fb2..d9b21326f3 100644 --- a/Items/Materials/AstralBar.cs +++ b/Items/Materials/AstralBar.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Materials public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddIngredient(2). AddTile(TileID.LunarCraftingStation). Register(); diff --git a/Items/Materials/MeldConstruct.cs b/Items/Materials/MeldConstruct.cs index b49062f647..feded67f84 100644 --- a/Items/Materials/MeldConstruct.cs +++ b/Items/Materials/MeldConstruct.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Materials { CreateRecipe(3). AddIngredient(6). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Materials/Necroplasm.cs b/Items/Materials/Necroplasm.cs index 95dceb3057..4a64871a61 100644 --- a/Items/Materials/Necroplasm.cs +++ b/Items/Materials/Necroplasm.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - [LegacyName("Phantoplasm")] + [LegacyName("Phantoplasm", "Polterplasm")] public class Necroplasm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Materials"; diff --git a/Items/Materials/Stardust.cs b/Items/Materials/StarblightSoot.cs similarity index 86% rename from Items/Materials/Stardust.cs rename to Items/Materials/StarblightSoot.cs index a7a658f3f7..a22b09e580 100644 --- a/Items/Materials/Stardust.cs +++ b/Items/Materials/StarblightSoot.cs @@ -4,7 +4,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - public class Stardust : ModItem, ILocalizedModType + [LegacyName("Stardust")] + public class StarblightSoot : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Materials"; public override void SetStaticDefaults() diff --git a/Items/Materials/Stardust.png b/Items/Materials/StarblightSoot.png similarity index 100% rename from Items/Materials/Stardust.png rename to Items/Materials/StarblightSoot.png diff --git a/Items/Materials/WulfrumMetalScrap.cs b/Items/Materials/WulfrumMetalScrap.cs index bd5a55c188..7df22c2da1 100644 --- a/Items/Materials/WulfrumMetalScrap.cs +++ b/Items/Materials/WulfrumMetalScrap.cs @@ -44,9 +44,9 @@ namespace CalamityMod.Items.Materials bool closePlayer = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - if ((Main.player[i].Center - Item.Center).Length() < 1200 && Main.player[i].GetModPlayer().battery) + if ((player.Center - Item.Center).Length() < 1200 && player.GetModPlayer().battery) { closePlayer = true; break; diff --git a/Items/Mounts/AlicornMount.cs b/Items/Mounts/AlicornMount.cs index 7db85ed596..d1f8acca61 100644 --- a/Items/Mounts/AlicornMount.cs +++ b/Items/Mounts/AlicornMount.cs @@ -71,12 +71,12 @@ namespace CalamityMod.Items.Mounts public override void SetMount(Player player, ref bool skipDust) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - if (Main.npc[i].type == ModContent.NPCType()) + if (npc.type == ModContent.NPCType()) { - Main.npc[i].active = false; - Main.npc[i].netUpdate = true; + npc.active = false; + npc.netUpdate = true; break; } } @@ -85,12 +85,8 @@ namespace CalamityMod.Items.Mounts public override void Dismount(Player player, ref bool skipDust) { bool anyPlayerOnFabMount = false; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player2 in Main.ActivePlayers) { - Player player2 = Main.player[i]; - if (!player2.active) - continue; - // The player that is dismounting is technically not on the mount anymore. if (player2.Calamity().fab && player2.whoAmI != player.whoAmI) { diff --git a/Items/PermanentBoosters/CometShard.cs b/Items/PermanentBoosters/CometShard.cs index 1f308af6b8..90cd2c4417 100644 --- a/Items/PermanentBoosters/CometShard.cs +++ b/Items/PermanentBoosters/CometShard.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Items.PermanentBoosters CreateRecipe(). AddIngredient(ItemID.MeteoriteBar, 10). AddIngredient(ItemID.FallenStar, 10). - AddIngredient(50). + AddIngredient(50). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Pets/HermitsBoxofOneHundredMedicines.cs b/Items/Pets/HermitsBoxofOneHundredMedicines.cs index 629e1afcc0..1c0be6bd28 100644 --- a/Items/Pets/HermitsBoxofOneHundredMedicines.cs +++ b/Items/Pets/HermitsBoxofOneHundredMedicines.cs @@ -31,8 +31,12 @@ namespace CalamityMod.Items.Pets Item.Calamity().devItem = true; } - public override bool AltFunctionUse(Player player) => true; - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) => false; + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(Item.buffType, 3600, true); + } + } } } diff --git a/Items/Placeables/CelestialRemains.cs b/Items/Placeables/CelestialRemains.cs index 2dd1b4e2d6..c597021aad 100644 --- a/Items/Placeables/CelestialRemains.cs +++ b/Items/Placeables/CelestialRemains.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Items.Placeables } else if (val < 68.03f) { - resultType = ModContent.ItemType(); + resultType = ModContent.ItemType(); resultStack = Main.rand.Next(1, 11); } else if (val < 69.03f) diff --git a/Items/Placeables/Furniture/AstralBeaconItem.cs b/Items/Placeables/Furniture/AstralBeaconItem.cs index 3e5a720a0e..0abe100357 100644 --- a/Items/Placeables/Furniture/AstralBeaconItem.cs +++ b/Items/Placeables/Furniture/AstralBeaconItem.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Placeables.Furniture { CreateRecipe(). AddIngredient(5). - AddIngredient(20). + AddIngredient(20). AddIngredient(30). AddTile(TileID.LunarCraftingStation). Register(); diff --git a/Items/Placeables/Furniture/AstralTorch.cs b/Items/Placeables/Furniture/AstralTorch.cs index fe74ba5bc3..4a537b11e8 100644 --- a/Items/Placeables/Furniture/AstralTorch.cs +++ b/Items/Placeables/Furniture/AstralTorch.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Items.Placeables.Furniture { CreateRecipe(3). AddIngredient(ItemID.Torch, 3). - AddIngredient(). + AddIngredient(). Register(); } } diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs index 0129ce79f2..17aec33a70 100644 --- a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs @@ -72,7 +72,8 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "CosmaticMango", "CrabBar", "Dia", - "Done", + "DylanDoe21", + "enamoured", "Fluffi", "HaguriHat", "Heart Plus Up!", @@ -121,10 +122,10 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Demik", "DM Dokuro", "Dominic Karma", + "Done", "Doog", "drh", "dwshin", - "DylanDoe21", "Earth", "EchoDuck", "Ein", diff --git a/Items/Placeables/NovaeSlag.cs b/Items/Placeables/NovaeSlag.cs index 37415c3674..78983dd0f0 100644 --- a/Items/Placeables/NovaeSlag.cs +++ b/Items/Placeables/NovaeSlag.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Items.Placeables } else if (val < 58.03f) { - resultType = ModContent.ItemType(); + resultType = ModContent.ItemType(); resultStack = Main.rand.Next(1, 21); } else if (val < 61.03f) diff --git a/Items/Potions/AstralInjection.cs b/Items/Potions/AstralInjection.cs index fd3aed69f5..682a341ce2 100644 --- a/Items/Potions/AstralInjection.cs +++ b/Items/Potions/AstralInjection.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Items.Potions { CreateRecipe(15). AddIngredient(ItemID.BottledWater, 15). - AddIngredient(4). + AddIngredient(4). AddIngredient(). AddTile(TileID.AlchemyTable). AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). diff --git a/Items/Potions/TeslaPotion.cs b/Items/Potions/TeslaPotion.cs index c2d8e0142b..1fa1a540b3 100644 --- a/Items/Potions/TeslaPotion.cs +++ b/Items/Potions/TeslaPotion.cs @@ -38,7 +38,6 @@ namespace CalamityMod.Items.Potions public override void AddRecipes() { - Condition evil2Dead = new(CalamityUtils.GetText("Condition.DownedEvil2Boss"), () => DownedBossSystem.downedHiveMind || DownedBossSystem.downedPerforator); CreateRecipe(5). AddIngredient(ItemID.BottledWater). AddIngredient(2). @@ -46,7 +45,7 @@ namespace CalamityMod.Items.Potions AddIngredient(). AddIngredient(). AddTile(TileID.Bottles). - AddDecraftCondition(evil2Dead). + AddDecraftCondition(CalamityConditions.DownedHiveMindOrPerforator). Register(); CreateRecipe(). diff --git a/Items/SirenproofEarMuffs.cs b/Items/SirenproofEarMuffs.cs index b4f61e1287..b05a825f31 100644 --- a/Items/SirenproofEarMuffs.cs +++ b/Items/SirenproofEarMuffs.cs @@ -1,12 +1,17 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { public class SirenproofEarMuffs : ModItem, ILocalizedModType { + public static bool state = false; public new string LocalizationCategory => "Items.Misc"; public override void SetDefaults() { @@ -21,10 +26,70 @@ namespace CalamityMod.Items itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; } - public override void UpdateInventory(Player player) + public override bool CanRightClick() => true; + + public override void RightClick(Player player) { - if (Item.favorited) + if (player.Calamity().disableAnahitaSpawns == true) + player.Calamity().disableAnahitaSpawns = false; + else player.Calamity().disableAnahitaSpawns = true; + Item.NetStateChanged(); + state = player.Calamity().disableAnahitaSpawns; + + bool favorited = Item.favorited; + Item.SetDefaults(ModContent.ItemType()); + Item.stack++; + Item.favorited = favorited; + } + + /* + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/SirenproofEarMuffs").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/SirenproofEarMuffs").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/SirenproofEarMuffs").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/SirenproofEarMuffs").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return false; + } + */ + + public override void ModifyTooltips(List tooltips) + { + string text; + if (state == true) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); } public override void AddRecipes() diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index dc9a0d9b4b..c5094efa77 100644 --- a/Items/SummonItems/AstralChunk.cs +++ b/Items/SummonItems/AstralChunk.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { CreateRecipe(). - AddIngredient(30). + AddIngredient(30). AddIngredient(ItemID.FallenStar, 20). AddTile(TileID.Anvils). Register(); diff --git a/Items/SummonItems/BloodyWormFood.cs b/Items/SummonItems/BloodyWormFood.cs index 67c13f0eea..c5847c9316 100644 --- a/Items/SummonItems/BloodyWormFood.cs +++ b/Items/SummonItems/BloodyWormFood.cs @@ -50,14 +50,13 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { - Condition downedPerfs = new(CalamityUtils.GetText("Condition.DownedPerfs"), () => DownedBossSystem.downedPerforator); - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 3). - AddIngredient(7). - AddIngredient(ItemID.Vertebrae, 13). - AddTile(TileID.DemonAltar). - AddDecraftCondition(downedPerfs). - Register(); + CreateRecipe() + .AddIngredient(ItemID.CrimtaneBar, 3) + .AddIngredient(7) + .AddIngredient(ItemID.Vertebrae, 13) + .AddTile(TileID.DemonAltar) + .AddDecraftCondition(CalamityConditions.DownedPerforator) + .Register(); } } } diff --git a/Items/SummonItems/Starcore.cs b/Items/SummonItems/Starcore.cs index e405deae7f..c1fb8b87ce 100644 --- a/Items/SummonItems/Starcore.cs +++ b/Items/SummonItems/Starcore.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { CreateRecipe(). - AddIngredient(25). + AddIngredient(25). AddIngredient(8). AddIngredient(4). AddTile(TileID.LunarCraftingStation). diff --git a/Items/SummonItems/Teratoma.cs b/Items/SummonItems/Teratoma.cs index 0266af0838..7f3fee2cbf 100644 --- a/Items/SummonItems/Teratoma.cs +++ b/Items/SummonItems/Teratoma.cs @@ -50,13 +50,12 @@ namespace CalamityMod.Items.SummonItems public override void AddRecipes() { - Condition downedHM = new(CalamityUtils.GetText("Condition.DownedHM"), () => DownedBossSystem.downedHiveMind); CreateRecipe(). AddIngredient(ItemID.DemoniteBar, 3). AddIngredient(7). AddIngredient(ItemID.RottenChunk, 13). AddTile(TileID.DemonAltar). - AddDecraftCondition(downedHM). + AddDecraftCondition(CalamityConditions.DownedHiveMind). Register(); } } diff --git a/Items/SuperDummy.cs b/Items/SuperDummy.cs index ed1859f390..2791c4a11f 100644 --- a/Items/SuperDummy.cs +++ b/Items/SuperDummy.cs @@ -30,16 +30,15 @@ namespace CalamityMod.Items public static void DeleteDummies() { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.type == ModContent.NPCType() && npc.active) + if (npc.type == ModContent.NPCType()) { npc.life = 0; npc.active = false; if (Main.netMode == NetmodeID.Server) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); } } } diff --git a/Items/Tools/WulfrumDiggingTurtle.cs b/Items/Tools/WulfrumDiggingTurtle.cs index 2150a3403e..f398ed1c3a 100644 --- a/Items/Tools/WulfrumDiggingTurtle.cs +++ b/Items/Tools/WulfrumDiggingTurtle.cs @@ -53,10 +53,9 @@ namespace CalamityMod.Items.Tools { bool explodedAny = false; - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (!p.active || p.owner != player.whoAmI || p.type != Item.shoot) + if (p.owner != player.whoAmI || p.type != Item.shoot) continue; p.ai[1] = 1f; diff --git a/Items/TreasureBags/AstrumAureusBag.cs b/Items/TreasureBags/AstrumAureusBag.cs index cb7ede8821..b94f45c744 100644 --- a/Items/TreasureBags/AstrumAureusBag.cs +++ b/Items/TreasureBags/AstrumAureusBag.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Items.TreasureBags // Materials itemLoot.Add(ModContent.ItemType(), 1, 12, 16); - itemLoot.Add(ModContent.ItemType(), 1, 30, 40); + itemLoot.Add(ModContent.ItemType(), 1, 30, 40); itemLoot.Add(ItemID.FallenStar, 1, 20, 30); // Weapons diff --git a/Items/TreasureBags/AstrumDeusBag.cs b/Items/TreasureBags/AstrumDeusBag.cs index c1f50152be..0edb610266 100644 --- a/Items/TreasureBags/AstrumDeusBag.cs +++ b/Items/TreasureBags/AstrumDeusBag.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 60, 90); + itemLoot.Add(ModContent.ItemType(), 1, 60, 90); itemLoot.Add(ItemID.FallenStar, 1, 30, 50); // Weapons diff --git a/Items/TreasureBags/ProvidenceBag.cs b/Items/TreasureBags/ProvidenceBag.cs index 7445639905..4feb1ba07a 100644 --- a/Items/TreasureBags/ProvidenceBag.cs +++ b/Items/TreasureBags/ProvidenceBag.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] { ModContent.ItemType(), - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs b/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs index c8314dbaac..d74e80cff3 100644 --- a/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs @@ -14,17 +14,17 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Crimson"; - public const float ArmorPieceDamage = 0.05f; + public const float ArmorPieceDamage = 0.06f; public const int ArmorPieceLifeRegen = 1; + public const int ChestPieceBonusLifeRegen = 1; // Set bonus clarification public override void UpdateSetBonusText(ref string setBonusText) { - Player player = Main.LocalPlayer; setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } - private void ApplyAnyPieceEffect(Player player) + private static void ApplyAnyPieceEffect(Player player) { // Remove the vanilla +3% damage and add the new damage value at the same time player.GetDamage() += ArmorPieceDamage - 0.03f; @@ -35,7 +35,11 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyHeadPieceEffect(Player player) => ApplyAnyPieceEffect(player); - public override void ApplyBodyPieceEffect(Player player) => ApplyAnyPieceEffect(player); + public override void ApplyBodyPieceEffect(Player player) + { + ApplyAnyPieceEffect(player); + player.lifeRegen += ChestPieceBonusLifeRegen; + } public override void ApplyLegPieceEffect(Player player) => ApplyAnyPieceEffect(player); } diff --git a/Items/VanillaArmorChanges/GoldArmorSetChange.cs b/Items/VanillaArmorChanges/GoldArmorSetChange.cs index eb18aab587..1cd9c38894 100644 --- a/Items/VanillaArmorChanges/GoldArmorSetChange.cs +++ b/Items/VanillaArmorChanges/GoldArmorSetChange.cs @@ -1,5 +1,4 @@ using System; -using System.Text; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -21,10 +20,10 @@ namespace CalamityMod.Items.VanillaArmorChanges public const float HeadDamage = 0.06f; public const float ChestDR = 0.05f; public const float LegsMoveSpeed = 0.1f; - public const float GoldDropChanceFromEnemies = 0.04f; + public const float GoldDropChanceFromEnemies = 0.02f; public const int GoldFromBosses = 3; - public const float SetBonusCritPerGoldCoin = 0.2f; // 5 gold coins = +1% crit chance - public const float MaximumCritBonus = 10f; + public const float SetBonusCritPerGoldCoin = 0.1f; // 10 gold coins = +1% crit chance + public const float MaximumCritBonus = 9f; public override void ApplyHeadPieceEffect(Player player) => player.GetDamage() += HeadDamage; @@ -50,8 +49,8 @@ namespace CalamityMod.Items.VanillaArmorChanges { // 13FEB2024: Ozzatron: this function doesn't cap at its second argument, it just stops counting if it exceeds that number // so this can give up to 100 gold coins - int goldCoins = player.CountItem(ItemID.GoldCoin, 50); - critFromGold = Math.Max(goldCoins * SetBonusCritPerGoldCoin, MaximumCritBonus); + int goldCoins = player.CountItem(ItemID.GoldCoin, 90); + critFromGold = Math.Min(goldCoins * SetBonusCritPerGoldCoin, MaximumCritBonus); } player.GetCritChance() += critFromGold; diff --git a/Items/VanillaArmorChanges/LeadArmorSetChange.cs b/Items/VanillaArmorChanges/LeadArmorSetChange.cs index fccf0e14f1..4fc7541f41 100644 --- a/Items/VanillaArmorChanges/LeadArmorSetChange.cs +++ b/Items/VanillaArmorChanges/LeadArmorSetChange.cs @@ -1,5 +1,4 @@ -using System.Text; -using Terraria; +using Terraria; using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges @@ -14,8 +13,8 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Lead"; - public const float ArmorPieceDR = 0.03f; - public const float SetBonusDR = 0.03f; + public const float ArmorPieceDR = 0.02f; + public const float SetBonusDR = 0.04f; public const int SetBonusLifeRegen = 1; public override void ApplyHeadPieceEffect(Player player) => player.endurance += ArmorPieceDR; diff --git a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs index 64a39bf6cb..d709df88d2 100644 --- a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs +++ b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs @@ -16,9 +16,8 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Platinum"; public const float HeadDamage = 0.06f; - public const float ChestCrit = 5f; + public const float ChestCrit = 3f; public const float LegsMoveSpeed = 0.1f; - public const float SetBonusLifeRegenPerDefense = 0.1f; // 10 defense = +1 life regen public const float SetBonusDamagePerDefense = 0.001f; // 10 defense = +1% damage public const float SetBonusCritPerDefense = 0.1f; // 10 defense = +1% crit chance public const int SetBonusDefenseCap = 40; @@ -36,12 +35,15 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyArmorSetBonus(Player player) { - int defense = player.statDefense; - if (defense > SetBonusDefenseCap) - defense = SetBonusDefenseCap; - player.lifeRegen += (int)(defense * SetBonusLifeRegenPerDefense); - player.GetDamage() += defense * SetBonusDamagePerDefense; - player.GetCritChance() += defense * SetBonusCritPerDefense; + // 07MAY2024: Ozzatron: Platinum armor doesn't count its own defense for its set bonus + int defenseBesidesThisArmor = player.statDefense - (4 + 6 + 4 + 4); + if (defenseBesidesThisArmor <= 0) + return; + + if (defenseBesidesThisArmor > SetBonusDefenseCap) + defenseBesidesThisArmor = SetBonusDefenseCap; + player.GetDamage() += defenseBesidesThisArmor * SetBonusDamagePerDefense; + player.GetCritChance() += defenseBesidesThisArmor * SetBonusCritPerDefense; } } } diff --git a/Items/VanillaArmorChanges/ShadowArmorSetChange.cs b/Items/VanillaArmorChanges/ShadowArmorSetChange.cs index b046bb9c76..b93bb0d478 100644 --- a/Items/VanillaArmorChanges/ShadowArmorSetChange.cs +++ b/Items/VanillaArmorChanges/ShadowArmorSetChange.cs @@ -1,6 +1,5 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -18,17 +17,14 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Shadow"; - public const float ArmorPieceDamage = 0.05f; - public const float ArmorPieceJumpBoost = 0.07f; - - private void ApplyAnyPieceEffect(Player player) + private static void ApplyAnyPieceEffect(Player player) { - // Remove the vanilla crit chance buff and replace it with damage - player.GetCritChance() -= 5; - player.GetDamage() += ArmorPieceDamage; - - // Give jump boost - player.jumpSpeedBoost += 5f * ArmorPieceJumpBoost; + // 15MAY2024: Ozzatron: Removed all standard changes to Shadow Armor. + // As such, this method intentionally does nothing. + // + // Shadow Armor's movement speed boosting effect is separately nerfed via an IL edit. + // + // Class is being left here so that further changes can be made to Shadow Armor as needed. } public override void ApplyHeadPieceEffect(Player player) => ApplyAnyPieceEffect(player); diff --git a/Items/VoodooDemonVoodooDoll.cs b/Items/VoodooDemonVoodooDoll.cs index 97e4e6283d..c098d72199 100644 --- a/Items/VoodooDemonVoodooDoll.cs +++ b/Items/VoodooDemonVoodooDoll.cs @@ -1,18 +1,25 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { public class VoodooDemonVoodooDoll : ModItem, ILocalizedModType { + public static bool state = false; public new string LocalizationCategory => "Items.Misc"; + public override void SetDefaults() { Item.width = 44; Item.height = 34; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; + Item.consumable = false; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -20,10 +27,69 @@ namespace CalamityMod.Items itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; } - public override void UpdateInventory(Player player) + public override bool CanRightClick() => true; + + public override void RightClick(Player player) { - if (Item.favorited) + if (player.Calamity().disableVoodooSpawns == true) + player.Calamity().disableVoodooSpawns = false; + else player.Calamity().disableVoodooSpawns = true; + Item.NetStateChanged(); + state = player.Calamity().disableVoodooSpawns; + bool favorited = Item.favorited; + Item.SetDefaults(ModContent.ItemType()); + Item.stack++; + Item.favorited = favorited; + } + + /* + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/VoodooDemonVoodooDoll").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/VoodooDemonVoodooDoll").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0); + } + + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture; + + if (state) + { + //Replace with enabled texture + texture = ModContent.Request("CalamityMod/Items/VoodooDemonVoodooDoll").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + else + { + texture = ModContent.Request("CalamityMod/Items/VoodooDemonVoodooDoll").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); + } + return false; + } + */ + + public override void ModifyTooltips(List tooltips) + { + string text; + if (state == true) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); } public override void AddRecipes() diff --git a/Items/Weapons/DraedonsArsenal/PoleWarper.cs b/Items/Weapons/DraedonsArsenal/PoleWarper.cs index 83a8625855..857a3d038e 100644 --- a/Items/Weapons/DraedonsArsenal/PoleWarper.cs +++ b/Items/Weapons/DraedonsArsenal/PoleWarper.cs @@ -56,9 +56,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal float magnetCount = 0f; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (p.type == type && p.owner == player.whoAmI) { magnetCount++; } @@ -67,12 +67,12 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal // Adjust the offset of all existing magnets such that they form a psuedo-circle. // This offset is used when determining where a magnet should move to relative to its true destination (such as the player or an enemy). int magnetIndex = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (p.type == type && p.owner == player.whoAmI) { - ((PoleWarperSummon)Main.projectile[i].ModProjectile).Time = 0f; - ((PoleWarperSummon)Main.projectile[i].ModProjectile).AngularOffset = MathHelper.TwoPi * magnetIndex / magnetCount; + ((PoleWarperSummon)p.ModProjectile).Time = 0f; + ((PoleWarperSummon)p.ModProjectile).AngularOffset = MathHelper.TwoPi * magnetIndex / magnetCount; magnetIndex++; } } diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index a9b060474c..9a68a38931 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -6,6 +6,7 @@ using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -17,26 +18,26 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public class PulseRifle : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/PulseRifleFire"); + public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/PulseRifleFire") { Volume = 0.8f }; - private int BaseDamage = 1150; + private int BaseDamage = 990; public int FiringTimer = 30; public override void SetDefaults() { CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 62; - Item.height = 22; + Item.width = 100; + Item.height = 32; Item.DamageType = DamageClass.Ranged; Item.damage = BaseDamage; Item.knockBack = 0f; - Item.useTime = 45; - Item.useAnimation = 45; + Item.useTime = 55; + Item.useAnimation = 55; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = null; + Item.UseSound = FireSound; Item.noMelee = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; @@ -52,13 +53,16 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - SoundEngine.PlaySound(FireSound with { Volume = 0.7f, Pitch = 0.3f }); Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PulseRifleGlow").Value); + } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.png b/Items/Weapons/DraedonsArsenal/PulseRifle.png index df7ca50eb2..bcb3e668d9 100644 Binary files a/Items/Weapons/DraedonsArsenal/PulseRifle.png and b/Items/Weapons/DraedonsArsenal/PulseRifle.png differ diff --git a/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png b/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png new file mode 100644 index 0000000000..49124dc1d0 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png differ diff --git a/Items/Weapons/Melee/ChronomancersScythe.cs b/Items/Weapons/Magic/ChronomancersScythe.cs similarity index 94% rename from Items/Weapons/Melee/ChronomancersScythe.cs rename to Items/Weapons/Magic/ChronomancersScythe.cs index 2c815eeb89..a872675c83 100644 --- a/Items/Weapons/Melee/ChronomancersScythe.cs +++ b/Items/Weapons/Magic/ChronomancersScythe.cs @@ -1,17 +1,16 @@ using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Rarities; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items.Weapons.Melee +namespace CalamityMod.Items.Weapons.Magic { public class ChronomancersScythe : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Weapons.Melee"; + public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 45; Item.height = 45; - Item.DamageType = DamageClass.MeleeNoSpeed; + Item.DamageType = DamageClass.Magic; Item.noMelee = true; Item.noUseGraphic = true; Item.channel = true; @@ -32,6 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.autoReuse = false; Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = SoundID.Item71; + Item.mana = 10; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; diff --git a/Items/Weapons/Melee/ChronomancersScythe.png b/Items/Weapons/Magic/ChronomancersScythe.png similarity index 100% rename from Items/Weapons/Melee/ChronomancersScythe.png rename to Items/Weapons/Magic/ChronomancersScythe.png diff --git a/Items/Weapons/Magic/Genesis.cs b/Items/Weapons/Magic/Genesis.cs index 4191f822ec..3574304c4f 100644 --- a/Items/Weapons/Magic/Genesis.cs +++ b/Items/Weapons/Magic/Genesis.cs @@ -11,12 +11,15 @@ namespace CalamityMod.Items.Weapons.Magic [LegacyName("Genisis")] public class Genesis : ModItem, ILocalizedModType { + public static float FireRate = 15f; + public static float StarterWindup = 60f; + public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() { Item.width = 108; Item.height = 46; - Item.damage = 60; + Item.damage = 65; Item.DamageType = DamageClass.Magic; Item.mana = 20; Item.useTime = 4; @@ -34,17 +37,17 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; // Makes the rotation of the mouse around the player sync in multiplayer. public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 0, 0); - holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); - + Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 1); return false; } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Magic/VividClarity.cs b/Items/Weapons/Magic/VividClarity.cs index b51b21e2f5..0180a48fb2 100644 --- a/Items/Weapons/Magic/VividClarity.cs +++ b/Items/Weapons/Magic/VividClarity.cs @@ -3,6 +3,7 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -24,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.width = 90; - Item.height = 112; + Item.width = 140; + Item.height = 140; Item.damage = 133; Item.DamageType = DamageClass.Magic; Item.mana = 42; @@ -71,6 +72,11 @@ namespace CalamityMod.Items.Weapons.Magic return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Magic/VividClarityGlow").Value); + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Magic/VividClarity.png b/Items/Weapons/Magic/VividClarity.png index a09e59afd7..e0f181f0ed 100644 Binary files a/Items/Weapons/Magic/VividClarity.png and b/Items/Weapons/Magic/VividClarity.png differ diff --git a/Items/Weapons/Magic/VividClarityGlow.png b/Items/Weapons/Magic/VividClarityGlow.png new file mode 100644 index 0000000000..f404339f68 Binary files /dev/null and b/Items/Weapons/Magic/VividClarityGlow.png differ diff --git a/Items/Weapons/Magic/Wingman.cs b/Items/Weapons/Magic/Wingman.cs index 078a802904..1526be5dd7 100644 --- a/Items/Weapons/Magic/Wingman.cs +++ b/Items/Weapons/Magic/Wingman.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 44; Item.height = 42; - Item.damage = 71; + Item.damage = 82; Item.DamageType = DamageClass.Magic; Item.mana = 5; Item.useTime = 15; diff --git a/Items/Weapons/Melee/BladecrestOathsword.cs b/Items/Weapons/Melee/BladecrestOathsword.cs index 066a995169..84639e8046 100644 --- a/Items/Weapons/Melee/BladecrestOathsword.cs +++ b/Items/Weapons/Melee/BladecrestOathsword.cs @@ -35,12 +35,12 @@ namespace CalamityMod.Items.Weapons.Melee public override bool CanUseItem(Player player) { int bladeProjID = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != bladeProjID || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + if (p.type != bladeProjID || p.owner != player.whoAmI) continue; - return Main.projectile[i].ModProjectile().PostSwingRepositionDelay <= 0f; + return p.ModProjectile().PostSwingRepositionDelay <= 0f; } return base.CanUseItem(player); diff --git a/Items/Weapons/Melee/SolarFlare.cs b/Items/Weapons/Melee/BurningRevelation.cs similarity index 87% rename from Items/Weapons/Melee/SolarFlare.cs rename to Items/Weapons/Melee/BurningRevelation.cs index 8bf48025bc..85c2b4d6e8 100644 --- a/Items/Weapons/Melee/SolarFlare.cs +++ b/Items/Weapons/Melee/BurningRevelation.cs @@ -5,7 +5,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class SolarFlare : ModItem, ILocalizedModType + [LegacyName("SolarFlare")] + public class BurningRevelation : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetStaticDefaults() @@ -32,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.noUseGraphic = true; Item.noMelee = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; diff --git a/Items/Weapons/Melee/SolarFlare.png b/Items/Weapons/Melee/BurningRevelation.png similarity index 100% rename from Items/Weapons/Melee/SolarFlare.png rename to Items/Weapons/Melee/BurningRevelation.png diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index eb19732c3d..b7e5f75b48 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -43,4 +43,4 @@ namespace CalamityMod.Items.Weapons.Melee Register(); } } -} +} \ No newline at end of file diff --git a/Items/Weapons/Melee/Exoblade.cs b/Items/Weapons/Melee/Exoblade.cs index c1c551acd5..3b47ca0784 100644 --- a/Items/Weapons/Melee/Exoblade.cs +++ b/Items/Weapons/Melee/Exoblade.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -99,15 +100,24 @@ namespace CalamityMod.Items.Weapons.Melee float state = 0; //If there are any exoblades in "stasis" after a bonk, the attack should be an empowered slash instead - if (Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ProjectileType() && n.ai[0] == 1 && n.ai[1] == 1 && n.timeLeft > LungeCooldown)) + bool empoweredSlash = false; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.owner == player.whoAmI && p.type == Item.shoot && p.ai[0] == 1 && p.ai[1] == 1 && p.timeLeft > LungeCooldown) + { + empoweredSlash = true; + break; + } + } + + if (empoweredSlash) { state = 2; //Put all the "post bonk" stasised exoblades into regular cooldown for the right click ljunge - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (!p.active || p.owner != player.whoAmI || p.type != Item.shoot || p.ai[0] != 1 || p.ai[1] != 1) + if (p.owner != player.whoAmI || p.type != Item.shoot || p.ai[0] != 1 || p.ai[1] != 1) continue; p.timeLeft = LungeCooldown; @@ -126,6 +136,11 @@ namespace CalamityMod.Items.Weapons.Melee return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Melee/ExobladeGlow").Value); + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Melee/ExobladeGlow.png b/Items/Weapons/Melee/ExobladeGlow.png new file mode 100644 index 0000000000..5529b42e13 Binary files /dev/null and b/Items/Weapons/Melee/ExobladeGlow.png differ diff --git a/Items/Weapons/Melee/ExobladeSquare.png b/Items/Weapons/Melee/ExobladeSquare.png index fd9fe0288c..f679194f8d 100644 Binary files a/Items/Weapons/Melee/ExobladeSquare.png and b/Items/Weapons/Melee/ExobladeSquare.png differ diff --git a/Items/Weapons/Melee/LionHeart.cs b/Items/Weapons/Melee/LionHeart.cs index dd0b0df4ed..5b06e0992b 100644 --- a/Items/Weapons/Melee/LionHeart.cs +++ b/Items/Weapons/Melee/LionHeart.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 60; Item.height = 62; - Item.damage = 323; + Item.damage = 960; Item.knockBack = 5.5f; Item.useStyle = ItemUseStyleID.Swing; Item.useAnimation = 15; diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index 3cc6fe5c75..19f4ae60b0 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 94; Item.height = 94; Item.DamageType = DamageClass.Melee; - Item.damage = 360; + Item.damage = 550; Item.knockBack = 8.5f; Item.useAnimation = 20; Item.useTime = 20; diff --git a/Items/Weapons/Melee/TheOracle.cs b/Items/Weapons/Melee/TheOracle.cs index 985ac51930..6708ca7991 100644 --- a/Items/Weapons/Melee/TheOracle.cs +++ b/Items/Weapons/Melee/TheOracle.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(5). AddTile(). diff --git a/Items/Weapons/Melee/TrueBiomeBlade.cs b/Items/Weapons/Melee/TrueBiomeBlade.cs index c562f63b80..d465084ed8 100644 --- a/Items/Weapons/Melee/TrueBiomeBlade.cs +++ b/Items/Weapons/Melee/TrueBiomeBlade.cs @@ -388,7 +388,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.SoulofMight). AddIngredient(ItemID.SoulofSight). AddIngredient(ItemID.PixieDust, 2). - AddIngredient(10). + AddIngredient(10). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Ranged/Auralis.cs b/Items/Weapons/Ranged/Auralis.cs index a346b19b08..b65b6d0d34 100644 --- a/Items/Weapons/Ranged/Auralis.cs +++ b/Items/Weapons/Ranged/Auralis.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.SniperRifle). AddIngredient(5). AddIngredient(5). - AddIngredient(50). + AddIngredient(50). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index 889f57a40e..5d4b85312a 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -66,10 +66,9 @@ namespace CalamityMod.Items.Weapons.Ranged private void DetonateRockets(Player player) { - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (!p.active || p.owner != player.whoAmI || p.type != Item.shoot) + if (p.owner != player.whoAmI || p.type != Item.shoot) continue; // All rockets will instantly explode on the next frame and send packets to indicate as such. diff --git a/Items/Weapons/Ranged/ConferenceCall.cs b/Items/Weapons/Ranged/ConferenceCall.cs index 9c9fa464e9..a673f01eb8 100644 --- a/Items/Weapons/Ranged/ConferenceCall.cs +++ b/Items/Weapons/Ranged/ConferenceCall.cs @@ -58,16 +58,15 @@ namespace CalamityMod.Items.Weapons.Ranged int[] targets = new int[maxTargets]; int targetArrayIndex = 0; Rectangle rectangle = new Rectangle((int)player.Center.X - 960, (int)player.Center.Y - 540, 1920, 1080); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) + if (npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) { if (npc.Hitbox.Intersects(rectangle)) { if (targetArrayIndex < maxTargets) { - targets[targetArrayIndex] = i; + targets[targetArrayIndex] = npc.whoAmI; targetArrayIndex++; } else diff --git a/Items/Weapons/Ranged/Disseminator.cs b/Items/Weapons/Ranged/Disseminator.cs index 2583ef4355..a777199c5a 100644 --- a/Items/Weapons/Ranged/Disseminator.cs +++ b/Items/Weapons/Ranged/Disseminator.cs @@ -58,16 +58,15 @@ namespace CalamityMod.Items.Weapons.Ranged int[] targets = new int[maxTargets]; int targetArrayIndex = 0; Rectangle rectangle = new Rectangle((int)player.Center.X - 960, (int)player.Center.Y - 540, 1920, 1080); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) + if (npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) { if (npc.Hitbox.Intersects(rectangle)) { if (targetArrayIndex < maxTargets) { - targets[targetArrayIndex] = i; + targets[targetArrayIndex] = npc.whoAmI; targetArrayIndex++; } else diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index 543b09b5a3..3c3643b112 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Ranged public const float ArrowTargetingRange = 1100f; - public const float MaxChargeDamageBoost = 4.5f; + public const float MaxChargeDamageBoost = 3.5f; public const float LightningDamageFactor = 0.36f; @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 138; Item.height = 176; - Item.damage = 215; + Item.damage = 256; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = ArrowShootTime; // 40 Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Ranged/Hydra.cs b/Items/Weapons/Ranged/Hydra.cs index 600a509958..d4a5d9ffa6 100644 --- a/Items/Weapons/Ranged/Hydra.cs +++ b/Items/Weapons/Ranged/Hydra.cs @@ -68,11 +68,11 @@ namespace CalamityMod.Items.Weapons.Ranged } else if (player.ActiveItem().type != Item.type || player.dead || !player.active) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { //Destroy all heads - if (Main.projectile[i].type == HeadID && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].active) - Main.projectile[i].Kill(); + if (p.type == HeadID && p.owner == player.whoAmI) + p.Kill(); } HeadSpawnTimer = 0; } @@ -85,9 +85,9 @@ namespace CalamityMod.Items.Weapons.Ranged return false; //Otherwise, launch the guns + SoundEngine.PlaySound(LaunchSound, player.Center); for (int i = 0; i < Main.maxProjectiles; i++) { - SoundEngine.PlaySound(LaunchSound, player.Center); if (Main.projectile[i].type == HeadID && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].active) Main.projectile[i].ai[1] = -1f; } @@ -111,11 +111,11 @@ namespace CalamityMod.Items.Weapons.Ranged Projectile.NewProjectile(source, newPos, spreadVelocity * spreadDirection, Item.shoot, damage, knockback, player.whoAmI); } - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { //Force all heads to shoot - if (Main.projectile[i].type == HeadID && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].active) - Main.projectile[i].ai[1] = 1f; + if (p.type == HeadID && p.owner == player.whoAmI) + p.ai[1] = 1f; } return false; } diff --git a/Items/Weapons/Ranged/Kingsbane.cs b/Items/Weapons/Ranged/Kingsbane.cs index 69fd57af7d..c98cb01137 100644 --- a/Items/Weapons/Ranged/Kingsbane.cs +++ b/Items/Weapons/Ranged/Kingsbane.cs @@ -40,7 +40,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.95f && player.ownedProjectileCounts[Item.shoot] > 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + Projectile holdout = Projectile.NewProjectileDirect(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/NitroExpressRifle.cs b/Items/Weapons/Ranged/NitroExpressRifle.cs index c7f04ab0ed..eab45c79d1 100644 --- a/Items/Weapons/Ranged/NitroExpressRifle.cs +++ b/Items/Weapons/Ranged/NitroExpressRifle.cs @@ -22,20 +22,20 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 100; Item.height = 22; - Item.damage = 1350; + Item.damage = 210; Item.DamageType = DamageClass.Ranged; - Item.useTime = 80; - Item.useAnimation = 80; + Item.useTime = 70; + Item.useAnimation = 70; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 8.5f; - Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.knockBack = 7.5f; + Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.UseSound = FireSound; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; - Item.rare = ModContent.RarityType(); + Item.rare = ItemRarityID.LightRed; Item.Calamity().canFirePointBlankShots = true; } @@ -47,17 +47,28 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.SniperRifle). - AddIngredient(3). - AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddIngredient(ItemID.Musket). + AddIngredient(3). + AddIngredient(3). + AddIngredient(ItemID.ExplosivePowder, 5). + AddTile(TileID.Anvils). + Register(); + + CreateRecipe(). + AddIngredient(ItemID.TheUndertaker). + AddIngredient(3). + AddIngredient(3). + AddIngredient(ItemID.ExplosivePowder, 5). + AddTile(TileID.Anvils). Register(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - player.velocity += -velocity * 0.45f; - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f); + player.velocity += -velocity * 0.3f; + if (type == ProjectileID.Bullet) + type = ModContent.ProjectileType(); + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f); return false; } diff --git a/Items/Weapons/Ranged/Norfleet.cs b/Items/Weapons/Ranged/Norfleet.cs index 80cfc81ac5..2f7500ee26 100644 --- a/Items/Weapons/Ranged/Norfleet.cs +++ b/Items/Weapons/Ranged/Norfleet.cs @@ -1,7 +1,9 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -45,14 +47,29 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 0, loadedShots); + // Funny punishment for trying to cheeese with Norfleet + bool cheater = (player.Calamity().NorfleetCounter >= 3 && player.Calamity().NorfleetCounter < 1000); + if (player.Calamity().NorfleetCounter >= 1000) + loadedShots = 1; + + if (cheater) + { + SoundStyle fire = new("CalamityMod/Sounds/Item/NuhUhUh"); + SoundEngine.PlaySound(fire, player.Center); + } + + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, (cheater ? 1000 : 0), loadedShots); // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + player.Calamity().NorfleetCounter++; loadedShots--; + if (loadedShots <= 0) + { loadedShots = 3; + } return false; } } diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index a6a8c92440..b65537e9bf 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -84,6 +85,11 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Ranged/PhotovisceratorGlow").Value); + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/PhotovisceratorGlow.png b/Items/Weapons/Ranged/PhotovisceratorGlow.png new file mode 100644 index 0000000000..90365e976f Binary files /dev/null and b/Items/Weapons/Ranged/PhotovisceratorGlow.png differ diff --git a/Items/Weapons/Rogue/AlphaVirus.cs b/Items/Weapons/Rogue/AlphaVirus.cs index 2cedc925c2..136298988c 100644 --- a/Items/Weapons/Rogue/AlphaVirus.cs +++ b/Items/Weapons/Rogue/AlphaVirus.cs @@ -32,6 +32,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } + public override float StealthDamageMultiplier => 0.70f; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) diff --git a/Items/Weapons/Rogue/ContaminatedBile.png b/Items/Weapons/Rogue/ContaminatedBile.png index ccc5e86737..e898b4fdb2 100644 Binary files a/Items/Weapons/Rogue/ContaminatedBile.png and b/Items/Weapons/Rogue/ContaminatedBile.png differ diff --git a/Items/Weapons/Rogue/HardenedHoneycomb.cs b/Items/Weapons/Rogue/HardenedHoneycomb.cs index fc50e89aa3..bfa4d589ab 100644 --- a/Items/Weapons/Rogue/HardenedHoneycomb.cs +++ b/Items/Weapons/Rogue/HardenedHoneycomb.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.value = 300; Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; + Item.shootSpeed = 14f; Item.DamageType = RogueDamageClass.Instance; } diff --git a/Items/Weapons/Rogue/HeavenfallenStardisk.cs b/Items/Weapons/Rogue/HeavenfallenStardisk.cs index feedf4ed5c..92de798ec1 100644 --- a/Items/Weapons/Rogue/HeavenfallenStardisk.cs +++ b/Items/Weapons/Rogue/HeavenfallenStardisk.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 44; Item.height = 48; - Item.damage = 90; + Item.damage = 165; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 40; @@ -28,16 +28,30 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20; + public override float StealthDamageMultiplier => 1.2f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int proj = Projectile.NewProjectile(source, position, velocity.Length() * -Vector2.UnitY, type, damage, knockback, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - - return false; + { + int proj = Projectile.NewProjectile(source, position, velocity.Length() * -Vector2.UnitY, type, damage, knockback, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike + { + int spread = 15; + for (int i = 0; i < 2; i++) + { + Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-8, 8), velocity.Y + Main.rand.Next(-2, 3)).RotatedBy(MathHelper.ToRadians(spread)); + Projectile.NewProjectile(source, position, perturbedspeed.Length() * -Vector2.UnitY, type, (int)(damage * 0.3), knockback, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + } + spread -= Main.rand.Next(5, 8); + } + } + return false; + } } } } diff --git a/Items/Weapons/Rogue/Mycoroot.cs b/Items/Weapons/Rogue/Mycoroot.cs index dd6856efe8..72bfad6516 100644 --- a/Items/Weapons/Rogue/Mycoroot.cs +++ b/Items/Weapons/Rogue/Mycoroot.cs @@ -43,12 +43,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (spore.WithinBounds(Main.maxProjectiles)) Main.projectile[spore].ai[1] = 1f; } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player other in Main.ActivePlayers) { - Player other = Main.player[i]; - if (other is null || !other.active || other.dead) + if (other.dead) continue; - if ((other.team == player.team && player.team != 0) || player.whoAmI == i) + if ((other.team == player.team && player.team != 0) || player.whoAmI == other.whoAmI) { if (player.Distance(other.Center) <= 800f) other.AddBuff(ModContent.BuffType(), 900); diff --git a/Items/Weapons/Rogue/Nychthemeron.cs b/Items/Weapons/Rogue/Nychthemeron.cs index 8cf3c076fb..7a4119a894 100644 --- a/Items/Weapons/Rogue/Nychthemeron.cs +++ b/Items/Weapons/Rogue/Nychthemeron.cs @@ -32,10 +32,9 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool AltFunctionUse(Player player) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI) + if (p.type == Item.shoot && p.owner == player.whoAmI) { p.ai[0] = 1f; } @@ -93,12 +92,11 @@ namespace CalamityMod.Items.Weapons.Rogue // Ideally new projectiles will fill in the most recently vacated spots in the pattern int[] activeSlots = new int[10] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && proj.active && proj.localAI[0] == 0f && activeSlots[(int)proj.localAI[1]] == -1) + if (proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && proj.localAI[0] == 0f && activeSlots[(int)proj.localAI[1]] == -1) { - activeSlots[(int)proj.localAI[1]] = i; + activeSlots[(int)proj.localAI[1]] = proj.whoAmI; } } diff --git a/Items/Weapons/Rogue/RadiantStar.cs b/Items/Weapons/Rogue/RadiantStar.cs index 8fafb6889e..16e52c9fc5 100644 --- a/Items/Weapons/Rogue/RadiantStar.cs +++ b/Items/Weapons/Rogue/RadiantStar.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(). AddIngredient(10). - AddIngredient(15). + AddIngredient(15). AddIngredient(ItemID.FallenStar, 10). AddTile(TileID.LunarCraftingStation). Register(); diff --git a/Items/Weapons/Rogue/Sacrifice.cs b/Items/Weapons/Rogue/Sacrifice.cs index 09e611d9d1..d13814e54e 100644 --- a/Items/Weapons/Rogue/Sacrifice.cs +++ b/Items/Weapons/Rogue/Sacrifice.cs @@ -39,18 +39,18 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.altFunctionUse == 2) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + if (p.type != type || p.owner != player.whoAmI) continue; - if (Main.projectile[i].ai[0] != 1f) + if (p.ai[0] != 1f) continue; - NPC attachedNPC = Main.npc[(int)Main.projectile[i].ai[1]]; - Main.projectile[i].ai[0] = 2f; - Main.projectile[i].ModProjectile().AbleToHealOwner = attachedNPC.type != NPCID.TargetDummy && attachedNPC.type != ModContent.NPCType(); - Main.projectile[i].netUpdate = true; + NPC attachedNPC = Main.npc[(int)p.ai[1]]; + p.ai[0] = 2f; + p.ModProjectile().AbleToHealOwner = attachedNPC.type != NPCID.TargetDummy && attachedNPC.type != ModContent.NPCType(); + p.netUpdate = true; } //TODO: Add something here to avoid stealth being consumed return false; diff --git a/Items/Weapons/Rogue/SlickCane.cs b/Items/Weapons/Rogue/SlickCane.cs index 09d437d088..22ee59fe16 100644 --- a/Items/Weapons/Rogue/SlickCane.cs +++ b/Items/Weapons/Rogue/SlickCane.cs @@ -19,14 +19,14 @@ namespace CalamityMod.Items.Weapons.Rogue Item.channel = true; Item.useAnimation = 26; Item.useTime = 26; - Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = 5f; + Item.useStyle = ItemUseStyleID.Shoot; + Item.knockBack = 6f; Item.UseSound = SoundID.DD2_GhastlyGlaivePierce; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; - Item.rare = ItemRarityID.LightRed; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 22f; + Item.shootSpeed = 16f; Item.DamageType = RogueDamageClass.Instance; } @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float ai0 = Main.rand.NextFloat() * Item.shootSpeed * 0.75f * (float)player.direction; - int projectileIndex = Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI, ai0, 0f); + float ai0 = Main.rand.NextFloat() * Item.shootSpeed * 1.5f * (float)player.direction; + int projectileIndex = Projectile.NewProjectile(source, position.X, position.Y+100, velocity.X*2f, velocity.Y*2f, type, damage, knockback, player.whoAmI, ai0, 0f); if (projectileIndex.WithinBounds(Main.maxProjectiles)) Main.projectile[projectileIndex].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; diff --git a/Items/Weapons/Rogue/Supernova.cs b/Items/Weapons/Rogue/Supernova.cs index 775fcbac13..d6bef9b091 100644 --- a/Items/Weapons/Rogue/Supernova.cs +++ b/Items/Weapons/Rogue/Supernova.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -53,6 +54,11 @@ namespace CalamityMod.Items.Weapons.Rogue return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Rogue/SupernovaGlow").Value); + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Rogue/SupernovaGlow.png b/Items/Weapons/Rogue/SupernovaGlow.png new file mode 100644 index 0000000000..0d383aedb3 Binary files /dev/null and b/Items/Weapons/Rogue/SupernovaGlow.png differ diff --git a/Items/Weapons/Summon/AbandonedSlimeStaff.cs b/Items/Weapons/Summon/AbandonedSlimeStaff.cs index baf024b006..5240e09f86 100644 --- a/Items/Weapons/Summon/AbandonedSlimeStaff.cs +++ b/Items/Weapons/Summon/AbandonedSlimeStaff.cs @@ -38,10 +38,9 @@ namespace CalamityMod.Items.Weapons.Summon player.jumpSpeedBoost += 0.5f; double minionCount = 0; - for (int j = 0; j < Main.projectile.Length; j++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - Projectile projectile = Main.projectile[j]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.minion && projectile.type != ModContent.ProjectileType()) + if (projectile.owner == player.whoAmI && projectile.minion && projectile.type != ModContent.ProjectileType()) { minionCount += projectile.minionSlots; } diff --git a/Items/Weapons/Summon/AresExoskeleton.cs b/Items/Weapons/Summon/AresExoskeleton.cs index 8d81e099cd..25c8513ee5 100644 --- a/Items/Weapons/Summon/AresExoskeleton.cs +++ b/Items/Weapons/Summon/AresExoskeleton.cs @@ -113,13 +113,13 @@ namespace CalamityMod.Items.Weapons.Summon // If the player owns a panel, make it fade away. if (player.ownedProjectileCounts[panelID] >= 1) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != panelID || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) + if (p.type != panelID || p.owner != player.whoAmI) continue; - Main.projectile[i].ai[0] = 1f; - Main.projectile[i].netUpdate = true; + p.ai[0] = 1f; + p.netUpdate = true; } } diff --git a/Items/Weapons/Summon/BrittleStarStaff.cs b/Items/Weapons/Summon/BrittleStarStaff.cs index 927726bba0..8a2b3ed5f5 100644 --- a/Items/Weapons/Summon/BrittleStarStaff.cs +++ b/Items/Weapons/Summon/BrittleStarStaff.cs @@ -53,13 +53,13 @@ namespace CalamityMod.Items.Weapons.Summon Item.noUseGraphic = true; } int bladeIndex = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (p.type == type && p.owner == player.whoAmI) { - Main.projectile[i].ModProjectile().StarIndex = bladeIndex++; - Main.projectile[i].ModProjectile().AITimer = 0f; - Main.projectile[i].netUpdate = true; + p.ModProjectile().StarIndex = bladeIndex++; + p.ModProjectile().AITimer = 0f; + p.netUpdate = true; } } return false; diff --git a/Items/Weapons/Summon/CosmicImmaterializer.cs b/Items/Weapons/Summon/CosmicImmaterializer.cs index 477e19cd22..d7d6ac4aa8 100644 --- a/Items/Weapons/Summon/CosmicImmaterializer.cs +++ b/Items/Weapons/Summon/CosmicImmaterializer.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -16,8 +17,8 @@ namespace CalamityMod.Items.Weapons.Summon public new string LocalizationCategory => "Items.Weapons.Summon"; public override void SetDefaults() { - Item.width = 74; - Item.height = 72; + Item.width = 170; + Item.height = 164; Item.mana = 10; Item.damage = 560; Item.useStyle = ItemUseStyleID.Swing; @@ -43,6 +44,11 @@ namespace CalamityMod.Items.Weapons.Summon return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Summon/CosmicImmaterializerGlow").Value); + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Summon/CosmicImmaterializer.png b/Items/Weapons/Summon/CosmicImmaterializer.png index aaf579725d..21ac8d7523 100644 Binary files a/Items/Weapons/Summon/CosmicImmaterializer.png and b/Items/Weapons/Summon/CosmicImmaterializer.png differ diff --git a/Items/Weapons/Summon/CosmicImmaterializerGlow.png b/Items/Weapons/Summon/CosmicImmaterializerGlow.png new file mode 100644 index 0000000000..b2854e2cae Binary files /dev/null and b/Items/Weapons/Summon/CosmicImmaterializerGlow.png differ diff --git a/Items/Weapons/Summon/Cosmilamp.cs b/Items/Weapons/Summon/Cosmilamp.cs index 231bd38e69..13dc9b4d22 100644 --- a/Items/Weapons/Summon/Cosmilamp.cs +++ b/Items/Weapons/Summon/Cosmilamp.cs @@ -45,12 +45,12 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { // Reset the timer for all lamps, to re-align the formation. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].active) + if (pro.type == type && pro.owner == player.whoAmI) { - Main.projectile[i].ModProjectile().Timer = 0f; - Main.projectile[i].netUpdate = true; + pro.ModProjectile().Timer = 0f; + pro.netUpdate = true; } } diff --git a/Items/Weapons/Summon/DazzlingStabberStaff.cs b/Items/Weapons/Summon/DazzlingStabberStaff.cs index bab08f23e9..3759fa322b 100644 --- a/Items/Weapons/Summon/DazzlingStabberStaff.cs +++ b/Items/Weapons/Summon/DazzlingStabberStaff.cs @@ -48,12 +48,12 @@ namespace CalamityMod.Items.Weapons.Summon angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 8) * 2.5f); } angleMax = angleMax > MathHelper.ToRadians(105f) ? MathHelper.ToRadians(105f) : angleMax; // More intuative than using a min function - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + if (p.type == type && p.owner == player.whoAmI) { - Main.projectile[i].ai[1] = (index / CalamityUtils.CountProjectiles(type)) * angleMax - angleMax / 2f; - Main.projectile[i].netUpdate = true; + p.ai[1] = (index / CalamityUtils.CountProjectiles(type)) * angleMax - angleMax / 2f; + p.netUpdate = true; index++; } } diff --git a/Items/Weapons/Summon/DormantBrimseeker.cs b/Items/Weapons/Summon/DormantBrimseeker.cs index ae2b2695e9..33371abda8 100644 --- a/Items/Weapons/Summon/DormantBrimseeker.cs +++ b/Items/Weapons/Summon/DormantBrimseeker.cs @@ -32,11 +32,11 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { float totalSlots = 0f; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].minion && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (p.minion && p.owner == player.whoAmI) { - totalSlots += Main.projectile[i].minionSlots; + totalSlots += p.minionSlots; } } if (totalSlots < player.maxMinions) diff --git a/Items/Weapons/Summon/EndoHydraStaff.cs b/Items/Weapons/Summon/EndoHydraStaff.cs index 163f44253a..6e96ca55f3 100644 --- a/Items/Weapons/Summon/EndoHydraStaff.cs +++ b/Items/Weapons/Summon/EndoHydraStaff.cs @@ -39,11 +39,11 @@ namespace CalamityMod.Items.Weapons.Summon { bool bodyExists = false; int bodyIndex = -1; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + if (p.type == type && p.owner == player.whoAmI) { - bodyIndex = i; + bodyIndex = p.whoAmI; bodyExists = true; break; } diff --git a/Items/Weapons/Summon/FlamsteedRing.cs b/Items/Weapons/Summon/FlamsteedRing.cs index 438bf16a36..697ee14482 100644 --- a/Items/Weapons/Summon/FlamsteedRing.cs +++ b/Items/Weapons/Summon/FlamsteedRing.cs @@ -122,13 +122,12 @@ namespace CalamityMod.Items.Weapons.Summon // If the player has any robots, kill them all. if (player.ownedProjectileCounts[Item.shoot] > 0) { - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && - Main.projectile[i].type == Item.shoot && - Main.projectile[i].owner == player.whoAmI) + if (p.type == Item.shoot && + p.owner == player.whoAmI) { - Main.projectile[i].Kill(); + p.Kill(); } } if (CalamityPlayer.areThereAnyDamnBosses) @@ -151,13 +150,12 @@ namespace CalamityMod.Items.Weapons.Summon int robotIndex = -1; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && - Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == player.whoAmI) + if (p.type == ModContent.ProjectileType() && + p.owner == player.whoAmI) { - robotIndex = i; + robotIndex = p.whoAmI; break; } } diff --git a/Items/Weapons/Summon/GlacialEmbrace.cs b/Items/Weapons/Summon/GlacialEmbrace.cs index bce8284a37..466e2ceb5e 100644 --- a/Items/Weapons/Summon/GlacialEmbrace.cs +++ b/Items/Weapons/Summon/GlacialEmbrace.cs @@ -35,11 +35,11 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { float totalMinionSlots = 0f; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI) + if (pro.minion && pro.owner == player.whoAmI) { - totalMinionSlots += Main.projectile[i].minionSlots; + totalMinionSlots += pro.minionSlots; } } if (player.altFunctionUse != 2 && totalMinionSlots < player.maxMinions) @@ -50,29 +50,29 @@ namespace CalamityMod.Items.Weapons.Summon if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; int pointyThingCount = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + if (pro.type == type && pro.owner == player.whoAmI) { - if (!(Main.projectile[i].ModProjectile as GlacialEmbracePointyThing).circlingPlayer) + if (!(pro.ModProjectile as GlacialEmbracePointyThing).circlingPlayer) continue; pointyThingCount++; } } float angleVariance = MathHelper.TwoPi / pointyThingCount; float angle = 0f; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].ai[1] == 0f) + if (pro.type == type && pro.owner == player.whoAmI && pro.ai[1] == 0f) { - if (!(Main.projectile[i].ModProjectile as GlacialEmbracePointyThing).circlingPlayer) + if (!(pro.ModProjectile as GlacialEmbracePointyThing).circlingPlayer) continue; - Main.projectile[i].ai[0] = angle; - Main.projectile[i].netUpdate = true; + pro.ai[0] = angle; + pro.netUpdate = true; angle += angleVariance; for (int j = 0; j < 22; j++) { - Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, DustID.Ice); + Dust dust = Dust.NewDustDirect(pro.position, pro.width, pro.height, DustID.Ice); dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool().ToDirectionInt(); dust.noGravity = true; } diff --git a/Items/Weapons/Summon/IgneousExaltation.cs b/Items/Weapons/Summon/IgneousExaltation.cs index f0ae80e6cc..b00537081a 100644 --- a/Items/Weapons/Summon/IgneousExaltation.cs +++ b/Items/Weapons/Summon/IgneousExaltation.cs @@ -37,11 +37,11 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { float totalMinionSlots = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI) + if (pro.minion && pro.owner == player.whoAmI) { - totalMinionSlots += Main.projectile[i].minionSlots; + totalMinionSlots += pro.minionSlots; } } if (player.altFunctionUse != 2 && totalMinionSlots < player.maxMinions) @@ -51,16 +51,16 @@ namespace CalamityMod.Items.Weapons.Summon if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; int swordCount = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + if (pro.type == type && pro.owner == player.whoAmI) { - if ((Main.projectile[i].ModProjectile as IgneousBlade).Firing) + if ((pro.ModProjectile as IgneousBlade).Firing) continue; swordCount++; for (int j = 0; j < 22; j++) { - Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, DustID.Torch); + Dust dust = Dust.NewDustDirect(pro.position, pro.width, pro.height, DustID.Torch); dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool().ToDirectionInt(); dust.noGravity = true; } @@ -68,17 +68,17 @@ namespace CalamityMod.Items.Weapons.Summon } float angleVariance = MathHelper.TwoPi / swordCount; float angle = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) + if (pro.type == type && pro.owner == player.whoAmI && pro.localAI[1] == 0f) { - if ((Main.projectile[i].ModProjectile as IgneousBlade).Firing) + if ((pro.ModProjectile as IgneousBlade).Firing) continue; - Main.projectile[i].ai[0] = angle; + pro.ai[0] = angle; angle += angleVariance; for (int j = 0; j < 22; j++) { - Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, DustID.Torch); + Dust dust = Dust.NewDustDirect(pro.position, pro.width, pro.height, DustID.Torch); dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool().ToDirectionInt(); dust.noGravity = true; } diff --git a/Items/Weapons/Summon/StaffoftheMechworm.cs b/Items/Weapons/Summon/StaffoftheMechworm.cs index c3555dbd4b..5a9a3a858f 100644 --- a/Items/Weapons/Summon/StaffoftheMechworm.cs +++ b/Items/Weapons/Summon/StaffoftheMechworm.cs @@ -35,10 +35,9 @@ namespace CalamityMod.Items.Weapons.Summon { float neededSlots = 1; float foundSlotsCount = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.active && p.minion && p.owner == player.whoAmI) + if (p.minion && p.owner == player.whoAmI) { foundSlotsCount += p.minionSlots; if (foundSlotsCount + neededSlots > player.maxMinions) @@ -100,17 +99,17 @@ namespace CalamityMod.Items.Weapons.Summon { int head = -1; int tail = -1; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer) + if (p.owner == Main.myPlayer) { - if (head == -1 && Main.projectile[i].type == ModContent.ProjectileType()) + if (head == -1 && p.type == ModContent.ProjectileType()) { - head = i; + head = p.whoAmI; } - if (tail == -1 && Main.projectile[i].type == ModContent.ProjectileType()) + if (tail == -1 && p.type == ModContent.ProjectileType()) { - tail = i; + tail = p.whoAmI; } if (head != -1 && tail != -1) { diff --git a/Items/Weapons/Summon/StarspawnHelixStaff.cs b/Items/Weapons/Summon/StarspawnHelixStaff.cs index 867e824854..ac6e306dcd 100644 --- a/Items/Weapons/Summon/StarspawnHelixStaff.cs +++ b/Items/Weapons/Summon/StarspawnHelixStaff.cs @@ -42,13 +42,13 @@ namespace CalamityMod.Items.Weapons.Summon } int bladeIndex = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (pro.type == type && pro.owner == player.whoAmI) { - Main.projectile[i].ModProjectile().ProbeIndex = bladeIndex++; - Main.projectile[i].ModProjectile().AITimer = 0f; - Main.projectile[i].netUpdate = true; + pro.ModProjectile().ProbeIndex = bladeIndex++; + pro.ModProjectile().AITimer = 0f; + pro.netUpdate = true; } } } diff --git a/Items/Weapons/Summon/ViralSprout.cs b/Items/Weapons/Summon/ViralSprout.cs index b8562622b7..a15b2b4211 100644 --- a/Items/Weapons/Summon/ViralSprout.cs +++ b/Items/Weapons/Summon/ViralSprout.cs @@ -39,13 +39,13 @@ namespace CalamityMod.Items.Weapons.Summon Main.projectile[p].originalDamage = Item.damage; int minionCount = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + if (pro.type != type || pro.owner != player.whoAmI) continue; - Main.projectile[i].localAI[0] = minionCount; - Main.projectile[i].netUpdate = true; + pro.localAI[0] = minionCount; + pro.netUpdate = true; minionCount++; } } diff --git a/Items/Weapons/Summon/ViridVanguard.cs b/Items/Weapons/Summon/ViridVanguard.cs index 99585eaccc..2e30e7403b 100644 --- a/Items/Weapons/Summon/ViridVanguard.cs +++ b/Items/Weapons/Summon/ViridVanguard.cs @@ -63,13 +63,13 @@ namespace CalamityMod.Items.Weapons.Summon } int bladeIndex = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + if (pro.type == type && pro.owner == player.whoAmI) { - Main.projectile[i].ModProjectile().BladeIndex = bladeIndex++; - Main.projectile[i].ModProjectile().AITimer = 0f; - Main.projectile[i].netUpdate = true; + pro.ModProjectile().BladeIndex = bladeIndex++; + pro.ModProjectile().AITimer = 0f; + pro.netUpdate = true; } } } diff --git a/Items/Weapons/Typeless/LunicEye.cs b/Items/Weapons/Typeless/LunicEye.cs index c1382ea084..83600706cf 100644 --- a/Items/Weapons/Typeless/LunicEye.cs +++ b/Items/Weapons/Typeless/LunicEye.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Typeless { CreateRecipe(). AddRecipeGroup("AnyCobaltBar", 10). - AddIngredient(20). + AddIngredient(20). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Typeless/RelicOfResilience.cs b/Items/Weapons/Typeless/RelicOfResilience.cs index a86f3f278e..a2b5adafcb 100644 --- a/Items/Weapons/Typeless/RelicOfResilience.cs +++ b/Items/Weapons/Typeless/RelicOfResilience.cs @@ -56,12 +56,12 @@ namespace CalamityMod.Items.Weapons.Typeless }; if (player.ownedProjectileCounts[Item.shoot] > 0) { - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == Item.shoot) + if (p.type == Item.shoot) { - Main.projectile[i].Center = Main.MouseWorld; - Main.projectile[i].netUpdate = true; + p.Center = Main.MouseWorld; + p.netUpdate = true; } } } diff --git a/Items/Weapons/Typeless/StarStruckWater.cs b/Items/Weapons/Typeless/StarStruckWater.cs index 9ab9498f8f..110edb02eb 100644 --- a/Items/Weapons/Typeless/StarStruckWater.cs +++ b/Items/Weapons/Typeless/StarStruckWater.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Typeless { CreateRecipe(10). AddIngredient(ItemID.BottledWater, 10). - AddIngredient(2). + AddIngredient(2). AddIngredient(). Register(); } diff --git a/Localization/en-US/Mods.CalamityMod.Biomes.hjson b/Localization/en-US/Mods.CalamityMod.Biomes.hjson index 7751dea39b..f6834ea4a1 100644 --- a/Localization/en-US/Mods.CalamityMod.Biomes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Biomes.hjson @@ -1,29 +1,28 @@ // For general uses Abyss: Abyss AstralInfection: Astral Infection -AstralDesert: Astral Desert AstralSnow: Astral Snow BrimstoneCrags: Brimstone Crags SulphurousSea: Sulphurous Sea SunkenSea: Sunken Sea -AbovegroundAstralBiome: { - DisplayName: Astral Infection - TownNPCDialogueName: Astral Infection -} - -AbovegroundAstralBiomeSurface: { - DisplayName: Astral Surface - TownNPCDialogueName: Astral Infection -} - -AbovegroundAstralDesertBiome: { +AstralDesert: { DisplayName: Astral Desert Surface TownNPCDialogueName: Astral Desert } -AbovegroundAstralSnowBiome: { - DisplayName: Astral Snow Surface +AstralBiome: { + DisplayName: Astral Infection + TownNPCDialogueName: Astral Infection +} + +AstralInfectionBiome: { + DisplayName: Astral Infection + TownNPCDialogueName: Astral Infection +} + +AstralIce: { + DisplayName: Astral Ice TownNPCDialogueName: Astral Snow } @@ -72,7 +71,12 @@ SunkenSeaBiome: { TownNPCDialogueName: Sunken Sea } -UndergroundAstralBiome: { +AstralUnderground: { DisplayName: Astral Underground TownNPCDialogueName: Underground Astral Infection } + +AstralCaveDesert: { + DisplayName: Astral Cave Desert + TownNPCDialogueName: the Astral Cave Desert +} diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 10e5e5fb54..ee2b18d646 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -634,7 +634,7 @@ AbyssalMadness: { AdrenalineMode: { DisplayName: Adrenaline Mode - Description: Total damage multiplied by 3x. Can be boosted by other items up to 3.45x + Description: Total damage multiplied by 2.5x. Can be boosted by other items up to 3.1x } Afflicted: { @@ -1046,11 +1046,6 @@ BlackHawkBuff: { Description: The fighter jet will protect you } -BloodClot: { - DisplayName: Blood Clot - Description: The blood clot will protect you -} - BrimseekerBuff: { DisplayName: Brimseeker Description: Does it want something from you? diff --git a/Localization/en-US/Mods.CalamityMod.Condition.hjson b/Localization/en-US/Mods.CalamityMod.Condition.hjson index bf60551d64..844e15ed3e 100644 --- a/Localization/en-US/Mods.CalamityMod.Condition.hjson +++ b/Localization/en-US/Mods.CalamityMod.Condition.hjson @@ -1,64 +1,43 @@ // Drop conditions Drops: { - Cynosure: Drops once you have defeated both Draedon and Calamitas - DownedKS: Drops after defeating King Slime - DownedDS: Drops after defeating the Desert Scourge - DownedEoC: Drops after defeating the Eye of Cthulhu - DownedCrab: Drops after defeating Crabulon - DownedEoW: Drops after defeating the Eater of Worlds - DownedBoC: Drops after defeating the Brain of Cthulhu - DownedHM: Drops after defeating the Hive Mind - DownedPerfs: Drops after defeating the Perforators - DownedQB: Drops after defeating the Queen Bee - DownedDeer: Drops after defeating Deerclops - DownedSkele: Drops after defeating Skeletron - DownedSG: Drops after defeating the Slime God - Hardmode: Drops in Hardmode - DownedQS: Drops after defeating Queen Slime - DownedCryo: Drops after defeating Cryogen - DownedAS: Drops after defeating the Aquatic Scourge - DownedBrim: Drops after defeating the Brimstone Elemental - DownedDest: Drops after defeating the Destroyer - DownedTwins: Drops after defeating the Twins - DownedSP: Drops after defeating Skeletron Prime - Downed1Mech: Drops after defeating a Mechanical Boss - Downed3Mechs: Drops after defeating all three Mechanical Bosses - DownedCal: Drops after defeating Calamitas Clone - DownedPlant: Drops after defeating Plantera - DownedCalPlant: Drops after defeating Calamitas or Plantera - DownedLevi: Drops after defeating the Leviathan and Anahita - DownedAureus: Drops after defeating Astrum Aureus - DownedGolem: Drops after defeating Golem - DownedPBG: Drops after defeating the Plaguebringer Goliath - DownedEoL: Drops after defeating the Empress of Light - DownedFish: Drops after defeating Duke Fishron - DownedRav: Drops after defeating the Ravager - DownedLC: Drops after defeating the Lunatic Cultist - DownedAD: Drops after defeating Astrum Deus - DownedML: Drops after defeating the Moon Lord - DownedGuard: Drops after defeating the Profaned Guardians - DownedBirb: Drops after defeating the Dragonfolly - DownedProv: Drops after defeating Providence - DownedSig: Drops after defeating Signus - DownedSW: Drops after defeating the Storm Weaver - DownedCV: Drops after defeating the Ceaseless Void - DownedPolter: Drops after defeating the Polterghast - DownedOD: Drops after defeating the Old Duke - DownedDoG: Drops after defeating the Devourer of Gods - DownedYharon: Drops after defeating Yharon - DownedExos: Drops after defeating the Exo Mechs - DownedSCal: Drops after defeating Calamitas - DownedAEW: Drops after defeating the Primordial Wyrm - DownedClam: Drops after defeating the Giant Clam - DownedClamHM: Drops after defeating the Giant Clam in Hardmode - DownedGSS: Drops after defeating the Great Sand Shark - DownedBetsy: Drops after defeating Betsy - DownedT1AR: Drops after defeating the first tier of Acid Rain - DownedT2AR: Drops after defeating the second tier of Acid Rain + Cynosure: After defeating both Draedon and Calamitas + DownedDS: After defeating the Desert Scourge + DownedCrab: After defeating Crabulon + DownedHM: After defeating the Hive Mind + DownedPerfs: After defeating the Perforators + DownedHMOrPerfs: After defeating the Hive Mind or the Perforators + DownedSG: After defeating the Slime God + DownedCryo: After defeating Cryogen + DownedAS: After defeating the Aquatic Scourge + DownedBrim: After defeating the Brimstone Elemental + DownedDest: After defeating the Destroyer + DownedCal: After defeating Calamitas Clone + DownedCalPlant: After defeating Calamitas or Plantera + DownedLevi: After defeating the Leviathan and Anahita + DownedAureus: After defeating Astrum Aureus + DownedPBG: After defeating the Plaguebringer Goliath + DownedRav: After defeating the Ravager + DownedAD: After defeating Astrum Deus + DownedGuard: After defeating the Profaned Guardians + DownedBirb: After defeating the Dragonfolly + DownedProv: After defeating Providence + DownedSig: After defeating Signus + DownedSW: After defeating the Storm Weaver + DownedCV: After defeating the Ceaseless Void + DownedPolter: After defeating the Polterghast + DownedOD: After defeating the Old Duke + DownedDoG: After defeating the Devourer of Gods + DownedYharon: After defeating Yharon + DownedExos: After defeating the Exo Mechs + DownedSCal: After defeating Calamitas + DownedAEW: After defeating the Primordial Wyrm + DownedClam: After defeating the Giant Clam + DownedClamHM: After defeating the Giant Clam in Hardmode + DownedGSS: After defeating the Great Sand Shark + DownedBetsy: After defeating Betsy + DownedT1AR: After defeating the first tier of Acid Rain + DownedT2AR: After defeating the second tier of Acid Rain FirstKill: Drops only on the first kill - IsGFB: This is an Everything Seed drop rate - IsRev: This is a Revengeance Mode drop rate - IsDeath: This is a Death Mode drop rate MechBoss: Drops on the first kill of the final Mechanical Boss ProvidenceHallow: ''' @@ -84,18 +63,16 @@ PotionConfig: While the Town NPC Potion Selling configuration option is enabled HasFlareGun: While holding a Flare Gun upgrade HasRogueArmor: While wearing rogue armor HasWings: While wearing wings -InAstral: While in the Astral Infection -InCrag: While in the Brimstone Crags -InSulph: While in the Sulphurous Sea -InSunken: While in the Sunken Sea +InAstral: In the Astral Infection +InCrag: In the Brimstone Crags +InSulph: In the Sulphurous Sea +InSunken: In the Sunken Sea InRev: In Revengeance Mode +IsRevOrMM: In Revengeance Mode or in Master Mode AlcoholPoison: While inflicted with Alcohol Poisoning -DownedHM: After the Hive Mind has been defeated -DownedPerfs: After the Perforator Hive has been defeated -DownedEvil2Boss: After the Hive Mind or the Perforators have been defeated -PostCal: After Calamitas Clone has been defeated -PostAureus: After Astrum Aureus has been defeated -PostPolter: After Polterghast has been defeated -PostOD: After the Old Duke has been defeated -PostDoG: After the Devourer of Gods has been defeated -PostYharon: After Yharon has been defeated +PostCal: After defeating Calamitas Clone +PostAureus: After defeating Astrum Aureus +PostPolter: After defeating Polterghast +PostOD: After defeating the Old Duke +PostDoG: After defeating the Devourer of Gods +PostYharon: After defeating Yharon diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 329846ae88..5726d7ac9a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -860,7 +860,7 @@ GrandGelatin: { ''' 12% increased movement speed and jump speed Using a healing potion will spawn a cleansing aura - Walking into the aura removes all debuffs and defense damage one time + Walking into the aura removes all debuffs one time The aura grants +2.5 HP/s life regen for all players inside for 8 seconds ''' } @@ -923,8 +923,8 @@ HideofAstrumDeus: { Tooltip: ''' Taking damage, or inflicting a true melee strike, drops an immense amount of astral stars from the sky - Taking damage boosts true melee damage by 50% - Boost duration is based on the amount of damage you took, the higher the damage the longer the boost + Taking damage boosts true melee damage by 30% + Boost duration scales with the amount of damage you took, up to 10 seconds Provides immunity to the astral infection, cursed inferno, on fire, and frostburn debuffs Enemies take damage when they hit you and are inflicted with the astral infection debuff ''' @@ -1053,8 +1053,8 @@ CleansingJelly: { DisplayName: Cleansing Jelly Tooltip: ''' - Using a healing potion will spawn a cleansing aura - Walking into the aura removes all debuffs and defense damage one time + Using a healing potion will spawn a cleansing aura + Walking into the aura removes all debuffs one time ''' } @@ -1316,8 +1316,19 @@ ProfanedSoulCrystal: { ''' } -Purity: { - DisplayName: Purity +QuiverofNihility: { + DisplayName: Quiver of Nihility + Tooltip: + ''' + 5% increased ranged critical strike chance + Summons a ring of four void fields to orbit you + Arrows that pass through these fields gain a 75% damage boost and double the speed + 'Filled with a substance darker than the night sky' + ''' +} + +Radiance: { + DisplayName: Radiance Tooltip: ''' +100 max life @@ -1335,17 +1346,6 @@ Purity: { ''' } -QuiverofNihility: { - DisplayName: Quiver of Nihility - Tooltip: - ''' - 5% increased ranged critical strike chance - Summons a ring of four void fields to orbit you - Arrows that pass through these fields gain a 75% damage boost and double the speed - 'Filled with a substance darker than the night sky' - ''' -} - RadiantOoze: { DisplayName: Radiant Ooze Tooltip: @@ -1766,7 +1766,7 @@ TheAbsorber: { Grants immunity to knockback Enemies take immense damage when they touch you and are afflicted with a damaging sickness debuff that reduces damage reduction significantly Using a healing potion will spawn a cleansing aura - Walking into the aura removes all debuffs and defense damage one time + Walking into the aura removes all debuffs one time The aura grants +3 HP/s life regen, +8% damage, and +5% damage reduction for all players inside for 10 seconds 5% of the damage from enemy attacks is absorbed and converted into healing ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson b/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson index 3832adc9b4..6c23f21453 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson @@ -302,8 +302,8 @@ SolarVeil: { Tooltip: Sunlight cannot penetrate the fabric of this cloth } -Stardust: { - DisplayName: Stardust +StarblightSoot: { + DisplayName: Starblight Soot Tooltip: "" } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson index 33d8d3ce0a..119da60e37 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson @@ -196,34 +196,67 @@ StarlightFuelCell: { } // Spawn Blockers +SpawnBlockersOn: Currently enabled +SpawnBlockersOff: Currently disabled + AntiCystOintment: { DisplayName: Anti-Cyst Ointment - Tooltip: Favorite this item to prevent perforator cysts from spawning near you + Tooltip: + ''' + Toggle this item to prevent hive cysts from spawning near you + Press to toggle + [STATE] + ''' } AntiTumorOintment: { DisplayName: Anti-Tumor Ointment - Tooltip: Favorite this item to prevent hive tumors from spawning near you + Tooltip: + ''' + Toggle this item to prevent hive tumors from spawning near you + Press to toggle + [STATE] + ''' } BleachBall: { DisplayName: Bleach Ball - Tooltip: Favorite this item to prevent the Aquatic Scourge from naturally spawning near you + Tooltip: + ''' + Toggle this item to prevent Aquatic Scourge from spawning + Press to toggle + [STATE] + ''' } BrokenWaterFilter: { DisplayName: Broken Water Filter - Tooltip: Favorite this item to disable natural Acid Rain spawns + Tooltip: + ''' + Toggle this item to prevent Acid Rain from occurring + Press to toggle + [STATE] + ''' } SirenproofEarMuffs: { DisplayName: Sirenproof Earmuffs - Tooltip: Favorite this item to prevent Anahita from spawning near you + Tooltip: + ''' + Toggle this item to prevent Anahita from spawning + Press to toggle + [STATE] + ''' } VoodooDemonVoodooDoll: { DisplayName: Voodoo Demon Voodoo Doll - Tooltip: Favorite this item to prevent voodoo demons from spawning near you + Tooltip: + ''' + Toggle this item to prevent voodoo demons from spawning near you + Press to toggle + [STATE] + ''' } // Uncategorized diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index db4c2e4495..9fe4dc7c45 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -147,12 +147,15 @@ BurningSea: { Tooltip: Fires a bouncing brimstone fireball that splits into homing fireballs upon collision with water } -CarnageRay: { - DisplayName: Carnage Ray +ChronomancersScythe: { + DisplayName: Chronomancer's Scythe Tooltip: ''' - Fires a wretched, bloody ray - The farther along the ray hit enemies are, the more damage they take + Rapidly fires icicles + Press to swing the scythe around you, creating a clock pattern of homing icicles + Direct hits with the scythe have a chance to spawn clocks + Collecting the clocks increases movement speed and acceleration by 5% for each clock collected + This stacks up to 3 times and each level wears off after 5 seconds ''' } @@ -347,7 +350,7 @@ Genesis: { ''' Fire an array of lasers that decreases in spread for each shot Every sixth shot fires a splitting Genesis Beam and resets the spread of the weapon - Hitting an enemy where the Genesis Beam splits deals increased damage + Hitting an enemy before the Genesis Beam splits deals increased damage ''' } @@ -871,7 +874,6 @@ UltraLiquidator: { Tooltip: ''' Summons liquidation blades that summon more blades on enemy hits - The blades inflict ichor, cursed inferno and brimstone flames ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index d42b8a42b1..afeab0b76b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -239,6 +239,15 @@ BrokenBiomeBlade: { DefaultFunction: Does nothing... yet } +BurningRevelation: { + DisplayName: Burning Revelation + Tooltip: + ''' + Emits large holy explosions on hit + An exceptionally agile yoyo + ''' +} + BurntSienna: { DisplayName: Burnt Sienna Tooltip: Causes enemies to erupt into healing projectiles on death @@ -259,18 +268,6 @@ CelestialClaymore: { Tooltip: Spawns cosmic energy stars near the cursor that inflict several debuffs } -ChronomancersScythe: { - DisplayName: Chronomancer's Scythe - Tooltip: - ''' - Rapidly fires icicles - Press to swing the scythe around you, creating a clock pattern of homing icicles - Direct hits with the scythe have a chance to spawn clocks - Collecting the clocks increases movement speed and acceleration by 5% for each clock collected - This stacks up to 3 times and each level wears off after 5 seconds - ''' -} - ClamCrusher: { DisplayName: Clam Crusher Tooltip: @@ -1040,15 +1037,6 @@ SmokingComet: { Tooltip: Rains stars from the sky } -SolarFlare: { - DisplayName: Solar Flare - Tooltip: - ''' - Emits large holy explosions on hit - An exceptionally agile yoyo - ''' -} - SolsticeClaymore: { DisplayName: Solstice Claymore Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index c301f41078..5b6a9163a6 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -498,6 +498,7 @@ FlakToxicannon: { Fires a toxic shell that explodes into a cone of radioactive sludge Toxic shells burst when they reach the cursor's position Direct hits with the toxic shell will reduce the damage dealt by the sludge + Uses rockets for ammo ''' } @@ -763,7 +764,11 @@ MidasPrime: { MineralMortar: { DisplayName: Mineral Mortar - Tooltip: Shoots an onyx bomb that explodes into huge area damage + Tooltip: + ''' + Shoots an onyx bomb that explodes into huge area damage + Uses rockets for ammo + ''' } Kingsbane: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 03a00d6437..abd9755e31 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -538,8 +538,8 @@ HeavenfallenStardisk: { Tooltip: ''' Throws a stardisk upwards which then launches itself towards your mouse cursor - Explodes into 5 astral energy bolts if the thrower is moving vertically when throwing it - Stealth strikes rain astral energy bolts from the sky + Explodes into a star of astral bolts on hit + Stealth strikes throw three disks that rain astral energy bolts from the sky ''' } @@ -1084,7 +1084,8 @@ SlickCane: { Tooltip: ''' Swipes a cane that steals money from enemies - Stealth strikes gives a 1 in 15 chance for enemies to drop 1-3 gold coins when hit + Stealth strikes gives a 1 in 20 chance for enemies to drop 1-3 gold coins when hit + Stealth strikes' damage increases in proportion to money in the inventory (up to 2 platinum) 'Economy at its finest' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index a5b665adab..0b7073c368 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -73,11 +73,6 @@ BlackHawkRemote: { ''' } -BloodClotStaff: { - DisplayName: Blood Clot Staff - Tooltip: Summons a blood clot to fight for you -} - BorealisBomber: { DisplayName: Borealis Bomber Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index 7a682b6ca9..b9a91f0fb0 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -43,6 +43,7 @@ CirrusVolatileVodkaBottle.DisplayName: Volatile Vodka Bottle DarkEnergyBall.DisplayName: Dark Energy DarkEnergyBall2.DisplayName: Dark Energy DarkOrb.DisplayName: Dark Orb +DesertScourgeDiveSplash.DisplayName: Desert Scourge Dive Splash DesertScourgeSpit.DisplayName: Scourge Spit DestroyerCursedLaser.DisplayName: Cursed Laser DestroyerElectricLaser.DisplayName: Electric Laser diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 820e7031d9..e3a591b39e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -41,6 +41,9 @@ BrimstoneFireball.DisplayName: Brimstone Fireball BrimstoneHellfireballFriendly.DisplayName: Hellfireball BrimstoneHomer.DisplayName: Brimstone Homer BrimstoneTentacle.DisplayName: Brimstone Tentacle +ChronoIcicleLarge.DisplayName: Chrono Icicle +ChronoIcicleSmall.DisplayName: Chrono Icicle +ChronomancersScytheHoldout.DisplayName: Chronomancer's Scythe ClamorNoctusStar.DisplayName: Clamor Star ClamorNoctusWyvern.DisplayName: Clamor Wyvern ClimaxBeam.DisplayName: Voltaic Bolt diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index a033012dfc..6f5c733c72 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -60,9 +60,6 @@ BurningMeteor.DisplayName: Meteor CatastropheClaymoreSparkle.DisplayName: Catastrophe Sparkle CausticEdgeProjectile.DisplayName: Caustic Edge ChainedMeatHook.DisplayName: Enchanted Meat Hook -ChronoIcicleLarge.DisplayName: Chrono Icicle -ChronoIcicleSmall.DisplayName: Chrono Icicle -ChronomancersScytheHoldout.DisplayName: Chronomancer's Scythe ClamCrusherFlail.DisplayName: Clam Crusher CometQuasherMeteor.DisplayName: Comet Quasher Meteor CosmicBolt.DisplayName: Cosmic Bolt diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 1b37a70385..897bada72a 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -34,7 +34,6 @@ BlackDragonTail.DisplayName: Black Celestial Dragon BlackHawkBullet.DisplayName: Black Hawk Bullet BlackHawkSummon.DisplayName: Black Hawk BloodBreath.DisplayName: Blood Dragon Fire -BloodClotMinion.DisplayName: Blood Clot BloodRain.DisplayName: Blood Rain BloodSpit.DisplayName: Blood Spit BoneMatter.DisplayName: Bone Matter diff --git a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson index cfc9b69a4a..7a65173f13 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson @@ -73,6 +73,7 @@ MiracleBlight1: "{0} was blown away by miraculous technological advancements." MiracleBlight2: "{0} disintegrated from the overpowering exotic resonance." MiracleBlight3: "{0}'s constituent atoms rearranged themselves... poorly." NecroRevive: "{0} fell to the inevitable." +Norfleet: Norfleet showed {0} what happens to cheaters. Nightwither: "{0} was enervated by lunar rays." Plague1: "{0}'s flesh was melted by the plague." Plague2: "{0} couldn't vaccinate against the plague." diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 9d2b324962..7fbda27580 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -145,7 +145,11 @@ ArtemisApolloIcon: Artemis and Apollo, a pair of extremely persistent automatons // Debuff System DebuffSystem: { Title: Debuff Resistances - Description: NPCs take increased or decreased damage from certain debuff types + Description: + ''' + NPCs take 2x damage from vulnerable debuff types, + and 0.5x damage from resisted debuff types + ''' Heat: Heat Cold: Cold Sickness: Sickness @@ -159,6 +163,10 @@ DebuffSystem: { // Draedon Contact UI. Repeated newlines indicate pauses in Draedon's speaking. As a result, newline characters may be explicitly defined. // The code that interprets these strings will transform them. +CommunicationStartInitial: ... +CommunicationStartNoForge: Craft something using my Forge, then return. +CommunicationStartNormal: State your inquiry. + Communication: { WhoAreYou: { Inquiry: Introduction @@ -190,7 +198,7 @@ Communication: { ''' My first memories are that of awakening in a distant laboratory on the date of 11.19.1227, well over six centuries ago. Surrounded by nothing but a vast taiga, I was accompanied by only one other thing: a dead organic.\n - Presumably, I was created by what I assume to be the laboratory’s former inhabitant, though I am unsure how they accomplished such a feat. From what I gathered, they were quite the prestigious inventor, not unlike I. Several gadgets assumedly of their own making were attached to their body, and the equipment in the lab was more advanced than any I found elsewhere in the world.\n + Presumably, I was created by what I assume to be the laboratory's former inhabitant, though I am unsure how they accomplished such a feat. From what I gathered, they were quite the prestigious inventor, not unlike I. Several gadgets assumedly of their own making were attached to their body, and the equipment in the lab was more advanced than any I found elsewhere in the world.\n I have no recollection of events prior to my activation, but from the start, I knew what my goal was: creation and scientific advancement. Many years were spent optimizing and building upon both the laboratory and myself to assure constant progress.\n @@ -214,7 +222,7 @@ Communication: { However, what I am most notorious for are my hulking machines of war. I am certain that you are familiar with them. Though Yharim was almost sycophantic in his praise of my results, even if he sometimes questioned my methods, our time together came to an abrupt end after he learned of the Plaguebringer Goliath. Regrettably, this event left a sizable hole in my laboratory. No longer subject to his restrictions, my work on cloning the Witch and creating exotechnology began.\n - My role in the Crusade summarily ended; I do not consider the later inclusion of exotechnology into Yharim’s armor a formal part of my work under him. Yharim's knights and other troops continued to use my "Arsenal" in their military efforts, but I no longer oversaw their research or production.\n + My role in the Crusade summarily ended; I do not consider the later inclusion of exotechnology into Yharim's armor a formal part of my work under him. Yharim's knights and other troops continued to use my "Arsenal" in their military efforts, but I no longer oversaw their research or production.\n The Crusade did not obstruct or interfere with my core objective of creation and scientific advancement; rather, it simply redirected my focus. Through it, I gained novel insights and reached heights I would not have reached without playing a part in it. I appreciate having had the opportunity to work with some of the greatest organic minds of the time, and I hope those that are still alive will bring progress to a plethora of fields I have yet to explore. ''' @@ -247,7 +255,7 @@ Communication: { I forged its armor using a process inspired by how Silva created Braelor's axe: by using particle jets to slowly and carefully fuse many elements together into a nanocomposite, the invincible armor organically "grows" over Thanatos' structure like a chrysalis. Regrettably, the plating's immense weight makes Thanatos notably slower than its siblings.\n When designing the third, Apollo, my goal was to downscale significantly; to make something powerful, yet compact. Reviewing the most compact forms of destructive potential I knew, I elected to simulate the Witch's flames.\n - + Apollo's searing exoplasma is fueled by unstable nanomachines that constantly shed a deluge of ultra high energy particles. This both heats the plasma to incredible temperatures and causes radiation burns of a severity on par with those inflicted by the Witch. The craft had little capability beyond its nanomachine plasma projector, but there was no worry. Apollo was never meant to fight alone.\n The final to begin construction was Artemis. Rather than being founded on raw power, it was made to be the apex of speed and accuracy. There is elegance in simplicity, for all of Artemis' combat efficacy comes from an onboard predictive AI and a battery of hard-light bolt emitters.\n @@ -333,7 +341,7 @@ Communication: { Even if I dared to evoke Yharim's wrath, I cannot survey the Aerie. My attempts at locating it have been fruitless despite having surveyed this world's surface and skies many times over. Perhaps it avoids observation, as per some manner of cloaking. It is also possible it simply exists outside of conventional space, in a pocket dimension of sorts. Either case would make detecting it via my current methods drastically more difficult.\n What I do know is that the Dragon Aerie is an unusually large sky island that acted as the sacred home of the Auric dragons. Few others were ever allowed to tread there, as a sort of religious sanctuary or holy ground.\n - + It is also where Auric dragons would be laid to rest in preparation for their revival by Yharon. As their revival on the Aerie was a commonly accepted fact even at the start of recorded history, the sky island must be at least 2,000 years old, with Yharon himself being a similar age.\n Considering the extraordinary power of the Auric dragons and the sanctity of the Dragon Aerie, I am left to ponder: did the Aerie make the Auric dragons powerful, or is the Aerie inundated with power due to their extended presence? Perhaps more importantly, what made them leave the safety of the Aerie even as their kind were being slain? I eagerly await the uncovering of such mysteries. diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson index dbc84a461e..f1625a0e8f 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson @@ -55,8 +55,8 @@ SetBonus: { ''' Gold: ''' - All enemies have a 4% chance to drop 1 gold. All bosses killed drop 3 gold - You gain 1% critical strike chance for every 5 gold in your inventory, capped at 10% + All enemies have a 2% chance to drop 1 gold. All bosses killed drop 3 gold + You gain 1% critical strike chance for every 10 gold in your inventory, capped at 9% ''' Iron: ''' @@ -66,7 +66,7 @@ SetBonus: { Jungle: 10% reduced mana costs Lead: ''' - Increases damage reduction by 3% + Increases damage reduction by 4% +0.5 HP/s life regen Grants immunity to knockback ''' @@ -99,10 +99,12 @@ SetBonus: { Increases minion damage by 15% Grants immunity to fire blocks and temporary immunity to lava ''' + PlatinumChainmail: 3% increased critical strike chance Platinum: ''' - Every 10 defense gives you +0.5 HP/s life regen, 1% increased damage and 1% increased critical strike chance - These effects cap at 40 defense + Every 10 extra defense gives you 1% increased damage and 1% increased critical strike chance + The 20 defense from the Platinum Armor itself does not contribute to this effect + Bonus damage and critical strike chance cap at 40 extra defense ''' Silver: ''' @@ -129,7 +131,6 @@ SetBonus: { ''' Increases your life regeneration 15% increased minion damage and 10% increased melee critical strike chance - Negates the summon damage penalty while wielding non-summon weapons ''' HuntressTier2: 10% increased minion and ranged damage ApprenticeTier2: 5% increased minion damage and 15% increased magic critical strike chance diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 3d31d57f06..086ae693e4 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -21,6 +21,7 @@ using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.Astral; @@ -235,7 +236,6 @@ namespace CalamityMod ItemRedirect(ItemType(), "Pineapple (calamity)"); ItemRedirect(ItemType(), "Trash Can (pet)"); ItemRedirect(ItemType(), "Butcher (weapon)"); - ItemRedirect(ItemType(), "Purity (accessory)"); ItemRedirect(ItemType(), "Sandstorm (weapon)"); ItemRedirect(ItemType(), "Thunderstorm (weapon)"); // Lore items diff --git a/NPCs/Abyss/BabyCannonballJellyfish.cs b/NPCs/Abyss/BabyCannonballJellyfish.cs index 95b7a901fb..b9dad300de 100644 --- a/NPCs/Abyss/BabyCannonballJellyfish.cs +++ b/NPCs/Abyss/BabyCannonballJellyfish.cs @@ -162,8 +162,13 @@ namespace CalamityMod.NPCs.Abyss NPC.height = (int)(NPC.height * 3f); NPC.position -= NPC.Size * 0.5f; //hitbox expansion + adjustments SoundEngine.PlaySound(SoundID.Item14, NPC.Center); //bomb sound - foreach (Player player in Main.player.Where(player => player.active && !player.dead && NPC.Hitbox.Intersects(player.Hitbox))) + foreach (Player player in Main.ActivePlayers) + { + if (player.dead || !NPC.Hitbox.Intersects(player.Hitbox)) + continue; + player.Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), explosionDamage, NPC.direction); + } for (int k = 0; k < 8; k++) { int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.MoonBoulder, 0f, -1f, 0, default, 1f); diff --git a/NPCs/Abyss/CannonballJellyfish.cs b/NPCs/Abyss/CannonballJellyfish.cs index 3985c19fbe..772500e4be 100644 --- a/NPCs/Abyss/CannonballJellyfish.cs +++ b/NPCs/Abyss/CannonballJellyfish.cs @@ -272,8 +272,14 @@ namespace CalamityMod.NPCs.Abyss NPC.width = NPC.height; NPC.position -= NPC.Size * 0.5f; //hitbox expansion + adjustments SoundEngine.PlaySound(SoundID.Item14, NPC.Center); //bomb sound - foreach (Player player in Main.player.Where(player => player.active && !player.dead && NPC.Hitbox.Intersects(player.Hitbox))) - player.Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), NPC.damage * 3, NPC.direction); //Due to how slow the jelly is, this might catch you unaware, but then you'll never get hit by it again + foreach (Player player in Main.ActivePlayers) + { + if (player.dead || !NPC.Hitbox.Intersects(player.Hitbox)) + continue; + + //Due to how slow the jelly is, this might catch you unaware, but then you'll never get hit by it again + player.Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), NPC.damage * 3, NPC.direction); + } for (int k = 0; k < 25; k++) { int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.MoonBoulder, 0f, -1f, 0, default, 2f); diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 7770841c3a..3081a1a826 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -540,24 +540,21 @@ namespace CalamityMod.NPCs.Abyss } float pushVelocity = 0.05f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC otherNPC in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (otherNPC.whoAmI != NPC.whoAmI && otherNPC.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, otherNPC.Center) < 160f) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 160f) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; + if (NPC.position.X < otherNPC.position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } + if (NPC.position.Y < otherNPC.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } } } diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index de8d0bb5d9..5e0b418ef0 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -62,9 +62,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index c0a31646c9..9e31e16946 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -62,9 +62,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 8b23bec9cf..b7b311396f 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -118,19 +118,18 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { - NPC.TargetClosest(true); - } + NPC.TargetClosest(); + if (NPC.justHit || detectsPlayer || Main.player[NPC.target].chaosState || adultWyrmAlive || (Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f)) { detectsPlayer = true; NPC.damage = Main.expertMode ? 340 : 170; } else - { NPC.damage = 0; - } + NPC.chaseable = detectsPlayer; + if (detectsPlayer) { if (NPC.soundDelay <= 0) @@ -142,14 +141,12 @@ namespace CalamityMod.NPCs.Abyss else { if (Main.rand.NextBool(900)) - { SoundEngine.PlaySound(roar, NPC.Center); - } } + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -161,18 +158,13 @@ namespace CalamityMod.NPCs.Abyss if (segments >= 0 && segments < minLength) { if (segments % 2 == 0) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -180,17 +172,16 @@ namespace CalamityMod.NPCs.Abyss NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = -1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = 1; - } + if (Main.player[NPC.target].dead) { NPC.TargetClosest(false); @@ -208,14 +199,16 @@ namespace CalamityMod.NPCs.Abyss } } } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f) + NPC.active = false; } float currentSpeed = speed; diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index 45ff9eb1da..78045ad275 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -62,9 +62,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index e043327a62..819cae17cd 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -70,9 +70,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index ce6ac572b1..73d68d7b0f 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -70,9 +70,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index 1d09fd334f..395fc3d696 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -115,19 +115,16 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { - NPC.TargetClosest(true); - } - if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || - NPC.justHit) - { + NPC.TargetClosest(); + + if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || NPC.justHit) detectsPlayer = true; - } + NPC.chaseable = detectsPlayer; + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -139,18 +136,13 @@ namespace CalamityMod.NPCs.Abyss if (segments >= 0 && segments < minLength) { if (segments == 0) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -158,29 +150,28 @@ namespace CalamityMod.NPCs.Abyss NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = 1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = -1; - } + if (Main.player[NPC.target].dead) - { NPC.TargetClosest(false); - } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; } float currentSpeed = speed; diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index 48748c15c8..8c0444d4c1 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -70,9 +70,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/MorayEel.cs b/NPCs/Abyss/MorayEel.cs index 35c2d095df..7da581930d 100644 --- a/NPCs/Abyss/MorayEel.cs +++ b/NPCs/Abyss/MorayEel.cs @@ -118,7 +118,6 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Flipper, 20); - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 15, 10)); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Abyss/OarfishBody.cs b/NPCs/Abyss/OarfishBody.cs index ac1f56f8e3..2849ab2efa 100644 --- a/NPCs/Abyss/OarfishBody.cs +++ b/NPCs/Abyss/OarfishBody.cs @@ -61,9 +61,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 5945215fc8..9459276e5a 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -155,7 +155,11 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) - NPC.active = false; + { + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; + } float currentSpeed = speed; float currentTurnSpeed = turnSpeed; diff --git a/NPCs/Abyss/OarfishTail.cs b/NPCs/Abyss/OarfishTail.cs index f91af05d87..eb0ce07f93 100644 --- a/NPCs/Abyss/OarfishTail.cs +++ b/NPCs/Abyss/OarfishTail.cs @@ -61,9 +61,9 @@ namespace CalamityMod.NPCs.Abyss // Check if other segments are still alive, if not, die bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { shouldDespawn = false; break; diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index f774286a91..c81ad502c2 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -3,6 +3,7 @@ using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,6 +11,7 @@ using ReLogic.Content; using Terraria; using Terraria.GameContent; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -158,6 +160,7 @@ namespace CalamityMod.NPCs.Abyss var postLevi = npcLoot.DefineConditionalDropSet(DropHelper.PostLevi()); postLevi.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 2, 3)); postLevi.Add(ModContent.ItemType(), 4); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 6)); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/AcidRain/BloodwormNormal.cs b/NPCs/AcidRain/BloodwormNormal.cs index 18c8b4e8c9..b95a54e1eb 100644 --- a/NPCs/AcidRain/BloodwormNormal.cs +++ b/NPCs/AcidRain/BloodwormNormal.cs @@ -56,10 +56,9 @@ namespace CalamityMod.NPCs.AcidRain NPC.velocity.X = xSpeed * NPC.ai[0]; NPC.spriteDirection = (int)NPC.ai[0]; bool flee = false; - for (int i = 0; i < Main.player.Length; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player.active && !player.dead && Vector2.Distance(player.Center, NPC.Center) <= 220f) + if (!player.dead && Vector2.Distance(player.Center, NPC.Center) <= 220f) { flee = true; break; diff --git a/NPCs/AcidRain/SulphurousSkater.cs b/NPCs/AcidRain/SulphurousSkater.cs index a984472c18..17b047ceb0 100644 --- a/NPCs/AcidRain/SulphurousSkater.cs +++ b/NPCs/AcidRain/SulphurousSkater.cs @@ -189,20 +189,20 @@ namespace CalamityMod.NPCs.AcidRain float minimumDistance = 2400f; Projectile closestBubble = null; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != bubbleType || !Main.projectile[i].active) + if (p.type != bubbleType) continue; - if (Math.Abs(NPC.Center.X - Main.projectile[i].Center.X) >= minimumDistance || - Main.projectile[i].Center.Y <= NPC.Bottom.Y || - !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height)) + if (Math.Abs(NPC.Center.X - p.Center.X) >= minimumDistance || + p.Center.Y <= NPC.Bottom.Y || + !Collision.CanHit(NPC.position, NPC.width, NPC.height, p.position, p.width, p.height)) { continue; } - minimumDistance = NPC.Distance(Main.projectile[i].Center); - closestBubble = Main.projectile[i]; + minimumDistance = NPC.Distance(p.Center); + closestBubble = p; } distanceToBubble = minimumDistance; diff --git a/NPCs/Astral/Aries.cs b/NPCs/Astral/Aries.cs index ce94a721d9..1ea110d392 100644 --- a/NPCs/Astral/Aries.cs +++ b/NPCs/Astral/Aries.cs @@ -50,7 +50,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -128,7 +128,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 1, 3)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 1, 3)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index bce7d6cf7d..b57bd3c99d 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -56,7 +56,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -338,7 +338,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 1, 3)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 1, 3)); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Astral/AstralSlime.cs b/NPCs/Astral/AstralSlime.cs index 46e1cb2284..9959c22d91 100644 --- a/NPCs/Astral/AstralSlime.cs +++ b/NPCs/Astral/AstralSlime.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -100,7 +100,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 1, 3)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 1, 2, 1, 3)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); var postDeus = npcLoot.DefineConditionalDropSet(() => DownedBossSystem.downedAstrumDeus); diff --git a/NPCs/Astral/AstralachneaWall.cs b/NPCs/Astral/AstralachneaWall.cs index 008bf67d41..ab3c5fc0d1 100644 --- a/NPCs/Astral/AstralachneaWall.cs +++ b/NPCs/Astral/AstralachneaWall.cs @@ -7,6 +7,7 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Sounds; using CalamityMod.World; +using CalamityMod.BiomeManagers.BestiaryCategories; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -58,7 +59,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -155,8 +156,8 @@ namespace CalamityMod.NPCs.Astral public static void ModifyAstralachneaLoot(NPCLoot npcLoot) { - npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 2, 3); - npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); + npcLoot.AddIf(() => !Main.expertMode, ModContent.ItemType(), 2, 2, 3); + npcLoot.AddIf(() => Main.expertMode, ModContent.ItemType(), 1, 1, 4); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 8f159e4f43..d3fc6d6641 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -153,7 +153,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -270,13 +270,13 @@ namespace CalamityMod.NPCs.Astral centerY - height / 2, width, height); - for (int i = 0; i < Main.player.Length; i++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[i].active && !Main.player[i].dead && Main.player[i].getRect().Intersects(hitbox)) + if (!player.dead && player.getRect().Intersects(hitbox)) { - Vector2 before = Main.player[i].velocity; - Main.player[i].Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), NPC.defDamage, NPC.direction); - Vector2 after = Main.player[i].velocity; + Vector2 before = player.velocity; + player.Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), NPC.defDamage, NPC.direction); + Vector2 after = player.velocity; Vector2 difference = after - before; float horMult = 3.5f; @@ -291,7 +291,7 @@ namespace CalamityMod.NPCs.Astral swingYeet = true; } - if (Main.player[i].noKnockback) + if (player.noKnockback) { horMult *= 0.5f; verMult *= 0.5f; @@ -299,7 +299,7 @@ namespace CalamityMod.NPCs.Astral difference *= new Vector2(horMult, verMult); - Main.player[i].velocity = before + difference; + player.velocity = before + difference; } } } @@ -657,7 +657,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType()); - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 6, 8, 7, 9)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 6, 8, 7, 9)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index e5a53cbf34..9df2efe204 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.BiomeManagers.BestiaryCategories; using CalamityMod.Projectiles.Enemy; using CalamityMod.Sounds; using Microsoft.Xna.Framework; @@ -75,7 +76,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -322,7 +323,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.SharkFin, 8); - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); } } } diff --git a/NPCs/Astral/Hadarian.cs b/NPCs/Astral/Hadarian.cs index 4ad21f25b4..8882cf68c8 100644 --- a/NPCs/Astral/Hadarian.cs +++ b/NPCs/Astral/Hadarian.cs @@ -8,6 +8,7 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.Sounds; using CalamityMod.Tiles.AstralDesert; using CalamityMod.World; +using CalamityMod.BiomeManagers.BestiaryCategories; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -58,7 +59,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -221,7 +222,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 3, 1, 4)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 3, 1, 4)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 10); } } diff --git a/NPCs/Astral/HiveEnemy.cs b/NPCs/Astral/HiveEnemy.cs index 7529bb4fc6..ab56f1f246 100644 --- a/NPCs/Astral/HiveEnemy.cs +++ b/NPCs/Astral/HiveEnemy.cs @@ -7,6 +7,7 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Sounds; using CalamityMod.World; +using CalamityMod.BiomeManagers.BestiaryCategories; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -50,7 +51,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; if (Main.zenithWorld) { NPC.scale = 3f; @@ -126,6 +127,8 @@ namespace CalamityMod.NPCs.Astral if (NPC.life <= 0) { int type = ModContent.NPCType(); + + // TODO: Should this use `Main.ActiveNPCs` iterator? for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].type == type) @@ -159,7 +162,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 3, 1, 4)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 3, 1, 4)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } diff --git a/NPCs/Astral/Hiveling.cs b/NPCs/Astral/Hiveling.cs index 8d57509795..1815cf10a8 100644 --- a/NPCs/Astral/Hiveling.cs +++ b/NPCs/Astral/Hiveling.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Sounds; using CalamityMod.World; +using CalamityMod.BiomeManagers.BestiaryCategories; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -50,7 +51,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); diff --git a/NPCs/Astral/Mantis.cs b/NPCs/Astral/Mantis.cs index a1c1558071..f4416a41f4 100644 --- a/NPCs/Astral/Mantis.cs +++ b/NPCs/Astral/Mantis.cs @@ -60,7 +60,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -250,7 +250,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 2, 1, 3)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 2, 1, 3)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } diff --git a/NPCs/Astral/Nova.cs b/NPCs/Astral/Nova.cs index 7869fe2cb7..19ad010c55 100644 --- a/NPCs/Astral/Nova.cs +++ b/NPCs/Astral/Nova.cs @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -228,12 +228,12 @@ namespace CalamityMod.NPCs.Astral if (Main.netMode != NetmodeID.MultiplayerClient) { - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[i].getRect().Intersects(myRect)) + if (player.getRect().Intersects(myRect)) { - int direction = NPC.Center.X - Main.player[i].Center.X < 0 ? -1 : 1; - Main.player[i].Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), NPC.damage, direction); + int direction = NPC.Center.X - player.Center.X < 0 ? -1 : 1; + player.Hurt(PlayerDeathReason.ByNPC(NPC.whoAmI), NPC.damage, direction); } } } @@ -297,7 +297,7 @@ namespace CalamityMod.NPCs.Astral var exploded = npcLoot.DefineConditionalDropSet((info) => info.npc.ai[3] <= -10000f); // 2-3 Stardust (3-4 Expert+) - exploded.OnFailedConditions(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); + exploded.OnFailedConditions(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); exploded.OnFailedConditions(ItemDropRule.ByCondition(DropHelper.If(() => DownedBossSystem.downedAstrumAureus), ModContent.ItemType(), 7)); // If exploded, then have a chance to drop Glorious End and nothing else diff --git a/NPCs/Astral/SightseerCollider.cs b/NPCs/Astral/SightseerCollider.cs index be6958cc53..5b0a72f09c 100644 --- a/NPCs/Astral/SightseerCollider.cs +++ b/NPCs/Astral/SightseerCollider.cs @@ -59,7 +59,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -157,7 +157,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 2, 1, 3)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 2, 1, 3)); } } } diff --git a/NPCs/Astral/SightseerSpitter.cs b/NPCs/Astral/SightseerSpitter.cs index 9bc3205ed2..18a292029b 100644 --- a/NPCs/Astral/SightseerSpitter.cs +++ b/NPCs/Astral/SightseerSpitter.cs @@ -61,7 +61,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -186,7 +186,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); } } diff --git a/NPCs/Astral/StellarCulex.cs b/NPCs/Astral/StellarCulex.cs index 87f8f9eebe..979055f748 100644 --- a/NPCs/Astral/StellarCulex.cs +++ b/NPCs/Astral/StellarCulex.cs @@ -5,6 +5,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.BiomeManagers.BestiaryCategories; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -59,7 +60,7 @@ namespace CalamityMod.NPCs.Astral } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; // Scale stats in Expert and Master CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); @@ -135,7 +136,7 @@ namespace CalamityMod.NPCs.Astral public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 2, 1, 3)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 2, 1, 3)); npcLoot.AddIf(() => DownedBossSystem.downedAstrumAureus, ModContent.ItemType(), 7); } } diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index d0b5d1794e..236659fd72 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Astral AIType = NPCID.LightningBug; AnimationType = NPCID.LightningBug; NPC.catchItem = (short)ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index a99da6194b..c2222cc170 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -106,7 +106,7 @@ namespace CalamityMod.NPCs.AstrumAureus NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; if (Main.getGoodWorld) NPC.scale *= 0.8f; @@ -439,7 +439,7 @@ namespace CalamityMod.NPCs.AstrumAureus } // Drop an Astral Meteor if applicable - ThreadPool.QueueUserWorkItem(_ => AstralBiome.PlaceAstralMeteor()); + ThreadPool.QueueUserWorkItem(_ => World.AstralBiome.PlaceAstralMeteor()); // Mark Astrum Aureus as dead DownedBossSystem.downedAstrumAureus = true; diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index 5c44436054..379d8a9e6d 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -115,24 +115,21 @@ namespace CalamityMod.NPCs.AstrumAureus // Push away from each other float pushVelocity = 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < (160f + 30f * (NPC.scale - 1f))) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < (160f + 30f * (NPC.scale - 1f))) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X = NPC.velocity.X - pushVelocity; - else - NPC.velocity.X = NPC.velocity.X + pushVelocity; + if (NPC.position.X < n.position.X) + NPC.velocity.X = NPC.velocity.X - pushVelocity; + else + NPC.velocity.X = NPC.velocity.X + pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y = NPC.velocity.Y - pushVelocity; - else - NPC.velocity.Y = NPC.velocity.Y + pushVelocity; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y = NPC.velocity.Y - pushVelocity; + else + NPC.velocity.Y = NPC.velocity.Y + pushVelocity; } } } diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index 181b292122..f814c85120 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -108,7 +108,7 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.netAlways = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; if (Main.zenithWorld) { @@ -229,7 +229,7 @@ namespace CalamityMod.NPCs.AstrumDeus } } - public override void BossLoot(ref string name, ref int potionType) => potionType = ModContent.ItemType(); + public override void BossLoot(ref string name, ref int potionType) => potionType = ModContent.ItemType(); public static bool ShouldNotDropThings(NPC npc) => npc.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && npc.Calamity().newAI[0] != 3f); @@ -253,10 +253,9 @@ namespace CalamityMod.NPCs.AstrumDeus return; // Killing ANY split Deus makes all other Deus heads die immediately. - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC otherWormHead in Main.ActiveNPCs) { - NPC otherWormHead = Main.npc[i]; - if (otherWormHead.active && otherWormHead.type == NPC.type) + if (otherWormHead.type == NPC.type) { // Kill the other worm head after setting it to not drop loot. otherWormHead.Calamity().newAI[0] = 0f; @@ -311,7 +310,7 @@ namespace CalamityMod.NPCs.AstrumDeus // Materials normalOnly.Add(ItemID.FallenStar, 1, 25, 40); - normalOnly.Add(ModContent.ItemType(), 1, 50, 80); + normalOnly.Add(ModContent.ItemType(), 1, 50, 80); } npcLoot.DefineConditionalDropSet(() => true).Add(DropHelper.PerPlayer(ItemID.SuperHealingPotion, 1, 5, 15), hideLootReport: true); // Healing Potions don't show up in the Bestiary diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index b538a4df94..f4fc581261 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -195,24 +195,21 @@ namespace CalamityMod.NPCs.BrimstoneElemental // Push away from other Brimlings float pushVelocity = 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 40f * NPC.scale) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 40f * NPC.scale) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } } } diff --git a/NPCs/CalClone/CalScreenShaderData.cs b/NPCs/CalClone/CalScreenShaderData.cs index 11ee4782e0..af7b7ada08 100644 --- a/NPCs/CalClone/CalScreenShaderData.cs +++ b/NPCs/CalClone/CalScreenShaderData.cs @@ -24,11 +24,11 @@ namespace CalamityMod.NPCs.CalClone return; } CalIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == CalType) + if (n.type == CalType) { - CalIndex = i; + CalIndex = n.whoAmI; break; } } diff --git a/NPCs/CalClone/CalSky.cs b/NPCs/CalClone/CalSky.cs index e7d242d4d0..21beea7407 100644 --- a/NPCs/CalClone/CalSky.cs +++ b/NPCs/CalClone/CalSky.cs @@ -52,11 +52,11 @@ namespace CalamityMod.NPCs.CalClone return true; } CalIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == CalType) + if (n.type == CalType) { - CalIndex = i; + CalIndex = n.whoAmI; break; } } diff --git a/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs index 08ee0cf57f..7383afb7d4 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs @@ -528,9 +528,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Set velocity for charge if (oldDukeAttackPicker == 1) { - // Set damage - npc.damage = setDamage; - npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -893,9 +890,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Set velocity for charge if (phase2AttackPicker == 1) { - // Set damage - npc.damage = setDamage; - npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1299,9 +1293,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Set velocity for charge if (phase3AttackPicker == 1) { - // Set damage - npc.damage = setDamage; - npc.ai[0] = 11f; npc.ai[1] = 0f; npc.ai[2] = 0f; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 48b166f1ce..9dc40ae725 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -127,6 +127,7 @@ namespace CalamityMod.NPCs // Fireball, Cinnamon Roll and Hellfire Treads effects public bool IncreasedHeatEffects_Fireball = false; public bool IncreasedHeatEffects_CinnamonRoll = false; + public bool IncreasedHeatEffects_FlameWakerBoots = false; public bool IncreasedHeatEffects_HellfireTreads = false; // Toxic Heart effect @@ -225,9 +226,10 @@ namespace CalamityMod.NPCs public const int knockbackResistanceMin = 180; public int knockbackResistanceTimer = 0; - // Used for particle drawing on NPCs affected by vanilla Cobalt/Mythril weapons - public bool isNerfedByCobalt = false; - public bool isNerfedByMythril = false; + // Used for NPCs affected by vanilla Cobalt/Mythril weapons + public const int cobaltAndMythrilNerfTime = 600; + public int cobaltNerfTimer = 0; + public int mythrilNerfTimer = 0; // Debuffs public int vaporfied = 0; @@ -406,6 +408,7 @@ namespace CalamityMod.NPCs myClone.IncreasedElectricityEffects_Transformer = IncreasedElectricityEffects_Transformer; myClone.IncreasedHeatEffects_Fireball = IncreasedHeatEffects_Fireball; myClone.IncreasedHeatEffects_CinnamonRoll = IncreasedHeatEffects_CinnamonRoll; + myClone.IncreasedHeatEffects_FlameWakerBoots = IncreasedHeatEffects_FlameWakerBoots; myClone.IncreasedHeatEffects_HellfireTreads = IncreasedHeatEffects_HellfireTreads; myClone.IncreasedSicknessEffects_ToxicHeart = IncreasedSicknessEffects_ToxicHeart; myClone.IncreasedSicknessAndWaterEffects_EvergreenGin = IncreasedSicknessAndWaterEffects_EvergreenGin; @@ -445,8 +448,8 @@ namespace CalamityMod.NPCs myClone.bossCanBeKnockedBack = bossCanBeKnockedBack; myClone.knockbackResistanceTimer = knockbackResistanceTimer; - myClone.isNerfedByCobalt = isNerfedByCobalt; - myClone.isNerfedByMythril = isNerfedByMythril; + myClone.cobaltNerfTimer = cobaltNerfTimer; + myClone.mythrilNerfTimer = mythrilNerfTimer; myClone.vaporfied = vaporfied; myClone.timeSlow = timeSlow; @@ -626,11 +629,10 @@ namespace CalamityMod.NPCs npc.lifeRegen = 0; int projectileCount = 0; - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active && - (Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType() || Main.projectile[j].type == ProjectileType()) && - Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) + if ((p.type == ProjectileType() || p.type == ProjectileType() || p.type == ProjectileType()) && + p.ai[0] == 1f && p.ai[1] == npc.whoAmI) { projectileCount++; } @@ -651,10 +653,10 @@ namespace CalamityMod.NPCs npc.lifeRegen = 0; int projectileCount = 0; - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() && - Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) + if (p.type == ProjectileType() && + p.ai[0] == 1f && p.ai[1] == npc.whoAmI) { projectileCount++; } @@ -673,12 +675,12 @@ namespace CalamityMod.NPCs { int projectileCount = 0; int owner = 255; - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() && - Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) + if (p.type == ProjectileType() && + p.ai[0] == 1f && p.ai[1] == npc.whoAmI) { - owner = Main.projectile[j].owner; + owner = p.owner; projectileCount++; if (projectileCount >= 5) { @@ -715,13 +717,13 @@ namespace CalamityMod.NPCs if (clamDebuff > 0) { int projectileCount = 0; - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active && Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) + if (p.ai[0] == 1f && p.ai[1] == npc.whoAmI) { - if (Main.projectile[j].type == ProjectileType()) + if (p.type == ProjectileType()) projectileCount += 2; - if (Main.projectile[j].type == ProjectileType()) + if (p.type == ProjectileType()) projectileCount++; } } @@ -732,10 +734,10 @@ namespace CalamityMod.NPCs if (irradiated > 0) { int projectileCount = 0; - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active && Main.projectile[j].type == ProjectileType() && - Main.projectile[j].ai[0] == 1f && Main.projectile[j].ai[1] == npc.whoAmI) + if (p.type == ProjectileType() && + p.ai[0] == 1f && p.ai[1] == npc.whoAmI) { projectileCount++; } @@ -851,6 +853,8 @@ namespace CalamityMod.NPCs if (IncreasedHeatEffects_Fireball) heatDamageMult += 0.25; + if (IncreasedHeatEffects_FlameWakerBoots) + heatDamageMult += 0.25; if (IncreasedHeatEffects_CinnamonRoll) heatDamageMult += 0.5; if (IncreasedHeatEffects_HellfireTreads) @@ -1242,7 +1246,7 @@ namespace CalamityMod.NPCs break; case NPCID.AncientCultistSquidhead: - npc.lifeMax = 4000; + npc.lifeMax = 3200; break; case NPCID.DukeFishron: @@ -3195,7 +3199,7 @@ namespace CalamityMod.NPCs if (CalamityLists.EaterofWorldsIDs.Contains(npc.type)) modifiers.FinalDamage *= 1f - MathHelper.Lerp(BossRushEvent.BossRushActive ? 0.8f : 0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / EaterOfWorldsAI.DRIncreaseTime, 0f, 1f)); if (CalamityLists.DestroyerIDs.Contains(npc.type)) - modifiers.FinalDamage *= 1f - MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / DestroyerAI.DRIncraeseTime, 0f, 1f)); + modifiers.FinalDamage *= 1f - MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / DestroyerAI.DRIncreaseTime, 0f, 1f)); if (CalamityLists.AstrumDeusIDs.Contains(npc.type)) modifiers.FinalDamage *= 1f - MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / (newAI[0] != 0f ? 300f : 600f), 0f, 1f)); } @@ -5080,6 +5084,11 @@ namespace CalamityMod.NPCs if (RancorBurnTime > 0) RancorBurnTime--; + if (cobaltNerfTimer > 0) + cobaltNerfTimer--; + if (mythrilNerfTimer > 0) + mythrilNerfTimer--; + if (veriumDoomTimer > 0) veriumDoomTimer--; if (veriumDoomTimer == 0 && veriumDoomMarked) @@ -5469,15 +5478,15 @@ namespace CalamityMod.NPCs { int bullseyeType = ProjectileType(); Projectile bullseye = null; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != bullseyeType || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + if (p.type != bullseyeType || p.owner != player.whoAmI) continue; // Only choose a bullseye if it is attached to the NPC that is being hit. - if (npc.whoAmI == (int)Main.projectile[i].ai[0]) + if (npc.whoAmI == (int)p.ai[0]) { - bullseye = Main.projectile[i]; + bullseye = p; break; } } @@ -5819,10 +5828,9 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[j]; - if (nPC.active && !nPC.buffImmune[BuffType()] && npc.Distance(nPC.Center) < 100f && !nPC.dontTakeDamage && nPC.lifeMax > 5 && !nPC.friendly && !nPC.townNPC) + if (!nPC.buffImmune[BuffType()] && npc.Distance(nPC.Center) < 100f && !nPC.dontTakeDamage && nPC.lifeMax > 5 && !nPC.friendly && !nPC.townNPC) nPC.AddBuff(BuffType(), 300); } } @@ -6069,7 +6077,7 @@ namespace CalamityMod.NPCs if (spawnInfo.Player.ZoneUnderworldHeight && !calamityBiomeZone && CalamityConfig.Instance.RemoveLavaDropsFromLavaSlimes && Main.expertMode) { pool.Add(NPCType(), SpawnCondition.Underworld.Chance); - pool[NPCID.LavaSlime] = 0f; + pool.Remove(NPCID.LavaSlime); } // Spawn Green Jellyfish in prehm and Blue Jellyfish in hardmode @@ -6376,9 +6384,12 @@ namespace CalamityMod.NPCs } } - // Cobalt and Mythril weapon particle effects - if (isNerfedByCobalt) + // Cobalt weapons reduce NPC defense + if (cobaltNerfTimer > 0) { + miscDefenseLoss = (int)(npc.defense * 0.25); + + // Particle effects if (Main.rand.NextBool(5)) { Vector2 spawnLocation = new Vector2(Main.rand.NextFloat(npc.position.X, npc.position.X + npc.width), Main.rand.NextFloat(npc.position.Y, npc.position.Y + npc.height)); @@ -6389,8 +6400,16 @@ namespace CalamityMod.NPCs } } - if (isNerfedByMythril) + // Mythril weapons reduce NPC contact damage + if (mythrilNerfTimer > 0) { + // Ensure that it isn't trying to set a non-zero damage value if the NPC's damage is currently 0 + if (npc.damage == 0) + npc.damage = 0; + else + npc.damage = (int)(npc.defDamage * 0.9); + + // Particle effects if (Main.rand.NextBool(5)) { Vector2 spawnLocation = new Vector2(Main.rand.NextFloat(npc.position.X, npc.position.X + npc.width), Main.rand.NextFloat(npc.position.Y, npc.position.Y + npc.height)); @@ -6787,7 +6806,9 @@ namespace CalamityMod.NPCs Vector2 halfSize = npc.frame.Size() / 2; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, alphaColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, alphaColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } else @@ -6968,7 +6989,7 @@ namespace CalamityMod.NPCs bool phase5 = destroyerLifeRatio < (death ? 0.2f : 0.1f); // Spawn DR check - bool hasSpawnDR = newAI[1] < DestroyerAI.DRIncraeseTime && newAI[1] > 60f; + bool hasSpawnDR = newAI[1] < DestroyerAI.DRIncreaseTime && newAI[1] > 60f; // Gradual color transition from ground to flight and vice versa // 0f = Red, 1f = Purple @@ -7162,7 +7183,9 @@ namespace CalamityMod.NPCs if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } } @@ -7212,7 +7235,9 @@ namespace CalamityMod.NPCs position.Y -= npc.height / 2; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } float secondAfterimageSetHealthValue = (int)(Main.npc[NPC.crimsonBoss].lifeMax * 0.8f); @@ -7293,7 +7318,9 @@ namespace CalamityMod.NPCs position.X -= npc.width / 2; position.Y -= npc.height / 2; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } } @@ -7806,9 +7833,9 @@ namespace CalamityMod.NPCs #region Player Counts public static bool AnyLivingPlayers() { - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[i] != null && Main.player[i].active && !Main.player[i].dead && !Main.player[i].ghost) + if (!player.dead && !player.ghost) { return true; } @@ -7823,15 +7850,7 @@ namespace CalamityMod.NPCs return 1; } - int players = 0; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i] != null && Main.player[i].active) - { - players++; - } - } - return players; + return Main.CurrentFrameFlags.ActivePlayersCount; } #endregion @@ -7897,12 +7916,11 @@ namespace CalamityMod.NPCs return; Projectile proj = null; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - proj = Main.projectile[i]; - if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == player.whoAmI) + proj = p; + if (p.bobber && p.owner == player.whoAmI) { - proj = Main.projectile[i]; break; } } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 85dd2cb643..6b875b8cad 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -2031,11 +2031,11 @@ DukeEditFailed: internal static void SplittingWormBroadcastInteraction(NPC npc, int player, int head, int body, int tail) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == head || Main.npc[i].type == body || Main.npc[i].type == tail)) + if (n.whoAmI != npc.whoAmI && (n.type == head || n.type == body || n.type == tail)) { - Main.npc[i].ApplyInteraction(player); + n.ApplyInteraction(player); } } } @@ -2105,9 +2105,9 @@ DukeEditFailed: bool CheckSegments(int head, int body, int tail) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == head || Main.npc[i].type == body || Main.npc[i].type == tail)) + if (n.whoAmI != npc.whoAmI && (n.type == head || n.type == body || n.type == tail)) { return false; } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 7800b4b05b..ae24263c1f 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -17,6 +17,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Projectiles.Rogue; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -1064,6 +1065,14 @@ namespace CalamityMod.NPCs defense += 20; } } + + public override bool? CanBeHitByProjectile(NPC npc, Projectile projectile) + { + //Not an axe but close enough + if (npc.type == NPCID.TaxCollector && projectile.type == ModContent.ProjectileType()) + return true; + return base.CanBeHitByProjectile(npc, projectile); + } #endregion #region Shop Stuff @@ -1074,14 +1083,14 @@ namespace CalamityMod.NPCs bool happy = Main.LocalPlayer.currentShoppingSettings.PriceAdjustment <= 0.9; - Condition potionSells = new(CalamityUtils.GetText("Condition.PotionConfig"), () => CalamityConfig.Instance.PotionSelling); + Condition potionSells = CalamityConditions.PotionSellingConfig; Condition hasFlareGunUpgrade = new(CalamityUtils.GetText("Condition.HasFlareGun"), () => (Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType())) && !Main.LocalPlayer.HasItem(ItemID.FlareGun)); - Condition roguePlayer = new(CalamityUtils.GetText("Condition.HasRogueArmor"), () => Main.LocalPlayer.Calamity().rogueStealthMax > 0f && Main.LocalPlayer.Calamity().wearingRogueArmor); - Condition wingedPlayer = new(CalamityUtils.GetText("Condition.HasWings"), () => Main.LocalPlayer.wingTimeMax > 0); - Condition revengeance = new(CalamityUtils.GetText("Condition.InRev"), () => CalamityWorld.revenge); - Condition drunk = new(CalamityUtils.GetText("Condition.AlcoholPoison"), () => Main.LocalPlayer.Calamity().alcoholPoisoning); - Condition downedPolterghast = new(CalamityUtils.GetText("Condition.PostPolter"), () => DownedBossSystem.downedPolterghast); - Condition downedDoG = new(CalamityUtils.GetText("Condition.PostDoG"), () => DownedBossSystem.downedDoG); + Condition roguePlayer = CalamityConditions.PlayerHasRogueArmor; + Condition wingedPlayer = CalamityConditions.PlayerHasWings; + Condition revengeance = CalamityConditions.InRevengeanceMode; + Condition drunk = CalamityConditions.PlayerAlcoholPoisoned; + Condition downedPolterghast = CalamityConditions.DownedPolterghast; + Condition downedDoG = CalamityConditions.DownedDevourerOfGods; if (type == NPCID.Merchant) { diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index fe2ecc6d04..c3dda3d521 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -106,24 +106,21 @@ namespace CalamityMod.NPCs.Crabulon if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) { float pushVelocity = 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 30f * NPC.scale) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 30f * NPC.scale) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } } } diff --git a/NPCs/Cryogen/CryogenShield.cs b/NPCs/Cryogen/CryogenShield.cs index 51ceed2e32..d16c2fbb85 100644 --- a/NPCs/Cryogen/CryogenShield.cs +++ b/NPCs/Cryogen/CryogenShield.cs @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.DeathSound = Main.zenithWorld ? SoundID.NPCDeath14 : BreakSound; NPC.Opacity += 0.01f; - if (NPC.Opacity > 1f) + if (NPC.Opacity >= 1f) { NPC.damage = NPC.defDamage; NPC.Opacity = 1f; @@ -86,6 +86,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.position.Y = NPC.position.Y - (NPC.height / 2); return; } + NPC.life = 0; NPC.HitEffect(); NPC.active = false; @@ -111,7 +112,7 @@ namespace CalamityMod.NPCs.Cryogen if (hitboxBotRight < minDist) minDist = hitboxBotRight; - return minDist <= (100f * NPC.scale) && NPC.Opacity == 1f; + return minDist <= (100f * NPC.scale) && NPC.Opacity >= 1f; } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index c4d0d59040..d61794d229 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -69,23 +69,6 @@ namespace CalamityMod.NPCs.DesertScourge public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; - public override void SendExtraAI(BinaryWriter writer) - { - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; - } - public override void AI() { bool bossRush = BossRushEvent.BossRushActive; @@ -104,10 +87,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -121,10 +102,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -138,10 +117,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; @@ -164,15 +141,7 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -217,8 +186,9 @@ namespace CalamityMod.NPCs.DesertScourge Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld : masterMode ? DesertNuisanceHead.SegmentVelocity_Master : DesertNuisanceHead.SegmentVelocity_Expert; + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs index 2094ce55fe..c1086817cc 100644 --- a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs @@ -69,23 +69,6 @@ namespace CalamityMod.NPCs.DesertScourge public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; - public override void SendExtraAI(BinaryWriter writer) - { - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; - } - public override void AI() { bool bossRush = BossRushEvent.BossRushActive; @@ -104,10 +87,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -121,10 +102,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -138,10 +117,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; @@ -217,8 +194,9 @@ namespace CalamityMod.NPCs.DesertScourge Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld : masterMode ? DesertNuisanceHeadYoung.SegmentVelocity_Master : DesertNuisanceHeadYoung.SegmentVelocity_Expert; + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index fc4b6f42e7..564cf646cc 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -19,10 +19,10 @@ namespace CalamityMod.NPCs.DesertScourge public bool flies = false; private bool tailSpawned = false; - public const float SegmentVelocity_Expert = 12f; - public const float SegmentVelocity_Master = 15f; - public const float SegmentVelocity_GoodWorld = 18f; - public const float SegmentVelocity_ZenithSeed = 21f; + public const float SegmentVelocity_Expert = 14f; + public const float SegmentVelocity_Master = 16.5f; + public const float SegmentVelocity_GoodWorld = 19f; + public const float SegmentVelocity_ZenithSeed = 21.5f; public const float OpenMouthForBiteDistance = 220f; @@ -115,7 +115,7 @@ namespace CalamityMod.NPCs.DesertScourge bool death = CalamityWorld.death || bossRush; // Become angry when the other Nuisance dies. - bool getMad = !NPC.AnyNPCs(ModContent.NPCType()) && expertMode; + bool getMad = (!NPC.AnyNPCs(ModContent.NPCType()) && revenge) || death; // Enrage if (!Main.player[NPC.target].ZoneDesert && !bossRush) @@ -140,6 +140,8 @@ namespace CalamityMod.NPCs.DesertScourge float speed = death ? 0.2f : 0.17f; float turnSpeed = death ? 0.3f : 0.25f; + speed += speed * 0.4f * (1f - lifeRatio); + turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); speed += 0.17f * enrageScale; turnSpeed += 0.25f * enrageScale; @@ -243,23 +245,19 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int directChaseDistance = 1000; + int directChaseDistance = revenge ? 500 : 1000; bool shouldDirectlyChase = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { - for (int m = 0; m < Main.maxPlayers; m++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[m].active) + Rectangle rectangle2 = new Rectangle((int)plr.position.X - directChaseDistance, (int)plr.position.Y - directChaseDistance, directChaseDistance * 2, directChaseDistance * 2); + if (rectangle.Intersects(rectangle2)) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - directChaseDistance, (int)Main.player[m].position.Y - directChaseDistance, directChaseDistance * 2, directChaseDistance * 2); - if (rectangle.Intersects(rectangle2)) - { - shouldDirectlyChase = false; - break; - } + shouldDirectlyChase = false; + break; } } - if (shouldDirectlyChase) shouldFly = true; } @@ -276,8 +274,9 @@ namespace CalamityMod.NPCs.DesertScourge Main.getGoodWorld ? SegmentVelocity_GoodWorld : masterMode ? SegmentVelocity_Master : SegmentVelocity_Expert; + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (Main.player[NPC.target].dead) { @@ -451,6 +450,10 @@ namespace CalamityMod.NPCs.DesertScourge } } + Vector2 destination = Main.player[NPC.target].Center; + if (NPC.Distance(destination) > 1000f) + NPC.velocity += (destination - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + // Calculate contact damage based on velocity float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 00c006ffab..9a3e19a915 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -20,10 +21,10 @@ namespace CalamityMod.NPCs.DesertScourge public bool flies = false; private bool tailSpawned = false; - public const float SegmentVelocity_Expert = 10f; - public const float SegmentVelocity_Master = 12.5f; - public const float SegmentVelocity_GoodWorld = 15f; - public const float SegmentVelocity_ZenithSeed = 17.5f; + public const float SegmentVelocity_Expert = 12f; + public const float SegmentVelocity_Master = 14f; + public const float SegmentVelocity_GoodWorld = 16f; + public const float SegmentVelocity_ZenithSeed = 18f; public const float SpitGateValue = 180f; @@ -110,7 +111,7 @@ namespace CalamityMod.NPCs.DesertScourge bool death = CalamityWorld.death || bossRush; // Become angry when the other Nuisance dies. - bool getMad = !NPC.AnyNPCs(ModContent.NPCType()) && expertMode; + bool getMad = (!NPC.AnyNPCs(ModContent.NPCType()) && revenge) || death; // Enrage if (!Main.player[NPC.target].ZoneDesert && !bossRush) @@ -135,6 +136,8 @@ namespace CalamityMod.NPCs.DesertScourge float speed = death ? 0.22f : 0.19f; float turnSpeed = death ? 0.32f : 0.27f; + speed += speed * 0.4f * (1f - lifeRatio); + turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); speed += 0.19f * enrageScale; turnSpeed += 0.27f * enrageScale; @@ -162,6 +165,7 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.Calamity().newAI[0] >= SpitGateValue) { NPC.Calamity().newAI[0] = 0f; + SoundEngine.PlaySound(SoundID.NPCDeath11, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (revenge ? 10f : 8f); @@ -179,6 +183,13 @@ namespace CalamityMod.NPCs.DesertScourge 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++) + { + int dust = Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, (int)CalamityDusts.SulphurousSeaAcid); + Main.dust[dust].velocity = perturbedSpeed; + } + if (Main.netMode != NetmodeID.MultiplayerClient) { int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); @@ -274,7 +285,7 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int directChaseDistance = 1000; + int directChaseDistance = revenge ? 500 : 1000; bool shouldDirectlyChase = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { @@ -307,8 +318,9 @@ namespace CalamityMod.NPCs.DesertScourge Main.getGoodWorld ? SegmentVelocity_GoodWorld : masterMode ? SegmentVelocity_Master : SegmentVelocity_Expert; + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (Main.player[NPC.target].dead) { @@ -482,6 +494,10 @@ namespace CalamityMod.NPCs.DesertScourge } } + Vector2 destination = Main.player[NPC.target].Center; + if (NPC.Distance(destination) > 1000f) + NPC.velocity += (destination - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + // Calculate contact damage based on velocity float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index f5ffaa7224..860e56f7b0 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -69,15 +69,7 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -146,8 +138,9 @@ namespace CalamityMod.NPCs.DesertScourge Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld : masterMode ? DesertNuisanceHead.SegmentVelocity_Master : DesertNuisanceHead.SegmentVelocity_Expert; + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs index 1f2e632dc6..df82733592 100644 --- a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs @@ -146,8 +146,9 @@ namespace CalamityMod.NPCs.DesertScourge Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld : masterMode ? DesertNuisanceHeadYoung.SegmentVelocity_Master : DesertNuisanceHeadYoung.SegmentVelocity_Expert; + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index c44d91cf26..1d30f4e6ce 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -80,23 +80,12 @@ namespace CalamityMod.NPCs.DesertScourge { writer.Write(NPC.alpha); writer.Write(NPC.dontTakeDamage); - - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); } public override void ReceiveExtraAI(BinaryReader reader) { NPC.alpha = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); - - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; } public override void AI() @@ -117,10 +106,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -134,10 +121,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -151,10 +136,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; @@ -176,18 +159,13 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Phases + bool phase2 = lifeRatio < 0.5f; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -210,7 +188,18 @@ namespace CalamityMod.NPCs.DesertScourge NPC.alpha = 0; } else + { NPC.alpha = Main.npc[(int)NPC.ai[1]].alpha; + if (NPC.alpha != 255 && NPC.dontTakeDamage) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.UnusedBrown, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + } if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -230,7 +219,7 @@ namespace CalamityMod.NPCs.DesertScourge NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); NPC head = Main.npc[(int)NPC.ai[2]]; - float burrowTimeGateValue = (CalamityWorld.death || BossRushEvent.BossRushActive) ? DesertScourgeHead.BurrowTimeGateValue_Death : DesertScourgeHead.BurrowTimeGateValue; + float burrowTimeGateValue = DesertScourgeHead.BurrowTimeGateValue; bool burrow = head.Calamity().newAI[0] >= burrowTimeGateValue; bool lungeUpward = burrow && head.Calamity().newAI[1] == 1f; bool quickFall = head.Calamity().newAI[1] == 2f; @@ -244,7 +233,7 @@ namespace CalamityMod.NPCs.DesertScourge if (burrow || lungeUpward) maxChaseSpeed *= 1.5f; if (expertMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 3fbde7a525..803655aa4d 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -44,9 +44,11 @@ namespace CalamityMod.NPCs.DesertScourge public const float SegmentVelocity_GoodWorld = 21f; public const float SegmentVelocity_ZenithSeed = 24f; - public const float BurrowTimeGateValue = 720f; - public const float BurrowTimeGateValue_Death = 600f; - public const float BurrowResetTimeGateValue = 600f; + public const float SpitGateValue = 300f; + public const float SpitGateValue_Death = 180f; + + public const float BurrowTimeGateValue = 600f; + public const float BurrowResetTimeGateValue = BurrowTimeGateValue + 600f; public const float LungeUpwardDistanceOffset = 600f; public const float LungeUpwardCutoffDistance = 420f; @@ -119,7 +121,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void BossHeadSlot(ref int index) { - if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + if ((NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) && !Main.masterMode) index = -1; } @@ -139,6 +141,7 @@ namespace CalamityMod.NPCs.DesertScourge writer.Write(biomeEnrageTimer); writer.Write(playRoarSound); writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -150,6 +153,7 @@ namespace CalamityMod.NPCs.DesertScourge biomeEnrageTimer = reader.ReadInt32(); playRoarSound = reader.ReadBoolean(); NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } @@ -163,12 +167,13 @@ namespace CalamityMod.NPCs.DesertScourge bool death = CalamityWorld.death || bossRush; // Check for Nuisances - bool hide = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()); + bool hide = (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) && !masterMode; if (hide) { NPC.Calamity().newAI[0] = 0f; NPC.Calamity().newAI[1] = 0f; NPC.Calamity().newAI[3] = 0f; + NPC.localAI[3] = 0f; playRoarSound = false; } @@ -205,8 +210,11 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Phases + bool phase2 = lifeRatio < 0.5f; + // Summon the Nuisances. - if (lifeRatio < 0.5f) + if (phase2 && expertMode) { if (NPC.localAI[2] == 0f) { @@ -216,16 +224,15 @@ namespace CalamityMod.NPCs.DesertScourge } } - // Only increment the burrow timer if the head is beneath the player. - if (NPC.Center.Y > Main.player[NPC.target].Center.Y) + // Only increment the burrow timer if the head is beneath the player, OR if the X distance is greater than a specified value. + if (NPC.Center.Y > Main.player[NPC.target].Center.Y || Math.Abs(NPC.Center.X - player.Center.X) > 480f) { if (revenge || lifeRatio < (expertMode ? 0.75f : 0.5f)) NPC.Calamity().newAI[0] += 1f; } - float burrowTimeGateValue = death ? BurrowTimeGateValue_Death : BurrowTimeGateValue; - bool burrow = NPC.Calamity().newAI[0] >= burrowTimeGateValue; - bool resetTime = NPC.Calamity().newAI[0] >= burrowTimeGateValue + BurrowResetTimeGateValue; + bool burrow = NPC.Calamity().newAI[0] >= BurrowTimeGateValue; + bool resetTime = NPC.Calamity().newAI[0] >= BurrowResetTimeGateValue; bool lungeUpward = burrow && NPC.Calamity().newAI[1] == 1f; bool quickFall = NPC.Calamity().newAI[1] == 2f; @@ -234,6 +241,12 @@ namespace CalamityMod.NPCs.DesertScourge float speed = death ? 0.18f : 0.15f; float turnSpeed = death ? 0.36f : 0.3f; + if (expertMode) + { + speed += speed * 0.2f * (1f - lifeRatio); + turnSpeed += turnSpeed * 0.2f * (1f - lifeRatio); + } + if (revenge) { speed += (death ? 0.06f : 0.05f) * (1f - lifeRatio); @@ -249,7 +262,134 @@ namespace CalamityMod.NPCs.DesertScourge turnSpeed *= 1.2f; } - if (lungeUpward || burrow || hide) + // Projectile spit (unused, for now) + /*if ((phase2 || death) && revenge && NPC.Distance(Main.player[NPC.target].Center) > 400f && (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) + { + if (NPC.Calamity().newAI[0] % (death ? SpitGateValue_Death : SpitGateValue) == 0f) + { + SoundEngine.PlaySound(SoundID.NPCDeath11, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (masterMode ? 10f : 8f); + int numProj = death ? 9 : 6; + int spread = masterMode ? 49 : 35; + if (masterMode) + { + numProj += 3; + spread += 14; + } + + float rotation = MathHelper.ToRadians(spread); + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + 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++) + { + int dust = Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, (int)CalamityDusts.SulphurousSeaAcid); + Main.dust[dust].velocity = perturbedSpeed; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Main.projectile[proj].aiStyle = -1; + Main.projectile[proj].netUpdate = true; + } + } + } + } + }*/ + + // Sand splash + if (!quickFall) + { + if (lungeUpward) + { + if (NPC.localAI[3] == 0f) + { + Point headTileCenter = NPC.Top.ToTileCoordinates(); + Tile tileSafely = Framing.GetTileSafely(headTileCenter); + bool inSolidTile = tileSafely.HasUnactuatedTile; + bool finsInSolidTile = Framing.GetTileSafely(Main.npc[(int)NPC.ai[0]].Center.ToTileCoordinates()).HasUnactuatedTile; + if (!inSolidTile && finsInSolidTile && Collision.CanHit(NPC.Top, 1, 1, player.Center, 1, 1)) + { + NPC.localAI[3] = 1f; + SoundEngine.PlaySound(SoundID.Item74, NPC.Center); + + int bestY = headTileCenter.Y; + for (int j = 0; j < 20; j++) + { + if (bestY < 10) + break; + + if (!WorldGen.SolidTile(headTileCenter.X, bestY)) + break; + + bestY--; + } + + for (int k = 0; k < 20; k++) + { + if (bestY > Main.maxTilesY - 10) + break; + + if (WorldGen.ActiveAndWalkableTile(headTileCenter.X, bestY)) + break; + + bestY++; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), new Vector2(headTileCenter.X * 16 + 8, bestY * 16 - 40), Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + } + } + } + else if (burrow) + { + if (NPC.localAI[3] == 0f) + { + Point headTileCenter = NPC.Center.ToTileCoordinates(); + Tile tileSafely = Framing.GetTileSafely(headTileCenter); + bool inSolidTile = tileSafely.HasUnactuatedTile; + if (inSolidTile && Collision.CanHit(NPC.Top, 1, 1, player.Center, 1, 1)) + { + NPC.localAI[3] = 1f; + SoundEngine.PlaySound(SoundID.Item74, NPC.Center); + + int bestY = headTileCenter.Y; + for (int j = 0; j < 20; j++) + { + if (bestY < 10) + break; + + if (!WorldGen.SolidTile(headTileCenter.X, bestY)) + break; + + bestY--; + } + + for (int k = 0; k < 20; k++) + { + if (bestY > Main.maxTilesY - 10) + break; + + if (WorldGen.ActiveAndWalkableTile(headTileCenter.X, bestY)) + break; + + bestY++; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), new Vector2(headTileCenter.X * 16 + 8, bestY * 16 - 40), Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + } + } + } + } + + if (lungeUpward || burrow) { speed *= 1.5f; turnSpeed *= 1.5f; @@ -265,7 +405,18 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.alpha += 3; if (NPC.alpha > 255) + { NPC.alpha = 255; + } + else + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.UnusedBrown, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } } else { @@ -342,7 +493,7 @@ namespace CalamityMod.NPCs.DesertScourge if (tileWidthPosY > Main.maxTilesY) tileWidthPosY = Main.maxTilesY; - bool shouldFly = lungeUpward || hide; + bool shouldFly = lungeUpward; if (!shouldFly) { for (int k = tilePositionX; k < tileWidthPosX; k++) @@ -368,7 +519,7 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int directChaseDistance = 1000; + int directChaseDistance = expertMode ? 800 : 1000; if (enrageScale > 0f) directChaseDistance = 100; @@ -377,21 +528,17 @@ namespace CalamityMod.NPCs.DesertScourge { int rectWidth = directChaseDistance * 2; int rectHeight = directChaseDistance * 2; - for (int m = 0; m < Main.maxPlayers; m++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[m].active) + int rectX = (int)plr.position.X - directChaseDistance; + int rectY = (int)plr.position.Y - directChaseDistance; + Rectangle directChaseRect = new Rectangle(rectX, rectY, rectWidth, rectHeight); + if (rectangle.Intersects(directChaseRect)) { - int rectX = (int)Main.player[m].position.X - directChaseDistance; - int rectY = (int)Main.player[m].position.Y - directChaseDistance; - Rectangle directChaseRect = new Rectangle(rectX, rectY, rectWidth, rectHeight); - if (rectangle.Intersects(directChaseRect)) - { - shouldDirectlyChase = false; - break; - } + shouldDirectlyChase = false; + break; } } - if (shouldDirectlyChase) shouldFly = true; } @@ -409,10 +556,10 @@ namespace CalamityMod.NPCs.DesertScourge masterMode ? SegmentVelocity_Master : expertMode ? SegmentVelocity_Expert : SegmentVelocity_Normal; - if (burrow || lungeUpward || hide) + if (burrow || lungeUpward) maxChaseSpeed *= 1.5f; if (expertMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (player.dead) { @@ -438,7 +585,7 @@ namespace CalamityMod.NPCs.DesertScourge float lungeTarget = NPC.Calamity().newAI[3]; Vector2 npcCenter = NPC.Center; float playerX = player.Center.X; - float targettingPosition = lungeUpward ? lungeTarget : (burrow || hide) ? burrowTarget : player.Center.Y; + float targettingPosition = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; playerX = (float)((int)(playerX / 16f) * 16); targettingPosition = (float)((int)(targettingPosition / 16f) * 16); npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16); @@ -451,6 +598,7 @@ namespace CalamityMod.NPCs.DesertScourge if (burrow && NPC.Center.Y >= burrowTarget - 16f) { NPC.Calamity().newAI[1] = 1f; + NPC.localAI[3] = 0f; if (!playRoarSound) { SoundEngine.PlaySound(RoarSound, player.Center); @@ -463,11 +611,11 @@ namespace CalamityMod.NPCs.DesertScourge { // Spit a huge spread of sand upwards that falls down SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); - float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 16f : bossRush ? 9f : death ? 7f : 6f; + float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 16f : bossRush ? 10f : death ? 8.5f : revenge ? 8f : expertMode ? 7.5f : 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 ? 30 : death ? 24 : revenge ? 20 : expertMode ? 16 : 12; + Vector2 projectileVelocity = (NPC.Center + NPC.velocity * 10f - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; + int numProj = bossRush ? 30 : death ? 24 : revenge ? 21 : expertMode ? 18 : 12; if (Main.getGoodWorld) numProj *= 2; @@ -478,7 +626,10 @@ namespace CalamityMod.NPCs.DesertScourge 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, (int)CalamityDusts.SulphurousSeaAcid, perturbedSpeed.X, perturbedSpeed.Y); + { + int dust = Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, (int)CalamityDusts.SulphurousSeaAcid); + Main.dust[dust].velocity = perturbedSpeed; + } if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); @@ -486,6 +637,7 @@ namespace CalamityMod.NPCs.DesertScourge NPC.TargetClosest(); NPC.Calamity().newAI[1] = 2f; + NPC.localAI[3] = 0f; playRoarSound = false; } @@ -498,6 +650,7 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().newAI[0] = 0f; NPC.Calamity().newAI[1] = 0f; NPC.Calamity().newAI[3] = 0f; + NPC.localAI[3] = 0f; playRoarSound = false; } } @@ -507,9 +660,14 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.Calamity().newAI[0] = 0f; NPC.Calamity().newAI[1] = 0f; + NPC.localAI[3] = 0f; } - if (!shouldFly) + if (hide && !player.dead) + { + NPC.SimpleFlyMovement((new Vector2(player.Center.X, burrowTarget) - NPC.Center).SafeNormalize(Vector2.UnitY) * maxChaseSpeed, turnSpeed); + } + else if (!shouldFly) { NPC.TargetClosest(); NPC.velocity.Y += 0.15f; @@ -644,10 +802,11 @@ namespace CalamityMod.NPCs.DesertScourge } } - if (!burrow && !quickFall && !hide) + if ((!burrow || lungeUpward) && !quickFall && !hide) { - if (NPC.Distance(player.Center) > 2000f) - NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + Vector2 destination = lungeUpward ? new Vector2(player.Center.X, lungeTarget) : player.Center; + if (NPC.Distance(destination) > (lungeUpward ? 1000f : 2000f)) + NPC.velocity += (destination - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; } // Calculate contact damage based on velocity @@ -691,6 +850,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.netUpdate = true; } + public override bool CheckActive() => false; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { Rectangle targetHitbox = target.Hitbox; @@ -715,8 +876,7 @@ namespace CalamityMod.NPCs.DesertScourge { // Open mouth to prepare for a nibble ;3 // Also open mouth if about to spit a projectile spread - float burrowTimeGateValue = (CalamityWorld.death || BossRushEvent.BossRushActive) ? BurrowTimeGateValue_Death : BurrowTimeGateValue; - bool burrow = NPC.Calamity().newAI[0] >= burrowTimeGateValue; + bool burrow = NPC.Calamity().newAI[0] >= BurrowTimeGateValue; bool lungeUpward = burrow && NPC.Calamity().newAI[1] == 1f; bool aboutToSpitSpread = lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance * 0.25f; diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index a9fcfafe36..749dd0791a 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -85,18 +85,13 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Phases + bool phase2 = lifeRatio < 0.5f; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -119,7 +114,18 @@ namespace CalamityMod.NPCs.DesertScourge NPC.alpha = 0; } else + { NPC.alpha = Main.npc[(int)NPC.ai[1]].alpha; + if (NPC.alpha != 255 && NPC.dontTakeDamage) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.UnusedBrown, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + } if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -163,7 +169,7 @@ namespace CalamityMod.NPCs.DesertScourge } NPC head = Main.npc[(int)NPC.ai[2]]; - float burrowTimeGateValue = (CalamityWorld.death || BossRushEvent.BossRushActive) ? DesertScourgeHead.BurrowTimeGateValue_Death : DesertScourgeHead.BurrowTimeGateValue; + float burrowTimeGateValue = DesertScourgeHead.BurrowTimeGateValue; bool burrow = head.Calamity().newAI[0] >= burrowTimeGateValue; bool lungeUpward = burrow && head.Calamity().newAI[1] == 1f; bool quickFall = head.Calamity().newAI[1] == 2f; @@ -177,7 +183,7 @@ namespace CalamityMod.NPCs.DesertScourge if (burrow || lungeUpward) maxChaseSpeed *= 1.5f; if (expertMode) - maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); + maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; diff --git a/NPCs/DevourerofGods/CosmicGuardianBody.cs b/NPCs/DevourerofGods/CosmicGuardianBody.cs index 184958c7f5..6c0600c59f 100644 --- a/NPCs/DevourerofGods/CosmicGuardianBody.cs +++ b/NPCs/DevourerofGods/CosmicGuardianBody.cs @@ -93,15 +93,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/DevourerofGods/CosmicGuardianHead.cs b/NPCs/DevourerofGods/CosmicGuardianHead.cs index 72df92eb3b..eb7ef94bad 100644 --- a/NPCs/DevourerofGods/CosmicGuardianHead.cs +++ b/NPCs/DevourerofGods/CosmicGuardianHead.cs @@ -199,11 +199,11 @@ namespace CalamityMod.NPCs.DevourerofGods else if (increaseSpeed) velocityMult *= 2f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && (Main.npc[i].type == NPC.type || Main.npc[i].type == ModContent.NPCType()) && i != NPC.whoAmI) + if ((n.type == NPC.type || n.type == ModContent.NPCType()) && n.whoAmI != NPC.whoAmI) { - Vector2 distFromHead = Main.npc[i].Center - NPC.Center; + Vector2 distFromHead = n.Center - NPC.Center; if (distFromHead.Length() < maxDistanceFromDoGHead) { distFromHead.Normalize(); diff --git a/NPCs/DevourerofGods/CosmicGuardianTail.cs b/NPCs/DevourerofGods/CosmicGuardianTail.cs index 5d2c622fa4..d44bab21c7 100644 --- a/NPCs/DevourerofGods/CosmicGuardianTail.cs +++ b/NPCs/DevourerofGods/CosmicGuardianTail.cs @@ -90,15 +90,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index b77ecc0466..aff92981bc 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -206,15 +206,7 @@ namespace CalamityMod.NPCs.DevourerofGods Player player = Main.player[NPC.target]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -376,9 +368,9 @@ namespace CalamityMod.NPCs.DevourerofGods private bool AnyTeleportRifts() { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == ModContent.ProjectileType()) + if (p.type == ModContent.ProjectileType()) return true; } return false; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index bfe4a051f5..705f248c4c 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -2454,20 +2454,20 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.netSpam >= 10) NPC.netSpam = 9; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) + if (n.type == ModContent.NPCType() || n.type == ModContent.NPCType()) { - Main.npc[i].position = newPosition; + n.position = newPosition; - if (Main.npc[i].type == ModContent.NPCType()) - ((DevourerofGodsTail)Main.npc[i].ModNPC).setInvulTime(720); + if (n.type == ModContent.NPCType()) + ((DevourerofGodsTail)n.ModNPC).setInvulTime(720); - Main.npc[i].netUpdate = true; + n.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. - if (Main.npc[i].netSpam >= 10) - Main.npc[i].netSpam = 9; + if (n.netSpam >= 10) + n.netSpam = 9; } } @@ -2498,28 +2498,28 @@ namespace CalamityMod.NPCs.DevourerofGods ModContent.NPCType(), ModContent.NPCType() }; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (segments.Contains(Main.npc[i].type) && Main.npc[i].active && - (Main.npc[i].type == segments[1] || Main.npc[i].ModNPC().SegmentIndex == index)) + if (segments.Contains(n.type) && n.active && + (n.type == segments[1] || n.ModNPC().SegmentIndex == index)) { for (int j = 0; j < 20; j++) { - Dust cosmicBurst = Dust.NewDustPerfect(Main.npc[i].Center + Main.rand.NextVector2Circular(25f, 25f), 234); + Dust cosmicBurst = Dust.NewDustPerfect(n.Center + Main.rand.NextVector2Circular(25f, 25f), 234); cosmicBurst.scale = 1.7f; cosmicBurst.velocity = Main.rand.NextVector2Circular(9f, 9f); cosmicBurst.noGravity = true; } - Main.npc[i].life = 0; - Main.npc[i].HitEffect(); - Main.npc[i].active = false; + n.life = 0; + n.HitEffect(); + n.active = false; - Main.npc[i].netUpdate = true; + n.netUpdate = true; // Prevent netUpdate from being blocked by the spam counter. - if (Main.npc[i].netSpam >= 10) - Main.npc[i].netSpam = 9; + if (n.netSpam >= 10) + n.netSpam = 9; destroyedSegments++; break; @@ -2588,9 +2588,8 @@ namespace CalamityMod.NPCs.DevourerofGods private Vector2 GetRiftLocation(bool spawnDust) { Vector2 realSpot = default; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; if (proj.type == ModContent.ProjectileType()) { if (!spawnDust) diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index ffcf9c3123..36b7a39663 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -217,15 +217,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.takenDamageMultiplier = 1.25f; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/DevourerofGods/DoGScreenShaderData.cs b/NPCs/DevourerofGods/DoGScreenShaderData.cs index 74963b76e8..78a58b4511 100644 --- a/NPCs/DevourerofGods/DoGScreenShaderData.cs +++ b/NPCs/DevourerofGods/DoGScreenShaderData.cs @@ -23,11 +23,11 @@ namespace CalamityMod.NPCs.DevourerofGods return; } DoGIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == DoGType) + if (n.type == DoGType) { - DoGIndex = i; + DoGIndex = n.whoAmI; break; } } diff --git a/NPCs/DevourerofGods/DoGSky.cs b/NPCs/DevourerofGods/DoGSky.cs index 76a41b16b9..ded6e6fd46 100644 --- a/NPCs/DevourerofGods/DoGSky.cs +++ b/NPCs/DevourerofGods/DoGSky.cs @@ -62,11 +62,11 @@ namespace CalamityMod.NPCs.DevourerofGods return true; } DoGIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == DoGType) + if (n.type == DoGType) { - DoGIndex = i; + DoGIndex = n.whoAmI; break; } } diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index d867d59bc8..012e36788c 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -87,9 +87,8 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.ai[2] *= -1; } // If she sees someone, start running - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { ChangeAI(1); @@ -152,12 +151,8 @@ namespace CalamityMod.NPCs.DraedonLabThings break; } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { Main.BestiaryTracker.Kills.RegisterKill(NPC); diff --git a/NPCs/DraedonLabThings/NanodroidDysfunctional.cs b/NPCs/DraedonLabThings/NanodroidDysfunctional.cs index fba1017618..c2ffabf81f 100644 --- a/NPCs/DraedonLabThings/NanodroidDysfunctional.cs +++ b/NPCs/DraedonLabThings/NanodroidDysfunctional.cs @@ -42,12 +42,8 @@ namespace CalamityMod.NPCs.DraedonLabThings { Lighting.AddLight(NPC.Center, 0.25f, 0.1f, 0f); } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { NPC nPC = new NPC(); diff --git a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs index 9b7f651e01..babe18e052 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs @@ -42,12 +42,8 @@ namespace CalamityMod.NPCs.DraedonLabThings { Lighting.AddLight(NPC.Center, 0.03f, 0.3f, 0.05f); } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { NPC nPC = new NPC(); diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs index 7473e4dd55..ca28f3ce7f 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs @@ -42,12 +42,8 @@ namespace CalamityMod.NPCs.DraedonLabThings { Lighting.AddLight(NPC.Center, 0.3f, 0.03f, 0f); } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { NPC nPC = new NPC(); diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index b6a844db97..0edf8ef94a 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -138,12 +138,8 @@ namespace CalamityMod.NPCs.DraedonLabThings } Time++; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { Main.BestiaryTracker.Kills.RegisterKill(NPC); diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index b21243039f..37f8031eee 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -250,7 +250,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.TargetClosest(); // Target variable - Player player = Main.player[NPC.target]; + int targetIndex = NPC.target; // Check if the other exo mechs are alive int otherExoMechsAlive = 0; @@ -275,7 +275,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) { // Set target to Thanatos' target if Thanatos is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target; otherExoMechsAlive++; exoWormAlive = true; @@ -286,7 +286,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { // Set target to Ares' target if Ares is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; otherExoMechsAlive++; exoPrimeAlive = true; @@ -366,7 +366,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo { NPC.ai[0] += 1f; if (NPC.ai[0] == 10f && !NPC.AnyNPCs(ModContent.NPCType())) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); } else { @@ -465,13 +465,13 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Default vector to fly to bool flyRight = NPC.ai[0] % 2f == 0f || NPC.ai[0] < 10f || !revenge; float destinationX = flyRight ? 750f : -750f; - float destinationY = player.Center.Y; + float destinationY = Main.player[targetIndex].Center.Y; float chargeComboXOffset = flyRight ? -600f : 600f; float chargeComboYOffset = NPC.ai[2] % 2f == 0f ? 480f : -480f; - Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + destinationX * 1.6f, destinationY) : - SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(player.Center.X + destinationX, destinationY + 360f) : - AIState == (float)Phase.LineUpChargeCombo ? new Vector2(player.Center.X + destinationX * 1.2f, destinationY + chargeComboYOffset) : - new Vector2(player.Center.X + destinationX, destinationY); + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(Main.player[targetIndex].Center.X + destinationX * 1.6f, destinationY) : + SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(Main.player[targetIndex].Center.X + destinationX, destinationY + 360f) : + AIState == (float)Phase.LineUpChargeCombo ? new Vector2(Main.player[targetIndex].Center.X + destinationX * 1.2f, destinationY + chargeComboYOffset) : + new Vector2(Main.player[targetIndex].Center.X + destinationX, destinationY); // Add some random distance to the destination after certain attacks if (pickNewLocation) @@ -523,9 +523,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo bool canFire = distanceFromDestination.Length() <= 320f; // Rotation - Vector2 aimedVector = player.Center - NPC.Center; + Vector2 aimedVector = Main.player[targetIndex].Center - NPC.Center; float rateOfRotation = 0.1f; - Vector2 rotateTowards = player.Center - NPC.Center; + Vector2 rotateTowards = Main.player[targetIndex].Center - NPC.Center; bool readyToCharge = AIState == (float)Phase.LineUpChargeCombo && (Vector2.Distance(NPC.Center, destination) <= chargeLocationDistanceGateValue || calamityGlobalNPC.newAI[2] > 0f); if (AIState == (int)Phase.ChargeCombo) { @@ -540,8 +540,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo } else { - float x = player.Center.X - NPC.Center.X; - float y = player.Center.Y - NPC.Center.Y; + float x = Main.player[targetIndex].Center.X - NPC.Center.X; + float y = Main.player[targetIndex].Center.Y - NPC.Center.Y; rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; } @@ -550,42 +550,37 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.rotation = NPC.rotation.AngleTowards((float)Math.Atan2(rotateTowards.Y, rotateTowards.X) + MathHelper.PiOver2, rateOfRotation); // Despawn if target is dead - if (player.dead) + if (Main.player[targetIndex].dead) { - NPC.TargetClosest(false); - player = Main.player[NPC.target]; - if (player.dead) - { - AIState = (float)Phase.Normal; - NPC.localAI[0] = 0f; - NPC.localAI[1] = 0f; - NPC.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - for (int i = 0; i < maxCharges; i++) - chargeLocations[i] = default; + AIState = (float)Phase.Normal; + NPC.localAI[0] = 0f; + NPC.localAI[1] = 0f; + NPC.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; - NPC.dontTakeDamage = true; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } - - return; } + + return; } // Cause the charge visual effects to begin while performing or preparing for a combo @@ -673,8 +668,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (Main.netMode != NetmodeID.MultiplayerClient) { // Spawn the fuckers - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); } } } @@ -989,7 +984,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo int damage = NPC.GetProjectileDamage(type); 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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaVelocity, type, damage, 0f, Main.myPlayer, Main.player[targetIndex].Center.X, Main.player[targetIndex].Center.Y); } } } @@ -1053,7 +1048,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo int damage = NPC.GetProjectileDamage(type); Vector2 rocketVelocity = Vector2.Normalize(aimedVector) * projectileVelocity * 1.2f; Vector2 offset = Vector2.Normalize(rocketVelocity) * 70f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, rocketVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, rocketVelocity, type, damage, 0f, Main.myPlayer, 0f, Main.player[targetIndex].Center.Y); } } @@ -1771,10 +1766,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo public override bool CheckDead() { // Kill Artemis if he's still alive when Apollo dies - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; - if (nPC.active && nPC.type == ModContent.NPCType() && nPC.life > 0) + if (nPC.type == ModContent.NPCType() && nPC.life > 0) { nPC.life = 0; nPC.HitEffect(); diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index b10fa96e8e..dec6dd8459 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -196,8 +196,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Whether Ares should be buffed while in berserk phase bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + // Target variables + int targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -237,8 +237,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (passivePhase) predictionAmt *= 0.5f; - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 rotationVector = player.Center + predictionVector - NPC.Center; + Vector2 predictionVector = Main.player[targetIndex].velocity * predictionAmt; + Vector2 rotationVector = Main.player[targetIndex].Center + predictionVector - NPC.Center; float projectileVelocity = passivePhase ? 9.6f : 12f; if (lastMechAlive) @@ -260,7 +260,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.rotation = NPC.rotation.AngleTowards(rotation, rateOfRotation); // Direction - int direction = Math.Sign(player.Center.X - NPC.Center.X); + int direction = Math.Sign(Main.player[targetIndex].Center.X - NPC.Center.X); if (direction != 0) { NPC.direction = direction; @@ -272,35 +272,31 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Despawn if target is dead - if (player.dead) + if (Main.player[targetIndex].dead) { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - NPC.dontTakeDamage = true; + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } - - return; } + + return; } // Default vector to fly to @@ -424,7 +420,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(gaussNukeVelocity) * offset, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, Main.player[targetIndex].Center.Y); } // Recoil diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs index 6622b7d54c..cbaacc311a 100644 --- a/NPCs/ExoMechs/Ares/AresLaserCannon.cs +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -199,8 +199,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Whether Ares should be buffed while in berserk phase bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + // Target variables + int targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -266,7 +266,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares bool horizontalLaserSweep = calamityGlobalNPC.newAI[3] == 0f; float rateOfRotation = AIState == (int)Phase.Deathray ? 0.08f : 0.04f; float lookAtX = flyLeft ? 1000f : -1000f; - Vector2 lookAt = AIState == (int)Phase.Deathray && !fireNormalLasers ? (horizontalLaserSweep ? new Vector2(NPC.Center.X, NPC.Center.Y + 1000f) : new Vector2(NPC.Center.X + lookAtX, NPC.Center.Y)) : player.Center; + Vector2 lookAt = AIState == (int)Phase.Deathray && !fireNormalLasers ? (horizontalLaserSweep ? new Vector2(NPC.Center.X, NPC.Center.Y + 1000f) : new Vector2(NPC.Center.X + lookAtX, NPC.Center.Y)) : Main.player[targetIndex].Center; float rotation = (float)Math.Atan2(lookAt.Y - NPC.Center.Y, lookAt.X - NPC.Center.X); if (NPC.spriteDirection == 1) @@ -279,7 +279,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.rotation = NPC.rotation.AngleTowards(rotation, rateOfRotation); // Direction - int direction = Math.Sign(((AIState == (int)Phase.Deathray && !horizontalLaserSweep) || fireNormalLasers ? lookAt.X : player.Center.X) - NPC.Center.X); + int direction = Math.Sign(((AIState == (int)Phase.Deathray && !horizontalLaserSweep) || fireNormalLasers ? lookAt.X : Main.player[targetIndex].Center.X) - NPC.Center.X); if (direction != 0) { NPC.direction = direction; @@ -291,35 +291,31 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Despawn if target is dead - if (player.dead) + if (Main.player[targetIndex].dead) { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - NPC.dontTakeDamage = true; + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } - - return; } + + return; } // Velocity and acceleration values @@ -351,7 +347,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares deathrayPhaseVelocity *= 1.1f; // If Laser Cannon can fire normal lasers, cannot fire if too close to the target and in deathray spiral phase - bool canFire = Vector2.Distance(NPC.Center, player.Center) > 320f || !fireNormalLasers; + bool canFire = Vector2.Distance(NPC.Center, Main.player[targetIndex].Center) > 320f || !fireNormalLasers; // Telegraph duration for deathray spiral float deathraySpiralTelegraphDuration = bossRush ? AresBody.deathrayTelegraphDuration_BossRush : death ? AresBody.deathrayTelegraphDuration_Death : @@ -454,9 +450,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 laserVelocity = Vector2.Normalize(player.Center - NPC.Center); + Vector2 laserVelocity = Vector2.Normalize(Main.player[targetIndex].Center - NPC.Center); Vector2 offset = laserVelocity * 70f + Vector2.UnitY * 16f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, player.Center, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, Main.player[targetIndex].Center, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index 7a649370d7..9aef9f09fb 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -195,8 +195,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Whether Ares should be buffed while in berserk phase bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + // Target variables + int targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -236,8 +236,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (passivePhase) predictionAmt *= 0.5f; - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 rotationVector = player.Center + predictionVector - NPC.Center; + Vector2 predictionVector = Main.player[targetIndex].velocity * predictionAmt; + Vector2 rotationVector = Main.player[targetIndex].Center + predictionVector - NPC.Center; float projectileVelocity = passivePhase ? 9.6f : 12f; if (lastMechAlive) @@ -259,7 +259,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.rotation = NPC.rotation.AngleTowards(rotation, rateOfRotation); // Direction - int direction = Math.Sign(player.Center.X - NPC.Center.X); + int direction = Math.Sign(Main.player[targetIndex].Center.X - NPC.Center.X); if (direction != 0) { NPC.direction = direction; @@ -284,35 +284,31 @@ namespace CalamityMod.NPCs.ExoMechs.Ares float setTimerTo = (int)(plasmaBoltPhaseGateValue * 0.95f) - 1; // Despawn if target is dead - if (player.dead) + if (Main.player[targetIndex].dead) { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = setTimerTo; - calamityGlobalNPC.newAI[2] = 0f; - NPC.dontTakeDamage = true; + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = setTimerTo; + calamityGlobalNPC.newAI[2] = 0f; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } - - return; } + + return; } // Default vector to fly to @@ -351,7 +347,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares bool boltsSplitLess = fireMoreBolts && !lastMechAlive; // If Plasma Cannon can fire projectiles, cannot fire if too close to the target and in deathray spiral phase - bool canFire = Vector2.Distance(NPC.Center, player.Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; + bool canFire = Vector2.Distance(NPC.Center, Main.player[targetIndex].Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; // Telegraph duration for deathray spiral float deathrayTelegraphDuration = bossRush ? AresBody.deathrayTelegraphDuration_BossRush : death ? AresBody.deathrayTelegraphDuration_Death : @@ -450,7 +446,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (boltsSplitLess) 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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, Main.player[targetIndex].Center.X, Main.player[targetIndex].Center.Y); } // Recoil diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index 5c2f2b8e2c..09d77162ed 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -194,8 +194,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Whether Ares should be buffed while in berserk phase bool shouldGetBuffedByBerserkPhase = berserk && !otherMechIsBerserk; - // Target variable - Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + // Target variables + int targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -237,8 +237,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (lastMechAlive) predictionAmt *= 1.5f; - Vector2 predictionVector = player.velocity * predictionAmt; - Vector2 rotationVector = player.Center + predictionVector - NPC.Center; + Vector2 predictionVector = Main.player[targetIndex].velocity * predictionAmt; + Vector2 rotationVector = Main.player[targetIndex].Center + predictionVector - NPC.Center; bool fireMoreOrbs = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; float projectileVelocity = (passivePhase || fireMoreOrbs) ? 5.2f : 7.8f; @@ -261,7 +261,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.rotation = NPC.rotation.AngleTowards(rotation, rateOfRotation); // Direction - int direction = Math.Sign(player.Center.X - NPC.Center.X); + int direction = Math.Sign(Main.player[targetIndex].Center.X - NPC.Center.X); if (direction != 0) { NPC.direction = direction; @@ -285,35 +285,31 @@ namespace CalamityMod.NPCs.ExoMechs.Ares float setTimerTo = (int)(teslaOrbPhaseGateValue * 0.3f) - 1; // Despawn if target is dead - if (player.dead) + if (Main.player[targetIndex].dead) { - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (player.dead) - { - AIState = (float)Phase.Nothing; - calamityGlobalNPC.newAI[1] = setTimerTo; - calamityGlobalNPC.newAI[2] = 0f; - NPC.dontTakeDamage = true; + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = setTimerTo; + calamityGlobalNPC.newAI[2] = 0f; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } - - return; } + + return; } // Default vector to fly to @@ -349,7 +345,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares float movementDistanceGateValue = 50f; // If Tesla Cannon can fire projectiles, cannot fire if too close to the target and in deathray spiral phase - bool canFire = Vector2.Distance(NPC.Center, player.Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; + bool canFire = Vector2.Distance(NPC.Center, Main.player[targetIndex].Center) > 320f || calamityGlobalNPC_Body.newAI[0] != (float)AresBody.Phase.Deathrays; // Telegraph duration for deathray spiral float deathrayTelegraphDuration = bossRush ? AresBody.deathrayTelegraphDuration_BossRush : death ? AresBody.deathrayTelegraphDuration_Death : diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index d346637495..f53b9eead4 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -286,7 +286,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis NPC.TargetClosest(); // Target variable - Player player = Main.player[NPC.target]; + int targetIndex = NPC.target; // Check if the other exo mechs are alive int otherExoMechsAlive = 0; @@ -299,7 +299,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) { // Set target to Apollo's target if Apollo is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].target]; + targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].target; // Link the HP of both twins if (NPC.life > Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life) @@ -314,7 +314,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) { // Set target to Thanatos' target if Thanatos is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target]; + targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target; otherExoMechsAlive++; exoWormAlive = true; @@ -325,7 +325,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { // Set target to Ares' target if Ares is alive - player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; otherExoMechsAlive++; exoPrimeAlive = true; @@ -409,7 +409,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis { NPC.ai[0] += 1f; if (NPC.ai[0] == 10f && !NPC.AnyNPCs(ModContent.NPCType())) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); } else { @@ -465,7 +465,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Spin variables float spinRadius = 500f; float spinLocationDistance = 50f; - Vector2 spinLocation = player.Center; + Vector2 spinLocation = Main.player[targetIndex].Center; switch ((int)NPC.ai[3]) { // Laser from top @@ -557,11 +557,11 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Default vector to fly to bool flyLeft = NPC.ai[0] % 2f == 0f || NPC.ai[0] < 10f || !revenge; float destinationX = flyLeft ? -750f : 750f; - float destinationY = player.Center.Y; - Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + destinationX * 1.6f, destinationY) : - SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(player.Center.X + destinationX, destinationY + 360f) : + float destinationY = Main.player[targetIndex].Center.Y; + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(Main.player[targetIndex].Center.X + destinationX * 1.6f, destinationY) : + SecondaryAIState == (float)SecondaryPhase.Passive ? new Vector2(Main.player[targetIndex].Center.X + destinationX, destinationY + 360f) : AIState == (float)Phase.Deathray ? spinLocation : - new Vector2(player.Center.X + destinationX, destinationY); + new Vector2(Main.player[targetIndex].Center.X + destinationX, destinationY); // Add a bit of randomness to the destination, but only in specific phases where it's necessary if (AIState == (float)Phase.Normal || AIState == (float)Phase.LaserShotgun || AIState == (float)Phase.PhaseTransition) @@ -588,10 +588,10 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis bool canFire = distanceFromDestination.Length() <= 320f && canFireLasers; // Rotation - Vector2 predictionVector = AIState == (float)Phase.Deathray ? Vector2.Zero : player.velocity * predictionAmt; - Vector2 aimedVector = player.Center + predictionVector - NPC.Center; + Vector2 predictionVector = AIState == (float)Phase.Deathray ? Vector2.Zero : Main.player[targetIndex].velocity * predictionAmt; + Vector2 aimedVector = Main.player[targetIndex].Center + predictionVector - NPC.Center; float rateOfRotation = 0.1f; - Vector2 rotateTowards = player.Center - NPC.Center; + Vector2 rotateTowards = Main.player[targetIndex].Center - NPC.Center; bool stopRotatingAndSlowDown = !phase2 && AIState == (float)Phase.Normal && lineUpAttack; if (!stopRotatingAndSlowDown) { @@ -616,8 +616,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis } else { - float x = player.Center.X + predictionVector.X - NPC.Center.X; - float y = player.Center.Y + predictionVector.Y - NPC.Center.Y; + float x = Main.player[targetIndex].Center.X + predictionVector.X - NPC.Center.X; + float y = Main.player[targetIndex].Center.Y + predictionVector.Y - NPC.Center.Y; rotateTowards = Vector2.Normalize(new Vector2(x, y)) * baseVelocity; } @@ -627,45 +627,40 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis } // Despawn if target is dead - if (player.dead) + if (Main.player[targetIndex].dead) { - NPC.TargetClosest(false); - player = Main.player[NPC.target]; - if (player.dead) - { - AIState = (float)Phase.Normal; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.localAI[0] = 0f; - NPC.localAI[1] = 0f; - NPC.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - rotationDirection = 0; - chargeVelocityNormalized = default; - spinningPoint = default; - spinVelocity = default; - NPC.dontTakeDamage = true; + AIState = (float)Phase.Normal; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.localAI[0] = 0f; + NPC.localAI[1] = 0f; + NPC.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + rotationDirection = 0; + chargeVelocityNormalized = default; + spinningPoint = default; + spinVelocity = default; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } - - return; } + + return; } // Duration of deathray spin to do a full circle @@ -778,7 +773,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis else { Vector2 laserVelocity = Vector2.Normalize(aimedVector); - Vector2 projectileDestination = player.Center + predictionVector; + Vector2 projectileDestination = Main.player[targetIndex].Center + predictionVector; pointToLookAt = projectileDestination; SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -948,9 +943,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis int baseSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 9 : lastMechAlive ? 20 : 15) + numLasersAddedByDifficulty * 2; int spread = baseSpread + (int)(calamityGlobalNPC.newAI[2] / divisor2) * (baseSpread / 4); float rotation = MathHelper.ToRadians(spread); - float distanceFromTarget = Vector2.Distance(NPC.Center, player.Center + predictionVector); + float distanceFromTarget = Vector2.Distance(NPC.Center, Main.player[targetIndex].Center + predictionVector); float setVelocityInAI = death ? 6.5f : revenge ? 6.25f : expertMode ? 6f : 5.5f; - pointToLookAt = player.Center + predictionVector; + pointToLookAt = Main.player[targetIndex].Center + predictionVector; for (int i = 0; i < numLasersPerSpread + 1; i++) { @@ -1049,7 +1044,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Laser from top case 0: case 1: - if (player.Center.X >= NPC.Center.X) + if (Main.player[targetIndex].Center.X >= NPC.Center.X) rotationDirection = 1; else rotationDirection = -1; @@ -1057,7 +1052,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Laser from bottom case 2: - if (player.Center.X >= NPC.Center.X) + if (Main.player[targetIndex].Center.X >= NPC.Center.X) rotationDirection = -1; else rotationDirection = 1; @@ -1066,7 +1061,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Laser from left case 3: - if (player.Center.Y >= NPC.Center.Y) + if (Main.player[targetIndex].Center.Y >= NPC.Center.Y) rotationDirection = -1; else rotationDirection = 1; @@ -1075,7 +1070,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Laser from right case 4: - if (player.Center.Y >= NPC.Center.Y) + if (Main.player[targetIndex].Center.Y >= NPC.Center.Y) rotationDirection = 1; else rotationDirection = -1; @@ -1147,11 +1142,11 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis { calamityGlobalNPC.newAI[3] = 0f; AIState = (float)Phase.Deathray; - for (int i = 0; i < Main.maxProjectiles; i ++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == ModContent.ProjectileType()) + if (p.type == ModContent.ProjectileType()) { - Main.projectile[i].active = false; + p.active = false; continue; } } @@ -1607,10 +1602,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public override bool CheckDead() { // Kill Apollo if he's still alive when Artemis dies - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; - if (nPC.active && nPC.type == ModContent.NPCType() && nPC.life > 0) + if (nPC.type == ModContent.NPCType() && nPC.life > 0) { nPC.life = 0; nPC.HitEffect(); diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index d14f1fbf62..4dc825f12a 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -147,15 +147,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool expertMode = Main.expertMode || bossRush; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -290,16 +282,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; @@ -354,16 +346,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 9b3cdbe77f..76c6275344 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -146,15 +146,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool expertMode = Main.expertMode || bossRush; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -289,16 +281,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; @@ -353,16 +345,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index 8ca44fe51a..3c7d01279b 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -250,7 +250,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public float GetSlowdownAreaEdgeRadius(bool lastMechAlive) => (BossRushEvent.BossRushActive ? 400f : CalamityWorld.death ? 600f : CalamityWorld.revenge ? 700f : Main.expertMode ? 800f : 1000f) * (lastMechAlive ? 0.6f : 1f) * (Main.zenithWorld && !exoMechdusa ? 2 : Main.getGoodWorld ? 0.5f : 1f); - public int CheckForOtherMechs(ref Player target, out bool exoPrimeAlive, out bool exoTwinsAlive) + public int CheckForOtherMechs(ref int targetIndex, out bool exoPrimeAlive, out bool exoTwinsAlive) { exoPrimeAlive = false; exoTwinsAlive = false; @@ -260,7 +260,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { // Set target to Ares' target if Ares is alive. - target = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + targetIndex = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target; otherExoMechsAlive++; exoPrimeAlive = true; @@ -303,10 +303,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.TargetClosest(); // Target variable - Player player = Main.player[NPC.target]; + int targetIndex = NPC.target; // Check if the other exo mechs are alive - int otherExoMechsAlive = CheckForOtherMechs(ref player, out bool exoPrimeAlive, out bool exoTwinsAlive); + int otherExoMechsAlive = CheckForOtherMechs(ref targetIndex, out bool exoPrimeAlive, out bool exoTwinsAlive); // These are 5 by default to avoid triggering passive phases after the other mechs are dead float exoPrimeLifeRatio = defaultLifeRatio; @@ -438,36 +438,31 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Despawn if target is dead bool targetDead = false; - if (player.dead) + if (Main.player[targetIndex].dead) { - NPC.TargetClosest(false); - player = Main.player[NPC.target]; - if (player.dead) - { - targetDead = true; - AIState = (float)Phase.Charge; - NPC.localAI[0] = 0f; - NPC.localAI[2] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - chargeVelocityScalar = 0f; - NPC.dontTakeDamage = true; + targetDead = true; + AIState = (float)Phase.Charge; + NPC.localAI[0] = 0f; + NPC.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + chargeVelocityScalar = 0f; + NPC.dontTakeDamage = true; + NPC.velocity.Y -= 1f; + if ((double)NPC.position.Y < Main.topWorld + 16f) NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) - NPC.velocity.Y -= 1f; - if ((double)NPC.position.Y < Main.topWorld + 16f) + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } + if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || + Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; } } } @@ -480,7 +475,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.netUpdate = true; // Default vector to fly to - Vector2 destination = player.Center; + Vector2 destination = Main.player[targetIndex].Center; // Move destination to somewhere far below the target for the first 3 seconds so that Thanatos can fully uncoil quickly bool speedUp = false; @@ -577,9 +572,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.netMode != NetmodeID.MultiplayerClient) { // Spawn the fuckers - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); } } } @@ -993,7 +988,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Increase velocity if velocity is ever zero if (NPC.velocity == Vector2.Zero) - NPC.velocity = Vector2.Normalize(player.Center - NPC.Center).SafeNormalize(Vector2.Zero) * baseVelocity; + NPC.velocity = Vector2.Normalize(Main.player[targetIndex].Center - NPC.Center).SafeNormalize(Vector2.Zero) * baseVelocity; // Acceleration if (!((destination - NPC.Center).Length() < turnDistance)) @@ -1143,7 +1138,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos float lifeRatio = NPC.life / (float)NPC.lifeMax; // Yes, this is bizarre as fuck. - Player completelyUseless = null; + int completelyUseless = 0; int otherExoMechsAlive = CheckForOtherMechs(ref completelyUseless, out _, out _); // A general factor for the aura. diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index 7b5ea2721a..23622c7c61 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -146,15 +146,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool expertMode = Main.expertMode || bossRush; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) @@ -289,16 +281,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; @@ -353,16 +345,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 2e57cf624f..6337421d61 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -256,6 +256,9 @@ namespace CalamityMod.NPCs.HiveMind if (phase2) { + if (frameY >= maxFramesY_Phase2) + frameY = 0; + NPC.frameCounter++; if (NPC.frameCounter >= 6D) { @@ -276,6 +279,8 @@ namespace CalamityMod.NPCs.HiveMind if ((frameX * maxFramesY_Phase2) + frameY > 15) frameX = frameY = 0; } + + NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); } else { @@ -295,7 +300,6 @@ namespace CalamityMod.NPCs.HiveMind { SpriteEffects spriteEffects = NPC.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture = Phase2Texture.Value; - Rectangle frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); Vector2 vector = new Vector2(NPC.width / 2, NPC.height / 2); Color afterimageBaseColor = Color.White; int numAfterimages = 5; @@ -316,7 +320,7 @@ namespace CalamityMod.NPCs.HiveMind } Vector2 center = NPC.Center - screenPos; - spriteBatch.Draw(texture, center, frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); return false; } @@ -455,7 +459,6 @@ namespace CalamityMod.NPCs.HiveMind NPC.height = height_Phase2; NPC.position -= NPC.Size * 0.5f; - NPC.frame.Y = 0; NPC.noGravity = true; NPC.noTileCollide = true; NPC.scale = 1f; @@ -465,8 +468,6 @@ namespace CalamityMod.NPCs.HiveMind NPC.netSpam = 0; NPC.netUpdate = true; } - - NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); } else { @@ -926,6 +927,9 @@ namespace CalamityMod.NPCs.HiveMind { if (!dashStarted) { + // Set damage + NPC.damage = NPC.defDamage; + dashStarted = true; SoundEngine.PlaySound(RoarSound, NPC.Center); NPC.velocity.X = MathHelper.Pi * teleportRadius / arcTime; @@ -935,6 +939,9 @@ namespace CalamityMod.NPCs.HiveMind } else { + // Set damage + NPC.damage = NPC.defDamage; + NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); phase2timer++; @@ -988,6 +995,9 @@ namespace CalamityMod.NPCs.HiveMind { if (!dashStarted) { + // Set damage + NPC.damage = NPC.defDamage; + dashStarted = true; SoundEngine.PlaySound(RoarSound, NPC.Center); NPC.velocity.X = teleportRadius / arcTime * 3; @@ -997,6 +1007,9 @@ namespace CalamityMod.NPCs.HiveMind } else { + // Set damage + NPC.damage = NPC.defDamage; + phase2timer++; if (phase2timer == (int)arcTime / 20) { diff --git a/NPCs/Leviathan/Anahita.cs b/NPCs/Leviathan/Anahita.cs index b9f23d68ed..270966cff3 100644 --- a/NPCs/Leviathan/Anahita.cs +++ b/NPCs/Leviathan/Anahita.cs @@ -324,7 +324,7 @@ namespace CalamityMod.NPCs.Leviathan { NPC.alpha = 255; } - else + else if (NPC.alpha < 255) { for (int k = 0; k < 3; k++) { @@ -511,13 +511,7 @@ namespace CalamityMod.NPCs.Leviathan float restingPlayerDistance = (float)Math.Sqrt(restingPlayerXDist * restingPlayerXDist + restingPlayerYDist * restingPlayerYDist); NPC.ai[1] += 1f; - int activePlayerAmt = 0; - for (int i = 0; i < 255; i++) - { - if (Main.player[i].active && !Main.player[i].dead && (NPC.Center - Main.player[i].Center).Length() < 1000f) - activePlayerAmt++; - } - NPC.ai[1] += activePlayerAmt / 2; + NPC.ai[1] += Main.CurrentFrameFlags.ActivePlayersCount / 2; bool spawnedBubble = false; float bubbleDelay = 20f; diff --git a/NPCs/Leviathan/AnahitasIceShield.cs b/NPCs/Leviathan/AnahitasIceShield.cs index 9baba8e7fa..a32c37cb9b 100644 --- a/NPCs/Leviathan/AnahitasIceShield.cs +++ b/NPCs/Leviathan/AnahitasIceShield.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.netUpdate = true; } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => NPC.ai[1] == 0f; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => NPC.ai[1] == 0f && NPC.alpha <= 100; public override Color? GetAlpha(Color drawColor) => NPC.ai[1] == 1f ? Color.Transparent : new Color(200, 200, 200, drawColor.A) * NPC.Opacity; diff --git a/NPCs/Leviathan/AquaticAberration.cs b/NPCs/Leviathan/AquaticAberration.cs index 55d330b8b9..e98ae031d8 100644 --- a/NPCs/Leviathan/AquaticAberration.cs +++ b/NPCs/Leviathan/AquaticAberration.cs @@ -237,24 +237,21 @@ namespace CalamityMod.NPCs.Leviathan if (death) { float pushVelocity = 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 80f * NPC.scale) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 80f * NPC.scale) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } } } diff --git a/NPCs/Leviathan/LevScreenShaderData.cs b/NPCs/Leviathan/LevScreenShaderData.cs index 3552560be3..8dc3343de2 100644 --- a/NPCs/Leviathan/LevScreenShaderData.cs +++ b/NPCs/Leviathan/LevScreenShaderData.cs @@ -24,11 +24,11 @@ namespace CalamityMod.NPCs.Leviathan return; } LevIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == LevType) + if (n.type == LevType) { - LevIndex = i; + LevIndex = n.whoAmI; break; } } diff --git a/NPCs/Leviathan/LevSky.cs b/NPCs/Leviathan/LevSky.cs index 17c53ba72b..fbe87825de 100644 --- a/NPCs/Leviathan/LevSky.cs +++ b/NPCs/Leviathan/LevSky.cs @@ -67,11 +67,11 @@ namespace CalamityMod.NPCs.Leviathan return true; } LevIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == LevType) + if (n.type == LevType) { - LevIndex = i; + LevIndex = n.whoAmI; break; } } diff --git a/NPCs/NormalNPCs/ArmoredDiggerBody.cs b/NPCs/NormalNPCs/ArmoredDiggerBody.cs index 8a6ecf8271..26296ef13d 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerBody.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerBody.cs @@ -81,10 +81,9 @@ namespace CalamityMod.NPCs.NormalNPCs else { // find a new npc to attatch to in gfb, it's not a bug, it's a feature:tm: - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC host in Main.ActiveNPCs) { - NPC host = Main.npc[i]; - if (host.active && !host.friendly && !host.dontTakeDamage && host.type != ModContent.NPCType() && host.type != ModContent.NPCType() && host.type != ModContent.NPCType()) + if (!host.friendly && !host.dontTakeDamage && host.type != ModContent.NPCType() && host.type != ModContent.NPCType() && host.type != ModContent.NPCType()) { NPC.ai[1] = host.whoAmI; NPC.ai[3] = host.whoAmI; diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index 448082010e..1fc942cfb8 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -169,16 +169,13 @@ namespace CalamityMod.NPCs.NormalNPCs bool outsideNoFlyZone = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { - for (int m = 0; m < 255; m++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[m].active) + Rectangle noFlyArea = new Rectangle((int)player.position.X - noFlyZone, (int)player.position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); + if (rectangle.Intersects(noFlyArea)) { - Rectangle noFlyArea = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); - if (rectangle.Intersects(noFlyArea)) - { - outsideNoFlyZone = false; - break; - } + outsideNoFlyZone = false; + break; } } if (outsideNoFlyZone) diff --git a/NPCs/NormalNPCs/BloodlettingServant.cs b/NPCs/NormalNPCs/BloodlettingServant.cs index 92d49c536e..3ec7e710f1 100644 --- a/NPCs/NormalNPCs/BloodlettingServant.cs +++ b/NPCs/NormalNPCs/BloodlettingServant.cs @@ -4,8 +4,10 @@ using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -15,9 +17,15 @@ namespace CalamityMod.NPCs.NormalNPCs { public override string Texture => $"Terraria/Images/NPC_{NPCID.WanderingEye}"; + private const float ChargeGateValue = 180f; + private const float ChargeTelegraphGateValue = 90f; + private const float ChargeDuration = 60f; + private const float ChargeDuration_Death = 50f; + public override void SetStaticDefaults() { - Main.npcFrameCount[NPC.type] = 4; + Main.npcFrameCount[Type] = 4; + NPCID.Sets.TrailingMode[Type] = 1; NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); } @@ -52,25 +60,15 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { + Lighting.AddLight(NPC.Center, 0.8f, 0f, 0f); + NPC.TargetClosest(); Player target = Main.player[NPC.target]; - - Vector2 lookAt = target.Center - NPC.Center; - if (lookAt.X > 0f) - { - NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); - } - if (lookAt.X < 0f) - { - NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2(lookAt.Y, lookAt.X) + MathHelper.Pi; - } - - Lighting.AddLight(NPC.Center, 0.8f, 0f, 0f); + bool targetDead = target.dead; bool phase2 = NPC.life < NPC.lifeMax * 0.5; float enrageScale = 1f + NPC.ai[2]; + float enrageScaleMaxSpeedBonus = 2f * enrageScale; float maxSpeedX = (phase2 ? (CalamityWorld.death ? 10f : 8f) : (CalamityWorld.death ? 8f : 6f)) + enrageScaleMaxSpeedBonus; float maxSpeedY = (phase2 ? (CalamityWorld.death ? 8f : 6f) : (CalamityWorld.death ? 4f : 3f)) + enrageScaleMaxSpeedBonus; @@ -81,43 +79,141 @@ namespace CalamityMod.NPCs.NormalNPCs float yAccelBoost1 = maxSpeedY * 0.01f; float yAccelBoost2 = maxSpeedY * 0.0075f; - if (target.dead) + float chargeVelocity = 12f + enrageScaleMaxSpeedBonus * 2f; + bool attemptingToCharge = NPC.ai[0] >= ChargeGateValue; + bool farEnoughForCharge = NPC.Distance(target.Center) >= 320f; + bool closeEnoughForCharge = NPC.Distance(target.Center) < 480f; + bool charging = (attemptingToCharge && farEnoughForCharge && closeEnoughForCharge) || NPC.ai[1] > 0f; + + float projectileShootGateValue = CalamityWorld.death ? 180f : 270f; + if (Main.getGoodWorld) + projectileShootGateValue *= 0.5f; + + Vector2 lookAt = target.Center - NPC.Center; + float rateOfRotation = charging ? 0f : 0.1f; + float chargeDuration = CalamityWorld.death ? ChargeDuration_Death : ChargeDuration; + NPC.Calamity().canBreakPlayerDefense = charging; + if (charging) + { + if (NPC.ai[1] == 0f) + { + SoundEngine.PlaySound(SoundID.NPCDeath9, NPC.Center); + NPC.velocity = lookAt.SafeNormalize(Vector2.UnitY) * chargeVelocity; + NPC.spriteDirection = lookAt.X < 0f ? -1 : 1; + NPC.rotation = NPC.velocity.ToRotation() + (lookAt.X < 0f ? MathHelper.Pi : 0f); + + NPC.ai[1] = 1f; + if (NPC.ai[3] > projectileShootGateValue * 0.5f) + NPC.ai[3] = projectileShootGateValue * 0.5f; + + NPC.netUpdate = true; + NPC.netSpam = 0; + } + + if (NPC.ai[1] < ChargeDuration + 1f) + { + NPC.ai[1] += 1f; + if (NPC.ai[1] > ChargeDuration + 1f - 10f) + NPC.velocity *= 0.8f; + + if (NPC.ai[1] >= ChargeDuration + 1f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + NPC.netSpam = 0; + } + } + } + else + { + if (lookAt.X > 0f) + { + NPC.spriteDirection = 1; + NPC.rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); + } + if (lookAt.X < 0f) + { + NPC.spriteDirection = -1; + NPC.rotation = (float)Math.Atan2(lookAt.Y, lookAt.X) + MathHelper.Pi; + } + } + + if (phase2) + { + NPC.damage = (int)Math.Round(NPC.defDamage * 1.3); + + if (NPC.ai[0] < ChargeGateValue && !targetDead) + { + NPC.ai[0] += 1f; + if (NPC.ai[0] == ChargeGateValue) + { + NPC.netUpdate = true; + NPC.netSpam = 0; + } + } + } + else + NPC.damage = NPC.defDamage; + + if (targetDead) { NPC.velocity.Y -= 0.04f; if (NPC.timeLeft > 10) NPC.timeLeft = 10; } - else + else if (!attemptingToCharge) + { DemonEyeAI.DemonEyeBatMovement(NPC, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); - if (phase2) - NPC.damage = (int)Math.Round(NPC.defDamage * 1.3); - else - NPC.damage = NPC.defDamage; - - if (!target.dead) NPC.ai[3] += enrageScale; - - float projectileShootGateValue = CalamityWorld.death ? 180f : 270f; - if (Main.getGoodWorld) - projectileShootGateValue *= 0.5f; - - bool shootProjectile = Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(NPC.Center, target.Center) > 240f; - if (NPC.ai[3] >= projectileShootGateValue && shootProjectile) - { - NPC.ai[3] = 0f; - float projectileSpeed = CalamityWorld.death ? 16f : 12f; - Vector2 projectileVelocity = NPC.SafeDirectionTo(target.Center) * projectileSpeed; - if (Main.netMode != NetmodeID.MultiplayerClient) + bool shootProjectile = Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(NPC.Center, target.Center) > 240f; + if (NPC.ai[3] >= projectileShootGateValue && shootProjectile) { - int projType = ProjectileID.BloodShot; - int projDamage = NPC.GetProjectileDamage(projType); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 10f, projectileVelocity, projType, projDamage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; + NPC.ai[3] = 0f; + float projectileSpeed = CalamityWorld.death ? 16f : 12f; + Vector2 projectileVelocity = NPC.SafeDirectionTo(target.Center) * projectileSpeed; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int projType = ProjectileID.BloodShot; + int projDamage = NPC.GetProjectileDamage(projType); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 10f, projectileVelocity, projType, projDamage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 600; + } + + NPC.netUpdate = true; + NPC.netSpam = 0; } - NPC.netUpdate = true; + float pushVelocity = 0.2f * enrageScale; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active) + { + if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + { + if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 48f * NPC.scale) + { + if (NPC.position.X < Main.npc[i].position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; + + if (NPC.position.Y < Main.npc[i].position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; + } + } + } + } + } + else if (!charging) + { + Vector2 destination = target.Center + new Vector2(-280f * NPC.spriteDirection, -280f); + Vector2 desiredVelocity = NPC.SafeDirectionTo(destination, -Vector2.UnitY) * chargeVelocity; + NPC.SimpleFlyMovement(desiredVelocity, enrageScale); } if (Main.rand.NextBool(20)) @@ -127,29 +223,6 @@ namespace CalamityMod.NPCs.NormalNPCs blood.velocity.X *= 0.5f; blood.velocity.Y *= 0.1f; } - - float pushVelocity = 0.2f * enrageScale; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active) - { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) - { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 48f * NPC.scale) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; - - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } - } - } - } } public override void FindFrame(int frameHeight) @@ -169,6 +242,48 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.frame.Y += frameHeight * 2; } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.ai[0] >= ChargeTelegraphGateValue) + { + Texture2D npcTexture = TextureAssets.Npc[NPC.type].Value; + Color originalColor = NPC.GetAlpha(drawColor); + Color newColor = new Color(255, 128, 128, 255 - NPC.alpha); + Vector2 drawPosition = NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY); + Vector2 origin = NPC.frame.Size() / 2; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + float telegraphScalar = MathHelper.Clamp((NPC.ai[0] - ChargeTelegraphGateValue) / ChargeTelegraphGateValue, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + + if (CalamityConfig.Instance.Afterimages && NPC.ai[1] > 0f) + { + int afterimageAmount = 10; + int afterImageIncrement = 2; + for (int j = 0; j < afterimageAmount; j += afterImageIncrement) + { + Color afterimageColor = telegraphColor; + afterimageColor = Color.Lerp(afterimageColor, originalColor, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmount - j) / 15f; + Vector2 afterimagePos = NPC.oldPos[j] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(npcTexture.Width, npcTexture.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(npcTexture, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + return false; + } + + return true; + } + public override Color? GetAlpha(Color drawColor) => new Color(128, 0, 0, 255 - NPC.alpha); public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/KingSlimeJewel2.cs b/NPCs/NormalNPCs/KingSlimeJewel2.cs index d1df10f218..d18df61e1d 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel2.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel2.cs @@ -1,4 +1,5 @@ -using CalamityMod.CalPlayer; +using System; +using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -118,9 +119,23 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[0] = 0f; + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + int distanceFromKingSlime = 1; + Vector2 kingSlimeCenter = NPC.Center; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == NPCID.KingSlime) + { + distanceFromKingSlime = (int)NPC.Distance(Main.npc[i].Center); + kingSlimeCenter = Main.npc[i].Center; + break; + } + } + for (int dusty = 0; dusty < 10; dusty++) { - Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + Vector2 dustVel = (kingSlimeCenter - NPC.Center).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(2f, 4f); int sapphire = Dust.NewDust(NPC.Center, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); Main.dust[sapphire].velocity = dustVel * Main.rand.NextFloat(1f, 2f); Main.dust[sapphire].noGravity = true; @@ -131,7 +146,40 @@ namespace CalamityMod.NPCs.NormalNPCs } } - SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + int maxDustIterations = distanceFromKingSlime; + int maxDust = 100; + int dustDivisor = maxDustIterations / maxDust; + if (dustDivisor < 2) + dustDivisor = 2; + + Vector2 dustLineStart = NPC.Center; + Vector2 dustLineEnd = kingSlimeCenter; + Vector2 currentDustPos = default; + Vector2 spinningpoint = new Vector2(0f, -1f).RotatedByRandom(MathHelper.Pi); + int dustSpawned = 0; + for (int i = 0; i < maxDustIterations; i++) + { + if (i % dustDivisor == 0) + { + currentDustPos = Vector2.Lerp(dustLineStart, dustLineEnd, i / (float)maxDustIterations); + int dust = Dust.NewDust(currentDustPos, 0, 0, DustID.GemSapphire, 0f, 0f, 100, default, 1f); + Main.dust[dust].position = currentDustPos; + Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxDustIterations) * (0.9f + Main.rand.NextFloat() * 0.2f); + Main.dust[dust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + + Dust dust2 = Dust.CloneDust(dust); + Dust dust3 = dust2; + dust3.scale *= 0.5f; + dust3 = dust2; + dust3.fadeIn *= 0.5f; + dustSpawned++; + } + } NPC.netUpdate = true; } diff --git a/NPCs/NormalNPCs/KingSlimeJewel3.cs b/NPCs/NormalNPCs/KingSlimeJewel3.cs index df9125952b..91668e6b70 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel3.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel3.cs @@ -85,7 +85,7 @@ namespace CalamityMod.NPCs.NormalNPCs { for (int dusty = 0; dusty < 10; dusty++) { - Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + Vector2 dustVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f, -Vector2.UnitY) * Main.rand.NextFloat(-4f, -1f); int emerald = Dust.NewDust(NPC.Center, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); Main.dust[emerald].velocity = dustVel * Main.rand.NextFloat(1f, 2f); Main.dust[emerald].noGravity = true; diff --git a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs index 0cbf988952..f3912e4d09 100644 --- a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs +++ b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs @@ -171,24 +171,21 @@ namespace CalamityMod.NPCs.NormalNPCs } float pushVelocity = 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 40f * NPC.scale) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 40f * NPC.scale) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } } } diff --git a/NPCs/NormalNPCs/SkeletronPrime2.cs b/NPCs/NormalNPCs/SkeletronPrime2.cs index f98e80ad41..6164daf879 100644 --- a/NPCs/NormalNPCs/SkeletronPrime2.cs +++ b/NPCs/NormalNPCs/SkeletronPrime2.cs @@ -100,14 +100,6 @@ namespace CalamityMod.NPCs.NormalNPCs bool bossRush = BossRushEvent.BossRushActive; bool death = CalamityWorld.death || bossRush; - // Get a target - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - NPC.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - NPC.TargetClosest(); - // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -145,9 +137,6 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - // Set target to the lead head's target - Main.player[NPC.target] = Main.player[Main.npc[(int)NPC.ai[0]].target]; - // Link the HP of both heads if (NPC.life > Main.npc[(int)NPC.ai[0]].life) NPC.life = Main.npc[(int)NPC.ai[0]].life; @@ -231,12 +220,8 @@ namespace CalamityMod.NPCs.NormalNPCs } // Despawn - if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) > 6000f || Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > 6000f) - { - NPC.TargetClosest(); - if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) > 6000f || Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > 6000f) - NPC.ai[1] = 3f; - } + if (Main.npc[(int)NPC.ai[0]].ai[1] == 3f) + NPC.ai[1] = 3f; // Activate daytime enrage if (Main.IsItDay() && !bossRush && NPC.ai[1] != 3f && NPC.ai[1] != 2f) @@ -273,7 +258,7 @@ namespace CalamityMod.NPCs.NormalNPCs bool normalLaserRotation = NPC.localAI[1] % 2f == 0f; // Prevents cheap hits - bool canUseAttackInMaster = NPC.position.Y < Main.player[NPC.target].position.Y - 350f; + bool canUseAttackInMaster = NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - 350f; // Float near player if (NPC.ai[1] == 0f || NPC.ai[1] == 4f) @@ -289,8 +274,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.ai[2] += phase3 ? 1.2f : 0.8f; if (NPC.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f)) && (!otherHeadChargingOrSpinning || phase3) && canUseAttackInMaster) { - bool shouldSpinAround = NPC.ai[1] == 4f && NPC.position.Y < Main.player[NPC.target].position.Y - 400f && - Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 400f; + bool shouldSpinAround = NPC.ai[1] == 4f && NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - 400f && + Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) > 400f; if (shouldSpinAround || NPC.ai[1] != 4f) { @@ -337,7 +322,7 @@ namespace CalamityMod.NPCs.NormalNPCs float headDecelerationUpDist = 0f; float headDecelerationDownDist = 0f; float headDecelerationHorizontalDist = 0f; - int headHorizontalDirection = ((!(Main.player[NPC.target].Center.X < NPC.Center.X)) ? 1 : (-1)); + int headHorizontalDirection = ((!(Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X < NPC.Center.X)) ? 1 : (-1)); if (NPC.IsMechQueenUp) { headDecelerationHorizontalDist = -150f * (float)headHorizontalDirection; @@ -345,7 +330,7 @@ namespace CalamityMod.NPCs.NormalNPCs headDecelerationDownDist = 50f; } - if (NPC.position.Y > Main.player[NPC.target].position.Y - (400f + headDecelerationUpDist)) + if (NPC.position.Y > Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - (400f + headDecelerationUpDist)) { if (NPC.velocity.Y > 0f) NPC.velocity.Y *= deceleration; @@ -355,7 +340,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y > topVelocity) NPC.velocity.Y = topVelocity; } - else if (NPC.position.Y < Main.player[NPC.target].position.Y - (450f + headDecelerationDownDist)) + else if (NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - (450f + headDecelerationDownDist)) { if (NPC.velocity.Y < 0f) NPC.velocity.Y *= deceleration; @@ -366,7 +351,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity.Y = -topVelocity; } - if (NPC.Center.X > Main.player[NPC.target].Center.X + (400f + headDecelerationHorizontalDist)) + if (NPC.Center.X > Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X + (400f + headDecelerationHorizontalDist)) { if (NPC.velocity.X > 0f) NPC.velocity.X *= deceleration; @@ -376,7 +361,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.X > topVelocity) NPC.velocity.X = topVelocity; } - if (NPC.Center.X < Main.player[NPC.target].Center.X - (400f + headDecelerationHorizontalDist)) + if (NPC.Center.X < Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X - (400f + headDecelerationHorizontalDist)) { if (NPC.velocity.X < 0f) NPC.velocity.X *= deceleration; @@ -459,8 +444,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.rotation += NPC.direction * 0.3f; Vector2 headPosition = NPC.Center; - float headTargetX = Main.player[NPC.target].Center.X - headPosition.X; - float headTargetY = Main.player[NPC.target].Center.Y - headPosition.Y; + float headTargetX = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X - headPosition.X; + float headTargetY = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.Y - headPosition.Y; float headTargetDistance = (float)Math.Sqrt(headTargetX * headTargetX + headTargetY * headTargetY); float speed = bossRush ? 12f : 8f; @@ -487,7 +472,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.IsMechQueenUp) { - float mechdusaAccelMult = Vector2.Distance(NPC.Center, Main.player[NPC.target].Center); + float mechdusaAccelMult = Vector2.Distance(NPC.Center, Main.player[Main.npc[(int)NPC.ai[0]].target].Center); if (mechdusaAccelMult < 0.1f) mechdusaAccelMult = 0f; @@ -512,8 +497,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.rotation += NPC.direction * 0.3f; Vector2 enragedHeadPosition = NPC.Center; - float enragedHeadTargetX = Main.player[NPC.target].Center.X - enragedHeadPosition.X; - float enragedHeadTargetY = Main.player[NPC.target].Center.Y - enragedHeadPosition.Y; + float enragedHeadTargetX = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X - enragedHeadPosition.X; + float enragedHeadTargetY = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.Y - enragedHeadPosition.Y; float enragedHeadTargetDist = (float)Math.Sqrt(enragedHeadTargetX * enragedHeadTargetX + enragedHeadTargetY * enragedHeadTargetY); float enragedHeadSpeed = 10f; @@ -534,11 +519,11 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[0] = 0f; Vector2 headCenter = NPC.Center; - if (Collision.CanHit(headCenter, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (Collision.CanHit(headCenter, 1, 1, Main.player[Main.npc[(int)NPC.ai[0]].target].position, Main.player[Main.npc[(int)NPC.ai[0]].target].width, Main.player[Main.npc[(int)NPC.ai[0]].target].height)) { enragedHeadSpeed = 7f; - float enragedHeadSkullTargetX = Main.player[NPC.target].Center.X - headCenter.X + Main.rand.Next(-20, 21); - float enragedHeadSkullTargetY = Main.player[NPC.target].Center.Y - headCenter.Y + Main.rand.Next(-20, 21); + float enragedHeadSkullTargetX = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X - headCenter.X + Main.rand.Next(-20, 21); + float enragedHeadSkullTargetY = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.Y - headCenter.Y + Main.rand.Next(-20, 21); float enragedHeadSkullTargetDist = (float)Math.Sqrt(enragedHeadSkullTargetX * enragedHeadSkullTargetX + enragedHeadSkullTargetY * enragedHeadSkullTargetY); enragedHeadSkullTargetDist = enragedHeadSpeed / enragedHeadSkullTargetDist; enragedHeadSkullTargetX *= enragedHeadSkullTargetDist; @@ -627,12 +612,12 @@ namespace CalamityMod.NPCs.NormalNPCs SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); // Set spin direction - if (Main.player[NPC.target].velocity.X > 0f) + if (Main.player[Main.npc[(int)NPC.ai[0]].target].velocity.X > 0f) calamityGlobalNPC.newAI[0] = 1f; - else if (Main.player[NPC.target].velocity.X < 0f) + else if (Main.player[Main.npc[(int)NPC.ai[0]].target].velocity.X < 0f) calamityGlobalNPC.newAI[0] = -1f; else - calamityGlobalNPC.newAI[0] = Main.player[NPC.target].direction; + calamityGlobalNPC.newAI[0] = Main.player[Main.npc[(int)NPC.ai[0]].target].direction; // Set spin velocity NPC.velocity.X = MathHelper.Pi * NPC.localAI[3] / spinVelocity; @@ -652,7 +637,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[0] += 1f; - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 64f) + if (Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) > 64f) { SoundEngine.PlaySound(SoundID.Item61, NPC.Center); CreateParticles(NPC, new Vector2(NPC.Center.X + Main.rand.Next(NPC.width / 2), NPC.Center.Y + 4f)); @@ -661,8 +646,8 @@ namespace CalamityMod.NPCs.NormalNPCs { Vector2 headCenter = NPC.Center; float enragedHeadSpeed = 6f + (death ? 2f * (1f - lifeRatio) : 0f); - float enragedHeadBombTargetX = Main.player[NPC.target].Center.X - headCenter.X + Main.rand.Next(-20, 21); - float enragedHeadBombTargetY = Main.player[NPC.target].Center.Y - headCenter.Y + Main.rand.Next(-20, 21); + float enragedHeadBombTargetX = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X - headCenter.X + Main.rand.Next(-20, 21); + float enragedHeadBombTargetY = Main.player[Main.npc[(int)NPC.ai[0]].target].Center.Y - headCenter.Y + Main.rand.Next(-20, 21); float enragedHeadBombTargetDist = (float)Math.Sqrt(enragedHeadBombTargetX * enragedHeadBombTargetX + enragedHeadBombTargetY * enragedHeadBombTargetY); enragedHeadBombTargetDist = enragedHeadSpeed / enragedHeadBombTargetDist; enragedHeadBombTargetX *= enragedHeadBombTargetDist; @@ -724,7 +709,7 @@ namespace CalamityMod.NPCs.NormalNPCs float flightVelocity = bossRush ? 32f : death ? 28f : 24f; float flightAcceleration = bossRush ? 1.28f : death ? 1.12f : 0.96f; - Vector2 destination = new Vector2(Main.player[NPC.target].Center.X, Main.player[NPC.target].Center.Y - 500f); + Vector2 destination = new Vector2(Main.player[Main.npc[(int)NPC.ai[0]].target].Center.X, Main.player[Main.npc[(int)NPC.ai[0]].target].Center.Y - 500f); NPC.SimpleFlyMovement((destination - NPC.Center).SafeNormalize(Vector2.UnitY) * flightVelocity, flightAcceleration); // Spit bombs and then go to floating phase diff --git a/NPCs/NormalNPCs/WulfrumAmplifier.cs b/NPCs/NormalNPCs/WulfrumAmplifier.cs index 5519d7528c..d6c1823226 100644 --- a/NPCs/NormalNPCs/WulfrumAmplifier.cs +++ b/NPCs/NormalNPCs/WulfrumAmplifier.cs @@ -165,12 +165,8 @@ namespace CalamityMod.NPCs.NormalNPCs } } - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var npcAtIndex in Main.ActiveNPCs) { - NPC npcAtIndex = Main.npc[i]; - if (!npcAtIndex.active) - continue; - // For some strange reason, the Wulfrum enemies are not counted when SuperchargableEnemies is a static list declared up front. // What I assume is going on is that it hasn't been loaded yet since it's later alphabetically (Amplifier is before the other enemies). if (!SuperchargableEnemies.Contains(npcAtIndex.type) && npcAtIndex.type != ModContent.NPCType()) diff --git a/NPCs/OldDuke/OldDukeToothBall.cs b/NPCs/OldDuke/OldDukeToothBall.cs index bf297747ac..f880849a6e 100644 --- a/NPCs/OldDuke/OldDukeToothBall.cs +++ b/NPCs/OldDuke/OldDukeToothBall.cs @@ -147,24 +147,21 @@ namespace CalamityMod.NPCs.OldDuke NPC.velocity.Y = (NPC.velocity.Y * inertia + targetYDist) / (inertia + 1f); float toothBallAccel = bossRush ? 0.65f : 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 48f) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 48f) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= toothBallAccel; - else - NPC.velocity.X += toothBallAccel; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= toothBallAccel; + else + NPC.velocity.X += toothBallAccel; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= toothBallAccel; - else - NPC.velocity.Y += toothBallAccel; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= toothBallAccel; + else + NPC.velocity.Y += toothBallAccel; } } } diff --git a/NPCs/OldDuke/SulphurousSharkron.cs b/NPCs/OldDuke/SulphurousSharkron.cs index e0d2298c82..f1480f9f0a 100644 --- a/NPCs/OldDuke/SulphurousSharkron.cs +++ b/NPCs/OldDuke/SulphurousSharkron.cs @@ -188,24 +188,21 @@ namespace CalamityMod.NPCs.OldDuke } float pushVelocity = 0.5f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 160f) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 160f) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; + if (NPC.position.X < n.position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } } } diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs index 99a6c00f2c..630cd48ca1 100644 --- a/NPCs/Other/DemonPortal.cs +++ b/NPCs/Other/DemonPortal.cs @@ -47,14 +47,14 @@ namespace CalamityMod.NPCs.Other NPC.dontTakeDamage = true; NPC.netUpdate = true; int demonType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != demonType || !Main.projectile[i].active || Main.projectile[i].hostile) + if (p.type != demonType || p.hostile) continue; - Main.projectile[i].hostile = true; - Main.projectile[i].friendly = false; - Main.projectile[i].netUpdate = true; + p.hostile = true; + p.friendly = false; + p.netUpdate = true; } } diff --git a/NPCs/Other/THELORDE.cs b/NPCs/Other/THELORDE.cs index bc6876021a..dc4b4ad615 100644 --- a/NPCs/Other/THELORDE.cs +++ b/NPCs/Other/THELORDE.cs @@ -320,9 +320,8 @@ namespace CalamityMod.NPCs.Other NPC.ai[3] = 0f; NPC.aiStyle = (urAMemeNow ? -1 : aiChoice); NPC.netUpdate = true; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; if (proj.type == ModContent.ProjectileType() || proj.type == ModContent.ProjectileType()) { proj.Kill(); diff --git a/NPCs/Perforator/PerforatorBodyLarge.cs b/NPCs/Perforator/PerforatorBodyLarge.cs index 01fb9ffb94..c25aae7727 100644 --- a/NPCs/Perforator/PerforatorBodyLarge.cs +++ b/NPCs/Perforator/PerforatorBodyLarge.cs @@ -91,15 +91,7 @@ namespace CalamityMod.NPCs.Perforator if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/Perforator/PerforatorBodySmall.cs b/NPCs/Perforator/PerforatorBodySmall.cs index edbe9583e2..08627fc303 100644 --- a/NPCs/Perforator/PerforatorBodySmall.cs +++ b/NPCs/Perforator/PerforatorBodySmall.cs @@ -86,15 +86,7 @@ namespace CalamityMod.NPCs.Perforator if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index 95dd7fde47..ae4e888120 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -246,19 +246,15 @@ namespace CalamityMod.NPCs.Perforator bool outsideFlyingRadius = true; if (NPC.position.Y > player.position.Y) { - for (int m = 0; m < Main.maxPlayers; m++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[m].active) + Rectangle rectangle2 = new Rectangle((int)plr.position.X - stopFlyingRadius, (int)plr.position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); + if (rectangle.Intersects(rectangle2)) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - stopFlyingRadius, (int)Main.player[m].position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); - if (rectangle.Intersects(rectangle2)) - { - outsideFlyingRadius = false; - break; - } + outsideFlyingRadius = false; + break; } } - if (outsideFlyingRadius) shouldFly = true; } diff --git a/NPCs/Perforator/PerforatorHeadMedium.cs b/NPCs/Perforator/PerforatorHeadMedium.cs index 4170cfdc34..acdb3c712b 100644 --- a/NPCs/Perforator/PerforatorHeadMedium.cs +++ b/NPCs/Perforator/PerforatorHeadMedium.cs @@ -527,11 +527,12 @@ namespace CalamityMod.NPCs.Perforator } } - for (int i = 0; i < Main.maxNPCs; i++) + // ???? + /*for (int i = 0; i < Main.maxNPCs; i++) { if (i != NPC.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPC.type || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType())) return; - } + }*/ } public override void BossLoot(ref string name, ref int potionType) diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index 8d341da595..40a2a555dc 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -238,19 +238,15 @@ namespace CalamityMod.NPCs.Perforator bool outsideFlyRadius = true; if (NPC.position.Y > player.position.Y) { - for (int m = 0; m < Main.maxPlayers; m++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[m].active) + Rectangle rectangle2 = new Rectangle((int)plr.position.X - stopFlyingRadius, (int)plr.position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); + if (rectangle.Intersects(rectangle2)) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - stopFlyingRadius, (int)Main.player[m].position.Y - stopFlyingRadius, stopFlyingRadius * 2, stopFlyingRadius * 2); - if (rectangle.Intersects(rectangle2)) - { - outsideFlyRadius = false; - break; - } + outsideFlyRadius = false; + break; } } - if (outsideFlyRadius) shouldFly = true; } diff --git a/NPCs/Perforator/PerforatorTailLarge.cs b/NPCs/Perforator/PerforatorTailLarge.cs index df4536e71a..5095d20a37 100644 --- a/NPCs/Perforator/PerforatorTailLarge.cs +++ b/NPCs/Perforator/PerforatorTailLarge.cs @@ -86,15 +86,7 @@ namespace CalamityMod.NPCs.Perforator if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/Perforator/PerforatorTailSmall.cs b/NPCs/Perforator/PerforatorTailSmall.cs index 7f5d26a183..30ad5f8738 100644 --- a/NPCs/Perforator/PerforatorTailSmall.cs +++ b/NPCs/Perforator/PerforatorTailSmall.cs @@ -86,15 +86,7 @@ namespace CalamityMod.NPCs.Perforator if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(true); - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs index d403dd897b..d8abae06ac 100644 --- a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs +++ b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs @@ -94,13 +94,7 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.timeLeft = 750; } - int playerAmt = 0; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && (NPC.Center - Main.player[i].Center).Length() < 1000f) - playerAmt++; - } - + int playerAmt = Main.CurrentFrameFlags.ActivePlayersCount; if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); diff --git a/NPCs/PlaguebringerGoliath/PbGScreenShaderData.cs b/NPCs/PlaguebringerGoliath/PbGScreenShaderData.cs index 717e8c0cc0..d31f5b22e0 100644 --- a/NPCs/PlaguebringerGoliath/PbGScreenShaderData.cs +++ b/NPCs/PlaguebringerGoliath/PbGScreenShaderData.cs @@ -22,15 +22,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { return; } - PbGIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == PbGType) - { - PbGIndex = i; - break; - } - } + PbGIndex = NPC.FindFirstNPC(PbGType); } public override void Update(GameTime gameTime) diff --git a/NPCs/PlaguebringerGoliath/PbGSky.cs b/NPCs/PlaguebringerGoliath/PbGSky.cs index ada84bda25..39e5888f4a 100644 --- a/NPCs/PlaguebringerGoliath/PbGSky.cs +++ b/NPCs/PlaguebringerGoliath/PbGSky.cs @@ -51,15 +51,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { return true; } - PbGIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == PbGType) - { - PbGIndex = i; - break; - } - } + PbGIndex = NPC.FindFirstNPC(PbGType); //this.DoGIndex = DoGIndex; return PbGIndex != -1; } diff --git a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs index dd170d4dfa..a01811e7b6 100644 --- a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs +++ b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs @@ -149,10 +149,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } float distanceBeforeExploding = 42f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player.active && !player.dead && Vector2.Distance(player.Center, NPC.Center) <= distanceBeforeExploding) + if (!player.dead && Vector2.Distance(player.Center, NPC.Center) <= distanceBeforeExploding) { CheckDead(); NPC.life = 0; diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 2b78a69901..e1983374f1 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -211,12 +211,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath MissileCountdown--; // Count nearby players - int activePlayers = 0; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && (NPC.Center - Main.player[i].Center).Length() < 1000f) - activePlayers++; - } + int activePlayers = Main.CurrentFrameFlags.ActivePlayersCount; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index 6593c96a5a..6724039449 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -207,12 +207,12 @@ namespace CalamityMod.NPCs.Polterghast float movementLimitX = 0f; float movementLimitY = 0f; int numHooks = 4; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { - movementLimitX += Main.npc[i].Center.X; - movementLimitY += Main.npc[i].Center.Y; + movementLimitX += n.Center.X; + movementLimitY += n.Center.Y; } } movementLimitX /= numHooks; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index d7f339cba4..1c8833c123 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -450,12 +450,12 @@ namespace CalamityMod.NPCs.Polterghast float movementLimitX = 0f; float movementLimitY = 0f; int numHooks = 4; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) { - movementLimitX += Main.npc[i].Center.X; - movementLimitY += Main.npc[i].Center.Y; + movementLimitX += n.Center.X; + movementLimitY += n.Center.Y; } } movementLimitX /= numHooks; diff --git a/NPCs/Polterghast/PolterghastHook.cs b/NPCs/Polterghast/PolterghastHook.cs index e6b04762ad..50c6039a49 100644 --- a/NPCs/Polterghast/PolterghastHook.cs +++ b/NPCs/Polterghast/PolterghastHook.cs @@ -229,9 +229,9 @@ namespace CalamityMod.NPCs.Polterghast if (!despawnBoost && NPC.localAI[0] <= 0f && NPC.ai[0] != 0f) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type && (Main.npc[i].velocity.X != 0f || Main.npc[i].velocity.Y != 0f)) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type && (n.velocity.X != 0f || n.velocity.Y != 0f)) NPC.localAI[0] = 180f; } } diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs b/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs index 8a8fb1aa1d..edd0b1f728 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs @@ -76,16 +76,8 @@ namespace CalamityMod.NPCs.PrimordialWyrm NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive. If not, die. - bool shouldDespawn = true; int wyrmHeadID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == wyrmHeadID) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(wyrmHeadID); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs b/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs index fa061524e4..823636e046 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs @@ -75,16 +75,8 @@ namespace CalamityMod.NPCs.PrimordialWyrm NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive. If not, die. - bool shouldDespawn = true; int wyrmHeadID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == wyrmHeadID) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(wyrmHeadID); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index 974863ec59..49391cd55c 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -609,16 +609,16 @@ namespace CalamityMod.NPCs.PrimordialWyrm int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; @@ -904,16 +904,16 @@ namespace CalamityMod.NPCs.PrimordialWyrm int numProjectiles = 0; float maxDistance = 2400f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (plr.dead) continue; - Vector2 playerCenter = Main.player[i].Center; + Vector2 playerCenter = plr.Center; float distance = Vector2.Distance(playerCenter, NPC.Center); if (distance < maxDistance) { - whoAmIArray[numProjectiles] = i; + whoAmIArray[numProjectiles] = plr.whoAmI; targetCenterArray[numProjectiles] = playerCenter; int projectileLimit = numProjectiles + 1; numProjectiles = projectileLimit; diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs b/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs index e192350bad..7b9aae19b0 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs @@ -64,16 +64,8 @@ namespace CalamityMod.NPCs.PrimordialWyrm NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive. If not, die. - bool shouldDespawn = true; int wyrmHeadID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == wyrmHeadID) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(wyrmHeadID); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/ProfanedGuardians/ProfanedRocks.cs b/NPCs/ProfanedGuardians/ProfanedRocks.cs index 9ef42786b6..6e8de8df02 100644 --- a/NPCs/ProfanedGuardians/ProfanedRocks.cs +++ b/NPCs/ProfanedGuardians/ProfanedRocks.cs @@ -231,29 +231,25 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (death) { float pushVelocity = bossRush ? 0.2f : 0.15f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + if (Vector2.Distance(NPC.Center, n.Center) < 160f) { - if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 160f) - { - if (NPC.position.X < Main.npc[i].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; - - if (NPC.position.Y < Main.npc[i].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } - - // Slow down so they don't push away from each other too far + if (NPC.position.X < n.position.X) + NPC.velocity.X -= pushVelocity; else - NPC.velocity *= 0.95f; + NPC.velocity.X += pushVelocity; + + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; } + // Slow down so they don't push away from each other too far + else + NPC.velocity *= 0.95f; } } } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 0619b23fc4..7f0bbfabc3 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -1353,10 +1353,10 @@ namespace CalamityMod.NPCs.Providence if (NPC.ai[3] % 60f == 0f && expertMode) { List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (!plr.dead) + targets.Add(plr.whoAmI); if (targets.Count > 4) break; @@ -1834,11 +1834,11 @@ namespace CalamityMod.NPCs.Providence DespawnSpecificProjectiles(); int laserType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!Main.projectile[i].active || Main.projectile[i].type != laserType) + if (p.type != laserType) continue; - Main.projectile[i].Kill(); + p.Kill(); } } @@ -2071,7 +2071,7 @@ namespace CalamityMod.NPCs.Providence int[] weapons = new int[] { ModContent.ItemType(), - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index ffee658261..09b76c70fb 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -201,19 +201,19 @@ namespace CalamityMod.NPCs.Ravager bool leftClawActive = false; bool freeHeadActive = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) headActive = true; - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) rightClawActive = true; - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) leftClawActive = true; - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) rightLegActive = true; - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) leftLegActive = true; - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType()) freeHeadActive = true; } @@ -619,13 +619,13 @@ namespace CalamityMod.NPCs.Ravager if (expertMode) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].type == ModContent.NPCType() && Main.npc[i].ai[0] == 0f) + if (n.type == ModContent.NPCType() && n.ai[0] == 0f) { - Main.npc[i].ai[1] = -1f; - Main.npc[i].direction = NPC.direction; - Main.npc[i].netUpdate = true; + n.ai[1] = -1f; + n.direction = NPC.direction; + n.netUpdate = true; } } diff --git a/NPCs/Signus/SignusScreenShaderData.cs b/NPCs/Signus/SignusScreenShaderData.cs index 902c4f9389..a2fa44c859 100644 --- a/NPCs/Signus/SignusScreenShaderData.cs +++ b/NPCs/Signus/SignusScreenShaderData.cs @@ -20,15 +20,7 @@ namespace CalamityMod.NPCs.Signus { return; } - SignusIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == SignusType) - { - SignusIndex = i; - break; - } - } + SignusIndex = NPC.FindFirstNPC(SignusType); } public override void Apply() diff --git a/NPCs/Signus/SignusSky.cs b/NPCs/Signus/SignusSky.cs index fe449714bb..a128b08f8c 100644 --- a/NPCs/Signus/SignusSky.cs +++ b/NPCs/Signus/SignusSky.cs @@ -60,15 +60,7 @@ namespace CalamityMod.NPCs.Signus { return true; } - SignusIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == SignusType) - { - SignusIndex = i; - break; - } - } + SignusIndex = NPC.FindFirstNPC(SignusType); return SignusIndex != -1; } diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index 0881cbf004..2efc4de6b7 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -462,10 +462,10 @@ namespace CalamityMod.NPCs.SlimeGod if (enraged && expertMode) { List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (!plr.dead) + targets.Add(plr.whoAmI); if (targets.Count > 1) break; diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index 6fb4067319..f8c225f0cb 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -506,10 +506,10 @@ namespace CalamityMod.NPCs.SlimeGod if (enraged && expertMode) { List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (!plr.dead) + targets.Add(plr.whoAmI); if (targets.Count > 1) break; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index d208410b88..c0bdd4c2f6 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -500,19 +500,16 @@ namespace CalamityMod.NPCs.SlimeGod float ignoreAllSlimesDistanceThreshold = 3200f; // Find all slimes within a generous area. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - int npcType = Main.npc[i].type; + int npcType = n.type; if (npcType != largeCrimulanPaladin && npcType != splitCrimulanPaladin && npcType != largeEbonianPaladin && npcType != splitEbonianPaladin) continue; - if (!Main.npc[i].active) + if (!NPC.WithinRange(n.Center, ignoreAllSlimesDistanceThreshold)) continue; - if (!NPC.WithinRange(Main.npc[i].Center, ignoreAllSlimesDistanceThreshold)) - continue; - - largeSlimes.Add(Main.npc[i]); + largeSlimes.Add(n); } // If no slimes were found, don't bother doing any more calculations. Just use the player's center. diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index 40504fa27a..d00c921ae9 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -446,10 +446,10 @@ namespace CalamityMod.NPCs.SlimeGod if (enraged && expertMode) { List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (!plr.dead) + targets.Add(plr.whoAmI); if (targets.Count > 1) break; diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 439b06b21e..91036c6d16 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -493,10 +493,10 @@ namespace CalamityMod.NPCs.SlimeGod if (enraged && expertMode) { List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (!plr.dead) + targets.Add(plr.whoAmI); if (targets.Count > 1) break; diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index cbddaba0a0..d921c85011 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -163,15 +163,7 @@ namespace CalamityMod.NPCs.StormWeaver } // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 3239bbd167..75e8814fe4 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -300,13 +300,13 @@ namespace CalamityMod.NPCs.StormWeaver if ((double)NPC.position.Y < Main.topWorld + 16f) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].active && (Main.npc[j].type == ModContent.NPCType() - || Main.npc[j].type == ModContent.NPCType() - || Main.npc[j].type == ModContent.NPCType())) + if ((n.type == ModContent.NPCType() + || n.type == ModContent.NPCType() + || n.type == ModContent.NPCType())) { - Main.npc[j].active = false; + n.active = false; } } } @@ -314,13 +314,13 @@ namespace CalamityMod.NPCs.StormWeaver if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 10000f && NPC.life > 0) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].type == ModContent.NPCType() - || Main.npc[j].type == ModContent.NPCType() - || Main.npc[j].type == ModContent.NPCType()) + if (n.type == ModContent.NPCType() + || n.type == ModContent.NPCType() + || n.type == ModContent.NPCType()) { - Main.npc[j].active = false; + n.active = false; } } } diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 668878f4ed..62afff7228 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -159,15 +159,7 @@ namespace CalamityMod.NPCs.StormWeaver } // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index fec26d9caa..6e520e527b 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -150,6 +150,8 @@ namespace CalamityMod.NPCs.SunkenSea // Avoid cheap bullshit NPC.damage = 0; + NPC.defense = Main.hardMode ? 35 : 10; + NPC.ai[0] += 1f; hide = false; } diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index 7a678cddb8..2cb2cdab19 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -84,15 +84,14 @@ namespace CalamityMod.NPCs.SunkenSea } } - Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f); + Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 0.3f / 255f, (255 - NPC.alpha) * 0.3f / 255f); + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { NPC.TargetClosest(true); - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -102,21 +101,14 @@ namespace CalamityMod.NPCs.SunkenSea { int lol = 0; if (segment == 0 || segment == 1 || segment == 4 || segment == 5) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 2 || segment == 3 || segment == 6) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 7) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 8) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -124,30 +116,30 @@ namespace CalamityMod.NPCs.SunkenSea NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = -1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = 1; - } + if (Main.player[NPC.target].dead) - { NPC.TargetClosest(false); - } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; } + float currentSpeed = speed; float currentTurnSpeed = turnSpeed; Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); diff --git a/NPCs/SunkenSea/SeaSerpent2.cs b/NPCs/SunkenSea/SeaSerpent2.cs index d64d5cc51c..4334908959 100644 --- a/NPCs/SunkenSea/SeaSerpent2.cs +++ b/NPCs/SunkenSea/SeaSerpent2.cs @@ -63,15 +63,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/SunkenSea/SeaSerpent3.cs b/NPCs/SunkenSea/SeaSerpent3.cs index 3274777561..3258776809 100644 --- a/NPCs/SunkenSea/SeaSerpent3.cs +++ b/NPCs/SunkenSea/SeaSerpent3.cs @@ -61,15 +61,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/SunkenSea/SeaSerpent4.cs b/NPCs/SunkenSea/SeaSerpent4.cs index 4d869b2c09..336e640558 100644 --- a/NPCs/SunkenSea/SeaSerpent4.cs +++ b/NPCs/SunkenSea/SeaSerpent4.cs @@ -61,15 +61,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/SunkenSea/SeaSerpent5.cs b/NPCs/SunkenSea/SeaSerpent5.cs index 671e3ea62f..419b90c22f 100644 --- a/NPCs/SunkenSea/SeaSerpent5.cs +++ b/NPCs/SunkenSea/SeaSerpent5.cs @@ -61,15 +61,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.realLife = (int)NPC.ai[2]; // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } + bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) { if (NPC.ai[1] <= 0f) diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index b2ffcd398e..299f2d5144 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -145,9 +145,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas int shootRate = BossRushEvent.BossRushActive ? 120 : 180; if (timer > shootRate) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC seeker in Main.ActiveNPCs) { - NPC seeker = Main.npc[i]; if (seeker.type == NPC.type) { if (seeker == NPC) diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 93038af046..42f996b630 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -98,6 +98,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public bool gettingTired5 = false; //1% public bool willCharge = false; public bool canFireSplitingFireball = true; + public bool fireFireblastFirst = true; public bool spawnArena = false; public bool enteredBrothersPhase = false; public bool hasSummonedBrothers = false; @@ -125,7 +126,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas public int alicornFrame = 0; public int alicornFrameCounter = 0; public int dashVisualCounter = 0; - public int brothersPause = 15; // Helps prevent telefragging + public int preventionPause = 15; // Helps prevent telefragging + public int attackPause = 0; + public bool respawnBro = true; // Master Mode change public float shieldOpacity = 1f; public float shieldRotation = 0f; @@ -1623,6 +1626,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!hasDoneDeathAnim && !bossRush) // Scrapped death animation for Scal { + attackPause = 5; Dust.QuickDustLine(NPC.Center, safeBox.Center() + new Vector2(0, -30), 500f, cirrus ? Color.Pink : Color.Red); NPC.Center = safeBox.Center() + new Vector2(0, -30); NPC.velocity = new Vector2(10 * NPC.spriteDirection, -7); @@ -2027,9 +2031,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (NPC.life > 0) { + if (attackPause > 0) + attackPause--; + if (lifeRatio < 0.45f && !enteredBrothersPhase) { - if (brothersPause == 0) + attackPause = 5; + if (preventionPause == 0) { enteredBrothersPhase = true; attackCastDelay = brothersSpawnCastTime; @@ -2067,7 +2075,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else { - brothersPause--; + preventionPause--; NPC.dontTakeDamage = true; NPC.velocity *= 0.85f; return; @@ -2234,6 +2242,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (NPC.ai[2] >= 300f) { NPC.ai[1] = -1f; + fireFireblastFirst = true; NPC.TargetClosest(); NPC.netUpdate = true; } @@ -2248,7 +2257,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.localAI[1] = 0f; int randomShot = Main.rand.Next(6); - if (randomShot == 0 && canFireSplitingFireball) + + if (randomShot == 0 && canFireSplitingFireball && !fireFireblastFirst) { canFireSplitingFireball = false; randomShot = gigablast; @@ -2267,7 +2277,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } } - else if (randomShot == 1 && canFireSplitingFireball) // Firing gigablast while hovering above pre laugh + else if ((randomShot == 1 && canFireSplitingFireball) || fireFireblastFirst) // Firing gigablast while hovering above pre laugh { canFireSplitingFireball = false; randomShot = fireblast; @@ -2286,7 +2296,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } } - else + else if (!fireFireblastFirst) { canFireSplitingFireball = true; randomShot = barrage; @@ -2311,6 +2321,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + fireFireblastFirst = false; } FrameType = FrameAnimationType.FasterUpwardDraft; @@ -2479,7 +2490,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 projectileSpawn = NPC.Center + projectileVelocity * 4f; projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, hellblastDamage, 0f, Main.myPlayer, 0f, 2f); + if (attackPause == 0) + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, hellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } @@ -2795,6 +2807,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (NPC.ai[2] >= 240f) { NPC.ai[1] = -1f; + fireFireblastFirst = true; NPC.TargetClosest(); NPC.netUpdate = true; } @@ -2809,7 +2822,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.localAI[1] = 0f; int randomShot = Main.rand.Next(6); - if (randomShot == 0 && canFireSplitingFireball) // fireblast while floating post laugh + + if (randomShot == 0 && canFireSplitingFireball && !fireFireblastFirst) // fireblast while floating post laugh { SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); canFireSplitingFireball = false; @@ -2826,10 +2840,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } } - else if (randomShot == 1 && canFireSplitingFireball) // Gigablast while floating post laugh + else if ((randomShot == 1 && canFireSplitingFireball) || fireFireblastFirst) // Gigablast while floating post laugh { SoundEngine.PlaySound(BrimstoneShotSound, NPC.Center); - canFireSplitingFireball = false; + if (NPC.ai[2] > 1) + canFireSplitingFireball = false; randomShot = fireblast; Particle pulse = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1.2f, cirrus ? Color.Pink : Color.Red, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.95f, 0f, 55); @@ -2843,7 +2858,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } } - else + else if (!fireFireblastFirst) { SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); canFireSplitingFireball = true; @@ -2868,6 +2883,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + fireFireblastFirst = false; } } else if (NPC.ai[1] == 1f) @@ -3007,7 +3023,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 projectileSpawn = NPC.Center + projectileVelocity * 4f; projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, hellblastDamage, 0f, Main.myPlayer, 0f, 2f); + if (attackPause == 0) + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, hellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index cca36fef24..005abccc7d 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -4,6 +4,7 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -173,6 +174,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas return; } + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + if (scal.ModNPC().respawnBro == false && Main.masterMode && !broIsAlive) + { + if (NPC.life > (NPC.lifeMax * 0.65f)) + NPC.life = (int)(NPC.lifeMax * 0.65f); + } + // Difficulty modes bool bossRush = BossRushEvent.BossRushActive; bool death = CalamityWorld.death || bossRush; @@ -326,7 +334,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas { PunchCounter = 0f; SoundEngine.PlaySound(SupremeCalamitas.HellblastSound, NPC.Center); + int type = ModContent.ProjectileType(); + + if (Main.zenithWorld) + type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); if (bossRush) damage /= 2; @@ -391,6 +404,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas PunchCounter = 0f; int type = ModContent.ProjectileType(); + + if (Main.zenithWorld) + type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); if (bossRush) damage /= 2; @@ -398,8 +415,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas if ((broIsAlive == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 1) && death) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, (NPC.DirectionTo(Target.Center) * 11f).RotatedBy(0.6f - BigAttackLimit * 0.16f), type, damage, 0f, Main.myPlayer, 0f, 0, 2); - Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, (NPC.DirectionTo(Target.Center) * 11f).RotatedBy(-0.6f + BigAttackLimit * 0.16f), type, damage, 0f, Main.myPlayer, 0f, 0, 2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, (NPC.DirectionTo(Target.Center) * (Main.zenithWorld ? 1 : 11f)).RotatedBy(0.6f - BigAttackLimit * 0.16f), type, damage, 0f, Main.myPlayer, 0f, 0, Main.zenithWorld ? 3 : 2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, (NPC.DirectionTo(Target.Center) * (Main.zenithWorld ? 1 : 11f)).RotatedBy(-0.6f + BigAttackLimit * 0.16f), type, damage, 0f, Main.myPlayer, 0f, 0, Main.zenithWorld ? 3 : 2); SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); SoundEngine.PlaySound(fire with { Volume = 0.4f, Pitch = -0.8f - BigAttackLimit * 0.1f }, NPC.Center); } @@ -407,7 +424,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center) * 9.5f, type, damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 3); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center) * 9.5f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 3); } SoundEngine.PlaySound(SupremeCalamitas.BrimstoneShotSound with { Volume = 1.8f, Pitch = 0.5f }, NPC.Center); SoundStyle charge = new("CalamityMod/Sounds/Item/ScorchedEarthShot", 3); @@ -533,7 +550,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Turn into dust on death. if (NPC.life <= 0) + { + if (NPC.AnyNPCs(ModContent.NPCType())) + { + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + if (scal.ModNPC().respawnBro == true && Main.masterMode && !broIsAlive) + { + for (int i = 0; i < 45; i++) + { + Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, 279, vel); + catastrophedust.noGravity = true; + catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); + catastrophedust.color = Color.DeepSkyBlue; + } + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, Color.Cyan, new Vector2(1f, 1f), 0, 0.1f, 5f, 25); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, Color.Lerp(Color.Cyan, Color.DodgerBlue, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 28); + GeneralParticleHandler.SpawnParticle(pulse2); + + SoundStyle respawn = new("CalamityMod/Sounds/NPCKilled/RavagerLimbLoss3"); + SoundEngine.PlaySound(respawn with { Volume = 0.9f, Pitch = 0.3f }, NPC.Center); + + CalamityUtils.SpawnBossBetter(NPC.Center, ModContent.NPCType(), null, MovingUp ? -1 : 1); + scal.ModNPC().respawnBro = false; + } + + } DeathAshParticle.CreateAshesFromNPC(NPC); + } } } } diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 06937b263d..c8b5db4dd0 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -167,6 +167,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas return; } + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + if (scal.ModNPC().respawnBro == false && Main.masterMode && !broIsAlive) + { + if (NPC.life > (NPC.lifeMax * 0.65f)) + NPC.life = (int)(NPC.lifeMax * 0.65f); + } + // Difficulty modes bool bossRush = BossRushEvent.BossRushActive; bool death = CalamityWorld.death || bossRush; @@ -275,17 +282,42 @@ namespace CalamityMod.NPCs.SupremeCalamitas dashes++; if (dashes == 30 && broIsAlive == false) { - SoundStyle slash = new("CalamityMod/Sounds/Item/MurasamaBigSwing"); - SoundEngine.PlaySound(slash with { Volume = 0.55f, Pitch = -0.3f }, NPC.Center); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.DirectionTo(Target.Center).RotatedBy(0.34f) * 130, NPC.DirectionTo(Target.Center).RotatedBy(0.34f) * 90f, type, damage, 0f, Main.myPlayer, 0f, 0, 50); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.DirectionTo(Target.Center).RotatedBy(-0.34f) * 130, NPC.DirectionTo(Target.Center).RotatedBy(-0.34f) * 90f, type, damage, 0f, Main.myPlayer, 0f, 0, 50); - for (int i = 0; i < 30; i++) + if (Main.zenithWorld) { - Vector2 vel = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); - Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, 279, vel); - catastrophedust.noGravity = true; - catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); - catastrophedust.color = Color.DeepSkyBlue; + SoundStyle charge = new("CalamityMod/Sounds/Item/ExobladeBeamSlash"); + SoundEngine.PlaySound(charge with { Volume = 0.85f, Pitch = -0.5f }, NPC.Center); + NPC.velocity = NPC.DirectionTo(Target.Center) * 150f; + + for (int i = 0; i < 30; i++) + { + Vector2 vel = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, 279, vel); + catastrophedust.noGravity = true; + catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); + catastrophedust.color = Color.DeepSkyBlue; + } + dashes = 0; + dashAttackTimer = 30; + BigAttackTimer = 500; + AttackDelayTimer = 120; + if (NPC.life > 10001) + NPC.life -= 10000; + return; + } + else + { + SoundStyle slash = new("CalamityMod/Sounds/Item/MurasamaBigSwing"); + SoundEngine.PlaySound(slash with { Volume = 0.55f, Pitch = -0.3f }, NPC.Center); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.DirectionTo(Target.Center).RotatedBy(0.34f) * 130, NPC.DirectionTo(Target.Center).RotatedBy(0.34f) * 90f, type, damage, 0f, Main.myPlayer, 0f, 0, 50); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.DirectionTo(Target.Center).RotatedBy(-0.34f) * 130, NPC.DirectionTo(Target.Center).RotatedBy(-0.34f) * 90f, type, damage, 0f, Main.myPlayer, 0f, 0, 50); + for (int i = 0; i < 30; i++) + { + Vector2 vel = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, 279, vel); + catastrophedust.noGravity = true; + catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); + catastrophedust.color = Color.DeepSkyBlue; + } } } NPC.velocity *= 0.975f; @@ -349,6 +381,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas SoundEngine.PlaySound(SupremeCalamitas.CatastropheSwing with { Volume = 0.5f, Pitch = (SlashingFromRight ? 0.2f : -0.2f) }, NPC.Center); int type = ModContent.ProjectileType(); + + if (Main.zenithWorld) + type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); if (bossRush) damage /= 2; @@ -368,7 +404,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas SoundStyle slash = new("CalamityMod/Sounds/Item/MurasamaBigSwing"); SoundEngine.PlaySound(slash with { Volume = 0.55f, Pitch = 0.4f }, NPC.Center); - Projectile.NewProjectile(NPC.GetSource_FromAI(), slashSpawnPosition, firingVelocity * 0.2f, type, damage, 0f, Main.myPlayer, 0f, SlashingFromRight.ToInt(), 3); + Projectile.NewProjectile(NPC.GetSource_FromAI(), slashSpawnPosition, firingVelocity * 0.2f, type, damage, 0f, Main.myPlayer, 0f, SlashingFromRight.ToInt(), Main.zenithWorld ? 0 : 3); accSlashCounter = 0; } } @@ -412,6 +448,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas SlashCounter = 0f; int type = ModContent.ProjectileType(); + + if (Main.zenithWorld) + type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); if (bossRush) damage /= 2; @@ -420,7 +460,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if ((broIsAlive == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 1) && death) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), slashSpawnPosition + firingVelocity * 130, (Phase2 ? NPC.DirectionTo(Target.Center) : firingVelocity) * 90f, type, damage, 0f, Main.myPlayer, 0f, 5, 50); + Projectile.NewProjectile(NPC.GetSource_FromAI(), slashSpawnPosition + firingVelocity * 130, (Phase2 ? NPC.DirectionTo(Target.Center) : firingVelocity) * 90f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 5, 50); SoundStyle slash = new("CalamityMod/Sounds/Item/MurasamaBigSwing"); SoundEngine.PlaySound(slash with { Volume = 0.55f, Pitch = -0.3f - BigAttackLimit * 0.1f }, NPC.Center); } @@ -545,7 +585,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Turn into dust on death. if (NPC.life <= 0) + { + if (NPC.AnyNPCs(ModContent.NPCType())) + { + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + if (scal.ModNPC().respawnBro == true && Main.masterMode && !broIsAlive) + { + for (int i = 0; i < 45; i++) + { + Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); + Dust cataclysmdust = Dust.NewDustPerfect(NPC.Center + vel * 2, 279, vel); + cataclysmdust.noGravity = true; + cataclysmdust.scale = Main.rand.NextFloat(1.2f, 1.8f); + cataclysmdust.color = Color.Red; + } + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 25); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 28); + GeneralParticleHandler.SpawnParticle(pulse2); + + SoundStyle respawn = new("CalamityMod/Sounds/NPCKilled/RavagerLimbLoss3"); + SoundEngine.PlaySound(respawn with { Volume = 0.9f, Pitch = 0.3f }, NPC.Center); + + CalamityUtils.SpawnBossBetter(NPC.Center, ModContent.NPCType(), null, MovingUp ? -1 : 1); + scal.ModNPC().respawnBro = false; + } + + } DeathAshParticle.CreateAshesFromNPC(NPC); + } } } } diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index b78f297891..a1c3038966 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -113,12 +113,8 @@ namespace CalamityMod.NPCs.TownNPCs break; } - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { Main.BestiaryTracker.Chats.RegisterChatStartWith(NPC); @@ -147,13 +143,13 @@ namespace CalamityMod.NPCs.TownNPCs type = ConvertType.Crimson; break; } - AstralBiome.ConvertFromAstral(x - 2, x + 2, y - 2, y + 2, type); + World.AstralBiome.ConvertFromAstral(x - 2, x + 2, y - 2, y + 2, type); WorldGen.Convert(x, y, conversionType, 2); } // Calamity solution(s) else if (conversionType == 8) { - AstralBiome.ConvertToAstral(x - 2, x + 2, y - 2, y + 2); + World.AstralBiome.ConvertToAstral(x - 2, x + 2, y - 2, y + 2); } // Solutions registered by other mods else diff --git a/NPCs/TownNPCs/DILF.cs b/NPCs/TownNPCs/DILF.cs index 93a834e7cb..9b2de8371c 100644 --- a/NPCs/TownNPCs/DILF.cs +++ b/NPCs/TownNPCs/DILF.cs @@ -140,7 +140,7 @@ namespace CalamityMod.NPCs.TownNPCs public override void AddShops() { - Condition potionSells = new(CalamityUtils.GetText("Condition.PotionConfig"), () => CalamityConfig.Instance.PotionSelling); + Condition potionSells = CalamityConditions.PotionSellingConfig; NPCShop shop = new(Type); shop.Add(ModContent.ItemType()) .Add(ModContent.ItemType()) diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 43bc9b2541..24b57edf9b 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -669,11 +669,10 @@ namespace CalamityMod.NPCs.TownNPCs if (CalamityWorld.spawnedCirrus) return true; - for (int k = 0; k < Main.maxPlayers; k++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[k]; bool hasVodka = player.InventoryHas(ModContent.ItemType()) || player.PortableStorageHas(ModContent.ItemType()); - if (player.active && hasVodka) + if (hasVodka) return Main.hardMode; } return false; @@ -883,8 +882,8 @@ namespace CalamityMod.NPCs.TownNPCs public override void AddShops() { - Condition potionSells = new(CalamityUtils.GetText("Condition.PotionConfig"), () => CalamityConfig.Instance.PotionSelling); - Condition downedAureus = new(CalamityUtils.GetText("Condition.PostAureus"), () => DownedBossSystem.downedAstrumAureus); + Condition potionSells = CalamityConditions.PotionSellingConfig; + Condition downedAureus = CalamityConditions.DownedAstrumAureus; NPCShop shop = new(Type); shop.AddWithCustomValue(ItemID.LovePotion, Item.buyPrice(silver: 25), potionSells, Condition.HappyEnough) diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index 778be0409f..b455f13eb2 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -198,7 +198,7 @@ namespace CalamityMod.NPCs.TownNPCs } public override void AddShops() { - Condition downedOldDuke = new(CalamityUtils.GetText("Condition.PostOD"), () => DownedBossSystem.downedBoomerDuke); + Condition downedOldDuke = CalamityConditions.DownedOldDuke; NPCShop shop = new(Type); shop.Add(ModContent.ItemType()) @@ -210,7 +210,7 @@ namespace CalamityMod.NPCs.TownNPCs .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) .Add(ModContent.ItemType()) - .AddWithCustomValue(ItemID.TruffleWorm, Item.buyPrice(gold: 10), Condition.Hardmode) + .AddWithCustomValue(ItemID.TruffleWorm, Item.buyPrice(gold: 15), Condition.Hardmode) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2), downedOldDuke) .AddWithCustomValue(ItemID.ShrimpPoBoy, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnough, Condition.InBeach) .AddWithCustomValue(ItemID.Fries, Item.buyPrice(gold: 2), Condition.HappyEnough, Condition.InBeach, Condition.DownedEyeOfCthulhu) diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index ca0b761bf9..c9ea97d8d4 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -91,11 +91,10 @@ namespace CalamityMod.NPCs.TownNPCs if (CalamityWorld.spawnedBandit) return true; - for (int k = 0; k < Main.maxPlayers; k++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[k]; bool rich = player.InventoryHas(ItemID.PlatinumCoin) || player.PortableStorageHas(ItemID.PlatinumCoin); - if (player.active && rich) + if (rich) return NPC.downedBoss3; } return false; @@ -269,10 +268,10 @@ namespace CalamityMod.NPCs.TownNPCs } public override void AddShops() { - Condition potionSells = new(CalamityUtils.GetText("Condition.PotionConfig"), () => CalamityConfig.Instance.PotionSelling); - Condition downedCalclone = new(CalamityUtils.GetText("Condition.PostCal"), () => DownedBossSystem.downedCalamitasClone); - Condition downedDoG = new(CalamityUtils.GetText("Condition.PostDoG"), () => DownedBossSystem.downedDoG); - Condition downedYharon = new(CalamityUtils.GetText("Condition.PostYharon"), () => DownedBossSystem.downedYharon); + Condition potionSells = CalamityConditions.PotionSellingConfig; + Condition downedCalclone = CalamityConditions.DownedCalamitasClone; + Condition downedDoG = CalamityConditions.DownedDevourerOfGods; + Condition downedYharon = CalamityConditions.DownedYharon; NPCShop shop = new(Type); shop.AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 9)) @@ -282,7 +281,7 @@ namespace CalamityMod.NPCs.TownNPCs .Add(ItemID.TigerClimbingGear) .AddWithCustomValue(ItemID.InvisibilityPotion, Item.buyPrice(silver: 25), potionSells, Condition.HappyEnough) .AddWithCustomValue(ItemID.NightOwlPotion, Item.buyPrice(silver: 25), potionSells, Condition.HappyEnough) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 25), Condition.Hardmode) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 25)) .Add(ModContent.ItemType(), Condition.DownedPirates) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 60), Condition.DownedMechBossAll) .Add(ModContent.ItemType(), downedCalclone) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs index 3eb437dcd6..22a0005454 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs @@ -554,22 +554,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (shadowHandTimer / shadowHandSpawnRate >= 3) npc.localAI[2] = 0f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - if (npc.Boss_CanShootExtraAt(i, rotation % 3, 3, 1200f, alwaysSkipMainTarget: false)) + if (npc.Boss_CanShootExtraAt(player.whoAmI, rotation % 3, 3, 1200f, alwaysSkipMainTarget: false)) { // Normal shadow hand spawn behavior // Modified to make the shadow hand spawns fair - RandomizeInsanityShadowFor(Main.player[i], death, isHostile: true, out var spawnPosition, out var spawnVelocity, out var ai, out var ai2); + RandomizeInsanityShadowFor(player, death, isHostile: true, out var spawnPosition, out var spawnVelocity, out var ai, out var ai2); // Spawn hands to cut the player off and force them back towards Deerclops // This only happens if the player is triggering Deerclops' increased DR float minShadowHandSpawnDistanceFromPlayer = 450f; - float playerDistanceFromDeerclops = Vector2.Distance(npc.Center, Main.player[i].Center); + float playerDistanceFromDeerclops = Vector2.Distance(npc.Center, player.Center); if (playerDistanceFromDeerclops >= 450f) { - spawnPosition = (Main.player[i].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (playerDistanceFromDeerclops + minShadowHandSpawnDistanceFromPlayer); - spawnVelocity = (Main.player[i].Center - spawnPosition).SafeNormalize(Vector2.UnitY) * spawnVelocity.Length(); + spawnPosition = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * (playerDistanceFromDeerclops + minShadowHandSpawnDistanceFromPlayer); + spawnVelocity = (player.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * spawnVelocity.Length(); } Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition, spawnVelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer, ai, ai2); @@ -871,7 +871,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + yVelocityIncrease, yVelocityMin, 0f); } - else if (npc.velocity.Y == 0f && moveUp) + else if (npc.velocity.Y == 0f && moveUp && npc.localAI[0] == 0f) { npc.velocity.Y = yVelocity; npc.localAI[0] = 1f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index e3c8676753..7582745b63 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { public static class DestroyerAI { - public const float DRIncraeseTime = 600f; + public const float DRIncreaseTime = 600f; public const float DeathModeLaserBreathGateValue = 600f; public const float LaserTelegraphTime = 120f; public const float SparkTelegraphTime = 30f; @@ -66,10 +66,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool death = CalamityWorld.death || bossRush; // 10 seconds of resistance to prevent spawn killing - if (calamityGlobalNPC.newAI[1] < DRIncraeseTime) + if (calamityGlobalNPC.newAI[1] < DRIncreaseTime) calamityGlobalNPC.newAI[1] += 1f; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < DRIncraeseTime; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < DRIncreaseTime; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Spawn DR check - bool hasSpawnDR = calamityGlobalNPC.newAI[1] < DRIncraeseTime && calamityGlobalNPC.newAI[1] > 60f; + bool hasSpawnDR = calamityGlobalNPC.newAI[1] < DRIncreaseTime && calamityGlobalNPC.newAI[1] > 60f; // Gradual color transition from ground to flight and vice versa // 0f = Red, 1f = Purple @@ -343,9 +343,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.type == NPCID.TheDestroyer) + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.type == NPCID.TheDestroyer) { // Spawn segments from head if (npc.ai[0] == 0f) @@ -368,197 +368,176 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses index = segment; } } - } - // Laser breath in Death Mode - if (spitLaserSpreads) - { - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1) + // Laser breath in Death Mode + if (spitLaserSpreads) { - calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; - npc.SyncDestroyerLaserColor(); - } - - float laserBreathGateValue = DeathModeLaserBreathGateValue; - if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) - calamityGlobalNPC.newAI[0] += 1f; - - // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 0f) - npc.SyncExtraAI(); - - if ((player.Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation() && - calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f && - Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - if (calamityGlobalNPC.newAI[0] % 30f == 0f) + // Set laser color and type + if (calamityGlobalNPC.destroyerLaserColor == -1) { - float velocity = bossRush ? 6f : death ? 5.333f : 5f; - int type = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) + calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; + npc.SyncDestroyerLaserColor(); + } + + float laserBreathGateValue = DeathModeLaserBreathGateValue; + if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) + calamityGlobalNPC.newAI[0] += 1f; + + // Sync newAI every 20 frames for the new telegraph + if (calamityGlobalNPC.newAI[0] % 20f == 0f) + npc.SyncExtraAI(); + + if ((player.Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation() && + calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f && + Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + if (calamityGlobalNPC.newAI[0] % 30f == 0f) { - default: - case 0: - break; - - case 1: - type = ModContent.ProjectileType(); - break; - - case 2: - type = ModContent.ProjectileType(); - break; - } - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; - double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; - if (!NPC.downedMechBossAny) - damage = (int)(damage * firstMechMultiplier); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - damage = (int)(damage * secondMechMultiplier); - } - - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4); - int spread = masterMode ? 38 : 26; - 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 (Main.netMode != NetmodeID.MultiplayerClient) + float velocity = bossRush ? 6f : death ? 5.333f : 5f; + int type = ProjectileID.DeathLaser; + switch (calamityGlobalNPC.destroyerLaserColor) { + default: + case 0: + break; + + case 1: + type = ModContent.ProjectileType(); + break; + + case 2: + type = ModContent.ProjectileType(); + break; + } + int damage = npc.GetProjectileDamage(type); + + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } + + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; + int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4); + int spread = masterMode ? 38 : 26; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 100f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 1200; } } - } - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - npc.SyncExtraAI(); + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + npc.SyncExtraAI(); + } } } } - } - // Fire lasers - if (npc.type == NPCID.TheDestroyerBody) - { - bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; - - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) + // Fire lasers + if (npc.type == NPCID.TheDestroyerBody) { - if (Main.rand.NextBool(masterMode ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) + bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; + + // Set laser color and type + if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) { - int random = phase3 ? 4 : phase2 ? 3 : 2; - switch (Main.rand.Next(random)) + if (Main.rand.NextBool(masterMode ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) { - case 0: - case 1: - calamityGlobalNPC.destroyerLaserColor = 0; - break; - case 2: - calamityGlobalNPC.destroyerLaserColor = 1; - break; - case 3: + int random = phase3 ? 4 : phase2 ? 3 : 2; + switch (Main.rand.Next(random)) + { + case 0: + case 1: + calamityGlobalNPC.destroyerLaserColor = 0; + break; + case 2: + calamityGlobalNPC.destroyerLaserColor = 1; + break; + case 3: + calamityGlobalNPC.destroyerLaserColor = 2; + break; + } + + if (calamityGlobalNPC.newAI[2] > 0f || bossRush) calamityGlobalNPC.destroyerLaserColor = 2; - break; + + npc.SyncDestroyerLaserColor(); } + } - if (calamityGlobalNPC.newAI[2] > 0f || bossRush) - calamityGlobalNPC.destroyerLaserColor = 2; - + if (probeLaunched && ableToFireLaser) + { + calamityGlobalNPC.destroyerLaserColor = -1; npc.SyncDestroyerLaserColor(); } - } - if (probeLaunched && ableToFireLaser) - { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - } + // Laser rate of fire + float shootProjectileTime = death ? (masterMode ? (phase5 ? 120f : phase4 ? 150f : 180f) : 270f) : (masterMode ? (phase5 ? 150f : phase4 ? 210f : 270f) : 450f); + float bodySegmentTime = npc.ai[0] * (masterMode ? 20f : 30f); + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; + if (ableToFireLaser) + calamityGlobalNPC.newAI[0] += laserTimerIncrement; - // Laser rate of fire - float shootProjectileTime = death ? (masterMode ? (phase5 ? 30f : phase4 ? 60f : 90f) : 270f) : (masterMode ? (phase5 ? 90f : phase4 ? 120f : 150f) : 450f); - float bodySegmentTime = npc.ai[0] * (masterMode ? 15f : 30f); - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; - if (ableToFireLaser) - calamityGlobalNPC.newAI[0] += laserTimerIncrement; - - // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 0f && ableToFireLaser) - npc.SyncExtraAI(); - - Color telegraphColor = Color.Transparent; - switch (calamityGlobalNPC.destroyerLaserColor) - { - case 0: - telegraphColor = Color.Red; - break; - case 1: - telegraphColor = Color.Green; - break; - case 2: - telegraphColor = Color.Cyan; - break; - } - - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) - { - Particle telegraph = new DestroyerReticleTelegraph( - npc, - telegraphColor, - 1.5f, - 0.15f, - (int)LaserTelegraphTime); - GeneralParticleHandler.SpawnParticle(telegraph); - } - - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) - { - Particle spark = new DestroyerSparkTelegraph( - npc, - telegraphColor * 2f, - Color.White, - 3f, - 30, - Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); - GeneralParticleHandler.SpawnParticle(spark); - } - - // Shoot lasers - // Shoot nothing if probe has been launched - if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) - { - if (!masterMode) - { - int numProbeSegments = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) - numProbeSegments++; - } - float lerpAmount = MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f); - float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); - calamityGlobalNPC.newAI[0] = laserShootTimeBonus; + // Sync newAI every 20 frames for the new telegraph + if (calamityGlobalNPC.newAI[0] % 20f == 0f && ableToFireLaser) npc.SyncExtraAI(); - npc.TargetClosest(); + + Color telegraphColor = Color.Transparent; + switch (calamityGlobalNPC.destroyerLaserColor) + { + case 0: + telegraphColor = Color.Red; + break; + case 1: + telegraphColor = Color.Green; + break; + case 2: + telegraphColor = Color.Cyan; + break; } - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) { - if (masterMode) + Particle telegraph = new DestroyerReticleTelegraph( + npc, + telegraphColor, + 1.5f, + 0.15f, + (int)LaserTelegraphTime); + GeneralParticleHandler.SpawnParticle(telegraph); + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) + { + Particle spark = new DestroyerSparkTelegraph( + npc, + telegraphColor * 2f, + Color.White, + 3f, + 30, + Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); + GeneralParticleHandler.SpawnParticle(spark); + } + + // Shoot lasers + // Shoot nothing if probe has been launched + if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) + { + if (!masterMode) { int numProbeSegments = 0; for (int i = 0; i < Main.maxNPCs; i++) @@ -573,65 +552,80 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.TargetClosest(); } - // Laser speed - float projectileSpeed = (masterMode ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; - projectileSpeed += enrageScale; - - // Set projectile damage and type - int projectileType = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - default: - case 0: - break; + if (masterMode) + { + int numProbeSegments = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) + numProbeSegments++; + } + float lerpAmount = MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f); + float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); + calamityGlobalNPC.newAI[0] = laserShootTimeBonus; + npc.SyncExtraAI(); + npc.TargetClosest(); + } - case 1: - projectileType = ModContent.ProjectileType(); - break; + // Laser speed + float projectileSpeed = (masterMode ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; + projectileSpeed += enrageScale; - case 2: - projectileType = ModContent.ProjectileType(); - break; - } + // Set projectile damage and type + int projectileType = ProjectileID.DeathLaser; + switch (calamityGlobalNPC.destroyerLaserColor) + { + default: + case 0: + break; - // Get target vector - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; + case 1: + projectileType = ModContent.ProjectileType(); + break; - // Shoot projectile - int damage = npc.GetProjectileDamage(projectileType); + case 2: + projectileType = ModContent.ProjectileType(); + break; + } - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; - double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; - if (!NPC.downedMechBossAny) - damage = (int)(damage * firstMechMultiplier); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - damage = (int)(damage * secondMechMultiplier); - } + // Get target vector + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; + Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; + + // Shoot projectile + int damage = npc.GetProjectileDamage(projectileType); + + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } - if (Main.netMode != NetmodeID.MultiplayerClient) - { int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 1200; + + npc.netUpdate = true; + + if (masterMode) + { + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + } } - npc.netUpdate = true; - - if (masterMode) + if (!masterMode) { calamityGlobalNPC.destroyerLaserColor = -1; npc.SyncDestroyerLaserColor(); } } - - if (!masterMode) - { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - } } } @@ -800,7 +794,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Despawn bool oblivionWasAlive = npc.localAI[3] == 1f && !oblivionAlive; - bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.7f) || oblivionWasAlive; + bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.75f) || oblivionWasAlive; if (player.dead || oblivionFightDespawn) { shouldFly = false; @@ -1064,10 +1058,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Force the fucker to turn around in ground phase in Master + // Turns slower if Oblivion is alive, for fairness if (npc.type == NPCID.TheDestroyer && masterMode && !flyAtTarget) { if (npc.Distance(player.Center) > 2000f) - npc.velocity += (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + npc.velocity += (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * (oblivionAlive ? speed : turnSpeed); } if (NPC.IsMechQueenUp && npc.type == NPCID.TheDestroyer) @@ -1147,10 +1142,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 10 seconds of resistance to prevent spawn killing - if (npc.Calamity().newAI[1] < DRIncraeseTime) + if (npc.Calamity().newAI[1] < DRIncreaseTime) npc.Calamity().newAI[1] += 1f; - npc.Calamity().CurrentlyIncreasingDefenseOrDR = npc.Calamity().newAI[1] < DRIncraeseTime; + npc.Calamity().CurrentlyIncreasingDefenseOrDR = npc.Calamity().newAI[1] < DRIncreaseTime; if (npc.ai[3] > 0f) npc.realLife = (int)npc.ai[3]; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs index 043c31d6d7..b351e11655 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs @@ -396,9 +396,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set velocity for charge if (attackPicker == 1) { - // Set damage - npc.damage = setDamage; - npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -662,9 +659,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set velocity for charge if (phase2AttackPicker == 1) { - // Set damage - npc.damage = setDamage; - npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -976,9 +970,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set velocity for charge if (phase3AttackPicker == 1) { - // Set damage - npc.damage = setDamage; - npc.ai[0] = 11f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1600,10 +1591,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (num27) { case 1: - - // Set damage - npc.damage = setDamage; - npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1873,10 +1860,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (num32) { case 1: - - // Set damage - npc.damage = setDamage; - npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -2104,10 +2087,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (num37) { case 1: - - // Set damage - npc.damage = setDamage; - npc.ai[0] = 11f; npc.ai[1] = 0f; npc.ai[2] = 0f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index e5cef221aa..22922a5ce6 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -779,6 +779,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // 10 seconds of resistance to prevent spawn killing + if (npc.Calamity().newAI[1] < DRIncreaseTime) + npc.Calamity().newAI[1] += 1f; + npc.realLife = -1; if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs index 52a67431e5..a00ffc39e3 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs @@ -317,19 +317,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] == 60f) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - Projectile projectile = Main.projectile[i]; - if (projectile.active && (projectile.type == ProjectileID.MoonLeech || projectile.type == ProjectileID.PhantasmalBolt || + if ((projectile.type == ProjectileID.MoonLeech || projectile.type == ProjectileID.PhantasmalBolt || projectile.type == ProjectileID.PhantasmalDeathray || projectile.type == ProjectileID.PhantasmalEye || projectile.type == ProjectileID.PhantasmalSphere)) projectile.Kill(); } - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC3 in Main.ActiveNPCs) { - NPC nPC3 = Main.npc[j]; - if (nPC3.active && nPC3.type == NPCID.MoonLordFreeEye) + if (nPC3.type == NPCID.MoonLordFreeEye) { nPC3.HitEffect(0, 9999.0); nPC3.active = false; @@ -445,10 +443,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.HitEffect(0, 1337.0); npc.checkDead(); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC5 in Main.ActiveNPCs) { - NPC nPC5 = Main.npc[i]; - if (nPC5.active && (nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead)) + if (nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead) { nPC5.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -477,16 +474,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] == 40f) { - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile projectile2 in Main.ActiveProjectiles) { - Projectile projectile2 = Main.projectile[j]; - if (projectile2.active && (projectile2.type == ProjectileID.MoonLeech || projectile2.type == ProjectileID.PhantasmalBolt || + if ((projectile2.type == ProjectileID.MoonLeech || projectile2.type == ProjectileID.PhantasmalBolt || projectile2.type == ProjectileID.PhantasmalDeathray || projectile2.type == ProjectileID.PhantasmalEye || projectile2.type == ProjectileID.PhantasmalSphere)) { projectile2.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, j, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, projectile2.whoAmI, 0f, 0f, 0f, 0, 0, 0); } } @@ -511,10 +507,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= 60f) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC5 in Main.ActiveNPCs) { - NPC nPC5 = Main.npc[i]; - if (nPC5.active && (nPC5.type == NPCID.MoonLordFreeEye || nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead)) + if (nPC5.type == NPCID.MoonLordFreeEye || nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead) { nPC5.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -586,13 +581,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Main.npc[(int)npc.localAI[2]].netUpdate = true; } - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC7 in Main.ActiveNPCs) { - NPC nPC7 = Main.npc[i]; if (nPC7.active && nPC7.type == NPCID.MoonLordFreeEye) { - NPC nPC6 = nPC7; - nPC6.position += value8; + nPC7.position += value8; nPC7.netUpdate = true; } } @@ -844,32 +837,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (attackTimer == 0f && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 leechNPCCenter = npc.Center + leechCenterOffset; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player6 in Main.ActivePlayers) { - Player player6 = Main.player[i]; - if (player6.active && !player6.dead && Vector2.Distance(player6.Center, leechNPCCenter) <= 3000f) + if (!player6.dead && Vector2.Distance(player6.Center, leechNPCCenter) <= 3000f) { Vector2 targetLeechDist = Main.player[npc.target].Center - leechNPCCenter; if (targetLeechDist != Vector2.Zero) targetLeechDist.Normalize(); - Projectile.NewProjectile(npc.GetSource_FromAI(), leechNPCCenter.X, leechNPCCenter.Y, targetLeechDist.X, targetLeechDist.Y, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, npc.whoAmI + 1, i); + Projectile.NewProjectile(npc.GetSource_FromAI(), leechNPCCenter.X, leechNPCCenter.Y, targetLeechDist.X, targetLeechDist.Y, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, npc.whoAmI + 1, player6.whoAmI); } } } if ((attackTimer == 120f || attackTimer == 150f || attackTimer == 180f || attackTimer == 210f || attackTimer == 240f) && Main.netMode != NetmodeID.MultiplayerClient) { - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile projectile6 in Main.ActiveProjectiles) { - Projectile projectile6 = Main.projectile[j]; - if (projectile6.active && projectile6.type == ProjectileID.MoonLeech && Main.player[(int)projectile6.ai[1]].FindBuffIndex(BuffID.MoonLeech) != -1) + if (projectile6.type == ProjectileID.MoonLeech && Main.player[(int)projectile6.ai[1]].FindBuffIndex(BuffID.MoonLeech) != -1) { Vector2 targetCenter = Main.player[npc.target].Center; int moonLeech = NPC.NewNPC(npc.GetSource_FromAI(), (int)targetCenter.X, (int)targetCenter.Y, NPCID.MoonLordLeechBlob); Main.npc[moonLeech].netUpdate = true; Main.npc[moonLeech].ai[0] = npc.whoAmI + 1; - Main.npc[moonLeech].ai[1] = j; + Main.npc[moonLeech].ai[1] = projectile6.whoAmI; } } } @@ -1391,10 +1382,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } sphereVelocity *= velocity; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile currentProjectile in Main.ActiveProjectiles) { - Projectile currentProjectile = Main.projectile[i]; - if (currentProjectile.active && currentProjectile.type == ProjectileID.PhantasmalSphere && currentProjectile.ai[1] == npc.whoAmI && currentProjectile.ai[0] != -1f) + if (currentProjectile.type == ProjectileID.PhantasmalSphere && currentProjectile.ai[1] == npc.whoAmI && currentProjectile.ai[0] != -1f) { currentProjectile.ai[0] = -1f; currentProjectile.velocity = sphereVelocity; @@ -1597,26 +1587,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (eyeCount > 1) { int eyesSynced = 1; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active) + if (n.whoAmI != npc.whoAmI && n.type == npc.type) { - if (i != npc.whoAmI && Main.npc[i].type == npc.type) - { - Main.npc[i].ai[0] = 0f; - Main.npc[i].ai[1] = 0f; - Main.npc[i].ai[2] = 0f; - Main.npc[i].localAI[0] = 0f; - Main.npc[i].localAI[1] = 0f; - Main.npc[i].localAI[2] = 0f; - calamityGlobalNPC.newAI[0] = 1f; - calamityGlobalNPC.newAI[1] = 0f; - npc.netUpdate = true; + n.ai[0] = 0f; + n.ai[1] = 0f; + n.ai[2] = 0f; + n.localAI[0] = 0f; + n.localAI[1] = 0f; + n.localAI[2] = 0f; + calamityGlobalNPC.newAI[0] = 1f; + calamityGlobalNPC.newAI[1] = 0f; + npc.netUpdate = true; - eyesSynced++; - if (eyesSynced >= eyeCount) - break; - } + eyesSynced++; + if (eyesSynced >= eyeCount) + break; } } } @@ -1739,24 +1726,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Fly towards Moon Lord Head and stay away from other True Eyes float freeEyeAccel = 0.5f; - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].active) + if (n.whoAmI != npc.whoAmI && n.type == npc.type) { - if (j != npc.whoAmI && Main.npc[j].type == npc.type) + if (Vector2.Distance(npc.Center, n.Center) < 150f) { - if (Vector2.Distance(npc.Center, Main.npc[j].Center) < 150f) - { - if (npc.position.X < Main.npc[j].position.X) - npc.velocity.X = npc.velocity.X - freeEyeAccel; - else - npc.velocity.X = npc.velocity.X + freeEyeAccel; - - if (npc.position.Y < Main.npc[j].position.Y) - npc.velocity.Y = npc.velocity.Y - freeEyeAccel; - else - npc.velocity.Y = npc.velocity.Y + freeEyeAccel; - } + if (npc.position.X < n.position.X) + npc.velocity.X = npc.velocity.X - freeEyeAccel; + else + npc.velocity.X = npc.velocity.X + freeEyeAccel; + + if (npc.position.Y < n.position.Y) + npc.velocity.Y = npc.velocity.Y - freeEyeAccel; + else + npc.velocity.Y = npc.velocity.Y + freeEyeAccel; } } } @@ -1905,13 +1889,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity = Vector2.UnitY * -7f; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile trueEyeSpheres in Main.ActiveProjectiles) { - Projectile trueEyeSpheres = Main.projectile[i]; - if (trueEyeSpheres.active && trueEyeSpheres.type == type && trueEyeSpheres.ai[1] == npc.whoAmI && trueEyeSpheres.ai[0] != -1f) + if (trueEyeSpheres.type == type && trueEyeSpheres.ai[1] == npc.whoAmI && trueEyeSpheres.ai[0] != -1f) { - Projectile trueEyeSphereVel = trueEyeSpheres; - trueEyeSphereVel.velocity += npc.velocity; + trueEyeSpheres.velocity += npc.velocity; trueEyeSpheres.netUpdate = true; } } @@ -1937,10 +1919,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 trueEyeSphereVelocity = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; npc.velocity = trueEyeSphereVelocity * 2f; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile trueEyeSphereProj in Main.ActiveProjectiles) { - Projectile trueEyeSphereProj = Main.projectile[i]; - if (trueEyeSphereProj.active && trueEyeSphereProj.type == type && trueEyeSphereProj.ai[1] == npc.whoAmI && trueEyeSphereProj.ai[0] != -1f) + if (trueEyeSphereProj.type == type && trueEyeSphereProj.ai[1] == npc.whoAmI && trueEyeSphereProj.ai[0] != -1f) { trueEyeSphereProj.ai[0] = -1f; trueEyeSphereProj.damage = damage; @@ -2154,14 +2135,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int rightHandHeal = -1; int headHeal = headNPCType; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].ai[3] == k) + if (n.ai[3] == k) { - if (leftHandHeal == -1 && Main.npc[i].type == NPCID.MoonLordHand && Main.npc[i].ai[2] == 0f) - leftHandHeal = i; - if (rightHandHeal == -1 && Main.npc[i].type == NPCID.MoonLordHand && Main.npc[i].ai[2] == 1f) - rightHandHeal = i; + if (leftHandHeal == -1 && n.type == NPCID.MoonLordHand && n.ai[2] == 0f) + leftHandHeal = n.whoAmI; + if (rightHandHeal == -1 && n.type == NPCID.MoonLordHand && n.ai[2] == 1f) + rightHandHeal = n.whoAmI; if (leftHandHeal != -1 && rightHandHeal != -1 && headHeal != -1) break; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index 46854826d6..a7c993715b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -107,13 +107,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float hookPositionX = 0f; float hookPositionY = 0f; int numHooksSpawned = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].aiStyle == NPCAIStyleID.PlanteraHook) + if (n.aiStyle == NPCAIStyleID.PlanteraHook) { - hookPositionX += Main.npc[i].Center.X; - hookPositionY += Main.npc[i].Center.Y; - hookArray[numHooksSpawned] = i; + hookPositionX += n.Center.X; + hookPositionY += n.Center.Y; + hookArray[numHooksSpawned] = n.whoAmI; numHooksSpawned++; if (numHooksSpawned >= maxHooks) @@ -146,6 +146,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float maxVelocityX = Main.player[npc.target].Center.X - npcCenterAccountingForHooks.X; float maxVelocityY = Main.player[npc.target].Center.Y - npcCenterAccountingForHooks.Y; bool phase1MoveAway = !phase2 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 480f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + bool adjustProjectileShootLocation = Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 80f; if (despawn) { maxVelocityY *= -1f; @@ -238,7 +239,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); if (projectileType == ProjectileID.ThornBall && (Main.rand.NextBool() || !Main.zenithWorld)) Main.projectile[proj].tileCollide = false; } @@ -296,7 +297,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float ai0 = Main.rand.Next(3); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, projectileVelocity * randomSpeed, type, damage, 0f, Main.myPlayer, ai0); + Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * randomSpeed, type, damage, 0f, Main.myPlayer, ai0); } } @@ -355,7 +356,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); } } @@ -639,7 +640,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); } } } @@ -679,14 +680,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].aiStyle == NPCAIStyleID.PlanteraHook) + if (n.aiStyle == NPCAIStyleID.PlanteraHook) { for (int j = 0; j < totalTentacles / 2 - 1; j++) { int hookIndex = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasTentacle, npc.whoAmI); - Main.npc[hookIndex].ai[3] = i + 1; + Main.npc[hookIndex].ai[3] = n.whoAmI + 1; } } } @@ -947,9 +948,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set timer to new amount if a different hook is currently moving if (!despawn && npc.localAI[0] <= 0f && npc.ai[0] != 0f) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && (Main.npc[i].velocity.X != 0f || Main.npc[i].velocity.Y != 0f)) + if (n.whoAmI != npc.whoAmI && n.type == npc.type && (n.velocity.X != 0f || n.velocity.Y != 0f)) npc.localAI[0] = Main.rand.Next(60, 301); } } @@ -1286,6 +1287,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float num781 = Main.player[npc.target].Center.X - vector97.X; float num782 = Main.player[npc.target].Center.Y - vector97.Y; bool phase1MoveAway = npc.life > npc.lifeMax / 2 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 480f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + bool adjustProjectileShootLocation = Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 80f; if (flag40) { num782 *= -1f; @@ -1467,7 +1469,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses damage *= 2; Vector2 projectileVelocity = new Vector2(num789, num790); - int num794 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector99 + projectileVelocity.SafeNormalize(Vector2.UnitY) * 70f, projectileVelocity, type, damage, 0f, Main.myPlayer); + int num794 = Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? vector99 : vector99 + projectileVelocity.SafeNormalize(Vector2.UnitY) * 70f, projectileVelocity, type, damage, 0f, Main.myPlayer); if (type != ProjectileID.ThornBall) Main.projectile[num794].timeLeft = 300; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index 5a9e132aa1..0eb710efcb 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -368,7 +368,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // New location npc.Center = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); - npc.velocity = Vector2.Zero; + + // Do not set velocity to zero during charge attacks + if (npc.ai[1] != 1f) + npc.velocity = Vector2.Zero; + npc.ai[3] = -60f; calamityGlobalNPC.newAI[2] = calamityGlobalNPC.newAI[3] = 0f; npc.SyncExtraAI(); @@ -403,7 +407,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, damage, 0f, Main.myPlayer, -1f); Main.projectile[skullProjectile].timeLeft = 600; - if (masterMode) + if (masterMode && handsDead) { skullProjDirection = new Vector2(skullProjTargetX, skullProjTargetY).SafeNormalize(Vector2.UnitY); skullProjDirection *= skullProjSpeed * 2f; @@ -424,6 +428,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[1] += 1f; float chargePhaseChangeRateBoost = phase5 ? (death ? 24f : 14f) : phase4 ? (death ? 8f : 6f) : (((masterMode && death) ? 6f : 4f) * ((1f - lifeRatio) / (1f - phase4LifeRatio))); + if (!handsDead) + chargePhaseChangeRateBoost *= 0.5f; + float chargePhaseChangeRate = chargePhaseChangeRateBoost + 1f; npc.ai[2] += chargePhaseChangeRate; npc.localAI[1] += chargePhaseChangeRate; @@ -953,6 +960,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] != 0f || cancelSlap) { + deceleration *= 0.75f; + velocityIncrement *= 1.5f; + float maxX = velocityIncrement * 100f * velocityMultiplier; float maxY = velocityIncrement * 100f * velocityMultiplier; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs index a062ee9db8..96febd4b2a 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs @@ -49,6 +49,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { int head = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); Main.npc[head].ai[0] = npc.whoAmI; + Main.npc[head].target = npc.target; Main.npc[head].netUpdate = true; npc.ai[0] = head; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index 9391dd89e0..7f270bebca 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -129,7 +129,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Phase HP ratios - float phase2LifeRatio = masterMode ? 0.85f : 0.7f; + float phase2LifeRatio = oblivionAlive ? 0.5f : masterMode ? 0.85f : 0.7f; float finalPhaseLifeRatio = masterMode ? 0.4f : 0.25f; // Movement variables @@ -170,7 +170,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Despawn bool oblivionWasAlive = npc.localAI[3] == 1f && !oblivionAlive; - bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.7f) || oblivionWasAlive || (oblivionAlive && !spazAlive && lifeRatio < 0.9f); + bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.75f) || oblivionWasAlive || (oblivionAlive && !spazAlive && lifeRatio < 0.95f); if (Main.player[npc.target].dead || oblivionFightDespawn) { npc.velocity.Y -= 0.04f; @@ -1108,7 +1108,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Phase HP ratios - float phase2LifeRatio = masterMode ? 0.85f : 0.7f; + float phase2LifeRatio = oblivionAlive ? 0.5f : masterMode ? 0.85f : 0.7f; float finalPhaseLifeRatio = masterMode ? 0.4f : 0.25f; // Movement variables @@ -1151,7 +1151,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Despawn bool oblivionWasAlive = npc.localAI[3] == 1f && !oblivionAlive; - bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.7f) || oblivionWasAlive || (oblivionAlive && !retAlive && lifeRatio < 0.9f); + bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.75f) || oblivionWasAlive || (oblivionAlive && !retAlive && lifeRatio < 0.95f); if (Main.player[npc.target].dead || oblivionFightDespawn) { npc.velocity.Y -= 0.04f; diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs index afeb4c188e..b8d7686a30 100644 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs @@ -1169,11 +1169,11 @@ PrepareToShoot: int nailCount = Main.rand.Next(3, 6); int[] players = new int[nailCount]; int i = 0; - for (int j = 0; j < Main.player.Length; j++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[j].active && !Main.player[j].dead && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[j].position, Main.player[j].width, Main.player[j].height)) + if (!plr.dead && Collision.CanHitLine(npc.position, npc.width, npc.height, plr.position, plr.width, plr.height)) { - players[i] = j; + players[i] = plr.whoAmI; i++; if (i == nailCount) { @@ -1975,9 +1975,9 @@ PrepareToShoot: { npc.hide = false; // I'd assume the Drakomire is drawn by the rider if it's present - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].type == NPCID.SolarDrakomireRider && Main.npc[i].ai[0] == (float)npc.whoAmI) + if (n.type == NPCID.SolarDrakomireRider && n.ai[0] == (float)npc.whoAmI) { npc.hide = true; break; @@ -2077,11 +2077,11 @@ PrepareToShoot: dust.customData = npc; } // Adjust velocity based on the other storm drivers who want to pump your face full of bullets - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npcType && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) + if (n.whoAmI != npc.whoAmI && n.type == npcType && Math.Abs(npc.position.X - n.position.X) + Math.Abs(npc.position.Y - n.position.Y) < (float)npc.width) { - if (npc.position.X < Main.npc[i].position.X) + if (npc.position.X < n.position.X) { npc.velocity.X -= 0.05f; } @@ -2089,7 +2089,7 @@ PrepareToShoot: { npc.velocity.X += 0.05f; } - if (npc.position.Y < Main.npc[i].position.Y) + if (npc.position.Y < n.position.Y) { npc.velocity.Y -= 0.05f; } @@ -2184,11 +2184,11 @@ PrepareToShoot: npc.velocity.Y += 0.25f; } } - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npcType && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) + if (n.whoAmI != npc.whoAmI && n.type == npcType && Math.Abs(npc.position.X - n.position.X) + Math.Abs(npc.position.Y - n.position.Y) < (float)npc.width) { - if (npc.position.X < Main.npc[i].position.X) + if (npc.position.X < n.position.X) { npc.velocity.X -= 0.05f; } @@ -2196,7 +2196,7 @@ PrepareToShoot: { npc.velocity.X += 0.05f; } - if (npc.position.Y < Main.npc[i].position.Y) + if (npc.position.Y < n.position.Y) { npc.velocity.Y -= 0.05f; } @@ -2260,11 +2260,11 @@ PrepareToShoot: { npc.velocity.Y = -8f; } - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npcType && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) + if (n.whoAmI != npc.whoAmI && n.type == npcType && Math.Abs(npc.position.X - n.position.X) + Math.Abs(npc.position.Y - n.position.Y) < (float)npc.width) { - if (npc.position.X < Main.npc[i].position.X) + if (npc.position.X < n.position.X) { npc.velocity.X -= 0.1f; } @@ -2272,7 +2272,7 @@ PrepareToShoot: { npc.velocity.X += 0.1f; } - if (npc.position.Y < Main.npc[i].position.Y) + if (npc.position.Y < n.position.Y) { npc.velocity.Y -= 0.1f; } @@ -7592,11 +7592,11 @@ PrepareToShoot: { turnAroundDelayMult = 3; bool noYVelocity = npc.velocity.Y == 0f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) + if (n.whoAmI != npc.whoAmI && n.type == npc.type && Math.Abs(npc.position.X - n.position.X) + Math.Abs(npc.position.Y - n.position.Y) < (float)npc.width) { - if (npc.position.X < Main.npc[i].position.X) + if (npc.position.X < n.position.X) { npc.velocity.X -= 0.05f; } @@ -7604,7 +7604,7 @@ PrepareToShoot: { npc.velocity.X += 0.05f; } - if (npc.position.Y < Main.npc[i].position.Y) + if (npc.position.Y < n.position.Y) { npc.velocity.Y -= 0.05f; } @@ -7661,9 +7661,9 @@ PrepareToShoot: bool spawnTwinkle = npc.ai[1] >= (CalamityWorld.death ? 60f : 120f); if (!spawnTwinkle && npc.velocity.Y == 0f) { - for (int j = 0; j < Main.maxPlayers; j++) + foreach (Player plr in Main.ActivePlayers) { - if (Main.player[j].active && !Main.player[j].dead && Main.player[j].Distance(npc.Center) < 800f && Main.player[j].Center.Y < npc.Center.Y && Math.Abs(Main.player[j].Center.X - npc.Center.X) < 20f) + if (!plr.dead && plr.Distance(npc.Center) < 800f && plr.Center.Y < npc.Center.Y && Math.Abs(plr.Center.X - npc.Center.X) < 20f) { spawnTwinkle = true; break; @@ -10704,19 +10704,19 @@ PrepareToShoot: npc.noTileCollide = true; npc.knockBackResist = 0f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i == npc.whoAmI || !Main.npc[i].active || Main.npc[i].type != npc.type) + if (n.whoAmI == npc.whoAmI || n.type != npc.type) continue; - Vector2 targetDirection = Main.npc[i].Center - npc.Center; + Vector2 targetDirection = n.Center - npc.Center; if (!(targetDirection.Length() < 50f)) continue; targetDirection.Normalize(); if (targetDirection.X == 0f && targetDirection.Y == 0f) { - if (i > npc.whoAmI) + if (n.whoAmI > npc.whoAmI) targetDirection.X = 1f; else targetDirection.X = -1f; @@ -10724,8 +10724,7 @@ PrepareToShoot: targetDirection *= 0.4f; npc.velocity -= targetDirection; - NPC nPC = Main.npc[i]; - nPC.velocity += targetDirection; + n.velocity += targetDirection; } if (npc.type == NPCID.ShadowFlameApparition) diff --git a/NPCs/Yharon/YScreenShader.cs b/NPCs/Yharon/YScreenShader.cs index af5d55aaed..f7f3cf9e44 100644 --- a/NPCs/Yharon/YScreenShader.cs +++ b/NPCs/Yharon/YScreenShader.cs @@ -23,15 +23,7 @@ namespace CalamityMod.NPCs.Yharon { return; } - YIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == YType) - { - YIndex = i; - break; - } - } + YIndex = NPC.FindFirstNPC(YType); } public override void Update(GameTime gameTime) diff --git a/NPCs/Yharon/YSky.cs b/NPCs/Yharon/YSky.cs index bb673e8253..c033a023ce 100644 --- a/NPCs/Yharon/YSky.cs +++ b/NPCs/Yharon/YSky.cs @@ -60,15 +60,7 @@ namespace CalamityMod.NPCs.Yharon { return true; } - YIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == YType) - { - YIndex = i; - break; - } - } + YIndex = NPC.FindFirstNPC(YType); //this.DoGIndex = DoGIndex; return YIndex != -1; } diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 979ac62f3b..400fdceecb 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -596,9 +596,6 @@ namespace CalamityMod.NPCs.Yharon if (aiState == 1) { - // Set damage - NPC.damage = setDamage; - NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; @@ -640,9 +637,6 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - // Set damage - NPC.damage = setDamage; - if (playFastChargeRoarSound) RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); @@ -886,9 +880,6 @@ namespace CalamityMod.NPCs.Yharon if (aiState == 1) { - // Set damage - NPC.damage = setDamage; - NPC.ai[0] = 7f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; @@ -977,9 +968,6 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - // Set damage - NPC.damage = setDamage; - if (playFastChargeRoarSound) RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); @@ -1263,9 +1251,6 @@ namespace CalamityMod.NPCs.Yharon if (aiState == 1) { - // Set damage - NPC.damage = setDamage; - NPC.ai[0] = 14f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; @@ -1354,9 +1339,6 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - // Set damage - NPC.damage = setDamage; - if (playFastChargeRoarSound) RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); @@ -2015,9 +1997,6 @@ namespace CalamityMod.NPCs.Yharon if (phase2AttackType == 5 && NPC.ai[1] < phaseSwitchTimer + teleportPhaseTimer) { - // Avoid cheap bullshit - NPC.damage = 0; - float newRotation = NPC.AngleTo(targetData.Center); float amount = 0.04f; @@ -2082,9 +2061,6 @@ namespace CalamityMod.NPCs.Yharon if (phase2AttackType == 7 && doFastChargeTelegraph) { - // Avoid cheap bullshit - NPC.damage = 0; - float newRotation = NPC.AngleTo(targetData.Center); float amount = 0.04f; @@ -2161,9 +2137,6 @@ namespace CalamityMod.NPCs.Yharon { case 2: // Charge { - // Set damage - NPC.damage = setDamage; - Vector2 vector = NPC.SafeDirectionTo(targetData.Center, Vector2.UnitX * NPC.spriteDirection); NPC.spriteDirection = (vector.X > 0f) ? 1 : -1; NPC.rotation = vector.ToRotation(); @@ -2196,9 +2169,6 @@ namespace CalamityMod.NPCs.Yharon case 7: // Fast charge { - // Set damage - NPC.damage = setDamage; - Vector2 vector = NPC.SafeDirectionTo(targetData.Center, Vector2.UnitX * NPC.spriteDirection); NPC.spriteDirection = (vector.X > 0f) ? 1 : -1; NPC.rotation = vector.ToRotation(); diff --git a/Particles/BloodParticle.cs b/Particles/BloodParticle.cs index 9bb8333486..bfe3e02e8f 100644 --- a/Particles/BloodParticle.cs +++ b/Particles/BloodParticle.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Particles @@ -31,6 +32,11 @@ namespace CalamityMod.Particles Velocity.Y = MathHelper.Clamp(Velocity.Y + 0.9f, -22f, 22f); Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + // Cycle through disco colors if blood and gore is off + if (!ChildSafety.Disabled) + { + Color = Main.DiscoColor; + } } public override void CustomDraw(SpriteBatch spriteBatch) diff --git a/Particles/BloodParticle2.cs b/Particles/BloodParticle2.cs index ee8b9bf707..53320c9c1b 100644 --- a/Particles/BloodParticle2.cs +++ b/Particles/BloodParticle2.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Particles @@ -29,6 +30,11 @@ namespace CalamityMod.Particles Velocity *= 0.98f; Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 4D)); Rotation = Velocity.ToRotation(); + // Cycle through disco colors if blood and gore is off + if (!ChildSafety.Disabled) + { + Color = Main.DiscoColor; + } } public override void CustomDraw(SpriteBatch spriteBatch) diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs index 847d09ec5d..ca12e9cbd7 100644 --- a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -171,7 +172,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// public virtual void KillHoldoutLogic() { - if (Owner.CantUseHoldout() || HeldItem.type != AssociatedItemID) + if (Owner.CantUseHoldout()) { Projectile.netUpdate = true; Projectile.Kill(); @@ -246,5 +247,39 @@ namespace CalamityMod.Projectiles.BaseProjectiles } #endregion + + #region Syncing + + public sealed override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.rotation); + writer.Write(KeepRefreshingLifetime); + writer.Write(OffsetLengthFromArm); + SendExtraAIHoldout(writer); + } + + public sealed override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + KeepRefreshingLifetime = reader.ReadBoolean(); + OffsetLengthFromArm = reader.ReadSingle(); + ReceiveExtraAIHoldout(reader); + } + + /// + /// The common is sealed to avoid deleting syncing of other properties without noticing.
+ /// Use this method instead, which uses the same . + ///
+ /// + public virtual void SendExtraAIHoldout(BinaryWriter writer) { } + + /// + /// The common is sealed to avoid deleting syncing of other properties without noticing.
+ /// Use this method instead, which uses the same . + ///
+ /// + public virtual void ReceiveExtraAIHoldout(BinaryReader reader) { } + + #endregion } } diff --git a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs index fa73780b80..34d117b2e6 100644 --- a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs @@ -51,9 +51,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles bool bladeIsPresent = false; int holdoutType = ItemProjectileRelationship[itemID]; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != holdoutType || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) + if (p.type != holdoutType || p.owner != player.whoAmI) continue; bladeIsPresent = true; diff --git a/Projectiles/Boss/AresTeslaOrb.cs b/Projectiles/Boss/AresTeslaOrb.cs index cec82cf781..3ccee65e4c 100644 --- a/Projectiles/Boss/AresTeslaOrb.cs +++ b/Projectiles/Boss/AresTeslaOrb.cs @@ -155,15 +155,15 @@ namespace CalamityMod.Projectiles.Boss bool expertMode = Main.expertMode || bossRush; float detachDistance = bossRush ? 1600f : death ? 1360f : revenge ? 1280f : expertMode ? 1200f : 960f; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != Projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active || Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays) + if (p.type != Projectile.type || p.ai[0] != Identity + 1f || Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays) continue; - if (Vector2.Distance(Projectile.Center, Main.projectile[i].Center) > detachDistance) + if (Vector2.Distance(Projectile.Center, p.Center) > detachDistance) continue; - return Main.projectile[i]; + return p; } return null; diff --git a/Projectiles/Boss/Basketball.png b/Projectiles/Boss/Basketball.png new file mode 100644 index 0000000000..e090379e6f Binary files /dev/null and b/Projectiles/Boss/Basketball.png differ diff --git a/Projectiles/Boss/DesertScourgeDiveSplash.cs b/Projectiles/Boss/DesertScourgeDiveSplash.cs new file mode 100644 index 0000000000..39d9946a5f --- /dev/null +++ b/Projectiles/Boss/DesertScourgeDiveSplash.cs @@ -0,0 +1,50 @@ +using System; +using System.IO; +using CalamityMod.Dusts; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DesertScourgeDiveSplash : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 14; + } + + public override void SetDefaults() + { + Projectile.width = 84; + Projectile.height = 84; + Projectile.hostile = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + } + + public override void AI() + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame >= Main.projFrames[Projectile.type]) + Projectile.Kill(); + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor); + return false; + } + } +} diff --git a/Projectiles/Boss/DesertScourgeDiveSplash.png b/Projectiles/Boss/DesertScourgeDiveSplash.png new file mode 100644 index 0000000000..cbb230d694 Binary files /dev/null and b/Projectiles/Boss/DesertScourgeDiveSplash.png differ diff --git a/Projectiles/Boss/DesertScourgeSpit.cs b/Projectiles/Boss/DesertScourgeSpit.cs index a73e39caac..66d6e6d8e8 100644 --- a/Projectiles/Boss/DesertScourgeSpit.cs +++ b/Projectiles/Boss/DesertScourgeSpit.cs @@ -89,7 +89,6 @@ namespace CalamityMod.Projectiles.Boss Main.dust[killSand].noLight = true; Main.dust[killSand].velocity = dustDirection * 0.5f; } - Projectile.Damage(); } public override void OnHitPlayer(Player target, Player.HurtInfo info) diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index 9039baeaf1..a77545e689 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -80,24 +80,21 @@ namespace CalamityMod.Projectiles.Boss return; float acceleration = 0.5f; - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active) + if (p.whoAmI != Projectile.whoAmI && p.type == Projectile.type) { - if (j != Projectile.whoAmI && Main.projectile[j].type == Projectile.type) + if (Vector2.Distance(Projectile.Center, p.Center) < 24f) { - if (Vector2.Distance(Projectile.Center, Main.projectile[j].Center) < 24f) - { - if (Projectile.position.X < Main.projectile[j].position.X) - Projectile.velocity.X -= acceleration; - else - Projectile.velocity.X += acceleration; - - if (Projectile.position.Y < Main.projectile[j].position.Y) - Projectile.velocity.Y -= acceleration; - else - Projectile.velocity.Y += acceleration; - } + if (Projectile.position.X < p.position.X) + Projectile.velocity.X -= acceleration; + else + Projectile.velocity.X += acceleration; + + if (Projectile.position.Y < p.position.Y) + Projectile.velocity.Y -= acceleration; + else + Projectile.velocity.Y += acceleration; } } } diff --git a/Projectiles/Boss/OldDukeVortex.cs b/Projectiles/Boss/OldDukeVortex.cs index 02f6b1d5a7..f2c1fd5171 100644 --- a/Projectiles/Boss/OldDukeVortex.cs +++ b/Projectiles/Boss/OldDukeVortex.cs @@ -124,10 +124,8 @@ namespace CalamityMod.Projectiles.Boss float distanceRequired = 800f * Projectile.scale; float succPower = Main.zenithWorld ? 1f : 0.5f; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { - Player player = Main.player[i]; - float distance = Vector2.Distance(player.Center, Projectile.Center); if (distance < distanceRequired && player.grappling[0] == -1) { diff --git a/Projectiles/Boss/OverlyDramaticDukeSummoner.cs b/Projectiles/Boss/OverlyDramaticDukeSummoner.cs index d9f506ba87..53510f205b 100644 --- a/Projectiles/Boss/OverlyDramaticDukeSummoner.cs +++ b/Projectiles/Boss/OverlyDramaticDukeSummoner.cs @@ -107,9 +107,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.alpha = (int)MathHelper.Lerp(0f, 255f, (Projectile.ai[0] - 600f) / 120f); bool canSpawnBoomer = false; - for (int i = 0; i < Main.player.Length; i++) + foreach (Player player in Main.ActivePlayers) { - if (!Main.player[i].dead && Projectile.Distance(Main.player[i].Center) < 12000f) + if (!player.dead && Projectile.Distance(player.Center) < 12000f) { canSpawnBoomer = true; break; diff --git a/Projectiles/Boss/SupremeCataclysmFist.cs b/Projectiles/Boss/SupremeCataclysmFist.cs index 5e630ed544..c6aa6cdf6c 100644 --- a/Projectiles/Boss/SupremeCataclysmFist.cs +++ b/Projectiles/Boss/SupremeCataclysmFist.cs @@ -51,98 +51,147 @@ namespace CalamityMod.Projectiles.Boss // The Orb if (Projectile.ai[2] >= 3) { - if (Projectile.timeLeft > 240) + if (Main.zenithWorld) { - shootVel = Projectile.velocity * 0.4f; - Projectile.timeLeft = 240; - rotDirection = Main.rand.NextBool() ? -1 : 1; - Projectile.velocity *= 5.5f; - broIsAlive = NPC.AnyNPCs(ModContent.NPCType()); + if (Projectile.timeLeft > 400) + { + shootVel = Projectile.velocity * 0.4f; + Projectile.timeLeft = 400; + rotDirection = Main.rand.NextBool() ? -1 : 1; + Projectile.velocity *= 6f; + broIsAlive = NPC.AnyNPCs(ModContent.NPCType()); + } + else + { + if (Time > 10) + Projectile.tileCollide = true; + else + Projectile.velocity *= 0.99f; + Projectile.rotation += 0.02f; + } + + if (Projectile.timeLeft == 1) + { + int points = 25; + float radians = MathHelper.TwoPi / points; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-4f, -4f)); + for (int b = 0; b < 2; b++) + { + float rotRando = Main.rand.NextFloat(0.1f, 2.5f); + for (int k = 0; k < points; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f * rotRando); + + Dust cataclysmdust = Dust.NewDustPerfect(Projectile.Center + velocity * (b == 0 ? 7 : 5), 279, velocity * (b == 0 ? 9 : 7)); + cataclysmdust.noGravity = true; + cataclysmdust.scale = Main.rand.NextFloat(1.3f, 1.9f); + cataclysmdust.color = Color.Red; + } + } + Projectile.Kill(); + } + + Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); + Dust cataclysmdust2 = Dust.NewDustPerfect(Projectile.Center + vel * 2, 279, vel); + cataclysmdust2.noGravity = true; + cataclysmdust2.scale = Main.rand.NextFloat(0.9f, 1.2f); + cataclysmdust2.color = Color.Red; } else { - float randSize = Main.rand.NextFloat(0.8f, 1.2f); - for (int i = 0; i < 2; i++) + if (Projectile.timeLeft > 240) { - Particle bloom = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.Red, Color.Magenta, 0.5f), "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 1.7f * randSize, 0f, 10); - GeneralParticleHandler.SpawnParticle(bloom); + shootVel = Projectile.velocity * 0.4f; + Projectile.timeLeft = 240; + rotDirection = Main.rand.NextBool() ? -1 : 1; + Projectile.velocity *= 5.5f; + broIsAlive = NPC.AnyNPCs(ModContent.NPCType()); } - Particle bloom3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White * 0.9f, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 1.4f * randSize, 0f, 10); - GeneralParticleHandler.SpawnParticle(bloom3); - - Projectile.velocity *= 0.945f; - } - - // Adds rotation, but it's SUPER unfair a lot of the time - //shootVel = shootVel.RotatedBy(Time * 0.00011f * rotDirection); - - - if (Projectile.timeLeft == 205) // Fist direction telegraphs - { - for (int k = 0; k < 28; k++) + else { - Vector2 vel1 = -shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f); - GlowSparkParticle spark = new GlowSparkParticle(Projectile.Center + vel1 * (9 + k * 11), vel1, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false); - GeneralParticleHandler.SpawnParticle(spark); + float randSize = Main.rand.NextFloat(0.8f, 1.2f); + for (int i = 0; i < 2; i++) + { + Particle bloom = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.Red, Color.Magenta, 0.5f), "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 1.7f * randSize, 0f, 10); + GeneralParticleHandler.SpawnParticle(bloom); + } + Particle bloom3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White * 0.9f, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 1.4f * randSize, 0f, 10); + GeneralParticleHandler.SpawnParticle(bloom3); + + Projectile.velocity *= 0.945f; } - if (broIsAlive == false) + + // Adds rotation, but it's SUPER unfair a lot of the time + //shootVel = shootVel.RotatedBy(Time * 0.00011f * rotDirection); + + + if (Projectile.timeLeft == 205) // Fist direction telegraphs { for (int k = 0; k < 28; k++) { - Vector2 vel2 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(120f)); - GlowSparkParticle spark2 = new GlowSparkParticle(Projectile.Center + vel2 * (9 + k * 11), vel2, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false); - GeneralParticleHandler.SpawnParticle(spark2); + Vector2 vel1 = -shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f); + GlowSparkParticle spark = new GlowSparkParticle(Projectile.Center + vel1 * (9 + k * 11), vel1, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false); + GeneralParticleHandler.SpawnParticle(spark); } - for (int k = 0; k < 28; k++) + if (broIsAlive == false) { - Vector2 vel3 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(-120f)); - GlowSparkParticle spark3 = new GlowSparkParticle(Projectile.Center + vel3 * (9 + k * 11), vel3, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false); - GeneralParticleHandler.SpawnParticle(spark3); + for (int k = 0; k < 28; k++) + { + Vector2 vel2 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(120f)); + GlowSparkParticle spark2 = new GlowSparkParticle(Projectile.Center + vel2 * (9 + k * 11), vel2, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false); + GeneralParticleHandler.SpawnParticle(spark2); + } + for (int k = 0; k < 28; k++) + { + Vector2 vel3 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(-120f)); + GlowSparkParticle spark3 = new GlowSparkParticle(Projectile.Center + vel3 * (9 + k * 11), vel3, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false); + GeneralParticleHandler.SpawnParticle(spark3); + } } } - } - if (Projectile.timeLeft <= 200 && Time % 3 == 0) - { - Vector2 randPos = (-shootVel * 1.5f).RotatedByRandom(1) * Main.rand.NextFloat(5, 15); - int type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SupremeCalamitas.BrimstoneShotSound with { Volume = 1.2f, Pitch = 0.55f }, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0); - } - if (Projectile.timeLeft <= 200 && Time % 3 == 0 && broIsAlive == false) - { - Vector2 randPos = (-shootVel * 1.5f).RotatedBy(MathHelper.ToRadians(120f)).RotatedByRandom(1) * Main.rand.NextFloat(5, 15); - Vector2 randPos2 = (-shootVel * 1.5f).RotatedBy(MathHelper.ToRadians(-120f)).RotatedByRandom(1) * Main.rand.NextFloat(5, 15); - int type = ModContent.ProjectileType(); - Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)).RotatedBy(MathHelper.ToRadians(120f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0); - Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos2, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)).RotatedBy(MathHelper.ToRadians(-120f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0); - } - if (Projectile.timeLeft == 1) - { - int points = 25; - float radians = MathHelper.TwoPi / points; - Vector2 spinningPoint = Vector2.Normalize(new Vector2(-4f, -4f)); - for (int b = 0; b < 2; b++) + if (Projectile.timeLeft <= 200 && Time % 3 == 0) { - float rotRando = Main.rand.NextFloat(0.1f, 2.5f); - for (int k = 0; k < points; k++) - { - Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f * rotRando); - - Dust cataclysmdust = Dust.NewDustPerfect(Projectile.Center + velocity * (b == 0 ? 7 : 5), 279, velocity * (b == 0 ? 9 : 7)); - cataclysmdust.noGravity = true; - cataclysmdust.scale = Main.rand.NextFloat(1.3f, 1.9f); - cataclysmdust.color = Color.Red; - } + Vector2 randPos = (-shootVel * 1.5f).RotatedByRandom(1) * Main.rand.NextFloat(5, 15); + int type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SupremeCalamitas.BrimstoneShotSound with { Volume = 1.2f, Pitch = 0.55f }, Projectile.Center); + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0); } - Projectile.Kill(); - } + if (Projectile.timeLeft <= 200 && Time % 3 == 0 && broIsAlive == false) + { + Vector2 randPos = (-shootVel * 1.5f).RotatedBy(MathHelper.ToRadians(120f)).RotatedByRandom(1) * Main.rand.NextFloat(5, 15); + Vector2 randPos2 = (-shootVel * 1.5f).RotatedBy(MathHelper.ToRadians(-120f)).RotatedByRandom(1) * Main.rand.NextFloat(5, 15); + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)).RotatedBy(MathHelper.ToRadians(120f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0); + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos2, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)).RotatedBy(MathHelper.ToRadians(-120f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0); + } + if (Projectile.timeLeft == 1) + { + int points = 25; + float radians = MathHelper.TwoPi / points; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-4f, -4f)); + for (int b = 0; b < 2; b++) + { + float rotRando = Main.rand.NextFloat(0.1f, 2.5f); + for (int k = 0; k < points; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f * rotRando); - Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); - Dust cataclysmdust2 = Dust.NewDustPerfect(Projectile.Center + vel * 2, 279, vel); - cataclysmdust2.noGravity = true; - cataclysmdust2.scale = Main.rand.NextFloat(0.9f, 1.2f); - cataclysmdust2.color = Color.Red; + Dust cataclysmdust = Dust.NewDustPerfect(Projectile.Center + velocity * (b == 0 ? 7 : 5), 279, velocity * (b == 0 ? 9 : 7)); + cataclysmdust.noGravity = true; + cataclysmdust.scale = Main.rand.NextFloat(1.3f, 1.9f); + cataclysmdust.color = Color.Red; + } + } + Projectile.Kill(); + } + + Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); + Dust cataclysmdust2 = Dust.NewDustPerfect(Projectile.Center + vel * 2, 279, vel); + cataclysmdust2.noGravity = true; + cataclysmdust2.scale = Main.rand.NextFloat(0.9f, 1.2f); + cataclysmdust2.color = Color.Red; + } } else if (Projectile.ai[2] <= 2) { @@ -165,6 +214,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.velocity *= 1.006f; } + if (Main.zenithWorld && Projectile.ai[2] >= 3) + return; + if (Projectile.velocity.X < 0f) { Projectile.spriteDirection = -1; @@ -187,7 +239,7 @@ namespace CalamityMod.Projectiles.Boss Time++; - if (NPC.AnyNPCs(ModContent.NPCType()) == false) + if (NPC.AnyNPCs(ModContent.NPCType()) == false && !Main.zenithWorld) { Projectile.timeLeft = 1; for (int k = 0; k < 10; k++) @@ -207,6 +259,13 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { + if (Main.zenithWorld && Projectile.ai[2] >= 3) + { + Texture2D ballTexture = ModContent.Request("CalamityMod/Projectiles/Boss/Basketball").Value; + Main.EntitySpriteDraw(ballTexture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, ballTexture.Size() * 0.5f, Projectile.scale / 1.8f, SpriteEffects.None, 0); + return false; + } + lightColor.R = (byte)(255 * Projectile.Opacity); SpriteEffects direction = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; @@ -229,6 +288,21 @@ namespace CalamityMod.Projectiles.Boss target.AddBuff(ModContent.BuffType(), 240, true); } + public override bool OnTileCollide(Vector2 oldVelocity) + { + SoundStyle b = new("CalamityMod/Sounds/Custom/Kickball"); + SoundEngine.PlaySound(b with { PitchVariance = 0.15f }, Projectile.Center); + + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, (Projectile.ai[2] >= 3 ? 90 : 35 * Projectile.scale), targetHitbox); } } diff --git a/Projectiles/Boss/SupremeCatastropheSlash.cs b/Projectiles/Boss/SupremeCatastropheSlash.cs index d875f0742a..9048168f99 100644 --- a/Projectiles/Boss/SupremeCatastropheSlash.cs +++ b/Projectiles/Boss/SupremeCatastropheSlash.cs @@ -175,7 +175,7 @@ namespace CalamityMod.Projectiles.Boss } } - if (NPC.AnyNPCs(ModContent.NPCType()) == false) + if (NPC.AnyNPCs(ModContent.NPCType()) == false && !Main.zenithWorld) { Projectile.timeLeft = 1; for (int k = 0; k < 10; k++) diff --git a/Projectiles/Boss/ThornBallSpike.cs b/Projectiles/Boss/ThornBallSpike.cs index f3db9317e9..86d5b8d957 100644 --- a/Projectiles/Boss/ThornBallSpike.cs +++ b/Projectiles/Boss/ThornBallSpike.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.velocity.Length() < MaxVelocity) { - Projectile.velocity *= 1.05f; + Projectile.velocity *= 1.045f; if (Projectile.velocity.Length() > MaxVelocity) { Projectile.velocity.Normalize(); @@ -58,6 +58,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Venom, 90); + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); + public override bool PreDraw(ref Color lightColor) { if (Projectile.timeLeft > TimeLeft - 5) diff --git a/Projectiles/Boss/ThornBallSpike.png b/Projectiles/Boss/ThornBallSpike.png index a1be17ccd9..9253275e89 100644 Binary files a/Projectiles/Boss/ThornBallSpike.png and b/Projectiles/Boss/ThornBallSpike.png differ diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 5ac6a49d8b..45f9f892d1 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -3587,17 +3587,17 @@ namespace CalamityMod.Projectiles float maxDistance = 460f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(projectile, false)) + if (n.CanBeChasedBy(projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (Main.npc[i].height / 2); + float extraDistance = (float)(n.width / 2) + (n.height / 2); - bool canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); + bool canHit = Collision.CanHit(projectile.Center, 1, 1, n.Center, 1, 1); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + if (Vector2.Distance(n.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } @@ -4390,15 +4390,15 @@ namespace CalamityMod.Projectiles if (projectile.type == ProjectileID.ThornBall) { - float startTurningBrownGateValue = 420f; - float timeToReachFullBrown = 180f; - float timeToReachThornExplosion = startTurningBrownGateValue + timeToReachFullBrown; + float startWarningColorGateValue = 420f; + float timeToReachFullIntensity = 180f; + float timeToReachThornExplosion = startWarningColorGateValue + timeToReachFullIntensity; Color initialColor = lightColor; - Color finalColor = new Color(125, 75, 75); + Color finalColor = Color.Lerp(new Color(125, 75, 75), Color.Red, (float)Math.Abs(Math.Sin((projectile.ai[1] - startWarningColorGateValue) * (MathHelper.Pi / 45)))); finalColor.A = (byte)(255 - projectile.alpha); - if (projectile.ai[1] > startTurningBrownGateValue) + if (projectile.ai[1] > startWarningColorGateValue) { - float colorTransitionRatio = (projectile.ai[1] - startTurningBrownGateValue) / timeToReachFullBrown; + float colorTransitionRatio = (projectile.ai[1] - startWarningColorGateValue) / timeToReachFullIntensity; Color dehydratedColor = Color.Lerp(initialColor, finalColor, colorTransitionRatio); return dehydratedColor; } @@ -4434,6 +4434,40 @@ namespace CalamityMod.Projectiles #endregion + if (projectile.type == ProjectileID.DeerclopsIceSpike && (CalamityWorld.revenge || BossRushEvent.BossRushActive)) + { + bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + Texture2D texture = TextureAssets.Projectile[projectile.type].Value; + Rectangle value26 = texture.Frame(1, 5, 0, projectile.frame); + Vector2 origin12 = new Vector2(16f, value26.Height / 2); + Color alpha5 = projectile.GetAlpha(lightColor); + Vector2 vector39 = new Vector2(projectile.scale); + float fadeOutGateValue = masterMode ? 80f : death ? 50f : 10f; + float killGateValue = masterMode ? 90f : death ? 60f : 20f; + float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 10f, projectile.ai[0], clamped: true); + vector39.Y *= lerpValue5; + Vector4 vector40 = lightColor.ToVector4(); + Vector4 vector41 = new Color(67, 17, 17).ToVector4(); + vector41 *= vector40; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(TextureAssets.Extra[98].Value, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY) - projectile.velocity * projectile.scale * 0.5f, null, projectile.GetAlpha(new Color(vector41.X, vector41.Y, vector41.Z, vector41.W)), projectile.rotation + MathHelper.PiOver2, TextureAssets.Extra[98].Value.Size() / 2f, projectile.scale * 0.9f, spriteEffects); + Color color49 = projectile.GetAlpha(Color.White) * Utils.Remap(projectile.ai[0], 0f, killGateValue, 0.5f, 0f); + color49.A = 0; + + for (int i = 0; i < 4; i++) + Main.EntitySpriteDraw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY) + projectile.rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2 * (float)i) * 2f * vector39, value26, color49, projectile.rotation, origin12, vector39, spriteEffects); + + Main.EntitySpriteDraw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), value26, alpha5, projectile.rotation, origin12, vector39, spriteEffects); + + return false; + } + if (projectile.type == ProjectileID.DemonSickle) { if (Main.wofNPCIndex < 0 || !Main.npc[Main.wofNPCIndex].active || Main.npc[Main.wofNPCIndex].life <= 0 || projectile.tileCollide) @@ -4856,16 +4890,15 @@ namespace CalamityMod.Projectiles float lowestHealthCheck = 0f; int healTarget = projectile.owner; - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player otherPlayer in Main.ActivePlayers) { - Player otherPlayer = Main.player[i]; - if (otherPlayer.active && !otherPlayer.dead && ((!player.hostile && !otherPlayer.hostile) || player.team == otherPlayer.team)) + if (!otherPlayer.dead && ((!player.hostile && !otherPlayer.hostile) || player.team == otherPlayer.team)) { float playerDist = Vector2.Distance(projectile.Center, otherPlayer.Center); if (playerDist < distanceRequired && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) { lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; - healTarget = i; + healTarget = otherPlayer.whoAmI; } } } diff --git a/Projectiles/CalamityGlobalProjectileTweaks.cs b/Projectiles/CalamityGlobalProjectileTweaks.cs index 658c5faae7..916a1412a8 100644 --- a/Projectiles/CalamityGlobalProjectileTweaks.cs +++ b/Projectiles/CalamityGlobalProjectileTweaks.cs @@ -133,9 +133,9 @@ namespace CalamityMod.Projectiles { ProjectileID.CrystalVileShardShaft, Do(LocalIFrames(23)) }, { ProjectileID.CursedBullet, standardBulletTweaks }, { ProjectileID.ClusterRocketI, Do(LocalIFrames(15)) }, - { ProjectileID.ClusterFragmentsI, Do(LocalIFrames(15)) }, + { ProjectileID.ClusterFragmentsI, Do(IDStaticIFrames(15)) }, { ProjectileID.ClusterRocketII, Do(LocalIFrames(15)) }, - { ProjectileID.ClusterFragmentsII, Do(LocalIFrames(15)) }, + { ProjectileID.ClusterFragmentsII, Do(IDStaticIFrames(15)) }, { ProjectileID.ClusterSnowmanRocketI, Do(LocalIFrames(15)) }, { ProjectileID.ClusterSnowmanRocketII, Do(LocalIFrames(15)) }, { ProjectileID.DD2SquireSonicBoom, Do(PiercingExact(3)) }, // Flying Dragon diff --git a/Projectiles/Damageable/DamageableProjectile.cs b/Projectiles/Damageable/DamageableProjectile.cs index 74b0bfe440..91d14e4f9d 100644 --- a/Projectiles/Damageable/DamageableProjectile.cs +++ b/Projectiles/Damageable/DamageableProjectile.cs @@ -169,14 +169,14 @@ namespace CalamityMod.Projectiles.Damageable public virtual bool NPCCollisionCheck() { Player player = Main.player[Projectile.owner]; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].IsAnEnemy() && DamageSources.HasFlag(DamageSourceType.HostileNPCs)) + if (n.IsAnEnemy() && DamageSources.HasFlag(DamageSourceType.HostileNPCs)) { - if (Main.npc[i].Hitbox.Intersects(Projectile.Hitbox) && !NPCsToIgnore.Contains(Main.npc[i].type)) + if (n.Hitbox.Intersects(Projectile.Hitbox) && !NPCsToIgnore.Contains(n.type)) { - int damage = Main.DamageVar(Main.npc[i].damage); - int bannerBuffId = Item.NPCtoBanner(Main.npc[i].BannerID()); + int damage = Main.DamageVar(n.damage); + int bannerBuffId = Item.NPCtoBanner(n.BannerID()); if (bannerBuffId > 0 && player.HasNPCBannerBuff(bannerBuffId)) { if (Main.expertMode) @@ -190,7 +190,7 @@ namespace CalamityMod.Projectiles.Damageable } CombatText.NewText(new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height), CombatText.DamagedFriendly, damage); Life -= damage; - HitEffectNPC(damage, Main.npc[i]); + HitEffectNPC(damage, n); DamageImmunityFrames = MaxDamageImmunityFrames; NetUpdate(true); return true; @@ -201,20 +201,20 @@ namespace CalamityMod.Projectiles.Damageable } public virtual bool ProjectileCollisionCheck() { - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - bool canBeHit = (Main.projectile[i].friendly && DamageSources.HasFlag(DamageSourceType.FriendlyProjectiles) || - Main.projectile[i].hostile && DamageSources.HasFlag(DamageSourceType.HostileProjectiles)) && - i != Projectile.whoAmI; - if (Main.projectile[i].active && canBeHit && Main.projectile[i].damage > 0) + bool canBeHit = (p.friendly && DamageSources.HasFlag(DamageSourceType.FriendlyProjectiles) || + p.hostile && DamageSources.HasFlag(DamageSourceType.HostileProjectiles)) && + p.whoAmI != Projectile.whoAmI; + if (canBeHit && p.damage > 0) { - if (Main.projectile[i].Colliding(Main.projectile[i].Hitbox, Projectile.Hitbox)) + if (p.Colliding(p.Hitbox, Projectile.Hitbox)) { - int damage = Main.DamageVar(Main.projectile[i].damage) * 2; + int damage = Main.DamageVar(p.damage) * 2; damage = Main.expertMode ? (int)(damage * Main.RegisteredGameModes[GameModeID.Expert].EnemyDamageMultiplier) : damage; CombatText.NewText(new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height), CombatText.DamagedFriendly, damage); Life -= damage; - HitEffectProjectile(damage, Main.projectile[i]); + HitEffectProjectile(damage, p); DamageImmunityFrames = MaxDamageImmunityFrames; if (Projectile.usesIDStaticNPCImmunity) DamageImmunityFrames = Projectile.idStaticNPCHitCooldown; diff --git a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs index 5c1b0f93f2..9a99cf55b4 100644 --- a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs +++ b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs @@ -129,19 +129,19 @@ namespace CalamityMod.Projectiles.DraedonsArsenal chargeCooldown = 60; TryToSuperchargeNPC(target); int extraZaps = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i != target.whoAmI && - Main.npc[i].CanBeChasedBy(Projectile, false) && - Main.npc[i].Distance(target.Center) < 240f && + if (n.whoAmI != target.whoAmI && + n.CanBeChasedBy(Projectile, false) && + n.Distance(target.Center) < 240f && extraZaps < 3) { - - if (TryToSuperchargeNPC(Main.npc[i])) + + if (TryToSuperchargeNPC(n)) { for (float increment = 0f; increment <= 1f; increment += 0.05f) { - Vector2 spawnPosition = Vector2.Lerp(target.Center, Main.npc[i].Center, increment); + Vector2 spawnPosition = Vector2.Lerp(target.Center, n.Center, increment); Dust dust = Dust.NewDustPerfect(spawnPosition, 226); dust.velocity = Vector2.Zero; dust.scale = 1.6f; @@ -162,11 +162,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return false; // Prevent supercharging an enemy twice. - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && - Main.projectile[i].type == attackType && - Main.projectile[i].ai[1] == i) + if (p.type == attackType && + p.ai[1] == p.whoAmI) { return false; } diff --git a/Projectiles/DraedonsArsenal/PoleWarperSummon.cs b/Projectiles/DraedonsArsenal/PoleWarperSummon.cs index 4458db75aa..61308df0d2 100644 --- a/Projectiles/DraedonsArsenal/PoleWarperSummon.cs +++ b/Projectiles/DraedonsArsenal/PoleWarperSummon.cs @@ -116,13 +116,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public void NPCMovement(NPC npc) { - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == Projectile.type && - Main.projectile[i].active && + if (p.type == Projectile.type && Projectile.owner == Projectile.owner) { - PoleWarperSummon otherPole = (PoleWarperSummon)Main.projectile[i].ModProjectile; + PoleWarperSummon otherPole = (PoleWarperSummon)p.ModProjectile; if (otherPole.Time != Time && otherPole.Time != Time + 1) { otherPole.Time = Time; @@ -152,22 +151,21 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public void RepelMovement() { // This does not incorporate attraction on purpose. Doing so causes the minions to very easily become distracted. - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == Projectile.type && - Main.projectile[i].active && - Projectile.Distance(Main.projectile[i].Center) < 40f) + if (p.type == Projectile.type && + Projectile.Distance(p.Center) < 40f) { - PoleWarperSummon otherPole = (PoleWarperSummon)Main.projectile[i].ModProjectile; + PoleWarperSummon otherPole = (PoleWarperSummon)p.ModProjectile; if (otherPole.North != North) { - float distanceFromOtherPole = Projectile.Distance(Main.projectile[i].Center) + 1f; + float distanceFromOtherPole = Projectile.Distance(p.Center) + 1f; if (float.IsNaN(distanceFromOtherPole) || distanceFromOtherPole < 1f) { distanceFromOtherPole = 1f; } float repulsionSpeed = MaximumRepulsionSpeed * (float)Math.Pow(3f, -distanceFromOtherPole / 27f); - Projectile.velocity -= (Main.projectile[i].Center - Projectile.Center).SafeNormalize(Vector2.UnitY) * repulsionSpeed; + Projectile.velocity -= (p.Center - Projectile.Center).SafeNormalize(Vector2.UnitY) * repulsionSpeed; } } } diff --git a/Projectiles/DraedonsArsenal/PulsePistolShot.cs b/Projectiles/DraedonsArsenal/PulsePistolShot.cs index abd03aceaf..86a4fa01e8 100644 --- a/Projectiles/DraedonsArsenal/PulsePistolShot.cs +++ b/Projectiles/DraedonsArsenal/PulsePistolShot.cs @@ -90,15 +90,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float minDistance = 600f; List potentialTargets = new List(); - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - bool legalTarget = Main.npc[i] != target && Main.npc[i].active && Main.npc[i].CanBeChasedBy(null); - float distanceToTarget = Projectile.Distance(Main.npc[i].Center); - if (legalTarget && distanceToTarget < minDistance && !NPCsAlreadyHit.Contains(Main.npc[i])) + bool legalTarget = n != target && n.CanBeChasedBy(null); + float distanceToTarget = Projectile.Distance(n.Center); + if (legalTarget && distanceToTarget < minDistance && !NPCsAlreadyHit.Contains(n)) { minDistance = distanceToTarget; // The NPCs at the bottom will always be at the bottom of the list because it works via a minimum distance. - potentialTargets.Add(Main.npc[i]); + potentialTargets.Add(n); } } diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index aabdd2c12e..1f7f997a7a 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -4,6 +4,7 @@ using System.Net.Sockets; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; +using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -123,8 +124,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { distance = 3000; - SoundStyle fire = new("CalamityMod/Sounds/Item/OpalFire"); - SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = 1f }, Projectile.Center); + SoundStyle fire = new("CalamityMod/Sounds/Item/PulseSound"); + SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = 0.3f, MaxInstances = -1 }, Projectile.Center); Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, mainColor, new Vector2(1f, 1f), Main.rand.NextFloat(12f, 25f), 0f, 0.5f, 15); @@ -242,9 +243,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // These should do a large fraction of the beam's damage so they will easily kill even some decently bulky enemies regular enemies in one hit // This is so it can better proc its on kill effect int numProj = 4; + int projectileDamage = (int)(Projectile.damage * 0.5f); for (int i = 0; i < numProj; i++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.Zero) * (14f - i * 0.7f)) * ((i + 1) * 0.25f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 1f + i); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.Zero) * (14f - i * 0.7f)) * ((i + 1) * 0.25f), ModContent.ProjectileType(), projectileDamage, Projectile.knockBack, Projectile.owner, 0f, 1f + i); } } // Split projectile on hit effects diff --git a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs index 62127086be..18ad44c4b2 100644 --- a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs +++ b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs @@ -139,10 +139,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // so it looks like the minion deflected his own projectile. if (HasShot) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj is not null && proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Owner.whoAmI && proj.ModProjectile().MinionID == Projectile.whoAmI && proj.ModProjectile().HasRedirected) + if (proj.type == ModContent.ProjectileType() && proj.owner == Owner.whoAmI && proj.ModProjectile().MinionID == Projectile.whoAmI && proj.ModProjectile().HasRedirected) { Projectile.Center = proj.Center; SwitchAIState(AIState.Redirecting); diff --git a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs index 6a6464955a..d0a4e1bc1f 100644 --- a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs +++ b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs @@ -96,14 +96,14 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (arcs < 10) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].CanBeChasedBy(Projectile, false) || !Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + if (!n.CanBeChasedBy(Projectile, false) || !Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) continue; - if (Projectile.Center.ManhattanDistance(Main.npc[i].Center) < 600f) + if (Projectile.Center.ManhattanDistance(n.Center) < 600f) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.SafeDirectionTo(Main.npc[i].Center) * 2f, Projectile.type, (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.6f, Projectile.owner, 0f, -1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.SafeDirectionTo(n.Center) * 2f, Projectile.type, (int)(Projectile.damage * 0.6), Projectile.knockBack * 0.6f, Projectile.owner, 0f, -1f); Projectile.ai[1] = 60f; diff --git a/Projectiles/Enemy/FlakAcid.cs b/Projectiles/Enemy/FlakAcid.cs index f51e4bc8d5..3edadc017d 100644 --- a/Projectiles/Enemy/FlakAcid.cs +++ b/Projectiles/Enemy/FlakAcid.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Projectiles.Enemy Projectile.velocity.Y += 0.15f; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - for (int i = 0; i < Main.player.Length; i++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[i].Distance(Projectile.Center) < 60f) + if (player.Distance(Projectile.Center) < 60f) { Projectile.Kill(); } diff --git a/Projectiles/Magic/ArtAttackStar.cs b/Projectiles/Magic/ArtAttackStar.cs index ecbbfc032d..aea6eae32c 100644 --- a/Projectiles/Magic/ArtAttackStar.cs +++ b/Projectiles/Magic/ArtAttackStar.cs @@ -134,9 +134,9 @@ namespace CalamityMod.Projectiles.Magic { float damageFactor = MathHelper.Lerp(1f, ArtAttack.MaxDamageBoostFactor, Utils.GetLerpValue(0f, ArtAttack.MaxDamageBoostTime, Time, true)); int damage = (int)(Projectile.damage * damageFactor); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (!Main.npc[i].CanBeChasedBy()) + if (!n.CanBeChasedBy()) continue; bool enemyIsInShape = false; @@ -159,9 +159,9 @@ namespace CalamityMod.Projectiles.Magic Rectangle shapeRectangle = Utils.CenteredRectangle(center, area); for (int j = 0; j < cleanOldPositions.Count; j++) { - Vector2 left = Main.npc[i].Center - Vector2.UnitX * 2000f; - Vector2 right = Main.npc[i].Center + Vector2.UnitX * 2000f; - bool inRangeOfStars = shapeRectangle.Intersects(Main.npc[i].Hitbox); + Vector2 left = n.Center - Vector2.UnitX * 2000f; + Vector2 right = n.Center + Vector2.UnitX * 2000f; + bool inRangeOfStars = shapeRectangle.Intersects(n.Hitbox); bool lineCheck = Collision.CheckLinevLine(left, right, cleanOldPositions[j], cleanOldPositions[(j + 1) % cleanOldPositions.Count]).Length > 0; if (lineCheck && inRangeOfStars) { @@ -173,12 +173,12 @@ namespace CalamityMod.Projectiles.Magic // Strike an enemy if it's in the shape. if (enemyIsInShape) { - SoundEngine.PlaySound(SoundID.DD2_LightningBugZap, Main.npc[i].Center); - CreateDustExplosionEffect(Main.npc[i].Center); + SoundEngine.PlaySound(SoundID.DD2_LightningBugZap, n.Center); + CreateDustExplosionEffect(n.Center); if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Main.npc[i].Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Projectile.owner, i); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Projectile.owner, n.whoAmI); } } } diff --git a/Projectiles/Magic/BlackAnurianPlankton.cs b/Projectiles/Magic/BlackAnurianPlankton.cs index 4269f14e51..ca29350bbc 100644 --- a/Projectiles/Magic/BlackAnurianPlankton.cs +++ b/Projectiles/Magic/BlackAnurianPlankton.cs @@ -57,14 +57,14 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[0] > 30f) { Projectile.ai[0] = 30f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && !Main.npc[i].wet) + if (n.CanBeChasedBy(Projectile, false) && !n.wet) { - float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcX = n.position.X + (float)(n.width / 2); + float npcY = n.position.Y + (float)(n.height / 2); float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); - if (npcDist < 800f && npcDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) + if (npcDist < 800f && npcDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { homingRange = npcDist; projX = npcX; diff --git a/Projectiles/Magic/BlindingLight.cs b/Projectiles/Magic/BlindingLight.cs index 8b4252e738..b4b206a6da 100644 --- a/Projectiles/Magic/BlindingLight.cs +++ b/Projectiles/Magic/BlindingLight.cs @@ -61,10 +61,9 @@ namespace CalamityMod.Projectiles.Magic { int lightBlade = ModContent.ProjectileType(); int extraDamage = 0; - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile otherProj in Main.ActiveProjectiles) { - Projectile otherProj = Main.projectile[i]; - if (otherProj is null || !otherProj.active || otherProj.owner != Projectile.owner || otherProj.type != lightBlade) + if (otherProj.owner != Projectile.owner || otherProj.type != lightBlade) continue; // Can only consume blades within the flash radius (which should be most if not all of them anyway) @@ -79,10 +78,9 @@ namespace CalamityMod.Projectiles.Magic private void DivideDamageAmongstTargets() { int numTargets = 0; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (var npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc is null || !npc.active || npc.friendly || npc.dontTakeDamage || npc.immortal) + if (npc.friendly || npc.dontTakeDamage || npc.immortal) continue; if (Projectile.Colliding(default, npc.Hitbox)) ++numTargets; diff --git a/Projectiles/Melee/ChronoIcicleLarge.cs b/Projectiles/Magic/ChronoIcicleLarge.cs similarity index 97% rename from Projectiles/Melee/ChronoIcicleLarge.cs rename to Projectiles/Magic/ChronoIcicleLarge.cs index 99cf9bb63f..79fa04c391 100644 --- a/Projectiles/Melee/ChronoIcicleLarge.cs +++ b/Projectiles/Magic/ChronoIcicleLarge.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics.Metrics; -using System.Security.Policy; using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; @@ -8,11 +6,11 @@ using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee +namespace CalamityMod.Projectiles.Magic { public class ChronoIcicleLarge : ModProjectile, ILocalizedModType { - public new string LocalizationCategory => "Projectiles.Melee"; + public new string LocalizationCategory => "Projectiles.Magic"; public static int HomingSpeed = 16; public static int IdleSpeedMax = 7; public override void SetDefaults() @@ -23,7 +21,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.coldDamage = true; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.DamageType = DamageClass.Melee; + Projectile.DamageType = DamageClass.Magic; Projectile.coldDamage = true; Projectile.tileCollide = false; Projectile.timeLeft = 180; diff --git a/Projectiles/Melee/ChronoIcicleLarge.png b/Projectiles/Magic/ChronoIcicleLarge.png similarity index 100% rename from Projectiles/Melee/ChronoIcicleLarge.png rename to Projectiles/Magic/ChronoIcicleLarge.png diff --git a/Projectiles/Melee/ChronoIcicleSmall.cs b/Projectiles/Magic/ChronoIcicleSmall.cs similarity index 93% rename from Projectiles/Melee/ChronoIcicleSmall.cs rename to Projectiles/Magic/ChronoIcicleSmall.cs index 6d60caa49c..e3c8e83f67 100644 --- a/Projectiles/Melee/ChronoIcicleSmall.cs +++ b/Projectiles/Magic/ChronoIcicleSmall.cs @@ -5,11 +5,11 @@ using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee +namespace CalamityMod.Projectiles.Magic { public class ChronoIcicleSmall : ModProjectile, ILocalizedModType { - public new string LocalizationCategory => "Projectiles.Melee"; + public new string LocalizationCategory => "Projectiles.Magic"; public override void SetDefaults() { Projectile.width = 12; @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.coldDamage = true; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.DamageType = DamageClass.Melee; + Projectile.DamageType = DamageClass.Magic; Projectile.coldDamage = true; } diff --git a/Projectiles/Melee/ChronoIcicleSmall.png b/Projectiles/Magic/ChronoIcicleSmall.png similarity index 100% rename from Projectiles/Melee/ChronoIcicleSmall.png rename to Projectiles/Magic/ChronoIcicleSmall.png diff --git a/Projectiles/Melee/ChronomancersScytheHoldout.cs b/Projectiles/Magic/ChronomancersScytheHoldout.cs similarity index 97% rename from Projectiles/Melee/ChronomancersScytheHoldout.cs rename to Projectiles/Magic/ChronomancersScytheHoldout.cs index 972b91a953..d5861097b5 100644 --- a/Projectiles/Melee/ChronomancersScytheHoldout.cs +++ b/Projectiles/Magic/ChronomancersScytheHoldout.cs @@ -9,13 +9,13 @@ using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee +namespace CalamityMod.Projectiles.Magic { public class ChronomancersScytheHoldout : ModProjectile, ILocalizedModType { - public new string LocalizationCategory => "Projectiles.Melee"; + public new string LocalizationCategory => "Projectiles.Magic"; public Player Owner => Main.player[Projectile.owner]; - public override string Texture => "CalamityMod/Items/Weapons/Melee/ChronomancersScythe"; + public override string Texture => "CalamityMod/Items/Weapons/Magic/ChronomancersScythe"; public static int ClockChance = 30; public override void SetDefaults() @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = 60; Projectile.height = 60; Projectile.friendly = true; - Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.DamageType = DamageClass.Magic; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/ChronomancersScytheSwing.cs b/Projectiles/Magic/ChronomancersScytheSwing.cs similarity index 91% rename from Projectiles/Melee/ChronomancersScytheSwing.cs rename to Projectiles/Magic/ChronomancersScytheSwing.cs index 432bf7c7d4..5cbd28a35b 100644 --- a/Projectiles/Melee/ChronomancersScytheSwing.cs +++ b/Projectiles/Magic/ChronomancersScytheSwing.cs @@ -1,7 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -10,7 +10,7 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee +namespace CalamityMod.Projectiles.Magic { public class ChronomancersScytheSwing : ModProjectile { @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.DamageType = DamageClass.Magic; Projectile.ownerHitCheck = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 5; @@ -60,6 +60,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.soundDelay = 24; } + if (Projectile.ai[2] >= 32) + { + bool manaCostPaid = Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + if (!manaCostPaid) + { + Projectile.Kill(); + return; + } + Projectile.ai[2] = 0; + } + Projectile.ai[2]++; + if (Main.myPlayer == Projectile.owner) { if (!Owner.CantUseHoldout()) diff --git a/Projectiles/Melee/ChronomancersScytheSwing.png b/Projectiles/Magic/ChronomancersScytheSwing.png similarity index 100% rename from Projectiles/Melee/ChronomancersScytheSwing.png rename to Projectiles/Magic/ChronomancersScytheSwing.png diff --git a/Projectiles/Magic/EternityHex.cs b/Projectiles/Magic/EternityHex.cs index b7d62c4130..8443eb4ffb 100644 --- a/Projectiles/Magic/EternityHex.cs +++ b/Projectiles/Magic/EternityHex.cs @@ -177,11 +177,8 @@ namespace CalamityMod.Projectiles.Magic TargetNPCIndex = newTarget.whoAmI; // Adjust the target index for the other components of the projectile. - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (!proj.active) - continue; if (proj.owner != Projectile.owner) continue; if (proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType()) diff --git a/Projectiles/Magic/EventHorizonStar.cs b/Projectiles/Magic/EventHorizonStar.cs index 3b7ec095cf..daf819b4d6 100644 --- a/Projectiles/Magic/EventHorizonStar.cs +++ b/Projectiles/Magic/EventHorizonStar.cs @@ -93,15 +93,15 @@ namespace CalamityMod.Projectiles.Magic float inertia = 25f; float homingSpeed = 23f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (float)(n.width / 2) + (float)(n.height / 2); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (homingRange + extraDistance)) + if (Vector2.Distance(n.Center, Projectile.Center) < (homingRange + extraDistance)) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } diff --git a/Projectiles/Magic/ExoVortex.cs b/Projectiles/Magic/ExoVortex.cs index fed7e9cdfc..aba7ceed69 100644 --- a/Projectiles/Magic/ExoVortex.cs +++ b/Projectiles/Magic/ExoVortex.cs @@ -8,6 +8,7 @@ using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Graphics.Primitives; namespace CalamityMod.Projectiles.Magic { diff --git a/Projectiles/Magic/ExoVortex2.cs b/Projectiles/Magic/ExoVortex2.cs index d9351189ea..594aac4474 100644 --- a/Projectiles/Magic/ExoVortex2.cs +++ b/Projectiles/Magic/ExoVortex2.cs @@ -8,6 +8,7 @@ using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Graphics.Primitives; namespace CalamityMod.Projectiles.Magic { diff --git a/Projectiles/Magic/GenesisBeam.cs b/Projectiles/Magic/GenesisBeam.cs index d18c26c832..9a2a2167fd 100644 --- a/Projectiles/Magic/GenesisBeam.cs +++ b/Projectiles/Magic/GenesisBeam.cs @@ -12,6 +12,8 @@ namespace CalamityMod.Projectiles.Magic public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public ref float time => ref Projectile.ai[0]; + public ref float isSplit => ref Projectile.ai[1]; + public bool splitShot = false; public Color mainColor = Color.MediumSlateBlue; public override void SetDefaults() @@ -29,15 +31,20 @@ namespace CalamityMod.Projectiles.Magic } public override void AI() { + if (isSplit == 0) + { + Projectile.netUpdate = true; + splitShot = true; + } if (time == 0) { - if (Projectile.ai[1] == 0) + if (splitShot) Projectile.penetrate = 1; else Projectile.timeLeft = 50; } - if (Projectile.timeLeft % 2 == 0 && (Projectile.ai[1] == 1 && time > 2 || (Projectile.ai[1] == 0 && time > 3 && Projectile.timeLeft > 2))) + if (Projectile.timeLeft % 2 == 0 && (!splitShot && time > 2 || (splitShot && time > 3 && Projectile.timeLeft > 2))) { Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 0.06f, mainColor, new Vector2(0.5f, 1.3f)); GeneralParticleHandler.SpawnParticle(spark); @@ -53,8 +60,8 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { int numProj = 2; - float rotation = MathHelper.ToRadians(20); - if (Projectile.ai[1] == 0) + float rotation = MathHelper.ToRadians(12); + if (splitShot) { for (int i = 0; i < numProj; i++) { @@ -90,7 +97,7 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.ai[1] == 0) // This is the sweet spot + if (splitShot) // This is the sweet spot { modifiers.SourceDamage *= 1.5f; diff --git a/Projectiles/Magic/GenesisHoldout.cs b/Projectiles/Magic/GenesisHoldout.cs index 5f25eaeac0..65385f8a61 100644 --- a/Projectiles/Magic/GenesisHoldout.cs +++ b/Projectiles/Magic/GenesisHoldout.cs @@ -1,12 +1,13 @@ -using CalamityMod.Items.Weapons.Magic; +using System.IO; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Magic.Genesis; namespace CalamityMod.Projectiles.Magic { @@ -19,20 +20,20 @@ namespace CalamityMod.Projectiles.Magic public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; - public Color StaticEffectsColor = Color.MediumSlateBlue; + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float MaxFirerateShots => ref Projectile.ai[1]; + public bool FireYBeam + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } - public float FiringTime = 15; - public float Windup = 60; - public bool WindingUp = false; - public int time = 0; - public bool fireYBeam = false; - public int maxFirerateShots = 0; - - private ref float ShootingTimer => ref Projectile.ai[0]; + public float Windup { get; set; } = StarterWindup; + public Color EffectsColor { get; set; } = Color.MediumSlateBlue; public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) + if (HeldItem.type != Owner.ActiveItem().type || Owner.CantUseHoldout()) { Projectile.Kill(); Projectile.netUpdate = true; @@ -41,56 +42,49 @@ namespace CalamityMod.Projectiles.Magic public override void HoldoutAI() { - Item heldItem = Owner.ActiveItem(); - // Fire if the owner stops channeling or otherwise cannot use the weapon. - if (Owner.CantUseHoldout()) - { - Projectile.Kill(); - } - else if (ShootingTimer >= FiringTime) + if (ShootingTimer >= FireRate) { if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false)) { - maxFirerateShots++; - - if (maxFirerateShots == 6) + if (MaxFirerateShots == 6f) { - fireYBeam = true; - Windup = 60; + FireYBeam = true; + Windup = 60f; + Projectile.netUpdate = true; } - if (fireYBeam) - { - Shoot(heldItem, true); - maxFirerateShots = 0; + if (FireYBeam) + { + Shoot(true); + MaxFirerateShots = 0f; } else - Shoot(heldItem, false); + Shoot(false); - ShootingTimer = 0; - - if (Windup > 10) + if (Windup > 10f) { - if (!fireYBeam) - Windup -= 12; + if (!FireYBeam) + Windup -= 12f; } else - { - Windup = 10; - } + Windup = 10f; - fireYBeam = false; + MaxFirerateShots++; + ShootingTimer = 0f; + FireYBeam = false; } else { SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center); Projectile.Kill(); + Projectile.netUpdate = true; } - } + ShootingTimer++; } - private void Shoot(Item item, bool yBeam) + + private void Shoot(bool yBeam) { Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); @@ -107,11 +101,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 9, Projectile.knockBack, Projectile.owner, 0, 0); - Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, StaticEffectsColor, new Vector2(1.7f, 0.8f), true); + Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); for (int i = 0; i < 8; i++) { - SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), StaticEffectsColor); + SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), EffectsColor); GeneralParticleHandler.SpawnParticle(spark2); } } @@ -131,10 +125,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); } - Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, StaticEffectsColor, new Vector2(1.7f, 0.8f), true); + Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); } + Projectile.netUpdate = true; + // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -147,7 +143,7 @@ namespace CalamityMod.Projectiles.Magic Dust dust2 = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(4) ? 267 : 66, shootVel); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = true; - dust2.color = Main.rand.NextBool() ? Color.Lerp(StaticEffectsColor, Color.White, 0.5f) : StaticEffectsColor; + dust2.color = Main.rand.NextBool() ? Color.Lerp(EffectsColor, Color.White, 0.5f) : EffectsColor; } // By decreasing the offset length of the gun from the arms, we give an effect of recoil. @@ -156,5 +152,9 @@ namespace CalamityMod.Projectiles.Magic else OffsetLengthFromArm -= 5f; } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(Windup); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => Windup = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/GranitePulse.cs b/Projectiles/Magic/GranitePulse.cs index 2a75dd05e4..1cee67b0f7 100644 --- a/Projectiles/Magic/GranitePulse.cs +++ b/Projectiles/Magic/GranitePulse.cs @@ -67,15 +67,14 @@ namespace CalamityMod.Projectiles.Magic int index = 0; float findOldest = 0f; int projType = Projectile.type; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == Projectile.owner && proj.type == projType && proj.ai[1] < 3600f) + if (proj.owner == Projectile.owner && proj.type == projType && proj.ai[1] < 3600f) { projCount++; if (proj.ai[1] > findOldest) { - index = i; + index = proj.whoAmI; findOldest = proj.ai[1]; } } diff --git a/Projectiles/Magic/HadalUrnJellyfish.cs b/Projectiles/Magic/HadalUrnJellyfish.cs index ed56c37ba2..dc57cb8008 100644 --- a/Projectiles/Magic/HadalUrnJellyfish.cs +++ b/Projectiles/Magic/HadalUrnJellyfish.cs @@ -75,17 +75,17 @@ namespace CalamityMod.Projectiles.Magic //Detect if any enemies are very close int maxDistance = 10; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + float extraDistance = (n.width / 2) + (n.height / 2); bool canHit = true; if (extraDistance < maxDistance) - canHit = Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); + canHit = Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1); - if (Projectile.WithinRange(Main.npc[i].Center, maxDistance + extraDistance) && canHit) + if (Projectile.WithinRange(n.Center, maxDistance + extraDistance) && canHit) { neartarget = true; } diff --git a/Projectiles/Magic/IceBlock.cs b/Projectiles/Magic/IceBlock.cs index da684fba9f..228677e7de 100644 --- a/Projectiles/Magic/IceBlock.cs +++ b/Projectiles/Magic/IceBlock.cs @@ -35,9 +35,8 @@ namespace CalamityMod.Projectiles.Magic { Projectile.alpha = 20; } - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; if (proj.type == ModContent.ProjectileType() && proj.owner == Main.myPlayer) { Vector2 pos1 = new Vector2(proj.Center.X, proj.Center.Y - (proj.height * 0.5f) - 44f); diff --git a/Projectiles/Magic/NebulaCloudCore.cs b/Projectiles/Magic/NebulaCloudCore.cs index 155380efe0..4543a55adc 100644 --- a/Projectiles/Magic/NebulaCloudCore.cs +++ b/Projectiles/Magic/NebulaCloudCore.cs @@ -169,17 +169,17 @@ namespace CalamityMod.Projectiles.Magic int npcTrack = 0; if (Projectile.ai[1] == 0f) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(this)) + if (n.CanBeChasedBy(this)) { - Vector2 npcCenter = Main.npc[i].Center; - if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 2), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) + Vector2 npcCenter = n.Center; + if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + Projectile.width / 2, Projectile.position.Y + Projectile.height / 2), 1, 1, n.position, n.width, n.height)) { homingRange = Projectile.Distance(npcCenter); projCenter = npcCenter; isHoming = true; - npcTrack = i; + npcTrack = n.whoAmI; } } } diff --git a/Projectiles/Magic/OmicronBeam.cs b/Projectiles/Magic/OmicronBeam.cs index ab72615ff1..e281affc55 100644 --- a/Projectiles/Magic/OmicronBeam.cs +++ b/Projectiles/Magic/OmicronBeam.cs @@ -15,6 +15,9 @@ namespace CalamityMod.Projectiles.Magic public Color mainColor = Color.MediumVioletRed; public bool HitDirect = false; + + public ref float isSplit => ref Projectile.ai[1]; + public bool splitShot = false; public override void SetDefaults() { Projectile.width = 50; @@ -30,6 +33,12 @@ namespace CalamityMod.Projectiles.Magic } public override void AI() { + if (isSplit == 0) + { + Projectile.netUpdate = true; + splitShot = true; + } + Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); if (Projectile.timeLeft % 2 == 0 && time > 2 && targetDist < 1400f) @@ -55,7 +64,7 @@ namespace CalamityMod.Projectiles.Magic { int numProj = 2; float rotation = MathHelper.ToRadians(10); - if (Projectile.ai[1] == 0 && time < 250 && !HitDirect) + if (splitShot && time < 250 && !HitDirect) { for (int i = 0; i < numProj; i++) { @@ -91,7 +100,7 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.ai[1] == 0 && time > 7 && !HitDirect) + if (splitShot && time > 7 && !HitDirect) Projectile.Kill(); Player Owner = Main.player[Projectile.owner]; @@ -101,7 +110,7 @@ namespace CalamityMod.Projectiles.Magic dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } - if (time <= 7 && Projectile.ai[1] == 0) // This is the sweet spot + if (time <= 7 && splitShot) // This is the sweet spot { modifiers.SourceDamage *= 5; diff --git a/Projectiles/Magic/OmicronHoldout.cs b/Projectiles/Magic/OmicronHoldout.cs index 98e9b76c57..49c022c8a6 100644 --- a/Projectiles/Magic/OmicronHoldout.cs +++ b/Projectiles/Magic/OmicronHoldout.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) + if (Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) { if (PostFireCooldown <= 0) Projectile.Kill(); @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Magic Item heldItem = Owner.ActiveItem(); // Fire if the owner stops channeling or otherwise cannot use the weapon. - if (Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType()) + if (Owner.CantUseHoldout()) { if (PostFireCooldown <= 0) Projectile.Kill(); @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Magic if (maxFirerateShots == 5) { Windup = 60; - maxFirerateShots = 0; + maxFirerateShots = 1; } Shoot(heldItem, false); @@ -146,12 +146,12 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 5; i++) { - firingVelocity3 = (shootDirection * 10).RotatedBy((0.04f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); + firingVelocity3 = (shootDirection * 10).RotatedBy((0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); } for (int i = 0; i < 5; i++) { - firingVelocity3 = (shootDirection * 10).RotatedBy((-0.04f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); + firingVelocity3 = (shootDirection * 10).RotatedBy((-0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); } @@ -182,6 +182,7 @@ namespace CalamityMod.Projectiles.Magic } private void PostFiringCooldown() { + Owner.channel = true; if (PostFireCooldown > 0 && Main.rand.NextBool()) { Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); diff --git a/Projectiles/Magic/OmicronWingman.cs b/Projectiles/Magic/OmicronWingman.cs index 350e8007ce..a932b15d32 100644 --- a/Projectiles/Magic/OmicronWingman.cs +++ b/Projectiles/Magic/OmicronWingman.cs @@ -188,9 +188,9 @@ namespace CalamityMod.Projectiles.Magic { SoundStyle fire = new("CalamityMod/Sounds/Item/DeadSunExplosion"); SoundEngine.PlaySound(fire with { Volume = 0.2f, Pitch = -0.4f, PitchVariance = 0.2f }, Projectile.Center); - Projectile bomb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage * 20, Projectile.knockBack * 5, Projectile.owner, 0, 2); + Projectile bomb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); bomb.timeLeft = 530; - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * 1.2f, ModContent.ProjectileType(), Projectile.damage * 20, Projectile.knockBack * 5, Projectile.owner, 0, 2); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * 1.2f, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); } else { @@ -229,6 +229,7 @@ namespace CalamityMod.Projectiles.Magic } private void PostFiringCooldown() { + Owner.channel = true; Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; if (PostFireCooldown > 0 && Main.rand.NextBool()) diff --git a/Projectiles/Magic/PlasmaShot.cs b/Projectiles/Magic/PlasmaShot.cs index d59a3bdedc..6107767870 100644 --- a/Projectiles/Magic/PlasmaShot.cs +++ b/Projectiles/Magic/PlasmaShot.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < cloudAmt; i++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); - Projectile cloud = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ProjectileID.ToxicCloud + Main.rand.Next(3), Projectile.damage, 1f, Projectile.owner, 0f, Main.rand.Next(-45, 1)); + Projectile cloud = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ProjectileID.ToxicCloud + Main.rand.Next(3), (int)(Projectile.damage * 0.3f), 1f, Projectile.owner, 0f, Main.rand.Next(-45, 1)); cloud.usesIDStaticNPCImmunity = true; cloud.idStaticNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/RancorLaserbeam.cs b/Projectiles/Magic/RancorLaserbeam.cs index df0f3ecfc8..b2d907be0d 100644 --- a/Projectiles/Magic/RancorLaserbeam.cs +++ b/Projectiles/Magic/RancorLaserbeam.cs @@ -21,12 +21,12 @@ namespace CalamityMod.Projectiles.Magic { get { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].identity != Projectile.ai[0] || !Main.projectile[i].active || Main.projectile[i].owner != Projectile.owner) + if (p.identity != Projectile.ai[0] || p.owner != Projectile.owner) continue; - return Main.projectile[i]; + return p; } return null; } diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 5b7c11d916..edbdac9ab9 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -68,12 +68,12 @@ namespace CalamityMod.Projectiles.Magic float projY = Projectile.Center.Y; float explodeRange = 250f; bool canExplode = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) { - float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcX = n.position.X + (float)(n.width / 2); + float npcY = n.position.Y + (float)(n.height / 2); float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); if (npcDist < explodeRange) { diff --git a/Projectiles/Magic/SmallSpirit.cs b/Projectiles/Magic/SmallSpirit.cs index fb98eb148e..ef1d961c19 100644 --- a/Projectiles/Magic/SmallSpirit.cs +++ b/Projectiles/Magic/SmallSpirit.cs @@ -15,15 +15,15 @@ namespace CalamityMod.Projectiles.Magic get { int spiritType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != spiritType || Main.projectile[i].identity != Projectile.ai[0] || - Main.projectile[i].owner != Projectile.owner) + if (p.type != spiritType || p.identity != Projectile.ai[0] || + p.owner != Projectile.owner) { continue; } - return Main.projectile[i]; + return p; } return null; } diff --git a/Projectiles/Magic/VoidVortexProj.cs b/Projectiles/Magic/VoidVortexProj.cs index f8c424ab86..d0ba7f2205 100644 --- a/Projectiles/Magic/VoidVortexProj.cs +++ b/Projectiles/Magic/VoidVortexProj.cs @@ -137,6 +137,7 @@ namespace CalamityMod.Projectiles.Magic } public override void OnKill(int timeLeft) { + Projectile.netUpdate = true; if (Projectile.ai[2] == 1) { doDamage = true; diff --git a/Projectiles/Magic/WingmanGrenade.cs b/Projectiles/Magic/WingmanGrenade.cs index c3c40281ad..fe6b7fb52a 100644 --- a/Projectiles/Magic/WingmanGrenade.cs +++ b/Projectiles/Magic/WingmanGrenade.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = -1; Projectile.timeLeft = 480; Projectile.DamageType = DamageClass.Magic; - Projectile.extraUpdates = 4; + Projectile.extraUpdates = 6; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } @@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Magic exploding = true; } if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.95f); + Projectile.damage = (int)(Projectile.damage * 0.80f); if (Projectile.damage < 1) Projectile.damage = 1; } diff --git a/Projectiles/Magic/WingmanHoldout.cs b/Projectiles/Magic/WingmanHoldout.cs index 82cbf1761d..bca2231d0b 100644 --- a/Projectiles/Magic/WingmanHoldout.cs +++ b/Projectiles/Magic/WingmanHoldout.cs @@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.Magic { SoundStyle fire = new("CalamityMod/Sounds/Item/DeadSunExplosion"); SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = -0.4f, PitchVariance = 0.2f }, Projectile.Center); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 4.5), Projectile.knockBack * 5, Projectile.owner, 0); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 2) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0); } else { @@ -248,6 +248,7 @@ namespace CalamityMod.Projectiles.Magic } private void PostFiringCooldown() { + Owner.channel = true; Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; if (PostFireCooldown > 0 && Main.rand.NextBool()) @@ -285,7 +286,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - if (time <= 0) + if (time <= 0 && !Main.dedServ) return false; Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; diff --git a/Projectiles/Magic/WulfrumBolt.cs b/Projectiles/Magic/WulfrumBolt.cs index fcc64df360..3565948b51 100644 --- a/Projectiles/Magic/WulfrumBolt.cs +++ b/Projectiles/Magic/WulfrumBolt.cs @@ -67,10 +67,8 @@ namespace CalamityMod.Projectiles.Magic float bestScore = 0; NPC bestTarget = null; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC potentialTarget in Main.ActiveNPCs) { - NPC potentialTarget = Main.npc[i]; - if (!potentialTarget.CanBeChasedBy(null, false)) continue; diff --git a/Projectiles/Magic/WulfrumManaDrain.cs b/Projectiles/Magic/WulfrumManaDrain.cs index 258f09e141..04ede744a2 100644 --- a/Projectiles/Magic/WulfrumManaDrain.cs +++ b/Projectiles/Magic/WulfrumManaDrain.cs @@ -94,11 +94,9 @@ namespace CalamityMod.Projectiles.Magic { float collisionPoint = 0f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC struckNPC in Main.ActiveNPCs) { - NPC struckNPC = Main.npc[i]; - - if (!struckNPC.active || struckNPC.townNPC || struckNPC.friendly) + if (struckNPC.townNPC || struckNPC.friendly) continue; float distance = struckNPC.Distance(Projectile.Center); diff --git a/Projectiles/Melee/AmidiasWhirlpool.cs b/Projectiles/Melee/AmidiasWhirlpool.cs index b0277b9fcd..bcaf24ed46 100644 --- a/Projectiles/Melee/AmidiasWhirlpool.cs +++ b/Projectiles/Melee/AmidiasWhirlpool.cs @@ -76,21 +76,20 @@ namespace CalamityMod.Projectiles.Melee int npcTracker = 0; if (Projectile.ai[1] == 0f) { - for (int j = 0; j < Main.maxNPCs; j = inc + 1) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - Vector2 npcCenter = Main.npc[j].Center; - if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) + Vector2 npcCenter = n.Center; + if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, n.position, n.width, n.height)) { homingRange = Projectile.Distance(npcCenter); projCenter = npcCenter; isHoming = true; - npcTracker = j; + npcTracker = n.whoAmI; break; } } - inc = j; } if (isHoming) { diff --git a/Projectiles/Melee/BalefulHarvesterProjectile.cs b/Projectiles/Melee/BalefulHarvesterProjectile.cs index d5371d6a92..8855fed60a 100644 --- a/Projectiles/Melee/BalefulHarvesterProjectile.cs +++ b/Projectiles/Melee/BalefulHarvesterProjectile.cs @@ -73,21 +73,19 @@ namespace CalamityMod.Projectiles.Melee else { float homingRange = 1000f; - int inc; - for (int i = 0; i < Main.maxNPCs; i = inc + 1) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcX = n.position.X + (float)(n.width / 2); + float npcY = n.position.Y + (float)(n.height / 2); float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); - if (npcDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) + if (npcDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { homingRange = npcDist; - Projectile.ai[0] = (float)i; + Projectile.ai[0] = (float)n.whoAmI; } } - inc = i; } } diff --git a/Projectiles/Melee/CosmicShivAura.cs b/Projectiles/Melee/CosmicShivAura.cs index 5abefa744d..43e42687bb 100644 --- a/Projectiles/Melee/CosmicShivAura.cs +++ b/Projectiles/Melee/CosmicShivAura.cs @@ -1,4 +1,12 @@ -using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -28,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnSpawn(IEntitySource source) { if (Main.npc[(int)Projectile.ai[0]] is not null || Main.npc[(int)Projectile.ai[0]].active) - target = Main.npc[(int)Projectile.ai[0]]; // Convert target.whoAmI to object + target = Main.npc[(int)Projectile.ai[0]]; // Convert target.whoAmI to object } // ai[0] for ID of target to follow until the end of projectile's lifespan or the target cannot be found @@ -41,7 +49,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); } - Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; // Stay with target + // Stay with target + Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; if (Projectile.ai[1] == CurrentSwordTimer) { @@ -49,10 +58,16 @@ namespace CalamityMod.Projectiles.Melee randomDirection.Normalize(); int randomDistance = Main.rand.Next(200, 426); Vector2 spawnPos = Projectile.Center + (randomDirection * randomDistance); - Vector2 velocity = Vector2.Normalize(Projectile.Center - spawnPos) * Utils.GetLerpValue(-100, 426, randomDistance, clamped: true) * 20f; // Sword moves a bit slower if spawned closer, moves faster if spawned further + + // Sword moves a bit slower if spawned closer, moves faster if spawned further + Vector2 velocity = Vector2.Normalize(Projectile.Center - spawnPos) * Utils.GetLerpValue(-100, 426, randomDistance, clamped: true) * 20f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPos.X, spawnPos.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.8f, Projectile.owner, randomDistance); - Projectile.ai[1] = 0; // Reset timer - CurrentSwordTimer = Main.rand.Next(SwordsAverageDelay - SwordsRandomOffset, SwordsAverageDelay + SwordsRandomOffset); // Determine when next sword will spawn + + // Reset timer + Projectile.ai[1] = 0; + + // Determine when next sword will spawn + CurrentSwordTimer = Main.rand.Next(SwordsAverageDelay - SwordsRandomOffset, SwordsAverageDelay + SwordsRandomOffset); } Projectile.ai[1]++; diff --git a/Projectiles/Melee/CosmicShivBlade.cs b/Projectiles/Melee/CosmicShivBlade.cs index 10b158513a..5ae1c83de6 100644 --- a/Projectiles/Melee/CosmicShivBlade.cs +++ b/Projectiles/Melee/CosmicShivBlade.cs @@ -66,13 +66,18 @@ namespace CalamityMod.Projectiles.Melee float rotation = Projectile.rotation; Color randomColor = Projectile.GetAlpha(lightColor); + // Afterimages to make the blade look longer float scaleMult = 1.2f; - for (int i = 0; i < Projectile.oldPos.Length; i++) // Afterimages to make the blade look longer + for (int i = 0; i < Projectile.oldPos.Length; i++) { Vector2 drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); Color color = randomColor * ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); - Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(sourceRectangle), color, rotation, origin, Projectile.scale * scaleMult, SpriteEffects.None, 0f); // Smaller, more visible layer - Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(sourceRectangle), color * 0.5f, rotation, origin, Projectile.scale * 1.6f * scaleMult, SpriteEffects.None, 0f); // Bigger, less visible layer + + // Smaller, more visible layer + Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(sourceRectangle), color, rotation, origin, Projectile.scale * scaleMult, SpriteEffects.None, 0f); + + // Bigger, less visible layer + Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(sourceRectangle), color * 0.5f, rotation, origin, Projectile.scale * 1.6f * scaleMult, SpriteEffects.None, 0f); scaleMult *= 0.95f; } @@ -88,12 +93,14 @@ namespace CalamityMod.Projectiles.Melee } } - public override Color? GetAlpha(Color lightColor) // Probably not the right way to use this function, but it works (hopefully) + // Probably not the right way to use this function, but it works (hopefully) + public override Color? GetAlpha(Color lightColor) { + // Take random color from a list and make it more white Color color = CosmicShivTrail.DustColors[ColorIndex] * Projectile.Opacity; color = Color.Lerp(color, Color.White, 0.6f); color.A = 0; - return color; // Take random color from a list and make it more white + return color; } } } diff --git a/Projectiles/Melee/CosmicShivTrail.cs b/Projectiles/Melee/CosmicShivTrail.cs index 8c7d14eb67..df703c0e46 100644 --- a/Projectiles/Melee/CosmicShivTrail.cs +++ b/Projectiles/Melee/CosmicShivTrail.cs @@ -7,6 +7,14 @@ using Terraria; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Buffs.DamageOverTime; +using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; +using System.Reflection.Metadata; +using Microsoft.Xna.Framework.Graphics; +using System.Diagnostics.Contracts; +using Terraria.GameContent; +using Terraria.Audio; namespace CalamityMod.Projectiles.Melee { @@ -104,6 +112,39 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(ModContent.BuffType(), 60); } + // pretty much entirely from the Oracle circular damage code + private void CircularDamage(float radius) + { + if (Projectile.owner != Main.myPlayer) + return; + Player owner = Main.player[Projectile.owner]; + + foreach (NPC target in Main.ActiveNPCs) + { + if (target.dontTakeDamage || target.friendly) + continue; + + // Shock any valid target within range. Check all four corners of their hitbox. + float d1 = Vector2.Distance(Projectile.Center, target.Hitbox.TopLeft()); + float d2 = Vector2.Distance(Projectile.Center, target.Hitbox.TopRight()); + float d3 = Vector2.Distance(Projectile.Center, target.Hitbox.BottomLeft()); + float d4 = Vector2.Distance(Projectile.Center, target.Hitbox.BottomRight()); + float dist = MathHelper.Min(d1, d2); + dist = MathHelper.Min(dist, d3); + dist = MathHelper.Min(dist, d4); + + if (dist <= radius) + { + int damage = (int)(Projectile.damage * ExplosionDamageMultiplier); + bool crit = Main.rand.Next(100) <= owner.GetCritChance() + 4; + target.StrikeNPC(target.CalculateHitInfo(damage, 0, crit, 0)); + + if (Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, target.whoAmI, damage, 0f, 0f, crit ? 1 : 0, 0, 0); + } + } + } + // Very similar to CosmicShivBlade PreDraw public override bool PreDraw(ref Color lightColor) { @@ -187,6 +228,8 @@ namespace CalamityMod.Projectiles.Melee dust.fadeIn = -1f; } } + + CircularDamage(80f); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/Cyclone.cs b/Projectiles/Melee/Cyclone.cs index ffd4d3fa0e..e079ace083 100644 --- a/Projectiles/Melee/Cyclone.cs +++ b/Projectiles/Melee/Cyclone.cs @@ -65,9 +65,8 @@ namespace CalamityMod.Projectiles.Melee } float projX = Projectile.Center.X; float projY = Projectile.Center.Y; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { float npcCenterX = npc.position.X + (float)(npc.width / 2); diff --git a/Projectiles/Melee/DivineHatchetBoomerang.cs b/Projectiles/Melee/DivineHatchetBoomerang.cs index a37d582fb4..7399a76afb 100644 --- a/Projectiles/Melee/DivineHatchetBoomerang.cs +++ b/Projectiles/Melee/DivineHatchetBoomerang.cs @@ -165,21 +165,20 @@ namespace CalamityMod.Projectiles.Melee //find a nearby NPC to track float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { bool hasHitNPC = false; for (int j = 0; j < previousNPCs.Count; j++) { - if (previousNPCs[j] == i) + if (previousNPCs[j] == npc.whoAmI) { hasHitNPC = true; } } - NPC npc = Main.npc[i]; if (npc == target) { - previousNPCs.Add(i); + previousNPCs.Add(npc.whoAmI); } if (npc.CanBeChasedBy(Projectile, false) && npc != target && !hasHitNPC) { @@ -187,7 +186,7 @@ namespace CalamityMod.Projectiles.Melee if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Melee/DraconicSpark.cs b/Projectiles/Melee/DraconicSpark.cs index 3ae085492e..2bd1719ad8 100644 --- a/Projectiles/Melee/DraconicSpark.cs +++ b/Projectiles/Melee/DraconicSpark.cs @@ -46,12 +46,12 @@ namespace CalamityMod.Projectiles.Melee float targetY = Projectile.Center.Y; bool foundTarget = false; float maxRange = MaxHomingRange; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) { - float iterCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float iterCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float iterCenterX = n.position.X + (float)(n.width / 2); + float iterCenterY = n.position.Y + (float)(n.height / 2); float dist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - iterCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - iterCenterY); if (dist < maxRange) { diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index c02a0bbd26..79c116440d 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -191,13 +191,12 @@ namespace CalamityMod.Projectiles.Melee Rectangle myRect = Projectile.Hitbox; if (Projectile.owner == Main.myPlayer) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; bool voodooDolls = Projectile.owner < Main.maxPlayers && (npc.type == NPCID.Guide && player.killGuide || npc.type == NPCID.Clothier && player.killClothier); bool friendlyProjs = Projectile.friendly && (!npc.friendly || voodooDolls); bool hostileProjs = Projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles; - if (npc.active && !npc.dontTakeDamage && (friendlyProjs || hostileProjs) && (Projectile.owner < 0 || npc.immune[Projectile.owner] == 0 || Projectile.maxPenetrate == 1)) + if (!npc.dontTakeDamage && (friendlyProjs || hostileProjs) && (Projectile.owner < 0 || npc.immune[Projectile.owner] == 0 || Projectile.maxPenetrate == 1)) { if (npc.noTileCollide || !Projectile.ownerHitCheck || (ProjectileLoader.CanHitNPC(Projectile, npc) ?? false)) { diff --git a/Projectiles/Melee/EonBolt.cs b/Projectiles/Melee/EonBolt.cs index d6aaba4fd7..ff20bd185c 100644 --- a/Projectiles/Melee/EonBolt.cs +++ b/Projectiles/Melee/EonBolt.cs @@ -8,6 +8,7 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; +using CalamityMod.Graphics.Primitives; namespace CalamityMod.Projectiles.Melee { diff --git a/Projectiles/Melee/Galaxia_AriesWrath.cs b/Projectiles/Melee/Galaxia_AriesWrath.cs index c948b565c9..fbfac04194 100644 --- a/Projectiles/Melee/Galaxia_AriesWrath.cs +++ b/Projectiles/Melee/Galaxia_AriesWrath.cs @@ -87,9 +87,8 @@ namespace CalamityMod.Projectiles.Melee { float longestReach = MaxProjReach; NPC target = null; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (!excludedTargets.Contains(npc) && npc.CanBeChasedBy() && !npc.friendly && !npc.townNPC) { float distance = Vector2.Distance(hitFrom, npc.Center); diff --git a/Projectiles/Melee/GalaxyBlast.cs b/Projectiles/Melee/GalaxyBlast.cs index f5065f0ba0..632f541652 100644 --- a/Projectiles/Melee/GalaxyBlast.cs +++ b/Projectiles/Melee/GalaxyBlast.cs @@ -79,16 +79,15 @@ namespace CalamityMod.Projectiles.Melee { int npcTracker = -1; float homingRange = 60f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; if (nPC.CanBeChasedBy(Projectile, false)) { float npcDistance = Projectile.Distance(nPC.Center); if (npcDistance < homingRange && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) { homingRange = npcDistance; - npcTracker = i; + npcTracker = nPC.whoAmI; } } } diff --git a/Projectiles/Melee/GalaxyBlastType2.cs b/Projectiles/Melee/GalaxyBlastType2.cs index c511cee1ba..69c316a3d8 100644 --- a/Projectiles/Melee/GalaxyBlastType2.cs +++ b/Projectiles/Melee/GalaxyBlastType2.cs @@ -80,16 +80,15 @@ namespace CalamityMod.Projectiles.Melee { int npcTracker = -1; float homingRange = 60f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; if (nPC.CanBeChasedBy(Projectile, false)) { float npcDistance = Projectile.Distance(nPC.Center); if (npcDistance < homingRange && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) { homingRange = npcDistance; - npcTracker = i; + npcTracker = nPC.whoAmI; } } } diff --git a/Projectiles/Melee/GalaxyBlastType3.cs b/Projectiles/Melee/GalaxyBlastType3.cs index 707c0e8973..6ee3f57b3a 100644 --- a/Projectiles/Melee/GalaxyBlastType3.cs +++ b/Projectiles/Melee/GalaxyBlastType3.cs @@ -79,16 +79,15 @@ namespace CalamityMod.Projectiles.Melee { int npcTracker = -1; float homingRange = 60f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; if (nPC.CanBeChasedBy(Projectile, false)) { float npcDistance = Projectile.Distance(nPC.Center); if (npcDistance < homingRange && Collision.CanHitLine(Projectile.Center, 0, 0, nPC.Center, 0, 0)) { homingRange = npcDistance; - npcTracker = i; + npcTracker = nPC.whoAmI; } } } diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs index 6a70c0a862..c689dd82ff 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs @@ -132,9 +132,8 @@ namespace CalamityMod.Projectiles.Melee { float longestReach = MaxTangleReach; NPC target = null; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (!excludedTargets.Contains(npc) && npc.CanBeChasedBy() && !npc.friendly && !npc.townNPC) { float distance = Vector2.Distance(hitFrom, npc.Center); diff --git a/Projectiles/Melee/MicrowaveAura.cs b/Projectiles/Melee/MicrowaveAura.cs index 3a35f35f65..06c548340b 100644 --- a/Projectiles/Melee/MicrowaveAura.cs +++ b/Projectiles/Melee/MicrowaveAura.cs @@ -66,10 +66,9 @@ namespace CalamityMod.Projectiles.Melee private Projectile FindParent() { Projectile parent = null; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.identity == Projectile.ai[0] && p.active && p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) + if (p.identity == Projectile.ai[0] && p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) { parent = p; break; diff --git a/Projectiles/Melee/MourningSkull.cs b/Projectiles/Melee/MourningSkull.cs index d3c6622512..b709078298 100644 --- a/Projectiles/Melee/MourningSkull.cs +++ b/Projectiles/Melee/MourningSkull.cs @@ -74,21 +74,19 @@ namespace CalamityMod.Projectiles.Melee else { float homingRange = 1000f; - int inc; - for (int j = 0; j < Main.maxNPCs; j = inc + 1) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float targetX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); - float targetY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float targetX = n.position.X + (float)(n.width / 2); + float targetY = n.position.Y + (float)(n.height / 2); float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - targetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - targetY); - if (targetDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) + if (targetDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { homingRange = targetDist; - Projectile.ai[0] = (float)j; + Projectile.ai[0] = (float)n.whoAmI; } } - inc = j; } } diff --git a/Projectiles/Melee/OrderbringerAura.cs b/Projectiles/Melee/OrderbringerAura.cs index ebf5317dae..bdc5e8c106 100644 --- a/Projectiles/Melee/OrderbringerAura.cs +++ b/Projectiles/Melee/OrderbringerAura.cs @@ -52,15 +52,15 @@ namespace CalamityMod.Projectiles.Melee int incTracker = 0; float aiTracker = 0f; int theProjectile = Projectile.type; - for (int i = 0; i < 1000; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner && Main.projectile[i].type == theProjectile && Main.projectile[i].ai[1] < 3600f) + if (p.owner == Projectile.owner && p.type == theProjectile && p.ai[1] < 3600f) { projTimer++; - if (Main.projectile[i].ai[1] > aiTracker) + if (p.ai[1] > aiTracker) { - incTracker = i; - aiTracker = Main.projectile[i].ai[1]; + incTracker = p.whoAmI; + aiTracker = p.ai[1]; } } } diff --git a/Projectiles/Melee/Shortswords/CosmicShivProj.cs b/Projectiles/Melee/Shortswords/CosmicShivProj.cs index ce21686f54..15a8518531 100644 --- a/Projectiles/Melee/Shortswords/CosmicShivProj.cs +++ b/Projectiles/Melee/Shortswords/CosmicShivProj.cs @@ -1,9 +1,14 @@ -using System; +using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; +using Terraria.Graphics; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -57,7 +62,8 @@ namespace CalamityMod.Projectiles.Melee.Shortswords OnHitEffect(); if (NumHits < 3) - { // Just to avoid insanity from stacking so many super dummies or hitting many worm segments at once + { + // Just to avoid insanity from stacking so many super dummies or hitting many worm segments at once // 2x bonus for true melee hits (spawns an additional aura plus the one aura from the cosmic shiv ball) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, target.whoAmI); NumHits++; diff --git a/Projectiles/Melee/SpatialSpear.cs b/Projectiles/Melee/SpatialSpear.cs index 0d3f9d7f29..8d06a0e6d5 100644 --- a/Projectiles/Melee/SpatialSpear.cs +++ b/Projectiles/Melee/SpatialSpear.cs @@ -13,11 +13,11 @@ namespace CalamityMod.Projectiles.Melee { public new string LocalizationCategory => "Projectiles.Melee"; - private const int TimeLeft = 300; + private const int TimeLeft = 180; private const int TimeToFall = TimeLeft / 2; - private const int TotalSplits = 30; + private const int TotalSplits = 6; private const int SplitTime = TimeLeft / TotalSplits; diff --git a/Projectiles/Melee/SpatialSpear2.cs b/Projectiles/Melee/SpatialSpear2.cs index 013bdb2914..bcf1a5c36b 100644 --- a/Projectiles/Melee/SpatialSpear2.cs +++ b/Projectiles/Melee/SpatialSpear2.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Melee private const int TimeToFall = TimeLeft / 2; - private const int TotalSplits = 4; + private const int TotalSplits = 3; private const int SplitTime = TimeLeft / TotalSplits; diff --git a/Projectiles/Melee/StygianShieldAttack.cs b/Projectiles/Melee/StygianShieldAttack.cs index 775bbf5d0c..2293e3eb0e 100644 --- a/Projectiles/Melee/StygianShieldAttack.cs +++ b/Projectiles/Melee/StygianShieldAttack.cs @@ -66,10 +66,9 @@ namespace CalamityMod.Projectiles.Melee // Detach the owner from any mounts/hooks if (Owner.mount != null) Owner.mount.Dismount(Owner); - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (!proj.active || proj.owner != Owner.whoAmI || proj.aiStyle != ProjAIStyleID.Hook) + if (proj.owner != Owner.whoAmI || proj.aiStyle != ProjAIStyleID.Hook) continue; if (proj.aiStyle == ProjAIStyleID.Hook) proj.Kill(); diff --git a/Projectiles/Melee/StygianShieldThrown.cs b/Projectiles/Melee/StygianShieldThrown.cs index 48aa964265..3ee45d065b 100644 --- a/Projectiles/Melee/StygianShieldThrown.cs +++ b/Projectiles/Melee/StygianShieldThrown.cs @@ -120,17 +120,16 @@ namespace CalamityMod.Projectiles.Melee // Find the closest NPC targetable float range = MaxHomingRange; int targetNPC = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; - if (!target.CanBeChasedBy(Projectile) || PreviousNPCs.Contains(i)) + if (!target.CanBeChasedBy(Projectile) || PreviousNPCs.Contains(target.whoAmI)) continue; float distance = Vector2.Distance(target.Center, Projectile.Center); if (distance < range && Collision.CanHit(Projectile, target)) { range = distance; - targetNPC = i; + targetNPC = target.whoAmI; } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSpear.cs b/Projectiles/Melee/TenebreusTidesWaterSpear.cs index 22fb1371eb..da2fbddebb 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSpear.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSpear.cs @@ -123,9 +123,8 @@ namespace CalamityMod.Projectiles.Melee int whoAmI = -1; Vector2 targetSpot = Projectile.Center; float detectRange = 700f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(npc.Center, Projectile.Center); @@ -133,7 +132,7 @@ namespace CalamityMod.Projectiles.Melee { detectRange = targetDist; targetSpot = npc.Center; - whoAmI = i; + whoAmI = npc.whoAmI; } } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSword.cs b/Projectiles/Melee/TenebreusTidesWaterSword.cs index bcec9f85c8..8eeca5bc8d 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSword.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSword.cs @@ -105,9 +105,8 @@ namespace CalamityMod.Projectiles.Melee int whoAmI = -1; Vector2 targetSpot = Projectile.Center; float detectRange = 700f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(npc.Center, Projectile.Center); @@ -115,7 +114,7 @@ namespace CalamityMod.Projectiles.Melee { detectRange = targetDist; targetSpot = npc.Center; - whoAmI = i; + whoAmI = npc.whoAmI; } } } diff --git a/Projectiles/Melee/Tornado.cs b/Projectiles/Melee/Tornado.cs index 035dbd64cf..e1c3021502 100644 --- a/Projectiles/Melee/Tornado.cs +++ b/Projectiles/Melee/Tornado.cs @@ -82,9 +82,8 @@ namespace CalamityMod.Projectiles.Melee } float projX = Projectile.Center.X; float projY = Projectile.Center.Y; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { float npcCenterX = npc.position.X + (float)(npc.width / 2); diff --git a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs index e01060d597..38a4346f7e 100644 --- a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs +++ b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs @@ -138,9 +138,8 @@ namespace CalamityMod.Projectiles.Melee { float longestReach = MaxTangleReach; NPC target = null; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (!excludedTargets.Contains(npc) && npc.CanBeChasedBy() && !npc.friendly && !npc.townNPC) { float distance = Vector2.Distance(hitFrom, npc.Center); diff --git a/Projectiles/Melee/UrchinSpikeFugu.cs b/Projectiles/Melee/UrchinSpikeFugu.cs index aa1e315677..8d22f3cf4a 100644 --- a/Projectiles/Melee/UrchinSpikeFugu.cs +++ b/Projectiles/Melee/UrchinSpikeFugu.cs @@ -29,15 +29,14 @@ namespace CalamityMod.Projectiles.Melee { float maxRange = Projectile.ai[1] == 1f ? 256f : 100f; // Increased homing range for Lionfish int npcIndex = -1; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { float targetDist = (npc.Center - Projectile.Center).Length(); if (targetDist < maxRange) { - npcIndex = i; + npcIndex = npc.whoAmI; maxRange = targetDist; } } diff --git a/Projectiles/Melee/VoidEssence.cs b/Projectiles/Melee/VoidEssence.cs index f04b58b948..692aea191f 100644 --- a/Projectiles/Melee/VoidEssence.cs +++ b/Projectiles/Melee/VoidEssence.cs @@ -88,19 +88,15 @@ namespace CalamityMod.Projectiles.Melee int targetIdx = -1; float maxHomingRange = 400f; bool hasHomingTarget = false; - for (int i = 0; i < Main.npc.Length; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc == null || !npc.active) - continue; - // Won't home in through walls and won't chase invulnerable targets. if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < maxHomingRange) { - targetIdx = i; + targetIdx = npc.whoAmI; maxHomingRange = dist; hasHomingTarget = true; } diff --git a/Projectiles/Melee/WhiteBoltAura.cs b/Projectiles/Melee/WhiteBoltAura.cs index 042342de1d..d361a79873 100644 --- a/Projectiles/Melee/WhiteBoltAura.cs +++ b/Projectiles/Melee/WhiteBoltAura.cs @@ -51,15 +51,15 @@ namespace CalamityMod.Projectiles.Melee int incTracker = 0; float aiTracker = 0f; int theProjectile = Projectile.type; - for (int j = 0; j < 1000; j++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[j].active && Main.projectile[j].owner == Projectile.owner && Main.projectile[j].type == theProjectile && Main.projectile[j].ai[1] < 3600f) + if (p.owner == Projectile.owner && p.type == theProjectile && p.ai[1] < 3600f) { projTimer++; - if (Main.projectile[j].ai[1] > aiTracker) + if (p.ai[1] > aiTracker) { - incTracker = j; - aiTracker = Main.projectile[j].ai[1]; + incTracker = p.whoAmI; + aiTracker = p.ai[1]; } } } diff --git a/Projectiles/Melee/WulfrumScrewdriverProj.cs b/Projectiles/Melee/WulfrumScrewdriverProj.cs index a87015759d..e5b86eea6a 100644 --- a/Projectiles/Melee/WulfrumScrewdriverProj.cs +++ b/Projectiles/Melee/WulfrumScrewdriverProj.cs @@ -88,9 +88,8 @@ namespace CalamityMod.Projectiles.Melee //Check for launchable screws. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; if (proj.ModProjectile != null && proj.owner == Projectile.owner && proj.ModProjectile is WulfrumScrew screw && screw.BazingaTime == 0) { float collisionPoint = 0f; @@ -132,10 +131,8 @@ namespace CalamityMod.Projectiles.Melee float bestScore = 0; NPC bestTarget = null; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC potentialTarget in Main.ActiveNPCs) { - NPC potentialTarget = Main.npc[i]; - if (!potentialTarget.CanBeChasedBy(null, false)) continue; diff --git a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs b/Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs similarity index 96% rename from Projectiles/Melee/Yoyos/SolarFlareYoyo.cs rename to Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs index e05dd23d09..c1b176f8e6 100644 --- a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs +++ b/Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs @@ -9,9 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Yoyos { - public class SolarFlareYoyo : ModProjectile + public class BurningRevelationYoyo : ModProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public const int MaxUpdates = 3; public override void SetStaticDefaults() diff --git a/Projectiles/Melee/Yoyos/SolarFlareYoyo.png b/Projectiles/Melee/Yoyos/BurningRevelationYoyo.png similarity index 100% rename from Projectiles/Melee/Yoyos/SolarFlareYoyo.png rename to Projectiles/Melee/Yoyos/BurningRevelationYoyo.png diff --git a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs index e95a5817f1..4676977462 100644 --- a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs @@ -95,19 +95,15 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { List targets = new List(); float laserRange = 300f; - for (int i = 0; i < Main.npc.Length; ++i) + foreach (NPC n in Main.ActiveNPCs) { - ref NPC n = ref Main.npc[i]; - if (n is null || !n.active) - continue; - if (n.CanBeChasedBy(Projectile, false) && (n.Center - Projectile.Center).Length() <= laserRange && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) { - targets.Add(i); + targets.Add(n.whoAmI); // Bosses are added 5 times instead of 1 so that they are preferentially but not exclusively targeted. if (n.boss) for (int j = 0; j < 4; ++j) - targets.Add(i); + targets.Add(n.whoAmI); } } if (targets.Count == 0) diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index 39ec79b67f..4ed630902c 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -236,10 +236,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos return; Player owner = Main.player[Projectile.owner]; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; - if (!target.active || target.dontTakeDamage || target.friendly) + if (target.dontTakeDamage || target.friendly) continue; // Shock any valid target within range. Check all four corners of their hitbox. @@ -256,7 +255,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos int finalDamage = (int)owner.GetTotalDamage().ApplyTo(baseDamage); if (Projectile.owner == Main.myPlayer) { - Projectile p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), finalDamage, 0f, Projectile.owner, i); + Projectile p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), finalDamage, 0f, Projectile.owner, target.whoAmI); if (p.whoAmI.WithinBounds(Main.maxProjectiles)) p.DamageType = DamageClass.MeleeNoSpeed; } diff --git a/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs b/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs index 851525836a..238cd1a404 100644 --- a/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs +++ b/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs @@ -59,10 +59,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (bubbleStronkCounter >= 180) bubbleStronk = false; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.type == ModContent.ProjectileType() && proj.ai[0] >= 40f && proj.owner == Projectile.owner) + if (proj.type == ModContent.ProjectileType() && proj.ai[0] >= 40f && proj.owner == Projectile.owner) { if (Projectile.Hitbox.Intersects(proj.Hitbox)) { diff --git a/Projectiles/Pets/LadShark.cs b/Projectiles/Pets/LadShark.cs index dceeda70ad..ca68ec4c9c 100644 --- a/Projectiles/Pets/LadShark.cs +++ b/Projectiles/Pets/LadShark.cs @@ -72,18 +72,16 @@ namespace CalamityMod.Projectiles.Pets SoundEngine.PlaySound(SoundID.Zombie15, Projectile.position); //mouse squeak sound float radius = 240f; // 15 blocks - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[j]; - if (npc.active && !npc.dontTakeDamage && Vector2.Distance(Projectile.Center, npc.Center) <= radius) + if (!npc.dontTakeDamage && Vector2.Distance(Projectile.Center, npc.Center) <= radius) { if (npc.Calamity().ladHearts <= 0) npc.Calamity().ladHearts = CalamityUtils.SecondsToFrames(9f); } } - for (int k = 0; k < Main.maxPlayers; k++) + foreach (Player players in Main.ActivePlayers) { - Player players = Main.player[k]; if (!players.dead && Vector2.Distance(Projectile.Center, players.Center) <= radius) { if (players.Calamity().ladHearts <= 0) diff --git a/Projectiles/Ranged/CinderArrowProj.cs b/Projectiles/Ranged/CinderArrowProj.cs index e4bef88e38..1933630860 100644 --- a/Projectiles/Ranged/CinderArrowProj.cs +++ b/Projectiles/Ranged/CinderArrowProj.cs @@ -13,7 +13,11 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Items/Ammo/CinderArrow"; - public bool isShrapnel = false; + + public ref float Time => ref Projectile.ai[1]; + public ref float isSplit => ref Projectile.ai[2]; + public bool splitShot = false; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; @@ -21,13 +25,12 @@ namespace CalamityMod.Projectiles.Ranged } public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.arrow = true; Projectile.penetrate = 1; - Projectile.extraUpdates = 1; + Projectile.MaxUpdates = 2; Projectile.timeLeft = 600; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; @@ -37,33 +40,31 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Projectile.ai[1] == 0) - { - isShrapnel = Projectile.ai[2] == 1; - if (isShrapnel) - { - Projectile.velocity *= 0.5f; - Projectile.timeLeft = 300; - } - } - Projectile.ai[1]++; + Time++; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - if (isShrapnel) - { - Projectile.arrow = false; - Projectile.extraUpdates = 3; + if (isSplit > 0) + { + Projectile.netUpdate = true; + splitShot = true; + } + + if (splitShot) + { + Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.15f); if (Main.rand.NextBool(4)) { Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 2, 90, -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.55f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.65f, 0.85f); + dust.noLight = true; + dust.noLightEmittence = true; } } else { Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.3f); - if (Projectile.ai[1] > 4 && Main.rand.NextBool(3)) + if (Time > 4f && Main.rand.NextBool(3)) { float velMulti = Main.rand.NextFloat(0.1f, 0.75f); Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 2, 90, -Projectile.velocity.RotatedBy(0.45) * velMulti); @@ -82,7 +83,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - if (!isShrapnel) + if (!splitShot) { int Dusts = 9; float radians = MathHelper.TwoPi / Dusts; @@ -95,44 +96,48 @@ namespace CalamityMod.Projectiles.Ranged } SoundEngine.PlaySound(SoundID.Item69 with { Volume = 0.35f, Pitch = 1f, PitchVariance = 0.15f }, Projectile.Center); + if (Main.myPlayer != Projectile.owner) + return; + for (int b = 0; b < 3; b++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(0, -10).RotatedByRandom(0.8f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.1f), 0f, Projectile.owner, 0f, 0f, 1f); + Vector2 velocity = Vector2.UnitY.RotatedByRandom(0.8f) * Main.rand.NextFloat(-3.5f, -3f); + Projectile shrapnel = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1f), 0f, Projectile.owner, ai2: 1f); + shrapnel.timeLeft = 300; + shrapnel.arrow = false; + shrapnel.MaxUpdates = 4; } - if (Projectile.owner == Main.myPlayer) - { - Projectile.damage = (int)(Projectile.damage * 0.5f); - Projectile.penetrate = -1; - Projectile.ExpandHitboxBy(110); - Projectile.Damage(); - } + Projectile.damage = (int)(Projectile.damage * 0.5f); + Projectile.penetrate = -1; + Projectile.ExpandHitboxBy(110); + Projectile.Damage(); } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (isShrapnel) + if (splitShot) { target.AddBuff(ModContent.BuffType(), 180); } } public override bool PreDraw(ref Color lightColor) { - if (isShrapnel) + if (splitShot) { Texture2D texture = ModContent.Request("CalamityMod/Particles/DrainLine").Value; - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.Crimson * 0.35f, 1, texture); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.Crimson * 0.3f, 1, texture); return false; } else { Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Ranged/BloodfireBulletProj").Value; - if (Projectile.ai[1] > 6) + if (Time > 6f) CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.White * 0.3f, 1, texture); return true; } } - public override bool? CanDamage() => isShrapnel && Projectile.ai[1] < 20 ? false : null; + public override bool? CanDamage() => splitShot && Time < 20 ? false : null; } } diff --git a/Projectiles/Ranged/DrataliornusFlame.cs b/Projectiles/Ranged/DrataliornusFlame.cs index dd09b0470e..eb614b0583 100644 --- a/Projectiles/Ranged/DrataliornusFlame.cs +++ b/Projectiles/Ranged/DrataliornusFlame.cs @@ -73,11 +73,9 @@ namespace CalamityMod.Projectiles.Ranged int possibleTarget = -1; float closestDistance = 700f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - - if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && + if (npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal && Collision.CanHit(Projectile.Center, 0, 0, npc.Center, 0, 0)) { float distance = Vector2.Distance(Projectile.Center, npc.Center); @@ -85,7 +83,7 @@ namespace CalamityMod.Projectiles.Ranged if (closestDistance > distance) { closestDistance = distance; - possibleTarget = i; + possibleTarget = npc.whoAmI; } } } diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index d905834c7f..d9b146600d 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -71,10 +71,10 @@ namespace CalamityMod.Projectiles.Ranged Projectile.scale = MathHelper.Lerp(0.001f, 1f, Utils.GetLerpValue(0f, 25f, Time, true)); if (Projectile.localAI[0] == 0f) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile.GetSource_FromThis(), false)) - NPCDestination = Main.npc[i].Center + Main.npc[i].velocity * 5f; + if (n.CanBeChasedBy(Projectile.GetSource_FromThis(), false)) + NPCDestination = n.Center + n.velocity * 5f; } InitialCenter = Projectile.Center; Projectile.localAI[0] = 1f; diff --git a/Projectiles/Ranged/ExoLightningBolt.cs b/Projectiles/Ranged/ExoLightningBolt.cs index 9bf2ca9680..1a3338f0af 100644 --- a/Projectiles/Ranged/ExoLightningBolt.cs +++ b/Projectiles/Ranged/ExoLightningBolt.cs @@ -86,6 +86,10 @@ namespace CalamityMod.Projectiles.Ranged HasPlayedSound = true; } + // This projectile is forced to critically strike. + // This technically is a nerf, as it makes DSO's crits deal less damage. + Projectile.Calamity().forcedCrit = true; + Lighting.AddLight(Projectile.Center, Color.White.ToVector3()); if (Projectile.frameCounter >= Projectile.extraUpdates * 2) { diff --git a/Projectiles/Ranged/HailstormBulletProj.cs b/Projectiles/Ranged/HailstormBulletProj.cs index 29712945f8..66721fffd5 100644 --- a/Projectiles/Ranged/HailstormBulletProj.cs +++ b/Projectiles/Ranged/HailstormBulletProj.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged WaterFlavoredParticle subTrail = new WaterFlavoredParticle(Projectile.Center + velocity * 4.5f + addedPlacement, velocity * 7, false, 6, 0.65f, Color.SkyBlue); GeneralParticleHandler.SpawnParticle(subTrail); } - int onHitDamage = Owner.CalcIntDamage(0.48f * Projectile.damage); + int onHitDamage = Owner.CalcIntDamage(0.36f * Projectile.damage); Owner.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); } } diff --git a/Projectiles/Ranged/HolyFireBulletProj.cs b/Projectiles/Ranged/HolyFireBulletProj.cs index 5b7bd37e5c..97da541fc2 100644 --- a/Projectiles/Ranged/HolyFireBulletProj.cs +++ b/Projectiles/Ranged/HolyFireBulletProj.cs @@ -32,8 +32,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.MaxUpdates = 5; - Projectile.localNPCHitCooldown = 10; - Projectile.usesLocalNPCImmunity = true; Projectile.timeLeft = Lifetime; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } diff --git a/Projectiles/Ranged/KingsbaneHoldout.cs b/Projectiles/Ranged/KingsbaneHoldout.cs index 9ac5958b2b..7d27d3545b 100644 --- a/Projectiles/Ranged/KingsbaneHoldout.cs +++ b/Projectiles/Ranged/KingsbaneHoldout.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Ranged public int fullRevShots = 50; public int windupAnim = 11; public int soundTimer = 0; + public bool discharging = false; public override void SetDefaults() { @@ -31,6 +32,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.ignoreWater = true; + Projectile.alpha = 255; } public override void SetStaticDefaults() { @@ -39,6 +41,10 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Time++; + + if (Time == 3) + Projectile.alpha = 0; + if (Time % 2 == 0) soundTimer++; Projectile.frameCounter++; @@ -77,8 +83,9 @@ namespace CalamityMod.Projectiles.Ranged Owner.PickAmmo(Owner.ActiveItem(), out bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out int _); // Fire Auric Bullets if the owner stops channeling or otherwise cannot use the weapon. - if (Owner.CantUseHoldout()) + if (Owner.CantUseHoldout() || discharging) { + discharging = true; if (fullRev && fullRevShots > 0) { Projectile.timeLeft = 2; @@ -93,6 +100,7 @@ namespace CalamityMod.Projectiles.Ranged Owner.velocity += -Projectile.velocity * fullRevShots * (Main.zenithWorld ? 0.028f : 0.013f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition + Projectile.velocity * 5 + Main.rand.NextVector2Circular(7, 7), shootVelocity.RotatedByRandom(MathHelper.ToRadians(4f)), ModContent.ProjectileType(), (int)(Projectile.damage * 0.9f), Projectile.knockBack, Projectile.owner); SoundEngine.PlaySound(SoundID.Item40 with { PitchVariance = 0.4f }, Projectile.Center); + Owner.channel = true; //SoundEngine.PlaySound(Kingsbane.AuricFire with { PitchVariance = 0.4f }, Projectile.Center); fullRevShots--; } @@ -137,9 +145,9 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.myPlayer == Projectile.owner) { - float interpolant = Utils.GetLerpValue(5f, 55f, Projectile.Distance(Main.MouseWorld), true); + float interpolant = Utils.GetLerpValue(0f, 55f, Owner.Distance(Main.MouseWorld), true); Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), 0.185f).SafeNormalize(Vector2.UnitY); if (Projectile.velocity != oldVelocity) { Projectile.netSpam = 0; @@ -151,9 +159,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.spriteDirection = Projectile.direction; // Rumble - if (Owner.CantUseHoldout()) + if (Owner.CantUseHoldout() || discharging) { - Projectile.position += Main.rand.NextVector2Circular(4.5f, 4.5f); + Projectile.Center += Main.rand.NextVector2Circular(4.5f, 4.5f); } } diff --git a/Projectiles/Ranged/MagnomalyAura.cs b/Projectiles/Ranged/MagnomalyAura.cs index 0d3807eddf..44c91fe234 100644 --- a/Projectiles/Ranged/MagnomalyAura.cs +++ b/Projectiles/Ranged/MagnomalyAura.cs @@ -30,9 +30,8 @@ namespace CalamityMod.Projectiles.Ranged { Projectile parent = Main.projectile[0]; bool active = false; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; if (p.identity == Projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) { parent = p; diff --git a/Projectiles/Ranged/MarksmanShot.cs b/Projectiles/Ranged/MarksmanShot.cs index 5afea94f6a..e7f74735cf 100644 --- a/Projectiles/Ranged/MarksmanShot.cs +++ b/Projectiles/Ranged/MarksmanShot.cs @@ -45,6 +45,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.friendly = true; Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; Projectile.timeLeft = Lifetime; Projectile.MaxUpdates = UpdateCount; Projectile.alpha = 255; diff --git a/Projectiles/Ranged/MineralMortarHoldout.cs b/Projectiles/Ranged/MineralMortarHoldout.cs index 72ced92643..aa1f8f32b6 100644 --- a/Projectiles/Ranged/MineralMortarHoldout.cs +++ b/Projectiles/Ranged/MineralMortarHoldout.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged { Owner.PickAmmo(Owner.ActiveItem(), out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * speed, ModContent.ProjectileType(), damage, knockback, Projectile.owner, usedItemAmmoId); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * speed * 1.5f, ModContent.ProjectileType(), damage, knockback, Projectile.owner, usedItemAmmoId); // Doesn't sync this to the server, it's just effects. if (!Main.dedServ) diff --git a/Projectiles/Ranged/NitroShot.cs b/Projectiles/Ranged/NitroShot.cs index d25a0330c6..1efd86ee4b 100644 --- a/Projectiles/Ranged/NitroShot.cs +++ b/Projectiles/Ranged/NitroShot.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.ignoreWater = true; - Projectile.penetrate = 9; + Projectile.penetrate = 5; Projectile.timeLeft = 600; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } diff --git a/Projectiles/Ranged/NorfleetCannon.cs b/Projectiles/Ranged/NorfleetCannon.cs index 82638e84c5..3a4177fb51 100644 --- a/Projectiles/Ranged/NorfleetCannon.cs +++ b/Projectiles/Ranged/NorfleetCannon.cs @@ -1,4 +1,6 @@ using System; +using System.Runtime.Intrinsics.X86; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Humanizer; @@ -37,6 +39,8 @@ namespace CalamityMod.Projectiles.Ranged public Color mainColor = Color.White; public Color randomColor = Color.White; public int colorTimer = 0; + public bool hasFired = false; + public bool PUNISHMENTMODE = false; public override void SetDefaults() { @@ -50,7 +54,10 @@ namespace CalamityMod.Projectiles.Ranged { Item heldItem = Owner.ActiveItem(); - randomColor = Main.rand.Next(3) switch + if (Owner.dead || Owner is null) + Projectile.Kill(); + + randomColor = Main.rand.Next(3) switch { 0 => Color.OrangeRed, 1 => Color.Aqua, @@ -59,6 +66,8 @@ namespace CalamityMod.Projectiles.Ranged if (mainColor == Color.White) { mainColor = randomColor; + if (Projectile.ai[1] == 1000) + PUNISHMENTMODE = true; } if (ShootingTimer % 15 == 0) @@ -77,7 +86,7 @@ namespace CalamityMod.Projectiles.Ranged mainColor = Color.Lerp(mainColor, variedColor, (PostFireCooldown <= 20 || recharging) ? 0.07f : 0); // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. - if (Owner.CantUseHoldout() && !HasLetGo || heldItem.type != ModContent.ItemType()) + if (Owner.CantUseHoldout() && !HasLetGo) { if (SoundEngine.TryGetActiveSound(NorfleetRecharge, out var hum) && hum.IsPlaying) { @@ -86,16 +95,16 @@ namespace CalamityMod.Projectiles.Ranged if (loadedShots > 1) { ShootRocket(heldItem); - PostFireCooldown = 55; + PostFireCooldown = PUNISHMENTMODE ? 1000 : 55; ShootingTimer = 1; - mainColor = Color.MediumOrchid; + mainColor = PUNISHMENTMODE ? Color.Red : Color.MediumOrchid; } else { ShootRocket(heldItem); - PostFireCooldown = 262; + PostFireCooldown = PUNISHMENTMODE ? 1000 : 262; ShootingTimer = 1; - mainColor = Color.MediumOrchid; + mainColor = PUNISHMENTMODE ? Color.Red : Color.MediumOrchid; } @@ -159,7 +168,7 @@ namespace CalamityMod.Projectiles.Ranged // Rumble (only while channeling) float rumble = 1f; - if (!Owner.CantUseHoldout()) + if (!Owner.CantUseHoldout() && PostFireCooldown <= 0) Projectile.Center += Main.rand.NextVector2Circular(rumble, rumble); if (PostFireCooldown < 297 && PostFireCooldown > 15 && recharging) { @@ -170,54 +179,77 @@ namespace CalamityMod.Projectiles.Ranged private void ShootRocket(Item item) { - // We use the velocity of this projectile as its direction vector. - Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); - - // The position of the tip of the gun. - Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 73f; - - // Spawns the projectile. - SoundStyle fire = new("CalamityMod/Sounds/Item/NorfleetFire"); - SoundEngine.PlaySound(fire with { Volume = 0.9f, PitchVariance = 0.25f }, Projectile.Center); - - for (int i = 0; i < 3; i++) + if (hasFired == false) { - Vector2 firingVelocity = shootDirection.RotatedByRandom((0.2f * i) + 0.02f) * 5f * Main.rand.NextFloat(0.7f, 1.3f); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, i); + // We use the velocity of this projectile as its direction vector. + Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); + + // The position of the tip of the gun. + Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 73f; + + // Spawns the projectile. + SoundStyle fire = new("CalamityMod/Sounds/Item/NorfleetFire"); + SoundEngine.PlaySound(fire with { Volume = 0.9f, PitchVariance = 0.25f }, Projectile.Center); + + for (int i = 0; i < 3; i++) + { + Vector2 firingVelocity = shootDirection.RotatedByRandom((0.2f * i) + 0.02f) * 5f * Main.rand.NextFloat(0.7f, 1.3f); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, i, PUNISHMENTMODE ? 1 : 0); + } + + NetUpdate(); + + // Inside here go all the things that dedicated servers shouldn't spend resources on. + // Like visuals and sounds. + if (Main.dedServ) + return; + + for (int k = 0; k < 30; k++) + { + Vector2 shootVel = (shootDirection * 10).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1.8f); + + Dust dust2 = Dust.NewDustPerfect(tipPosition, Main.rand.NextBool(4) ? 264 : 66, shootVel); + dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust2.noGravity = true; + if (dust2.type == 66) + dust2.color = Main.rand.NextBool() ? Color.DarkViolet : Color.MediumOrchid; + else + dust2.color = Color.White; + } + for (int k = 0; k < 15; k++) + { + Particle pulse = new GlowSparkParticle((tipPosition - shootDirection * 14) + Main.rand.NextVector2Circular(12, 12), shootDirection * 17 * Main.rand.NextFloat(0.35f, 1.35f), false, Main.rand.Next(7, 11 + 1), 0.025f * Main.rand.NextFloat(0.45f, 1.25f), Color.MediumOrchid, new Vector2(1.5f, 0.9f), true); + GeneralParticleHandler.SpawnParticle(pulse); + } + + // By decreasing the offset length of the gun from the arms, we give an effect of recoil. + OffsetLength -= 34f; + hasFired = true; } - - NetUpdate(); - - // Inside here go all the things that dedicated servers shouldn't spend resources on. - // Like visuals and sounds. - if (Main.dedServ) - return; - - for (int k = 0; k < 30; k++) + else { - Vector2 shootVel = (shootDirection * 10).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1.8f); - - Dust dust2 = Dust.NewDustPerfect(tipPosition, Main.rand.NextBool(4) ? 264 : 66, shootVel); - dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); - dust2.noGravity = true; - if (dust2.type == 66) - dust2.color = Main.rand.NextBool() ? Color.DarkViolet : Color.MediumOrchid; + if (Owner.Calamity().NorfleetCounter >= 1000) + Owner.Calamity().NorfleetCounter = 3; else - dust2.color = Color.White; - } - for (int k = 0; k < 15; k++) - { - Particle pulse = new GlowSparkParticle((tipPosition - shootDirection * 14) + Main.rand.NextVector2Circular(12, 12), shootDirection * 17 * Main.rand.NextFloat(0.35f, 1.35f), false, Main.rand.Next(7, 11 + 1), 0.025f * Main.rand.NextFloat(0.45f, 1.25f), Color.MediumOrchid, new Vector2(1.5f, 0.9f), true); - GeneralParticleHandler.SpawnParticle(pulse); - } + Owner.Calamity().NorfleetCounter = 1000; - // By decreasing the offset length of the gun from the arms, we give an effect of recoil. - OffsetLength -= 34f; + Projectile.Kill(); + } } private void PostFiringCooldown() { + Owner.channel = true; Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 73f; + if (PUNISHMENTMODE) + { + PostFireCooldown = 1000; + Owner.AddBuff(ModContent.BuffType(), 900); + Owner.AddBuff(ModContent.BuffType(), 900); + if (Owner.statLife > 1) + Owner.statLife = (int)(Owner.statLife * 0.99f); + } + if (PostFireCooldown == 207) { OffsetLength -= 24f; @@ -228,12 +260,12 @@ namespace CalamityMod.Projectiles.Ranged if (PostFireCooldown > 0 && !recharging) { Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); - Particle smoke = new HeavySmokeParticle(tipPosition, smokeVel, StaticEffectsColor, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.3f, 0.6f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + Particle smoke = new HeavySmokeParticle(tipPosition, smokeVel, PUNISHMENTMODE ? Color.Red : StaticEffectsColor, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.3f, 0.6f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); GeneralParticleHandler.SpawnParticle(smoke); Dust dust = Dust.NewDustPerfect(tipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; - dust.color = Color.White; + dust.color = PUNISHMENTMODE ? Color.Red : Color.White; } else if (!recharging) { @@ -268,6 +300,7 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle click = new("CalamityMod/Sounds/Item/DudFire"); SoundEngine.PlaySound(click with { Volume = 1f, Pitch = 0.7f }, Projectile.Center); + Owner.Calamity().NorfleetCounter = 0; } if (PostFireCooldown > 15) { @@ -336,7 +369,7 @@ namespace CalamityMod.Projectiles.Ranged Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); - Main.EntitySpriteDraw(glowTexture, drawPosition, null, mainColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, null, PUNISHMENTMODE ? Color.Red : mainColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); if (PostFireCooldown > 15 && recharging) { float randSize = Main.rand.NextFloat(0.8f, 1.2f); diff --git a/Projectiles/Ranged/NorfleetComet.cs b/Projectiles/Ranged/NorfleetComet.cs index ef0dbb752f..e10696a580 100644 --- a/Projectiles/Ranged/NorfleetComet.cs +++ b/Projectiles/Ranged/NorfleetComet.cs @@ -39,15 +39,37 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Player player = Main.player[Projectile.owner]; float rotationRando = Main.rand.NextFloat(-0.02f, 0.02f); Projectile.velocity = Projectile.velocity.RotatedBy(rotationRando); Projectile.rotation += 0.05f; + if (Projectile.ai[2] == 1) + { + Projectile.friendly = false; + if (time >= 75) + { + Projectile.hostile = true; + + float distanceFromPlayer = Projectile.Distance(player.Center); + + // This is done instead of a Normalize or DirectionTo call because the variables needed are already present and calculating the square root again would be unnecessary. + Vector2 idealVelocity = (player.Center - Projectile.Center) / distanceFromPlayer * 8f; + + Projectile.velocity.X += Math.Sign(idealVelocity.X - Projectile.velocity.X) * (0.0005f * time); + Projectile.velocity.Y += Math.Sign(idealVelocity.Y - Projectile.velocity.Y) * (0.0005f * time); + + if (Projectile.Hitbox.Intersects(player.Hitbox)) + Projectile.Kill(); + + Projectile.timeLeft = 5; + } + } if (time > 25) { for (int i = 0; i < 2; i++) { Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 30f; - Dust dust = Dust.NewDustPerfect(dustPos, Main.rand.NextBool(3) ? 272 : 86, (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 3f); + Dust dust = Dust.NewDustPerfect(dustPos, (Projectile.ai[2] == 1 ? 219 : Main.rand.NextBool(3) ? 272 : 86), (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 3f); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.6f, 0.9f); } @@ -67,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0, Projectile.ai[1]); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0, Projectile.ai[1], Projectile.ai[2] == 1 ? 1 : 0); if (Projectile.ai[1] == 0) { diff --git a/Projectiles/Ranged/NorfleetExplosion.cs b/Projectiles/Ranged/NorfleetExplosion.cs index d0a0bf3fde..66a58bd95a 100644 --- a/Projectiles/Ranged/NorfleetExplosion.cs +++ b/Projectiles/Ranged/NorfleetExplosion.cs @@ -40,9 +40,13 @@ namespace CalamityMod.Projectiles.Ranged Projectile.damage = 1; } - public override void OnKill(int timeLeft) + public override void AI() { - + if (Projectile.ai[2] == 1) + { + Projectile.friendly = false; + Projectile.hostile = true; + } } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.cs b/Projectiles/Ranged/PhotovisceratorHoldout.cs index 14ddf60640..2b5d81ed2c 100644 --- a/Projectiles/Ranged/PhotovisceratorHoldout.cs +++ b/Projectiles/Ranged/PhotovisceratorHoldout.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; @@ -269,5 +270,16 @@ namespace CalamityMod.Projectiles.Ranged Sound?.Stop(); PhotoTimer = 90; } + + public override void PostDraw(Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Vector2 origin = new Vector2(85f, 33f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Ranged/PhotovisceratorHoldoutGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + } } } diff --git a/Projectiles/Ranged/PhotovisceratorHoldoutGlow.png b/Projectiles/Ranged/PhotovisceratorHoldoutGlow.png new file mode 100644 index 0000000000..5ad78c0e7e Binary files /dev/null and b/Projectiles/Ranged/PhotovisceratorHoldoutGlow.png differ diff --git a/Projectiles/Ranged/PolarStar.cs b/Projectiles/Ranged/PolarStar.cs index bdc4de08d8..b870ab4aff 100644 --- a/Projectiles/Ranged/PolarStar.cs +++ b/Projectiles/Ranged/PolarStar.cs @@ -46,6 +46,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = true; } public override void AI() @@ -126,30 +127,6 @@ namespace CalamityMod.Projectiles.Ranged DoSlowdown = false; } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Time = 2; - - if (tileBounces >= 2) - Projectile.Kill(); - else - tileBounces++; - - for (int i = 0; i <= 5; i++) - { - SquishyLightParticle energy = new(Projectile.Center, Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(0.08f, 0.15f), Main.rand.NextFloat(0.4f, 0.7f), EffectsColor, Main.rand.Next(40, 50 + 1), 0.25f, 2f); - GeneralParticleHandler.SpawnParticle(energy); - } - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } - return false; - } public override void OnKill(int timeLeft) { int points = 5; diff --git a/Projectiles/Ranged/PrismMine.cs b/Projectiles/Ranged/PrismMine.cs index 363878009d..d677b63c99 100644 --- a/Projectiles/Ranged/PrismMine.cs +++ b/Projectiles/Ranged/PrismMine.cs @@ -68,10 +68,9 @@ namespace CalamityMod.Projectiles.Ranged public List LocateOtherMines() { List mines = new List(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj.type != Projectile.type || !proj.active || proj.timeLeft <= 12 || i == Projectile.whoAmI) + if (proj.type != Projectile.type || proj.timeLeft <= 12 || proj.whoAmI == Projectile.whoAmI) continue; if (!Projectile.WithinRange(proj.Center, MineConnectDistanceMax)) continue; diff --git a/Projectiles/Ranged/TheHiveHoldout.cs b/Projectiles/Ranged/TheHiveHoldout.cs index 6d2e6234a6..f29cb26b3e 100644 --- a/Projectiles/Ranged/TheHiveHoldout.cs +++ b/Projectiles/Ranged/TheHiveHoldout.cs @@ -36,18 +36,13 @@ namespace CalamityMod.Projectiles.Ranged public override void KillHoldoutLogic() { - if (HeldItem.type != ItemType()) - { - Projectile.Kill(); - Projectile.netUpdate = true; - } - if (HasLetGo) PostFiringCooldown(); } public override void HoldoutAI() { + FireNuke = ShootingTimer > MaxCharge; // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. @@ -57,7 +52,8 @@ namespace CalamityMod.Projectiles.Ranged { hum?.Stop(); } - ShootRocket(); + if (HeldItem.type == ItemType()) + ShootRocket(); NetUpdate(); HasLetGo = true; } @@ -216,6 +212,7 @@ namespace CalamityMod.Projectiles.Ranged private void PostFiringCooldown() { + Owner.channel = true; if (PostFireCooldown > 0) { PostFireCooldown--; @@ -267,7 +264,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 rotationPoint = texture.Size() * 0.5f; SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - if (!Owner.CantUseHoldout()) + if (!Owner.CantUseHoldout() && PostFireCooldown <= 0) { float rumble = Utils.GetLerpValue(0f, MaxCharge, ShootingTimer, true) * ShootingTimer >= MaxCharge ? 2 : 0.8f; drawPosition += Main.rand.NextVector2Circular(rumble, rumble); diff --git a/Projectiles/Ranged/ThePackMissile.cs b/Projectiles/Ranged/ThePackMissile.cs index 3ae4347197..9a369c0616 100644 --- a/Projectiles/Ranged/ThePackMissile.cs +++ b/Projectiles/Ranged/ThePackMissile.cs @@ -36,11 +36,11 @@ namespace CalamityMod.Projectiles.Ranged Vector2 targetCenter = Projectile.Center; float minTargetDistance = 2500f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) { - float distanceFromTarget = Projectile.Center.ManhattanDistance(Main.npc[i].Center); + float distanceFromTarget = Projectile.Center.ManhattanDistance(n.Center); if (distanceFromTarget < 200f) { if (Projectile.owner == Main.myPlayer) @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged else if (distanceFromTarget < minTargetDistance) { minTargetDistance = distanceFromTarget; - targetCenter = Main.npc[i].Center; + targetCenter = n.Center; homeIn = true; } } diff --git a/Projectiles/Ranged/UniversalGenesisStarcaller.cs b/Projectiles/Ranged/UniversalGenesisStarcaller.cs index 0f32060983..2c95e6bdeb 100644 --- a/Projectiles/Ranged/UniversalGenesisStarcaller.cs +++ b/Projectiles/Ranged/UniversalGenesisStarcaller.cs @@ -87,9 +87,8 @@ namespace CalamityMod.Projectiles.Ranged bool bossFound = false; int life = 0; Vector2 targetVec = Projectile.Center; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (bossFound && !npc.IsABoss()) continue; if (npc.CanBeChasedBy(Projectile, false)) diff --git a/Projectiles/Rogue/AlphaSeeker.cs b/Projectiles/Rogue/AlphaSeeker.cs index 40721f2fb7..7d91a5bc1f 100644 --- a/Projectiles/Rogue/AlphaSeeker.cs +++ b/Projectiles/Rogue/AlphaSeeker.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = 1; Projectile.timeLeft = lifetime; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.Calamity().CannotProc = true; Projectile.extraUpdates = 1; } @@ -50,10 +51,9 @@ namespace CalamityMod.Projectiles.Rogue Projectile parent = Main.projectile[0]; bool active = false; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.identity == Projectile.ai[1] && p.active) + if (p.identity == Projectile.ai[1]) { parent = p; active = true; @@ -141,10 +141,9 @@ namespace CalamityMod.Projectiles.Rogue { int target = -1; float minDist = HomingStartRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (var npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) + if (npc.type == NPCID.TargetDummy) continue; if (npc.CanBeChasedBy(Projectile, false)) @@ -155,7 +154,7 @@ namespace CalamityMod.Projectiles.Rogue if (distToNPC < minDist) { minDist = distToNPC; - target = i; + target = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/AuroradicalStar.cs b/Projectiles/Rogue/AuroradicalStar.cs index e577cdd132..2b0acbde3b 100644 --- a/Projectiles/Rogue/AuroradicalStar.cs +++ b/Projectiles/Rogue/AuroradicalStar.cs @@ -72,16 +72,15 @@ namespace CalamityMod.Projectiles.Rogue //Home in float maxDistance = 800f; int targetIndex = -1; - int i; - for (i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + float extraDistance = (n.width / 2) + (n.height / 2); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance)) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance)) { - targetIndex = i; + targetIndex = n.whoAmI; break; } } diff --git a/Projectiles/Rogue/BlunderBoosterLightning.cs b/Projectiles/Rogue/BlunderBoosterLightning.cs index dd935e3195..322fa2d5f9 100644 --- a/Projectiles/Rogue/BlunderBoosterLightning.cs +++ b/Projectiles/Rogue/BlunderBoosterLightning.cs @@ -57,16 +57,15 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = -1; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/BouncyBol.cs b/Projectiles/Rogue/BouncyBol.cs index 5c62b6b6ef..32dfaba20c 100644 --- a/Projectiles/Rogue/BouncyBol.cs +++ b/Projectiles/Rogue/BouncyBol.cs @@ -47,21 +47,20 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { bool hasHitNPC = false; for (int j = 0; j < previousNPCs.Count; j++) { - if (previousNPCs[j] == i) + if (previousNPCs[j] == npc.whoAmI) { hasHitNPC = true; } } - NPC npc = Main.npc[i]; if (npc == target) { - previousNPCs.Add(i); + previousNPCs.Add(npc.whoAmI); } if (npc.CanBeChasedBy(Projectile, false) && npc != target && !hasHitNPC) { @@ -69,7 +68,7 @@ namespace CalamityMod.Projectiles.Rogue if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/CobaltEnergy.cs b/Projectiles/Rogue/CobaltEnergy.cs index 0d43432bde..d6ead0de25 100644 --- a/Projectiles/Rogue/CobaltEnergy.cs +++ b/Projectiles/Rogue/CobaltEnergy.cs @@ -59,21 +59,20 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { bool hasHitNPC = false; for (int j = 0; j < previousNPCs.Count; j++) { - if (previousNPCs[j] == i) + if (previousNPCs[j] == npc.whoAmI) { hasHitNPC = true; } } - NPC npc = Main.npc[i]; if (npc == target) { - previousNPCs.Add(i); + previousNPCs.Add(npc.whoAmI); } if (npc.CanBeChasedBy(Projectile, false) && npc != target && !hasHitNPC) { @@ -81,7 +80,7 @@ namespace CalamityMod.Projectiles.Rogue if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/ContaminatedBileFlask.cs b/Projectiles/Rogue/ContaminatedBileFlask.cs index 93140dc3f7..2d130b58eb 100644 --- a/Projectiles/Rogue/ContaminatedBileFlask.cs +++ b/Projectiles/Rogue/ContaminatedBileFlask.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - Projectile.width = Projectile.height = 24; + Projectile.width = Projectile.height = 28; Projectile.friendly = true; Projectile.penetrate = 1; Projectile.timeLeft = 300; diff --git a/Projectiles/Rogue/DestructionBolt.cs b/Projectiles/Rogue/DestructionBolt.cs index 71daf97bbe..7ab9e7cc56 100644 --- a/Projectiles/Rogue/DestructionBolt.cs +++ b/Projectiles/Rogue/DestructionBolt.cs @@ -55,16 +55,16 @@ namespace CalamityMod.Projectiles.Rogue { int index = -1; float otherConstant = 300f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - Vector2 npcCenter = Main.npc[i].Center; + Vector2 npcCenter = n.Center; float targetDist = Vector2.Distance(npcCenter, Projectile.Center); if (targetDist < otherConstant && index == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, npcCenter, 1, 1)) { otherConstant = targetDist; - index = i; + index = n.whoAmI; } } } diff --git a/Projectiles/Rogue/DynamicPursuerProjectile.cs b/Projectiles/Rogue/DynamicPursuerProjectile.cs index f0b630c69a..d12823defd 100644 --- a/Projectiles/Rogue/DynamicPursuerProjectile.cs +++ b/Projectiles/Rogue/DynamicPursuerProjectile.cs @@ -241,18 +241,18 @@ namespace CalamityMod.Projectiles.Rogue float targettingDistance = MaxTargetSearchDistance * 2f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var n in Main.ActiveNPCs) { - if (i == target.whoAmI) + if (n.whoAmI == target.whoAmI) continue; - if (Main.npc[i].CanBeChasedBy(Projectile)) + if (n.CanBeChasedBy(Projectile)) { - float potentialNewDistance = (Projectile.Center - Main.npc[i].Center).Length(); + float potentialNewDistance = (Projectile.Center - n.Center).Length(); if (potentialNewDistance < targettingDistance && potentialNewDistance < closestNPCDistance) { closestNPCDistance = potentialNewDistance; - newTarget = Main.npc[i]; + newTarget = n; nextTarget = newTarget; if (Projectile.timeLeft < 300) Projectile.timeLeft = 300; diff --git a/Projectiles/Rogue/ElementalDiskProj.cs b/Projectiles/Rogue/ElementalDiskProj.cs index a262f8d9b0..0d32eba95d 100644 --- a/Projectiles/Rogue/ElementalDiskProj.cs +++ b/Projectiles/Rogue/ElementalDiskProj.cs @@ -116,9 +116,8 @@ namespace CalamityMod.Projectiles.Rogue float maxDistance = 300f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float extraDistance = npc.width / 2 + npc.height / 2; diff --git a/Projectiles/Rogue/EnchantedAxeProj.cs b/Projectiles/Rogue/EnchantedAxeProj.cs index ab8ce605d0..3ef7ccf355 100644 --- a/Projectiles/Rogue/EnchantedAxeProj.cs +++ b/Projectiles/Rogue/EnchantedAxeProj.cs @@ -73,16 +73,15 @@ namespace CalamityMod.Projectiles.Rogue float minDist = 999f; int index = 0; // Get the closest enemy to the axe - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/EquanimityDarkShard.cs b/Projectiles/Rogue/EquanimityDarkShard.cs index 42da8f6630..aa65007872 100644 --- a/Projectiles/Rogue/EquanimityDarkShard.cs +++ b/Projectiles/Rogue/EquanimityDarkShard.cs @@ -30,16 +30,15 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/FinalDawnThrow2.cs b/Projectiles/Rogue/FinalDawnThrow2.cs index 9109382a0a..71e5979a8f 100644 --- a/Projectiles/Rogue/FinalDawnThrow2.cs +++ b/Projectiles/Rogue/FinalDawnThrow2.cs @@ -77,11 +77,9 @@ namespace CalamityMod.Projectiles.Rogue } // Kill any hooks from the projectile owner. - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - - if (!proj.active || proj.owner != player.whoAmI || proj.aiStyle != ProjAIStyleID.Hook) + if (proj.owner != player.whoAmI || proj.aiStyle != ProjAIStyleID.Hook) continue; if (proj.aiStyle == ProjAIStyleID.Hook) diff --git a/Projectiles/Rogue/FishboneBoomerangProjectile.cs b/Projectiles/Rogue/FishboneBoomerangProjectile.cs index 905b5409b5..f15ed5da4d 100644 --- a/Projectiles/Rogue/FishboneBoomerangProjectile.cs +++ b/Projectiles/Rogue/FishboneBoomerangProjectile.cs @@ -168,18 +168,18 @@ namespace CalamityMod.Projectiles.Rogue float closestNPCDistance = 10000f; float targettingDistance = 400f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (i == target.whoAmI) + if (n.whoAmI == target.whoAmI) continue; - if (Main.npc[i].CanBeChasedBy(Projectile)) + if (n.CanBeChasedBy(Projectile)) { - float potentialNewDistance = (Projectile.Center - Main.npc[i].Center).Length(); + float potentialNewDistance = (Projectile.Center - n.Center).Length(); if (potentialNewDistance < targettingDistance && potentialNewDistance < closestNPCDistance) { closestNPCDistance = potentialNewDistance; - newTarget = Main.npc[i]; + newTarget = n; } } } diff --git a/Projectiles/Rogue/FrostyFlareProj.cs b/Projectiles/Rogue/FrostyFlareProj.cs index 8b8ea4711f..f101b2cb23 100644 --- a/Projectiles/Rogue/FrostyFlareProj.cs +++ b/Projectiles/Rogue/FrostyFlareProj.cs @@ -96,15 +96,15 @@ namespace CalamityMod.Projectiles.Rogue int flaresFound = 0; int oldestFlare = -1; int oldestFlareTimeLeft = 300; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == Projectile.type && i != Projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) + if (p.owner == Main.myPlayer && p.type == Projectile.type && p.whoAmI != Projectile.whoAmI && p.ai[1] == target.whoAmI) { flaresFound++; - if (Main.projectile[i].timeLeft < oldestFlareTimeLeft) + if (p.timeLeft < oldestFlareTimeLeft) { - oldestFlareTimeLeft = Main.projectile[i].timeLeft; - oldestFlare = Main.projectile[i].whoAmI; + oldestFlareTimeLeft = p.timeLeft; + oldestFlare = p.whoAmI; } if (flaresFound >= maxFlares) break; diff --git a/Projectiles/Rogue/FrostyFlareStealth.cs b/Projectiles/Rogue/FrostyFlareStealth.cs index 3bda873ea7..e485108463 100644 --- a/Projectiles/Rogue/FrostyFlareStealth.cs +++ b/Projectiles/Rogue/FrostyFlareStealth.cs @@ -105,15 +105,15 @@ namespace CalamityMod.Projectiles.Rogue int flaresFound = 0; int oldestFlare = -1; int oldestFlareTimeLeft = 300; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == Projectile.type && i != Projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) + if (p.owner == Main.myPlayer && p.type == Projectile.type && p.whoAmI != Projectile.whoAmI && p.ai[1] == target.whoAmI) { flaresFound++; - if (Main.projectile[i].timeLeft < oldestFlareTimeLeft) + if (p.timeLeft < oldestFlareTimeLeft) { - oldestFlareTimeLeft = Main.projectile[i].timeLeft; - oldestFlare = Main.projectile[i].whoAmI; + oldestFlareTimeLeft = p.timeLeft; + oldestFlare = p.whoAmI; } if (flaresFound >= maxFlares) break; diff --git a/Projectiles/Rogue/GildedDaggerProj.cs b/Projectiles/Rogue/GildedDaggerProj.cs index 19b51fd850..5d1d4d48f2 100644 --- a/Projectiles/Rogue/GildedDaggerProj.cs +++ b/Projectiles/Rogue/GildedDaggerProj.cs @@ -70,21 +70,20 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { bool hasHitNPC = false; for (int j = 0; j < previousNPCs.Count; j++) { - if (previousNPCs[j] == i) + if (previousNPCs[j] == npc.whoAmI) { hasHitNPC = true; } } - NPC npc = Main.npc[i]; if (npc == target) { - previousNPCs.Add(i); + previousNPCs.Add(npc.whoAmI); } if (npc.CanBeChasedBy(Projectile, false) && npc != target && !hasHitNPC) { @@ -92,7 +91,7 @@ namespace CalamityMod.Projectiles.Rogue if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/GleamingDaggerProj.cs b/Projectiles/Rogue/GleamingDaggerProj.cs index 14913d4f07..99c742ee71 100644 --- a/Projectiles/Rogue/GleamingDaggerProj.cs +++ b/Projectiles/Rogue/GleamingDaggerProj.cs @@ -70,21 +70,20 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { bool hasHitNPC = false; for (int j = 0; j < previousNPCs.Count; j++) { - if (previousNPCs[j] == i) + if (previousNPCs[j] == npc.whoAmI) { hasHitNPC = true; } } - NPC npc = Main.npc[i]; if (npc == target) { - previousNPCs.Add(i); + previousNPCs.Add(npc.whoAmI); } if (npc.CanBeChasedBy(Projectile, false) && npc != target && !hasHitNPC) { @@ -92,7 +91,7 @@ namespace CalamityMod.Projectiles.Rogue if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs index 1b8beb43bd..2916cc6b65 100644 --- a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs +++ b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs @@ -30,14 +30,14 @@ namespace CalamityMod.Projectiles.Rogue Projectile.ignoreWater = true; Projectile.netImportant = true; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 150; Projectile.DamageType = RogueDamageClass.Instance; } public override void AI() { - if (Projectile.Calamity().stealthStrike && Projectile.timeLeft % 5f == 4f) // every 5 frames - CalamityUtils.ProjectileRain(Projectile.GetSource_FromThis(), Projectile.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); + if (Projectile.Calamity().stealthStrike && Projectile.timeLeft % 20f == 4f) // every 5 frames + CalamityUtils.ProjectileRain(Projectile.GetSource_FromThis(), Projectile.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), Projectile.damage / 6, Projectile.knockBack * 0.5f, Projectile.owner); if (Projectile.alpha > 0) { @@ -63,9 +63,6 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation += 0.5f; - if (Owner.position.Y != Owner.oldPosition.Y && Projectile.ai[0] == 0f) - Projectile.ai[1]++; - Projectile.ai[0]++; if (Main.myPlayer == Projectile.owner && Projectile.ai[0] == 20f) @@ -158,12 +155,12 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[dusty].velocity *= 0f; } - if (Projectile.owner == Main.myPlayer && Projectile.ai[1] > 0) + if (Projectile.owner == Main.myPlayer) { for (int i = 0; i < 5; i++) { Vector2 velocity = ((MathHelper.TwoPi * i / 5f) - MathHelper.PiOver2).ToRotationVector2() * 4f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner, 0f, 1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage / 4, Projectile.knockBack * 0.5f, Projectile.owner, 0f, 1f); } } } diff --git a/Projectiles/Rogue/Honeycomb.cs b/Projectiles/Rogue/Honeycomb.cs index 9b67402379..5e3ca0a392 100644 --- a/Projectiles/Rogue/Honeycomb.cs +++ b/Projectiles/Rogue/Honeycomb.cs @@ -21,12 +21,24 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 30; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.aiStyle = ProjAIStyleID.ThrownProjectile; Projectile.timeLeft = 300; - AIType = ProjectileID.ThrowingKnife; Projectile.DamageType = RogueDamageClass.Instance; } + public override void AI() + { + Projectile.ai[0]++; + + Projectile.rotation += MathHelper.ToRadians(Projectile.velocity.X * 1.25f); + if (Projectile.ai[0] > 45) + { + Projectile.velocity.X *= 0.97f; + Projectile.velocity.Y += 0.28f; + if (Projectile.velocity.Y > 18f) + Projectile.velocity.Y = 18f; + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Player player = Main.player[Main.myPlayer]; @@ -43,6 +55,20 @@ namespace CalamityMod.Projectiles.Rogue SpawnProjectiles(); } + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.position); + SpawnProjectiles(); + + //Dust on impact + int dust_splash = 0; + while (dust_splash < 9) + { + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Copper, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.15f, 159, default, 1.5f); + dust_splash += 1; + } + } + public void SpawnProjectiles() { Player player = Main.player[Main.myPlayer]; @@ -72,17 +98,5 @@ namespace CalamityMod.Projectiles.Rogue Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.position); - //Dust on impact - int dust_splash = 0; - while (dust_splash < 9) - { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Copper, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.15f, 159, default, 1.5f); - dust_splash += 1; - } - } } } diff --git a/Projectiles/Rogue/IcebreakerHammer.cs b/Projectiles/Rogue/IcebreakerHammer.cs index ff7f603d8d..4ae1e85156 100644 --- a/Projectiles/Rogue/IcebreakerHammer.cs +++ b/Projectiles/Rogue/IcebreakerHammer.cs @@ -64,10 +64,9 @@ namespace CalamityMod.Projectiles.Rogue int buffType = ModContent.BuffType(); float radius = 112f; // 7 blocks - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC in Main.ActiveNPCs) { - NPC nPC = Main.npc[i]; - if (nPC.active && !nPC.dontTakeDamage && !nPC.buffImmune[buffType] && Vector2.Distance(Projectile.Center, nPC.Center) <= radius) + if (!nPC.dontTakeDamage && !nPC.buffImmune[buffType] && Vector2.Distance(Projectile.Center, nPC.Center) <= radius) { if (nPC.FindBuffIndex(buffType) == -1) nPC.AddBuff(buffType, 60, false); @@ -93,10 +92,9 @@ namespace CalamityMod.Projectiles.Rogue int buffType = ModContent.BuffType(); float radius = 112f; // 7 blocks - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player player in Main.ActivePlayers) { Player owner = Main.player[Projectile.owner]; - Player player = Main.player[i]; if ((owner.team != player.team || player.team == 0) && player.hostile && owner.hostile && !player.dead && !player.buffImmune[buffType] && Vector2.Distance(Projectile.Center, player.Center) <= radius) { if (player.FindBuffIndex(buffType) == -1) diff --git a/Projectiles/Rogue/MalachiteStealth.cs b/Projectiles/Rogue/MalachiteStealth.cs index 2f6451498f..77206f17f0 100644 --- a/Projectiles/Rogue/MalachiteStealth.cs +++ b/Projectiles/Rogue/MalachiteStealth.cs @@ -127,15 +127,15 @@ namespace CalamityMod.Projectiles.Rogue int kunaiFound = 0; int oldestKunai = -1; int oldestKunaiTimeLeft = lifeSpan; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == Projectile.type && i != Projectile.whoAmI && Main.projectile[i].ai[1] == target.whoAmI) + if (p.owner == Main.myPlayer && p.type == Projectile.type && p.whoAmI != Projectile.whoAmI && p.ai[1] == target.whoAmI) { kunaiFound++; - if (Main.projectile[i].timeLeft < oldestKunaiTimeLeft) + if (p.timeLeft < oldestKunaiTimeLeft) { - oldestKunaiTimeLeft = Main.projectile[i].timeLeft; - oldestKunai = Main.projectile[i].whoAmI; + oldestKunaiTimeLeft = p.timeLeft; + oldestKunai = p.whoAmI; } if (kunaiFound >= maxKunai) break; diff --git a/Projectiles/Rogue/MeteorFistStealth.cs b/Projectiles/Rogue/MeteorFistStealth.cs index d7e386cc7f..d08caeb9a1 100644 --- a/Projectiles/Rogue/MeteorFistStealth.cs +++ b/Projectiles/Rogue/MeteorFistStealth.cs @@ -157,16 +157,15 @@ namespace CalamityMod.Projectiles.Rogue // Get the closest enemy to the fist if (Projectile.penetrate != -1) { - for (int i = 0; i < Main.npc.Length; i++) + foreach (var npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && npc != target) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/NanoblackSplit.cs b/Projectiles/Rogue/NanoblackSplit.cs index 03d77819c7..6fb8f943a6 100644 --- a/Projectiles/Rogue/NanoblackSplit.cs +++ b/Projectiles/Rogue/NanoblackSplit.cs @@ -128,10 +128,9 @@ namespace CalamityMod.Projectiles.Rogue bool bossFound = false; int target = -1; float minDist = HomingStartRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) + if (npc.type == NPCID.TargetDummy) continue; // If we've found a valid boss target, ignore ALL targets which aren't bosses. @@ -149,7 +148,7 @@ namespace CalamityMod.Projectiles.Rogue if (npc.boss) bossFound = true; minDist = distToNPC; - target = i; + target = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/NanoblackStealthSplit.cs b/Projectiles/Rogue/NanoblackStealthSplit.cs index a9dc579fb6..b91da360f6 100644 --- a/Projectiles/Rogue/NanoblackStealthSplit.cs +++ b/Projectiles/Rogue/NanoblackStealthSplit.cs @@ -137,10 +137,9 @@ namespace CalamityMod.Projectiles.Rogue bool bossFound = false; int target = -1; float minDist = HomingStartRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) + if (npc.type == NPCID.TargetDummy) continue; // If we've found a valid boss target, ignore ALL targets which aren't bosses. @@ -158,7 +157,7 @@ namespace CalamityMod.Projectiles.Rogue if (npc.boss) bossFound = true; minDist = distToNPC; - target = i; + target = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/NightsGazeStar.cs b/Projectiles/Rogue/NightsGazeStar.cs index bcf4b231a2..fad89f3222 100644 --- a/Projectiles/Rogue/NightsGazeStar.cs +++ b/Projectiles/Rogue/NightsGazeStar.cs @@ -65,16 +65,15 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/NychthemeronOrb.cs b/Projectiles/Rogue/NychthemeronOrb.cs index 9a16edbac9..2c2a439121 100644 --- a/Projectiles/Rogue/NychthemeronOrb.cs +++ b/Projectiles/Rogue/NychthemeronOrb.cs @@ -30,10 +30,9 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { bool isActive = false; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.identity == Projectile.ai[1] && p.active) + if (p.identity == Projectile.ai[1]) { isActive = true; } @@ -64,16 +63,15 @@ namespace CalamityMod.Projectiles.Rogue // Follow Enemy float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/RadiantExplosion.cs b/Projectiles/Rogue/RadiantExplosion.cs index ed8f447e7d..9c6a87fafe 100644 --- a/Projectiles/Rogue/RadiantExplosion.cs +++ b/Projectiles/Rogue/RadiantExplosion.cs @@ -60,30 +60,30 @@ namespace CalamityMod.Projectiles.Rogue { float projX = Projectile.Center.X; float projY = Projectile.Center.Y; - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[j].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); - float npcCenterY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float npcCenterX = n.position.X + (float)(n.width / 2); + float npcCenterY = n.position.Y + (float)(n.height / 2); float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); if (targetDist < 600f) { - if (Main.npc[j].position.X < projX) + if (n.position.X < projX) { - Main.npc[j].velocity.X += 0.25f; + n.velocity.X += 0.25f; } else { - Main.npc[j].velocity.X -= 0.25f; + n.velocity.X -= 0.25f; } - if (Main.npc[j].position.Y < projY) + if (n.position.Y < projY) { - Main.npc[j].velocity.Y += 0.25f; + n.velocity.Y += 0.25f; } else { - Main.npc[j].velocity.Y -= 0.25f; + n.velocity.Y -= 0.25f; } } } diff --git a/Projectiles/Rogue/RadiantStar2.cs b/Projectiles/Rogue/RadiantStar2.cs index 44e60111e5..2fc8e04e0a 100644 --- a/Projectiles/Rogue/RadiantStar2.cs +++ b/Projectiles/Rogue/RadiantStar2.cs @@ -41,30 +41,30 @@ namespace CalamityMod.Projectiles.Rogue float projY = Projectile.Center.Y; float homeRange = Projectile.Calamity().stealthStrike ? 1800f : 600f; float homingSpeed = 0.25f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcCenterX = n.position.X + (float)(n.width / 2); + float npcCenterY = n.position.Y + (float)(n.height / 2); float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); if (targetDist < homeRange) { - if (Main.npc[i].position.X < projX) + if (n.position.X < projX) { - Main.npc[i].velocity.X += homingSpeed; + n.velocity.X += homingSpeed; } else { - Main.npc[i].velocity.X -= homingSpeed; + n.velocity.X -= homingSpeed; } - if (Main.npc[i].position.Y < projY) + if (n.position.Y < projY) { - Main.npc[i].velocity.Y += homingSpeed; + n.velocity.Y += homingSpeed; } else { - Main.npc[i].velocity.Y -= homingSpeed; + n.velocity.Y -= homingSpeed; } } } diff --git a/Projectiles/Rogue/RadiantStarKnife.cs b/Projectiles/Rogue/RadiantStarKnife.cs index 1c9a51d6d7..fa3d6ca7ff 100644 --- a/Projectiles/Rogue/RadiantStarKnife.cs +++ b/Projectiles/Rogue/RadiantStarKnife.cs @@ -41,9 +41,8 @@ namespace CalamityMod.Projectiles.Rogue float projY = Projectile.Center.Y; float homeRange = Projectile.Calamity().stealthStrike ? 1800f : 600f; float homingSpeed = 0.25f; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !npc.boss) { float npcX = npc.position.X + (float)(npc.width / 2); diff --git a/Projectiles/Rogue/RealityRuptureMini.cs b/Projectiles/Rogue/RealityRuptureMini.cs index 9a5a53d134..aa16a31513 100644 --- a/Projectiles/Rogue/RealityRuptureMini.cs +++ b/Projectiles/Rogue/RealityRuptureMini.cs @@ -53,16 +53,16 @@ namespace CalamityMod.Projectiles.Rogue float maxDistance = 350f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - bool canHit = Projectile.Calamity().stealthStrike || Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); + float extraDistance = (float)(n.width / 2) + (float)(n.height / 2); + bool canHit = Projectile.Calamity().stealthStrike || Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance) && canHit) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance) && canHit) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } diff --git a/Projectiles/Rogue/ReaperProjectile.cs b/Projectiles/Rogue/ReaperProjectile.cs index fd8bfe5e4e..b1f15611b0 100644 --- a/Projectiles/Rogue/ReaperProjectile.cs +++ b/Projectiles/Rogue/ReaperProjectile.cs @@ -87,10 +87,9 @@ namespace CalamityMod.Projectiles.Rogue Vector2 homingTarget = Projectile.Center; bool foundTarget = false; Vector2 targetVelocity = new Vector2(0f); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC potentialTarget in Main.ActiveNPCs) { - NPC potentialTarget = Main.npc[i]; - if (potentialTarget.CanBeChasedBy(Projectile, false) && Projectile.WithinRange(Main.npc[i].Center, homingRange)) + if (potentialTarget.CanBeChasedBy(Projectile, false) && Projectile.WithinRange(potentialTarget.Center, homingRange)) { if (!foundTarget) { diff --git a/Projectiles/Rogue/RegulusEnergy.cs b/Projectiles/Rogue/RegulusEnergy.cs index e7a56a394b..cac9b64289 100644 --- a/Projectiles/Rogue/RegulusEnergy.cs +++ b/Projectiles/Rogue/RegulusEnergy.cs @@ -54,15 +54,15 @@ namespace CalamityMod.Projectiles.Rogue float maxDistance = 500f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (float)(n.width / 2) + (float)(n.height / 2); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } diff --git a/Projectiles/Rogue/SamsaraSlicerProjectile.cs b/Projectiles/Rogue/SamsaraSlicerProjectile.cs index e0bfbd6a17..e0c48554f8 100644 --- a/Projectiles/Rogue/SamsaraSlicerProjectile.cs +++ b/Projectiles/Rogue/SamsaraSlicerProjectile.cs @@ -143,9 +143,8 @@ namespace CalamityMod.Projectiles.Rogue const float maxDistance = 300f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float extraDistance = npc.width / 2 + npc.height / 2; diff --git a/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs b/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs index 220b381b0d..9d0c40de2b 100644 --- a/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs +++ b/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs @@ -47,10 +47,9 @@ namespace CalamityMod.Projectiles.Rogue Projectile parent = Main.projectile[0]; bool active = false; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.identity == Projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) + if (p.identity == Projectile.ai[0] && p.type == ModContent.ProjectileType()) { parent = p; active = true; diff --git a/Projectiles/Rogue/ScourgeoftheDesertProj.cs b/Projectiles/Rogue/ScourgeoftheDesertProj.cs index 186ae20d14..15f6029cb4 100644 --- a/Projectiles/Rogue/ScourgeoftheDesertProj.cs +++ b/Projectiles/Rogue/ScourgeoftheDesertProj.cs @@ -101,19 +101,28 @@ namespace CalamityMod.Projectiles.Rogue } if (InsideTiles) { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(Projectile.GetSource_FromThis(), false)) - NPCDestination = Main.npc[i].Center + Main.npc[i].velocity * 5f; - } - TimeUnderground++; Vector3 DustLight = new Vector3(0.171f, 0.124f, 0.086f); - Lighting.AddLight(Projectile.Center + Projectile.velocity, DustLight * 4); + Lighting.AddLight(Projectile.Center + Projectile.velocity, DustLight * 1.5f); if (Time % 15 == 0 && TimeUnderground < 120) { SoundEngine.PlaySound(SoundID.WormDig with { Volume = 0.7f, Pitch = 0.2f }, Projectile.Center); } + + + NPC target = Projectile.Center.ClosestNPCAt(1800, true); + if (target == null) + { + if (Projectile.velocity.Y < 0) + { + Projectile.velocity.Y *= 0.98f; + } + Projectile.velocity.Y += 0.08f; + Projectile.velocity.X *= 0.99f; + return; + } + NPCDestination = target.Center + target.velocity * 5f; + float returnSpeed = 10; float acceleration = 0.2f; float xDist = NPCDestination.X - Projectile.Center.X; diff --git a/Projectiles/Rogue/SearedPanProjectile.cs b/Projectiles/Rogue/SearedPanProjectile.cs index 174bc44bc7..a7022fce06 100644 --- a/Projectiles/Rogue/SearedPanProjectile.cs +++ b/Projectiles/Rogue/SearedPanProjectile.cs @@ -129,18 +129,18 @@ namespace CalamityMod.Projectiles.Rogue { if (Projectile.owner == Main.myPlayer) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!Main.projectile[i].active || Main.projectile[i].owner != Projectile.owner) + if (p.owner != Projectile.owner) continue; - if (Main.projectile[i].ModProjectile is NiceCock) + if (p.ModProjectile is NiceCock) { if (!activate) - Main.projectile[i].Kill(); + p.Kill(); else { - Main.projectile[i].ModProjectile().homing = true; - Main.projectile[i].extraUpdates += 2; + p.ModProjectile().homing = true; + p.extraUpdates += 2; } } } @@ -151,14 +151,14 @@ namespace CalamityMod.Projectiles.Rogue { int fireballCount = 0; // Count how many fireballs exist already around the given target - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { // Keep the loop as short as possible - if (!Main.projectile[i].active || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].CountsAsClass() || targetIndex != (int)Main.projectile[i].ai[1]) + if (p.owner != Projectile.owner || !p.CountsAsClass() || targetIndex != (int)p.ai[1]) continue; - if (Main.projectile[i].ModProjectile is NiceCock) + if (p.ModProjectile is NiceCock) { - if (Main.projectile[i].ModProjectile().homing) + if (p.ModProjectile().homing) continue; fireballCount++; } @@ -166,16 +166,16 @@ namespace CalamityMod.Projectiles.Rogue // Adjust the angle of the existing fireballs around a target float angleVariance = MathHelper.TwoPi / fireballCount; float angle = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!Main.projectile[i].active || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].CountsAsClass() || targetIndex != (int)Main.projectile[i].ai[1]) + if (p.owner != Projectile.owner || !p.CountsAsClass() || targetIndex != (int)p.ai[1]) continue; - if (Main.projectile[i].ModProjectile is NiceCock) + if (p.ModProjectile is NiceCock) { - if (Main.projectile[i].ModProjectile().homing) + if (p.ModProjectile().homing) continue; - Main.projectile[i].ai[0] = angle; - Main.projectile[i].netUpdate = true; + p.ai[0] = angle; + p.netUpdate = true; angle += angleVariance; } } diff --git a/Projectiles/Rogue/ShatteredSunKnife.cs b/Projectiles/Rogue/ShatteredSunKnife.cs index 1c6ecfe6de..9a6017b8d5 100644 --- a/Projectiles/Rogue/ShatteredSunKnife.cs +++ b/Projectiles/Rogue/ShatteredSunKnife.cs @@ -90,30 +90,30 @@ namespace CalamityMod.Projectiles.Rogue { float projX = Projectile.Center.X; float projY = Projectile.Center.Y; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcCenterX = n.position.X + (float)(n.width / 2); + float npcCenterY = n.position.Y + (float)(n.height / 2); float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); if (targetDist < 600f) { - if (Main.npc[i].position.X < projX) + if (n.position.X < projX) { - Main.npc[i].velocity.X += 0.25f; + n.velocity.X += 0.25f; } else { - Main.npc[i].velocity.X -= 0.25f; + n.velocity.X -= 0.25f; } - if (Main.npc[i].position.Y < projY) + if (n.position.Y < projY) { - Main.npc[i].velocity.Y += 0.25f; + n.velocity.Y += 0.25f; } else { - Main.npc[i].velocity.Y -= 0.25f; + n.velocity.Y -= 0.25f; } } } diff --git a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs index de1bbed1c3..ce556d1071 100644 --- a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs +++ b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs @@ -76,9 +76,8 @@ namespace CalamityMod.Projectiles.Rogue float targetDistStore; Vector2 homingPos = Projectile.position; bool isHoming = false; - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); @@ -112,30 +111,30 @@ namespace CalamityMod.Projectiles.Rogue { float projX = Projectile.Center.X; float projY = Projectile.Center.Y; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { - float npcCenterX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcCenterY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcCenterX = n.position.X + (float)(n.width / 2); + float npcCenterY = n.position.Y + (float)(n.height / 2); float targetDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); if (targetDistance < 600f) { - if (Main.npc[i].position.X < projX) + if (n.position.X < projX) { - Main.npc[i].velocity.X += 0.25f; + n.velocity.X += 0.25f; } else { - Main.npc[i].velocity.X -= 0.25f; + n.velocity.X -= 0.25f; } - if (Main.npc[i].position.Y < projY) + if (n.position.Y < projY) { - Main.npc[i].velocity.Y += 0.25f; + n.velocity.Y += 0.25f; } else { - Main.npc[i].velocity.Y -= 0.25f; + n.velocity.Y -= 0.25f; } } } diff --git a/Projectiles/Rogue/ShockGrenadeBolt.cs b/Projectiles/Rogue/ShockGrenadeBolt.cs index e9b685a881..3d647376a3 100644 --- a/Projectiles/Rogue/ShockGrenadeBolt.cs +++ b/Projectiles/Rogue/ShockGrenadeBolt.cs @@ -56,16 +56,15 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Rogue/SlickCaneProjectile.cs b/Projectiles/Rogue/SlickCaneProjectile.cs index 4c1acff6de..5e325c56e6 100644 --- a/Projectiles/Rogue/SlickCaneProjectile.cs +++ b/Projectiles/Rogue/SlickCaneProjectile.cs @@ -1,9 +1,13 @@ using System; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -21,7 +25,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.width = 42; Projectile.height = 36; Projectile.DamageType = RogueDamageClass.Instance; - Projectile.timeLeft = 90; + Projectile.timeLeft = 120; Projectile.friendly = true; Projectile.hostile = false; Projectile.tileCollide = false; @@ -32,6 +36,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 2; Projectile.alpha = 180; + Projectile.scale = 1.25f; } public override SpearType SpearAiType => SpearType.GhastlyGlaiveSpear; public override float TravelSpeed => 8f; @@ -80,11 +85,13 @@ namespace CalamityMod.Projectiles.Rogue float moneyValueToDrop = target.value / Main.rand.NextFloat(15f, 35f); // Maximum of 50 silver, not counting steath strikes moneyValueToDrop = (int)MathHelper.Clamp(moneyValueToDrop, 0, 5000f); - if (Projectile.Calamity().stealthStrike && Main.rand.NextBool(15)) + if (Projectile.Calamity().stealthStrike && Main.rand.NextBool(20)) { moneyValueToDrop += Item.buyPrice(0, Main.rand.Next(1, 4), Main.rand.Next(0, 100), Main.rand.Next(0, 100)); + SoundEngine.PlaySound(TheSevensStriker.TriplesSound, Projectile.Center); } - + else if (moneyValueToDrop > 0f) + SoundEngine.PlaySound(TheSevensStriker.DoublesSound, Projectile.Center); while (moneyValueToDrop > 10000f) { int modifiedMoneyValue = (int)(moneyValueToDrop / 10000f); @@ -133,5 +140,29 @@ namespace CalamityMod.Projectiles.Rogue } } } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // Boost dmg in proportion to money, caps at 2 plat + if (Projectile.Calamity().stealthStrike) + { + Player player = Main.player[Projectile.owner]; + double money = Utils.CoinsCount(out bool overflow, player.inventory); + if (money >= 2000000) + money = 2000000; + if (money != 0) + { + modifiers.SourceDamage *= (float)(money / 500000 + 1); + SoundEngine.PlaySound(TheSevensStriker.JackpotSound, Projectile.Center); + for (int j = 0; j < 8; j++) + { + int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 3f); + Main.dust[dust2].noGravity = true; + Main.dust[dust2].velocity *= 5f; + dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 2f); + Main.dust[dust2].velocity *= 2f; + } + } + } + } } } diff --git a/Projectiles/Rogue/SpearofDestinyProjectile.cs b/Projectiles/Rogue/SpearofDestinyProjectile.cs index 27f75dbf83..cbec922070 100644 --- a/Projectiles/Rogue/SpearofDestinyProjectile.cs +++ b/Projectiles/Rogue/SpearofDestinyProjectile.cs @@ -63,16 +63,16 @@ namespace CalamityMod.Projectiles.Rogue float maxDistance = 200f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - bool canHit = Projectile.Calamity().stealthStrike || Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); + float extraDistance = (float)(n.width / 2) + (float)(n.height / 2); + bool canHit = Projectile.Calamity().stealthStrike || Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance) && canHit) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance) && canHit) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } diff --git a/Projectiles/Rogue/StellarKnifeProj.cs b/Projectiles/Rogue/StellarKnifeProj.cs index 62c1b8abf3..1b90218b98 100644 --- a/Projectiles/Rogue/StellarKnifeProj.cs +++ b/Projectiles/Rogue/StellarKnifeProj.cs @@ -69,15 +69,15 @@ namespace CalamityMod.Projectiles.Rogue float maxDistance = 600f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (float)(n.width / 2) + (float)(n.height / 2); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance)) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance)) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } diff --git a/Projectiles/Rogue/SupernovaStealthBoom.cs b/Projectiles/Rogue/SupernovaStealthBoom.cs index 9ddb03c9b1..aaa399a2cc 100644 --- a/Projectiles/Rogue/SupernovaStealthBoom.cs +++ b/Projectiles/Rogue/SupernovaStealthBoom.cs @@ -285,7 +285,7 @@ namespace CalamityMod.Projectiles.Rogue _ => Color.LawnGreen, }; - Particle pulse2 = new CustomPulse(Projectile.Center, Vector2.Zero, randomColor * 0.7f, "CalamityMod/Particles/HighResHollowCircleHardEdge", new Vector2(1f, 1f), 0f, 0f, 4f - i * 0.28f, 50); + Particle pulse2 = new CustomPulse(Projectile.Center, Vector2.Zero, randomColor * 0.7f, "CalamityMod/Particles/FlameExplosion", new Vector2(1f, 1f), Main.rand.NextFloat(-20, 20), 0f, 4f - i * 0.28f, 50); GeneralParticleHandler.SpawnParticle(pulse2); } diff --git a/Projectiles/Rogue/TimeBoltKnife.cs b/Projectiles/Rogue/TimeBoltKnife.cs index e60f1d8767..0372da7e39 100644 --- a/Projectiles/Rogue/TimeBoltKnife.cs +++ b/Projectiles/Rogue/TimeBoltKnife.cs @@ -132,9 +132,8 @@ namespace CalamityMod.Projectiles.Rogue int whoAmI = -1; Vector2 targetSpot = Projectile.Center; float detectRange = 1000f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(npc.Center, Projectile.Center); @@ -142,7 +141,7 @@ namespace CalamityMod.Projectiles.Rogue { detectRange = targetDist; targetSpot = npc.Center; - whoAmI = i; + whoAmI = npc.whoAmI; } } } @@ -304,10 +303,9 @@ namespace CalamityMod.Projectiles.Rogue int buffType = ModContent.BuffType(); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.active && !npc.dontTakeDamage && !npc.buffImmune[buffType] && Vector2.Distance(Projectile.Center, npc.Center) <= radius) + if (!npc.dontTakeDamage && !npc.buffImmune[buffType] && Vector2.Distance(Projectile.Center, npc.Center) <= radius) { if (npc.FindBuffIndex(buffType) == -1) npc.AddBuff(buffType, 60, false); diff --git a/Projectiles/Rogue/VeneratedKnife.cs b/Projectiles/Rogue/VeneratedKnife.cs index 93830c3b28..960c4eb363 100644 --- a/Projectiles/Rogue/VeneratedKnife.cs +++ b/Projectiles/Rogue/VeneratedKnife.cs @@ -37,16 +37,15 @@ namespace CalamityMod.Projectiles.Rogue { float minDist = 999f; int index = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < minDist) { minDist = dist; - index = i; + index = npc.whoAmI; } } } diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index 7bba64724b..58ba156d6c 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -126,9 +126,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/AquasScepterCloud.cs b/Projectiles/Summon/AquasScepterCloud.cs index 1d8af26757..37e01d580f 100644 --- a/Projectiles/Summon/AquasScepterCloud.cs +++ b/Projectiles/Summon/AquasScepterCloud.cs @@ -57,10 +57,8 @@ namespace CalamityMod.Projectiles.Summon } - for (int i = 0; i < Main.maxNPCs; i++) + foreach (var npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy()) { float between = Vector2.Distance(npc.Center, Projectile.Center); diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index 675c375416..4d1f353634 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -123,9 +123,8 @@ namespace CalamityMod.Projectiles.Summon } else { - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { bool lineOfSight = Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height); diff --git a/Projectiles/Summon/AtlasMunitionsAutocannon.cs b/Projectiles/Summon/AtlasMunitionsAutocannon.cs index d01046351f..5161f2b0b5 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannon.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannon.cs @@ -200,20 +200,20 @@ namespace CalamityMod.Projectiles.Summon if (!CannonIsMounted) { int detachedCannonID = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != detachedCannonID || !Main.projectile[i].active || Main.projectile[i].owner != Projectile.owner) + if (p.type != detachedCannonID || p.owner != Projectile.owner) continue; - if (!Main.projectile[i].Hitbox.Intersects(Projectile.Hitbox)) + if (!p.Hitbox.Intersects(Projectile.Hitbox)) continue; - if (Main.projectile[i].ModProjectile().BeingHeld) + if (p.ModProjectile().BeingHeld) continue; - Main.projectile[i].Kill(); + p.Kill(); CannonIsMounted = true; - HeatInterpolant = Main.projectile[i].ModProjectile().HeatInterpolant; + HeatInterpolant = p.ModProjectile().HeatInterpolant; Projectile.netUpdate = true; break; } @@ -222,11 +222,13 @@ namespace CalamityMod.Projectiles.Summon // If a cannon is not mounted, die if the owner goes very, very far away. else if (!Projectile.WithinRange(Owner.Center, 7200f)) { - for (int i = 0; i < Main.maxProjectiles; i++) + int podID = ModContent.ProjectileType(); + int podUpperID = ModContent.ProjectileType(); + foreach (Projectile p in Main.ActiveProjectiles) { - bool validID = Main.projectile[i].type == ModContent.ProjectileType(); - if (Main.projectile[i].active && validID && Main.projectile[i].owner == Projectile.owner) - Main.projectile[i].Kill(); + bool validID = p.type == podID || p.type == podUpperID; + if (validID && p.owner == Projectile.owner) + p.Kill(); } Projectile.Kill(); diff --git a/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs b/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs index 64a475442a..be7518fde5 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs @@ -171,11 +171,11 @@ namespace CalamityMod.Projectiles.Summon int podID = ModContent.ProjectileType(); int podUpperID = ModContent.ProjectileType(); int cannonID = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - bool validID = Main.projectile[i].type == podID || Main.projectile[i].type == podUpperID || Main.projectile[i].type == cannonID; - if (Main.projectile[i].active && validID && Main.projectile[i].owner == Projectile.owner) - Main.projectile[i].Kill(); + bool validID = p.type == podID || p.type == podUpperID || p.type == cannonID; + if (validID && p.owner == Projectile.owner) + p.Kill(); } Projectile.Kill(); diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index 9ea82a99b5..3bd8c32128 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -53,11 +53,10 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - for (int j = 0; j < Main.maxProjectiles; j++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[j]; // Short circuits to make the loop as fast as possible - if (!proj.active || proj.owner != Projectile.owner || !proj.minion || proj.Calamity().lineColor != 1) + if (proj.owner != Projectile.owner || !proj.minion || proj.Calamity().lineColor != 1) continue; if (proj.type == Projectile.type) { diff --git a/Projectiles/Summon/BabyPlaguebringer.cs b/Projectiles/Summon/BabyPlaguebringer.cs index 62cd29c934..862928f071 100644 --- a/Projectiles/Summon/BabyPlaguebringer.cs +++ b/Projectiles/Summon/BabyPlaguebringer.cs @@ -100,9 +100,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/BlackDragonBody.cs b/Projectiles/Summon/BlackDragonBody.cs index 9b945dff76..27168209bd 100644 --- a/Projectiles/Summon/BlackDragonBody.cs +++ b/Projectiles/Summon/BlackDragonBody.cs @@ -63,10 +63,9 @@ namespace CalamityMod.Projectiles.Summon var live = false; Projectile nextSegment = new Projectile(); BlackDragonHead head = new BlackDragonHead(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == Type && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == Type && projectile.owner == Projectile.owner) { if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) { @@ -74,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon nextSegment = projectile; } } - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { if (segmentIndex == 1) { @@ -108,10 +107,9 @@ namespace CalamityMod.Projectiles.Summon { if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { projectile.Kill(); } diff --git a/Projectiles/Summon/BlackDragonTail.cs b/Projectiles/Summon/BlackDragonTail.cs index 9cdd238f9f..0b9be2eff1 100644 --- a/Projectiles/Summon/BlackDragonTail.cs +++ b/Projectiles/Summon/BlackDragonTail.cs @@ -50,10 +50,9 @@ namespace CalamityMod.Projectiles.Summon Projectile nextSegment = new Projectile(); BlackDragonHead head = new BlackDragonHead(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) { @@ -61,7 +60,7 @@ namespace CalamityMod.Projectiles.Summon nextSegment = projectile; } } - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { if (segmentIndex == 1) { @@ -96,10 +95,9 @@ namespace CalamityMod.Projectiles.Summon { if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { projectile.Kill(); } diff --git a/Projectiles/Summon/BrimstoneElementalMinion.cs b/Projectiles/Summon/BrimstoneElementalMinion.cs index 7d4a7de5dc..7abda0562d 100644 --- a/Projectiles/Summon/BrimstoneElementalMinion.cs +++ b/Projectiles/Summon/BrimstoneElementalMinion.cs @@ -117,9 +117,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack && !passive) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/CnidarianJellyfishOnTheString.cs b/Projectiles/Summon/CnidarianJellyfishOnTheString.cs index 04d14b3cc5..45e342e5a3 100644 --- a/Projectiles/Summon/CnidarianJellyfishOnTheString.cs +++ b/Projectiles/Summon/CnidarianJellyfishOnTheString.cs @@ -13,6 +13,7 @@ using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; using static Terraria.ModLoader.ModContent; +using CalamityMod.Graphics.Primitives; namespace CalamityMod.Projectiles.Summon { @@ -143,16 +144,16 @@ namespace CalamityMod.Projectiles.Summon int[] targetArray = new int[maxTargets]; int targetsAquired = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { if (targetsAquired == maxTargets) break; - if (Main.npc[i].CanBeChasedBy(Projectile)) + if (n.CanBeChasedBy(Projectile)) { - if ((CnidarianPos - Main.npc[i].Center).Length() < targettingDistance) + if ((CnidarianPos - n.Center).Length() < targettingDistance) { - targetArray[targetsAquired] = i; + targetArray[targetsAquired] = n.whoAmI; targetsAquired++; } } diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index d7e0585150..a57cf8ad25 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -76,9 +76,8 @@ namespace CalamityMod.Projectiles.Summon } else { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { float maxTargetDist = Vector2.Distance(nPC2.Center, Projectile.Center); @@ -87,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon targetDist = maxTargetDist; projPos = nPC2.Center; canAttack = true; - target = i; + target = nPC2.whoAmI; } } } @@ -180,12 +179,12 @@ namespace CalamityMod.Projectiles.Summon float projY = Projectile.position.Y; float homeDistance = 1200f; bool isInRange = false; - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float npcX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); - float npcY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float npcX = n.position.X + (float)(n.width / 2); + float npcY = n.position.Y + (float)(n.height / 2); float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); if (npcDistance < homeDistance) { diff --git a/Projectiles/Summon/CosmicViperHomingRocket.cs b/Projectiles/Summon/CosmicViperHomingRocket.cs index 9f0cb319ed..c5efb9e256 100644 --- a/Projectiles/Summon/CosmicViperHomingRocket.cs +++ b/Projectiles/Summon/CosmicViperHomingRocket.cs @@ -86,15 +86,15 @@ namespace CalamityMod.Projectiles.Summon } if (!homeIn) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); + float extraDistance = (float)(n.width / 2) + (float)(n.height / 2); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance)) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance)) { - center = Main.npc[i].Center; + center = n.Center; homeIn = true; break; } diff --git a/Projectiles/Summon/DaedalusCrystal.cs b/Projectiles/Summon/DaedalusCrystal.cs index 68aeab7cef..590cf7215a 100644 --- a/Projectiles/Summon/DaedalusCrystal.cs +++ b/Projectiles/Summon/DaedalusCrystal.cs @@ -111,14 +111,14 @@ namespace CalamityMod.Projectiles.Summon } if (!isInRange) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float otherNPCX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); - float otherNPCY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float otherNPCX = n.position.X + (float)(n.width / 2); + float otherNPCY = n.position.Y + (float)(n.height / 2); float otherNPCDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - otherNPCX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - otherNPCY); - if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) + if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { attackRange = otherNPCDist; projX = otherNPCX; diff --git a/Projectiles/Summon/DankCreeperMinion.cs b/Projectiles/Summon/DankCreeperMinion.cs index 2eca566982..d18311e5fc 100644 --- a/Projectiles/Summon/DankCreeperMinion.cs +++ b/Projectiles/Summon/DankCreeperMinion.cs @@ -103,14 +103,14 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float otherNPCX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); - float otherNPCY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float otherNPCX = n.position.X + (float)(n.width / 2); + float otherNPCY = n.position.Y + (float)(n.height / 2); float otherNPCDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - otherNPCX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - otherNPCY); - if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) + if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { attackRange = otherNPCDist; projX = otherNPCX; diff --git a/Projectiles/Summon/DormantBrimseekerAura.cs b/Projectiles/Summon/DormantBrimseekerAura.cs index 95d4cff152..e92f6098c6 100644 --- a/Projectiles/Summon/DormantBrimseekerAura.cs +++ b/Projectiles/Summon/DormantBrimseekerAura.cs @@ -71,20 +71,20 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(360)) dust.scale = 1.5f; } - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == Projectile.owner && Main.projectile[i].localAI[1] == 0f) + if (p.type == ModContent.ProjectileType() && + p.owner == Projectile.owner && p.localAI[1] == 0f) { - if (Main.projectile[i].Distance(Projectile.Center) < Projectile.localAI[1]) + if (p.Distance(Projectile.Center) < Projectile.localAI[1]) { for (int j = 0; j < 30; j++) { - Dust dust = Dust.NewDustPerfect(Main.projectile[i].Center, (int)CalamityDusts.Brimstone); + Dust dust = Dust.NewDustPerfect(p.Center, (int)CalamityDusts.Brimstone); dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 7f; } - Main.projectile[i].localAI[1] = 1f; - SoundEngine.PlaySound(SoundID.Item45, Main.projectile[i].Center); + p.localAI[1] = 1f; + SoundEngine.PlaySound(SoundID.Item45, p.Center); } } } @@ -99,18 +99,18 @@ namespace CalamityMod.Projectiles.Summon } public override void OnKill(int timeLeft) { - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == Projectile.owner && Main.projectile[i].localAI[1] == 1f) + if (p.type == ModContent.ProjectileType() && + p.owner == Projectile.owner && p.localAI[1] == 1f) { for (int j = 0; j < 30; j++) { Dust dust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.Brimstone); dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 7f; } - SoundEngine.PlaySound(SoundID.Item29, Main.projectile[i].Center); - Main.projectile[i].localAI[1] = 0f; + SoundEngine.PlaySound(SoundID.Item29, p.Center); + p.localAI[1] = 0f; } } } diff --git a/Projectiles/Summon/Dreadmine.cs b/Projectiles/Summon/Dreadmine.cs index 3230ecfc43..d352755434 100644 --- a/Projectiles/Summon/Dreadmine.cs +++ b/Projectiles/Summon/Dreadmine.cs @@ -140,17 +140,17 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float npcX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float npcY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float npcX = n.position.X + (float)(n.width / 2); + float npcY = n.position.Y + (float)(n.height / 2); float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); if (npcDist < attackDistance) { attackDistance = npcDist; - center12 = Main.npc[i].Center; + center12 = n.Center; canAttack = true; } } diff --git a/Projectiles/Summon/DreadmineTurret.cs b/Projectiles/Summon/DreadmineTurret.cs index ea90f19aa5..ee71f068e6 100644 --- a/Projectiles/Summon/DreadmineTurret.cs +++ b/Projectiles/Summon/DreadmineTurret.cs @@ -50,9 +50,9 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(15)) { int mineAmt = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == ModContent.ProjectileType()) + if (p.owner == Main.myPlayer && p.type == ModContent.ProjectileType()) { mineAmt++; } diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index 33109677d6..4013aebaef 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -177,9 +177,8 @@ namespace CalamityMod.Projectiles.Summon } if (!gotoenemy) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[i]; if (nPC2.CanBeChasedBy(Projectile, false)) { float disttoobjective = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/EndoIceShard.cs b/Projectiles/Summon/EndoIceShard.cs index 90acd42f3a..9d87d5f665 100644 --- a/Projectiles/Summon/EndoIceShard.cs +++ b/Projectiles/Summon/EndoIceShard.cs @@ -80,18 +80,14 @@ namespace CalamityMod.Projectiles.Summon } if (!hasHomingTarget) { - for (int i = 0; i < Main.npc.Length; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc == null || !npc.active) - continue; - if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < maxHomingRange) { - targetIdx = i; + targetIdx = npc.whoAmI; maxHomingRange = dist; hasHomingTarget = true; } diff --git a/Projectiles/Summon/ForbiddenCircletEater.cs b/Projectiles/Summon/ForbiddenCircletEater.cs index c7789a909f..23a01694bd 100644 --- a/Projectiles/Summon/ForbiddenCircletEater.cs +++ b/Projectiles/Summon/ForbiddenCircletEater.cs @@ -89,9 +89,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[j]; if (npc.CanBeChasedBy(Projectile, false)) { float npcX = npc.position.X + (float)(npc.width / 2); diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index ddb1374ee2..c79c442c8f 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -156,13 +156,12 @@ namespace CalamityMod.Projectiles.Summon // If the player has any existing UIs, kill them all. if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && - Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == player.whoAmI) + if (p.type == ModContent.ProjectileType() && + p.owner == player.whoAmI) { - Main.projectile[i].Kill(); + p.Kill(); } } } @@ -289,13 +288,12 @@ namespace CalamityMod.Projectiles.Summon } int slashIndex = -1; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && - Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == Projectile.owner) + if (p.type == ModContent.ProjectileType() && + p.owner == Projectile.owner) { - slashIndex = i; + slashIndex = p.whoAmI; break; } } @@ -310,13 +308,12 @@ namespace CalamityMod.Projectiles.Summon int laserBeamIndex = -1; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && - Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == Projectile.owner) + if (p.type == ModContent.ProjectileType() && + p.owner == Projectile.owner) { - laserBeamIndex = i; + laserBeamIndex = p.whoAmI; break; } } diff --git a/Projectiles/Summon/GlacialEmbracePointyThing.cs b/Projectiles/Summon/GlacialEmbracePointyThing.cs index 287b3c2479..a06cefa7f5 100644 --- a/Projectiles/Summon/GlacialEmbracePointyThing.cs +++ b/Projectiles/Summon/GlacialEmbracePointyThing.cs @@ -240,12 +240,12 @@ namespace CalamityMod.Projectiles.Summon { target.AddBuff(BuffID.Frostburn2, 300); int circlers = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner && Main.projectile[i].type == Projectile.type) + if (p.owner == Projectile.owner && p.type == Projectile.type) { - GlacialEmbracePointyThing pointy = (GlacialEmbracePointyThing)Main.projectile[i].ModProjectile; - if (Main.projectile[i].ai[1] > 2f) + GlacialEmbracePointyThing pointy = (GlacialEmbracePointyThing)p.ModProjectile; + if (p.ai[1] > 2f) circlers += Main.rand.Next(1, 4); } } diff --git a/Projectiles/Summon/HermitCrabMinion.cs b/Projectiles/Summon/HermitCrabMinion.cs index 176c6e52b6..924e296129 100644 --- a/Projectiles/Summon/HermitCrabMinion.cs +++ b/Projectiles/Summon/HermitCrabMinion.cs @@ -117,9 +117,8 @@ namespace CalamityMod.Projectiles.Summon } if (!chaseNPC) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC npcTarget in Main.ActiveNPCs) { - NPC npcTarget = Main.npc[j]; if (npcTarget.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(npcTarget.Center, Projectile.Center); diff --git a/Projectiles/Summon/Hive.cs b/Projectiles/Summon/Hive.cs index 500cdee637..3f2f6adc50 100644 --- a/Projectiles/Summon/Hive.cs +++ b/Projectiles/Summon/Hive.cs @@ -67,9 +67,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); @@ -78,7 +77,7 @@ namespace CalamityMod.Projectiles.Summon attackDist = targetDist; projPos = nPC2.Center; canAttack = true; - target = j; + target = nPC2.whoAmI; } } } diff --git a/Projectiles/Summon/HowlsHeartFireball.cs b/Projectiles/Summon/HowlsHeartFireball.cs index 1d4932627f..d343308b61 100644 --- a/Projectiles/Summon/HowlsHeartFireball.cs +++ b/Projectiles/Summon/HowlsHeartFireball.cs @@ -82,9 +82,8 @@ namespace CalamityMod.Projectiles.Summon } if (!homeIn) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float extraDistance = (npc.width / 2) + (npc.height / 2); diff --git a/Projectiles/Summon/IceSentry.cs b/Projectiles/Summon/IceSentry.cs index 170aa4b52c..e6532ff2ba 100644 --- a/Projectiles/Summon/IceSentry.cs +++ b/Projectiles/Summon/IceSentry.cs @@ -117,16 +117,15 @@ namespace CalamityMod.Projectiles.Summon float maxDistance = 1000f; int possibleTarget = -1; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile)) { float npcDistance = Projectile.Distance(npc.Center); if (npcDistance < maxDistance) { maxDistance = npcDistance; - possibleTarget = i; + possibleTarget = npc.whoAmI; } } } diff --git a/Projectiles/Summon/LanternSoul.cs b/Projectiles/Summon/LanternSoul.cs index f0f4202a2a..98817c5858 100644 --- a/Projectiles/Summon/LanternSoul.cs +++ b/Projectiles/Summon/LanternSoul.cs @@ -53,9 +53,9 @@ namespace CalamityMod.Projectiles.Summon } int flameCount = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == ModContent.ProjectileType()) + if (p.owner == Main.myPlayer && p.type == ModContent.ProjectileType()) { flameCount++; } diff --git a/Projectiles/Summon/LiliesOfFinalityAriane.cs b/Projectiles/Summon/LiliesOfFinalityAriane.cs index 4d094e340a..1da87b762c 100644 --- a/Projectiles/Summon/LiliesOfFinalityAriane.cs +++ b/Projectiles/Summon/LiliesOfFinalityAriane.cs @@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.Summon if (!Projectile.getRect().Intersects(Elster.getRect())) { int walkDirection = Sign(Elster.Center.X - Projectile.Center.X); - float maxSpeed = Utils.Remap(Abs(Elster.Center.X - Projectile.Center.X), 160f, 0f, 6f, 0f); + float maxSpeed = Utils.Remap(Abs(Elster.Center.X - Projectile.Center.X), 160f, 0f, 8f, 0f); Projectile.velocity.X += 0.08f * walkDirection; if (Abs(Projectile.velocity.X) > maxSpeed) Projectile.velocity.X = maxSpeed * walkDirection; @@ -257,7 +257,7 @@ namespace CalamityMod.Projectiles.Summon return; } - FlyTowardsPlace(Owner.velocity.Length() + 6f, Owner.Center, Sign(Projectile.velocity.X)); + FlyTowardsPlace(Owner.velocity.Length() + 8f, Owner.Center, Sign(Projectile.velocity.X)); Animation = AnimationState.Fly; } diff --git a/Projectiles/Summon/LiliesOfFinalityElster.cs b/Projectiles/Summon/LiliesOfFinalityElster.cs index f226867adb..a34bfd5172 100644 --- a/Projectiles/Summon/LiliesOfFinalityElster.cs +++ b/Projectiles/Summon/LiliesOfFinalityElster.cs @@ -201,7 +201,7 @@ namespace CalamityMod.Projectiles.Summon if (!Projectile.WithinRange(idlePosition, 8f)) { int walkDirection = Sign(idlePosition.X - Projectile.Center.X); - float maxSpeed = Utils.Remap(Abs(idlePosition.X - Projectile.Center.X), 160f, 0f, 6f, 0f); + float maxSpeed = Utils.Remap(Abs(idlePosition.X - Projectile.Center.X), 160f, 0f, 8f, 0f); Projectile.velocity.X += 0.08f * walkDirection; if (Abs(Projectile.velocity.X) > maxSpeed) Projectile.velocity.X = maxSpeed * walkDirection; @@ -234,7 +234,7 @@ namespace CalamityMod.Projectiles.Summon return; } - FlyTowardsPlace(Owner.velocity.Length() + 6f, Owner.Center, Sign(Projectile.velocity.X), AnimationState.Fly); + FlyTowardsPlace(Owner.velocity.Length() + 8f, Owner.Center, Sign(Projectile.velocity.X), AnimationState.Fly); Projectile.rotation = MathHelper.ToRadians(Projectile.velocity.Length()) * Sign(Projectile.velocity.X); ElevationDust(false); } diff --git a/Projectiles/Summon/MK2FlaskSummon.cs b/Projectiles/Summon/MK2FlaskSummon.cs index 23f918e7e3..13769a795a 100644 --- a/Projectiles/Summon/MK2FlaskSummon.cs +++ b/Projectiles/Summon/MK2FlaskSummon.cs @@ -51,11 +51,11 @@ namespace CalamityMod.Projectiles.Summon Main.projectile[p].originalDamage = Projectile.originalDamage; int beeArrayIndex = 0; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile pro in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner && Main.projectile[i].type == ModContent.ProjectileType()) + if (pro.owner == Projectile.owner && pro.type == ModContent.ProjectileType()) { - Main.projectile[i].ai[1] = beeArrayIndex; + pro.ai[1] = beeArrayIndex; beeArrayIndex++; } } diff --git a/Projectiles/Summon/MechwormBody.cs b/Projectiles/Summon/MechwormBody.cs index 70e74c2a7e..071383cb99 100644 --- a/Projectiles/Summon/MechwormBody.cs +++ b/Projectiles/Summon/MechwormBody.cs @@ -174,11 +174,11 @@ namespace CalamityMod.Projectiles.Summon public static Projectile LocateHead(Projectile projectile) { int headType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != headType || !Main.projectile[i].active || Main.projectile[i].owner != projectile.owner) + if (p.type != headType || p.owner != projectile.owner) continue; - return Main.projectile[i]; + return p; } return null; } diff --git a/Projectiles/Summon/MechwormHead.cs b/Projectiles/Summon/MechwormHead.cs index 4e7ba8024c..d84c7adc57 100644 --- a/Projectiles/Summon/MechwormHead.cs +++ b/Projectiles/Summon/MechwormHead.cs @@ -338,10 +338,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.Center = TeleportStartingPoint; // Reset the alpha and position across the entire worm for the next charge. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile otherProj in Main.ActiveProjectiles) { - Projectile otherProj = Main.projectile[i]; - if (!otherProj.active || otherProj.owner != Projectile.owner || i == Projectile.whoAmI) + if (otherProj.owner != Projectile.owner || otherProj.whoAmI == Projectile.whoAmI) continue; if (otherProj.type == ModContent.ProjectileType() || otherProj.type == ModContent.ProjectileType()) @@ -377,10 +376,9 @@ namespace CalamityMod.Projectiles.Summon private void CleanUpMechwormPortals() { int portalType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj.type != portalType || !proj.active || proj.owner != Projectile.owner) + if (proj.type != portalType || proj.owner != Projectile.owner) continue; proj.Kill(); diff --git a/Projectiles/Summon/MutatedTruffleMinion.cs b/Projectiles/Summon/MutatedTruffleMinion.cs index 6a4e05edb0..20ca2992a1 100644 --- a/Projectiles/Summon/MutatedTruffleMinion.cs +++ b/Projectiles/Summon/MutatedTruffleMinion.cs @@ -194,10 +194,9 @@ namespace CalamityMod.Projectiles.Summon if (Target is not null) { // Find the vortex that it shot. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj is null || !proj.active || proj.type != ModContent.ProjectileType() || proj.owner != Owner.whoAmI || proj.timeLeft < MutatedTruffle.VortexTimeUntilNextState) + if (proj.type != ModContent.ProjectileType() || proj.owner != Owner.whoAmI || proj.timeLeft < MutatedTruffle.VortexTimeUntilNextState) continue; // Spin around the vortex. diff --git a/Projectiles/Summon/OldDukeSharkVomit.cs b/Projectiles/Summon/OldDukeSharkVomit.cs index 5a3afae25e..be484f33a8 100644 --- a/Projectiles/Summon/OldDukeSharkVomit.cs +++ b/Projectiles/Summon/OldDukeSharkVomit.cs @@ -73,18 +73,14 @@ namespace CalamityMod.Projectiles.Summon } if (!hasHomingTarget) { - for (int i = 0; i < Main.npc.Length; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc is null || !npc.active) - continue; - if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < maxHomingRange && Collision.CanHit(Projectile.Center, Projectile.width, Projectile.height, npc.Center, npc.width, npc.height)) { - targetIdx = i; + targetIdx = npc.whoAmI; maxHomingRange = dist; hasHomingTarget = true; } diff --git a/Projectiles/Summon/PhantomGuy.cs b/Projectiles/Summon/PhantomGuy.cs index 472e64dc8a..fbaf86c064 100644 --- a/Projectiles/Summon/PhantomGuy.cs +++ b/Projectiles/Summon/PhantomGuy.cs @@ -90,9 +90,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/PinkButterfly.cs b/Projectiles/Summon/PinkButterfly.cs index bdb465766b..ffdfa52520 100644 --- a/Projectiles/Summon/PinkButterfly.cs +++ b/Projectiles/Summon/PinkButterfly.cs @@ -106,10 +106,9 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[j]; - if ((nPC2.CanBeChasedBy(Projectile, false) || nPC2.type == NPCID.DukeFishron) && nPC2.active) + if (nPC2.CanBeChasedBy(Projectile, false) || nPC2.type == NPCID.DukeFishron) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); if (!canAttack && targetDist < attackRange) @@ -117,7 +116,7 @@ namespace CalamityMod.Projectiles.Summon attackRange = targetDist; projPos = nPC2.Center; canAttack = true; - targetIndex = j; + targetIndex = nPC2.whoAmI; } } } diff --git a/Projectiles/Summon/PlantationStaffTentacle.cs b/Projectiles/Summon/PlantationStaffTentacle.cs index ee8898e20b..a713ee71f3 100644 --- a/Projectiles/Summon/PlantationStaffTentacle.cs +++ b/Projectiles/Summon/PlantationStaffTentacle.cs @@ -101,11 +101,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.Center = Vector2.Lerp(Projectile.Center, MainMinion.Center + DesiredLocation, interpolant); Projectile.rotation = (Projectile.Center - MainMinion.Center).ToRotation(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - - if (proj is null || !proj.active || proj.owner != Owner.whoAmI || proj.type != ModContent.ProjectileType() || proj.ModProjectile().State == PlantationStaffSummon.AIState.Ramming) + if (proj.owner != Owner.whoAmI || proj.type != ModContent.ProjectileType() || proj.ModProjectile().State == PlantationStaffSummon.AIState.Ramming) continue; State = AIState.Seeking; diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index 9dbe380c6a..66da00abc3 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -102,20 +102,20 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[j].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float npcX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2); - float npcY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2); + float npcX = n.position.X + (float)(n.width / 2); + float npcY = n.position.Y + (float)(n.height / 2); float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); - if (npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height)) + if (npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { attackDistance = npcDist; projX = npcX; projY = npcY; canAttack = true; - target = j; + target = n.whoAmI; } } } diff --git a/Projectiles/Summon/SakuraBullet.cs b/Projectiles/Summon/SakuraBullet.cs index 485334b7dd..b1d43958f6 100644 --- a/Projectiles/Summon/SakuraBullet.cs +++ b/Projectiles/Summon/SakuraBullet.cs @@ -65,9 +65,8 @@ namespace CalamityMod.Projectiles.Summon } if (!homeIn) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if ((npc.CanBeChasedBy(Projectile, false) || (npc.type == NPCID.DukeFishron && (!npc.dontTakeDamage || npc.ai[0] > 9f))) && npc.active) { float extraDistance = (npc.width / 2) + (npc.height / 2); diff --git a/Projectiles/Summon/SandElementalMinion.cs b/Projectiles/Summon/SandElementalMinion.cs index 073149b87b..c748e8c0da 100644 --- a/Projectiles/Summon/SandElementalMinion.cs +++ b/Projectiles/Summon/SandElementalMinion.cs @@ -106,9 +106,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack && !passive) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Summon/SeekerSummonProj.cs b/Projectiles/Summon/SeekerSummonProj.cs index bb5f4a1e55..99a0bc8d05 100644 --- a/Projectiles/Summon/SeekerSummonProj.cs +++ b/Projectiles/Summon/SeekerSummonProj.cs @@ -100,10 +100,9 @@ namespace CalamityMod.Projectiles.Summon { // Make an imp laugh sound every so often if you're the first seeker in the projectile array. if (Main.rand.NextBool(1600)) - { - for (int i = 0; i < Main.maxProjectiles; i++) + { + foreach (Projectile seeker in Main.ActiveProjectiles) { - Projectile seeker = Main.projectile[i]; if (seeker.type == Projectile.type) { if (seeker == Projectile) diff --git a/Projectiles/Summon/SepulcherMinion.cs b/Projectiles/Summon/SepulcherMinion.cs index 38197aa588..93860c3ce5 100644 --- a/Projectiles/Summon/SepulcherMinion.cs +++ b/Projectiles/Summon/SepulcherMinion.cs @@ -503,16 +503,16 @@ namespace CalamityMod.Projectiles.Summon } float distance = searchDistance * searchDistance; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy() && Main.npc[i].type != heartType) + if (n.CanBeChasedBy() && n.type != heartType) { - float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + float extraDistance = (n.width / 2) + (n.height / 2); - if (Main.npc[i].WithinRange(Projectile.Center, distance + extraDistance)) + if (n.WithinRange(Projectile.Center, distance + extraDistance)) { - distance = Main.npc[i].DistanceSQ(Projectile.Center); - closestTarget = Main.npc[i]; + distance = n.DistanceSQ(Projectile.Center); + closestTarget = n; } } } diff --git a/Projectiles/Summon/SilvaCrystal.cs b/Projectiles/Summon/SilvaCrystal.cs index 134940397a..34b378dcc7 100644 --- a/Projectiles/Summon/SilvaCrystal.cs +++ b/Projectiles/Summon/SilvaCrystal.cs @@ -114,20 +114,17 @@ namespace CalamityMod.Projectiles.Summon } if (targetID < 0) { - int targetIDCopy; - for (int i = 0; i < Main.maxNPCs; i = targetIDCopy + 1) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; if (target.CanBeChasedBy(Projectile, false)) { float targetDistance = Projectile.Distance(target.Center); if (targetDistance < attackRange && Collision.CanHitLine(Projectile.Center, 0, 0, target.Center, 0, 0)) { attackRange = targetDistance; - targetID = i; + targetID = target.whoAmI; } } - targetIDCopy = i; } } if (targetID != -1) diff --git a/Projectiles/Summon/SkeletalDragonMother.cs b/Projectiles/Summon/SkeletalDragonMother.cs index 6a33794efb..b8864fe285 100644 --- a/Projectiles/Summon/SkeletalDragonMother.cs +++ b/Projectiles/Summon/SkeletalDragonMother.cs @@ -112,13 +112,13 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.Distance(player.Center) > 3250f) { Projectile.Center = player.Center; - for (int i = 0; i < Main.projectile.Length; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner && - Main.projectile[i].type == ModContent.ProjectileType()) + if (p.owner == Projectile.owner && + p.type == ModContent.ProjectileType()) { - Main.projectile[i].Center = player.Center; - Main.projectile[i].netUpdate = true; + p.Center = player.Center; + p.netUpdate = true; } } Projectile.netUpdate = true; diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs index 5fc5c0e894..bb7dfcce40 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs @@ -160,22 +160,22 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms // Dynamically update panel icons. for (int i = 0; i < 4; i++) PanelIcons[i].CurrentState = IconType.Inactive; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active) + if (!arms.Contains(p.type) || p.owner != Projectile.owner) continue; IconType stateFromID = IconType.Inactive; - if (Main.projectile[i].type == plasmaCannonID) + if (p.type == plasmaCannonID) stateFromID = IconType.Plasma; - if (Main.projectile[i].type == teslaCannonID) + if (p.type == teslaCannonID) stateFromID = IconType.Tesla; - if (Main.projectile[i].type == laserCannonID) + if (p.type == laserCannonID) stateFromID = IconType.Laser; - if (Main.projectile[i].type == gaussNukeID) + if (p.type == gaussNukeID) stateFromID = IconType.Gauss; - PanelIcons[(int)Main.projectile[i].ai[0]].CurrentState = stateFromID; + PanelIcons[(int)p.ai[0]].CurrentState = stateFromID; } // Handle fade effects. @@ -195,9 +195,9 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms if (ArmIDToSpawn >= 0) { bool armAlreadyExists = false; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active || Main.projectile[i].ai[0] != ArmIndex) + if (!arms.Contains(p.type) || p.owner != Projectile.owner || p.ai[0] != ArmIndex) continue; armAlreadyExists = true; @@ -215,12 +215,12 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms if (ShouldDeleteArmIndex) { SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active || Main.projectile[i].ai[0] != ArmIndex) + if (!arms.Contains(p.type) || p.owner != Projectile.owner || p.ai[0] != ArmIndex) continue; - - Main.projectile[i].Kill(); + + p.Kill(); } } diff --git a/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs b/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs index bbcee7b814..7e24206cd7 100644 --- a/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs +++ b/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs @@ -74,15 +74,15 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms public Projectile GetOrbToAttachTo() { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != Projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active) + if (p.type != Projectile.type || p.ai[0] != Identity + 1f) continue; - if (!Main.projectile[i].WithinRange(Projectile.Center, AresExoskeleton.TeslaOrbDetatchDistance)) + if (!p.WithinRange(Projectile.Center, AresExoskeleton.TeslaOrbDetatchDistance)) continue; - return Main.projectile[i]; + return p; } return null; diff --git a/Projectiles/Summon/SolarGod.cs b/Projectiles/Summon/SolarGod.cs index 9ca80b96e9..5f9ee985f2 100644 --- a/Projectiles/Summon/SolarGod.cs +++ b/Projectiles/Summon/SolarGod.cs @@ -100,9 +100,8 @@ namespace CalamityMod.Projectiles.Summon } if (!foundTarget) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float npcDist = Vector2.Distance(Projectile.Center, npc.Center); diff --git a/Projectiles/Summon/SolarPixie.cs b/Projectiles/Summon/SolarPixie.cs index cd909e789c..fd06939b02 100644 --- a/Projectiles/Summon/SolarPixie.cs +++ b/Projectiles/Summon/SolarPixie.cs @@ -100,9 +100,8 @@ namespace CalamityMod.Projectiles.Summon } if (!foundTarget) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float npcDist = Vector2.Distance(Projectile.Center, npc.Center); diff --git a/Projectiles/Summon/Spikecrag.cs b/Projectiles/Summon/Spikecrag.cs index 4700e18d10..219ca81408 100644 --- a/Projectiles/Summon/Spikecrag.cs +++ b/Projectiles/Summon/Spikecrag.cs @@ -56,13 +56,13 @@ namespace CalamityMod.Projectiles.Summon float maxDistance = 1000f; bool homeIn = false; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float extraDistance = (float)(Main.npc[i].width / 2) + (Main.npc[i].height / 2); + float extraDistance = (float)(n.width / 2) + (n.height / 2); - if (Vector2.Distance(Main.npc[i].Center, Projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(Projectile.Center, Projectile.width, Projectile.height, Main.npc[i].Center, Main.npc[i].width, Main.npc[i].height)) + if (Vector2.Distance(n.Center, Projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(Projectile.Center, Projectile.width, Projectile.height, n.Center, n.width, n.height)) { homeIn = true; break; diff --git a/Projectiles/Summon/StormjawBaby.cs b/Projectiles/Summon/StormjawBaby.cs index 28a737829d..1b27ab23b2 100644 --- a/Projectiles/Summon/StormjawBaby.cs +++ b/Projectiles/Summon/StormjawBaby.cs @@ -111,15 +111,14 @@ namespace CalamityMod.Projectiles.Summon } if (targetIndex < 0) { - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { float num1 = (npc.Center - Projectile.Center).Length(); if (num1 < maxDistance) { - targetIndex = i; + targetIndex = npc.whoAmI; maxDistance = num1; } } @@ -299,9 +298,8 @@ namespace CalamityMod.Projectiles.Summon else { Rectangle rectangle = new Rectangle((int)(Projectile.position.X + Projectile.velocity.X * 0.5f - 4f), (int)(Projectile.position.Y + Projectile.velocity.Y * 0.5f - 4f), Projectile.width + 8, Projectile.height + 8); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false) && npc.immune[Projectile.owner] <= 0) { Rectangle rect = npc.getRect(); diff --git a/Projectiles/Summon/Umbrella/MagicBird.cs b/Projectiles/Summon/Umbrella/MagicBird.cs index efe57b47a0..2672893275 100644 --- a/Projectiles/Summon/Umbrella/MagicBird.cs +++ b/Projectiles/Summon/Umbrella/MagicBird.cs @@ -88,18 +88,14 @@ namespace CalamityMod.Projectiles.Summon.Umbrella } if (!hasHomingTarget) { - for (int i = 0; i < Main.npc.Length; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc is null || !npc.active) - continue; - if (npc.CanBeChasedBy(Projectile, false)) { float dist = (Projectile.Center - npc.Center).Length(); if (dist < maxHomingRange) { - targetIdx = i; + targetIdx = npc.whoAmI; maxHomingRange = dist; hasHomingTarget = true; } diff --git a/Projectiles/Summon/Umbrella/MagicUmbrella.cs b/Projectiles/Summon/Umbrella/MagicUmbrella.cs index 5dd12a0966..952850a152 100644 --- a/Projectiles/Summon/Umbrella/MagicUmbrella.cs +++ b/Projectiles/Summon/Umbrella/MagicUmbrella.cs @@ -255,19 +255,18 @@ namespace CalamityMod.Projectiles.Summon.Umbrella return selectedTarget.whoAmI; } - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(this) && (npc.boss || !blackListedTargets.Contains(i))) - { - float npcDist = npc.Distance(center); - if (npcDist <= MagicHat.Range && (npcDist <= closestDist || closestDist == -1f)) - { - closestDist = npcDist; - target = i; - } - } - } + if (npc.CanBeChasedBy(this) && (npc.boss || !blackListedTargets.Contains(npc.whoAmI))) + { + float npcDist = npc.Distance(center); + if (npcDist <= MagicHat.Range && (npcDist <= closestDist || closestDist == -1f)) + { + closestDist = npcDist; + target = npc.whoAmI; + } + } + } return target; } diff --git a/Projectiles/Summon/VictideSeaSnail.cs b/Projectiles/Summon/VictideSeaSnail.cs index 2d90f53ec7..52e1cc5bf2 100644 --- a/Projectiles/Summon/VictideSeaSnail.cs +++ b/Projectiles/Summon/VictideSeaSnail.cs @@ -154,9 +154,8 @@ namespace CalamityMod.Projectiles.Summon bool foundTarget = false; float maxDist = 300f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile, false)) { if (Vector2.Distance(Projectile.Center, npc.Center) < maxDist && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) diff --git a/Projectiles/Summon/VileFeederProjectile.cs b/Projectiles/Summon/VileFeederProjectile.cs index 83e73f76d5..8e0b672027 100644 --- a/Projectiles/Summon/VileFeederProjectile.cs +++ b/Projectiles/Summon/VileFeederProjectile.cs @@ -90,9 +90,8 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[j]; if (npc.CanBeChasedBy(Projectile, false)) { float npcX = npc.position.X + (float)(npc.width / 2); diff --git a/Projectiles/Summon/VoidConcentrationBlackhole.cs b/Projectiles/Summon/VoidConcentrationBlackhole.cs index 6e0fc0f7d6..b92eae0d7f 100644 --- a/Projectiles/Summon/VoidConcentrationBlackhole.cs +++ b/Projectiles/Summon/VoidConcentrationBlackhole.cs @@ -166,12 +166,12 @@ namespace CalamityMod.Projectiles.Summon } Projectile.frameCounter++; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && !Main.npc[i].friendly && CalamityGlobalNPC.ShouldAffectNPC(Main.npc[i])) + if (!n.friendly && CalamityGlobalNPC.ShouldAffectNPC(n)) { - if (Vector2.Distance(Projectile.Center, Main.npc[i].Center) <= radius) - ApplySucc(Main.npc[i]); + if (Vector2.Distance(Projectile.Center, n.Center) <= radius) + ApplySucc(n); } } diff --git a/Projectiles/Summon/WaterElementalMinion.cs b/Projectiles/Summon/WaterElementalMinion.cs index 5acfa868b6..86e7a1de94 100644 --- a/Projectiles/Summon/WaterElementalMinion.cs +++ b/Projectiles/Summon/WaterElementalMinion.cs @@ -125,14 +125,14 @@ namespace CalamityMod.Projectiles.Summon } if (!canAttack) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - float targetX = Main.npc[i].position.X + (float)(Main.npc[i].width / 2); - float targetY = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2); + float targetX = n.position.X + (float)(n.width / 2); + float targetY = n.position.Y + (float)(n.height / 2); float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - targetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - targetY); - if (targetDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height)) + if (targetDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) { attackRange = targetDist; projX = targetX; diff --git a/Projectiles/Summon/WhiteDragonBody.cs b/Projectiles/Summon/WhiteDragonBody.cs index 954983e8b7..918211fc27 100644 --- a/Projectiles/Summon/WhiteDragonBody.cs +++ b/Projectiles/Summon/WhiteDragonBody.cs @@ -62,10 +62,9 @@ namespace CalamityMod.Projectiles.Summon var live = false; Projectile nextSegment = new Projectile(); WhiteDragonHead head = new WhiteDragonHead(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == Type && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == Type && projectile.owner == Projectile.owner) { if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) { @@ -73,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon nextSegment = projectile; } } - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { if (segmentIndex == 1) { @@ -106,10 +105,9 @@ namespace CalamityMod.Projectiles.Summon { if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { projectile.Kill(); } diff --git a/Projectiles/Summon/WhiteDragonTail.cs b/Projectiles/Summon/WhiteDragonTail.cs index 0dbbdb3352..8a14b34937 100644 --- a/Projectiles/Summon/WhiteDragonTail.cs +++ b/Projectiles/Summon/WhiteDragonTail.cs @@ -51,10 +51,9 @@ namespace CalamityMod.Projectiles.Summon Projectile nextSegment = new Projectile(); WhiteDragonHead head = new WhiteDragonHead(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) { @@ -62,7 +61,7 @@ namespace CalamityMod.Projectiles.Summon nextSegment = projectile; } } - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { if (segmentIndex == 1) { @@ -97,10 +96,9 @@ namespace CalamityMod.Projectiles.Summon { if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile projectile in Main.ActiveProjectiles) { - var projectile = Main.projectile[i]; - if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) { projectile.Kill(); } diff --git a/Projectiles/Summon/WulfrumDroid.cs b/Projectiles/Summon/WulfrumDroid.cs index 74fa359aa1..1a5083b4db 100644 --- a/Projectiles/Summon/WulfrumDroid.cs +++ b/Projectiles/Summon/WulfrumDroid.cs @@ -32,10 +32,9 @@ namespace CalamityMod.Projectiles.Summon get { int minionCount = 1; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj.active && proj.owner == Owner.whoAmI && proj.type == Type && proj.whoAmI != Projectile.whoAmI) + if (proj.owner == Owner.whoAmI && proj.type == Type && proj.whoAmI != Projectile.whoAmI) { minionCount++; } @@ -315,14 +314,14 @@ namespace CalamityMod.Projectiles.Summon if (Main.netMode == NetmodeID.MultiplayerClient && mouseDistanceToOwner > 120f) { - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player p in Main.ActivePlayers) { - if (Main.player[i].active && !Main.player[i].dead && (Main.player[i].team == Owner.team || Main.player[i].team == 0)) + if (!p.dead && (p.team == Owner.team || p.team == 0)) { - float mouseDistanceToPotentialTarget = (Main.player[i].MountedCenter - Owner.Calamity().mouseWorld).Length(); + float mouseDistanceToPotentialTarget = (p.MountedCenter - Owner.Calamity().mouseWorld).Length(); if (mouseDistanceToPotentialTarget < 120f && mouseDistanceToOwner > mouseDistanceToPotentialTarget) { - playerToBuff = Main.player[i]; + playerToBuff = p; mouseDistanceToOwner = mouseDistanceToPotentialTarget; } } diff --git a/Projectiles/Summon/WulfrumEnergyBurst.cs b/Projectiles/Summon/WulfrumEnergyBurst.cs index 687a48141d..836cfab051 100644 --- a/Projectiles/Summon/WulfrumEnergyBurst.cs +++ b/Projectiles/Summon/WulfrumEnergyBurst.cs @@ -65,10 +65,8 @@ namespace CalamityMod.Projectiles.Summon float bestScore = 0; NPC bestTarget = null; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC potentialTarget in Main.ActiveNPCs) { - NPC potentialTarget = Main.npc[i]; - if (!potentialTarget.CanBeChasedBy(null, false)) continue; diff --git a/Projectiles/Summon/WulfrumFusionBolt.cs b/Projectiles/Summon/WulfrumFusionBolt.cs index a32b4ef95a..2007486933 100644 --- a/Projectiles/Summon/WulfrumFusionBolt.cs +++ b/Projectiles/Summon/WulfrumFusionBolt.cs @@ -68,10 +68,8 @@ namespace CalamityMod.Projectiles.Summon float bestScore = 0; NPC bestTarget = null; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC potentialTarget in Main.ActiveNPCs) { - NPC potentialTarget = Main.npc[i]; - if (!potentialTarget.CanBeChasedBy(null, false)) continue; diff --git a/Projectiles/Typeless/ArtifactOfResilienceShards.cs b/Projectiles/Typeless/ArtifactOfResilienceShards.cs index 7b769f1616..782c9d73ab 100644 --- a/Projectiles/Typeless/ArtifactOfResilienceShards.cs +++ b/Projectiles/Typeless/ArtifactOfResilienceShards.cs @@ -88,17 +88,16 @@ namespace CalamityMod.Projectiles.Typeless } if (projectile.ModProjectile is ArtifactOfResilienceShard1) { - for (int i = 0; i < Main.npc.Length; i++) + foreach (var n in Main.ActiveNPCs) { - if (Main.npc[i].active && - Main.npc[i].Distance(StartingPosition) < projectile.ai[1] && - Main.npc[i].damage > 0) + if (n.Distance(StartingPosition) < projectile.ai[1] && + n.damage > 0) { - if (Main.npc[i].Calamity().relicOfResilienceCooldown <= 0) + if (n.Calamity().relicOfResilienceCooldown <= 0) { - Main.npc[i].Calamity().relicOfResilienceCooldown = 600; - Main.npc[i].Calamity().relicOfResilienceWeakness = 180; - Main.npc[i].AddBuff(ModContent.BuffType(), Main.npc[i].Calamity().relicOfResilienceWeakness); + n.Calamity().relicOfResilienceCooldown = 600; + n.Calamity().relicOfResilienceWeakness = 180; + n.AddBuff(ModContent.BuffType(), n.Calamity().relicOfResilienceWeakness); } } } diff --git a/Projectiles/Typeless/BossRushEndEffectThing.cs b/Projectiles/Typeless/BossRushEndEffectThing.cs index 06c25dedcc..879c088d75 100644 --- a/Projectiles/Typeless/BossRushEndEffectThing.cs +++ b/Projectiles/Typeless/BossRushEndEffectThing.cs @@ -1,5 +1,6 @@ using CalamityMod.Events; using CalamityMod.Items; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -35,26 +36,29 @@ namespace CalamityMod.Projectiles.Typeless BossRushEvent.SyncEndTimer((int)Time); float currentShakePower = MathHelper.Lerp(1f, 20f, Utils.GetLerpValue(140f, 180f, Time, true) * Utils.GetLerpValue(10f, 40f, Projectile.timeLeft, true)); - Main.LocalPlayer.Calamity().GeneralScreenShakePower = currentShakePower; + if (Projectile.timeLeft > 5) + Main.LocalPlayer.Calamity().GeneralScreenShakePower = currentShakePower; MoonlordDeathDrama.RequestLight(Utils.GetLerpValue(220f, 265f, Time, true) * Utils.GetLerpValue(10f, 30f, Projectile.timeLeft, true), Main.LocalPlayer.Center); + // Bit of an ugly solution, but this code prevents the end effect projectile from despawning while the end dialogue is playing. + // This fixes a bug where the first-time end dialogue did not play as intended. + if (Projectile.timeLeft < 5 && BossRushDialogueSystem.CurrentDialogueDelay != 0) + Projectile.timeLeft = 5; + Time++; } public override void OnKill(int timeLeft) { BossRushEvent.End(); - for (int i = Main.maxPlayers - 1; i >= 0; i--) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (p is null || !p.active) - continue; int rock = Item.NewItem(p.GetSource_Misc("CalamityMod_BossRushRock"), (int)p.position.X, (int)p.position.Y, p.width, p.height, ModContent.ItemType()); if (Main.netMode == NetmodeID.Server) { Main.timeItemSlotCannotBeReusedFor[rock] = 54000; - NetMessage.SendData(MessageID.InstancedItem, i, -1, null, rock); + NetMessage.SendData(MessageID.InstancedItem, p.whoAmI, -1, null, rock); } } } diff --git a/Projectiles/Typeless/CursorProj.cs b/Projectiles/Typeless/CursorProj.cs index c27d89b830..af813ea592 100644 --- a/Projectiles/Typeless/CursorProj.cs +++ b/Projectiles/Typeless/CursorProj.cs @@ -57,16 +57,16 @@ namespace CalamityMod.Projectiles.Typeless { int targetID = -1; float hitDistance = 300f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - Vector2 targetCenter = Main.npc[i].Center; + Vector2 targetCenter = n.Center; float targetDist = Vector2.Distance(targetCenter, Projectile.Center); if (targetDist < hitDistance && targetID == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, targetCenter, 1, 1)) { hitDistance = targetDist; - targetID = i; + targetID = n.whoAmI; } } } diff --git a/Projectiles/Typeless/CursorProjSplit.cs b/Projectiles/Typeless/CursorProjSplit.cs index 3271984fc2..1031a67052 100644 --- a/Projectiles/Typeless/CursorProjSplit.cs +++ b/Projectiles/Typeless/CursorProjSplit.cs @@ -58,16 +58,16 @@ namespace CalamityMod.Projectiles.Typeless { int targetID = -1; float hitDistance = 300f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - Vector2 targetCenter = Main.npc[i].Center; + Vector2 targetCenter = n.Center; float targetDist = Vector2.Distance(targetCenter, Projectile.Center); if (targetDist < hitDistance && targetID == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, targetCenter, 1, 1)) { hitDistance = targetDist; - targetID = i; + targetID = n.whoAmI; } } } diff --git a/Projectiles/Typeless/DemonshadeRedDevil.cs b/Projectiles/Typeless/DemonshadeRedDevil.cs index 5a1b926bbd..df25b38ec2 100644 --- a/Projectiles/Typeless/DemonshadeRedDevil.cs +++ b/Projectiles/Typeless/DemonshadeRedDevil.cs @@ -132,9 +132,8 @@ namespace CalamityMod.Projectiles.Typeless } else { - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC nPC2 in Main.ActiveNPCs) { - NPC nPC2 = Main.npc[j]; if (nPC2.CanBeChasedBy(Projectile, false)) { float npcDist = Vector2.Distance(nPC2.Center, Projectile.Center); diff --git a/Projectiles/Typeless/LunicBeam.cs b/Projectiles/Typeless/LunicBeam.cs index ffdce3a0c2..99360f627e 100644 --- a/Projectiles/Typeless/LunicBeam.cs +++ b/Projectiles/Typeless/LunicBeam.cs @@ -46,16 +46,16 @@ namespace CalamityMod.Projectiles.Typeless { int targetID = -1; float hitDistance = 150f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - Vector2 targetCenter = Main.npc[i].Center; + Vector2 targetCenter = n.Center; float targetDist = Vector2.Distance(targetCenter, Projectile.Center); if (targetDist < hitDistance && targetID == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, targetCenter, 1, 1)) { hitDistance = targetDist; - targetID = i; + targetID = n.whoAmI; } } } diff --git a/Projectiles/Typeless/MagnusBeam.cs b/Projectiles/Typeless/MagnusBeam.cs index 0b17ba7cc9..c5ca9718f5 100644 --- a/Projectiles/Typeless/MagnusBeam.cs +++ b/Projectiles/Typeless/MagnusBeam.cs @@ -39,16 +39,16 @@ namespace CalamityMod.Projectiles.Typeless { int targetIdx = -1; float npcRange = 150f; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].active && Main.npc[i].CanBeChasedBy(Projectile, false)) + if (n.CanBeChasedBy(Projectile, false)) { - Vector2 npcPos = Main.npc[i].Center; + Vector2 npcPos = n.Center; float npcDist = Vector2.Distance(npcPos, Projectile.Center); if (npcDist < npcRange && targetIdx == -1 && Collision.CanHitLine(Projectile.Center, 1, 1, npcPos, 1, 1)) { npcRange = npcDist; - targetIdx = i; + targetIdx = n.whoAmI; } } } diff --git a/Projectiles/Typeless/OmegaBlueTentacle.cs b/Projectiles/Typeless/OmegaBlueTentacle.cs index 80e2c60add..b908dd04a6 100644 --- a/Projectiles/Typeless/OmegaBlueTentacle.cs +++ b/Projectiles/Typeless/OmegaBlueTentacle.cs @@ -96,16 +96,15 @@ namespace CalamityMod.Projectiles.Typeless Projectile.ai[0] = 10 + Main.rand.Next(10); float maxDistance = hentai ? 900f : 600f; int target = -1; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(Projectile)) { float npcDistance = Projectile.Distance(npc.Center); if (npcDistance < maxDistance) { maxDistance = npcDistance; - target = i; + target = npc.whoAmI; } } } diff --git a/Projectiles/Typeless/WulfrumLureSignal.cs b/Projectiles/Typeless/WulfrumLureSignal.cs index 2c78db94ac..4b103fbb0f 100644 --- a/Projectiles/Typeless/WulfrumLureSignal.cs +++ b/Projectiles/Typeless/WulfrumLureSignal.cs @@ -43,13 +43,13 @@ namespace CalamityMod.Projectiles.Typeless if (Main.netMode == NetmodeID.MultiplayerClient) { float closestPlayerDistance = (Main.LocalPlayer.Center - Projectile.Center).Length(); - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player plr in Main.ActivePlayers) { - float newDistance = (Main.player[i].Center - Projectile.Center).Length(); + float newDistance = (plr.Center - Projectile.Center).Length(); if (newDistance < closestPlayerDistance) { closestPlayerDistance = newDistance; - player = Main.player[i]; + player = plr; } } } diff --git a/Scenes/MusicScenes/BaseMusicSceneEffect.cs b/Scenes/MusicScenes/BaseMusicSceneEffect.cs index 79b5f1802c..03a575e50f 100644 --- a/Scenes/MusicScenes/BaseMusicSceneEffect.cs +++ b/Scenes/MusicScenes/BaseMusicSceneEffect.cs @@ -38,12 +38,12 @@ namespace CalamityMod.Systems // You can't even edit music if the game has Otherworld toggle on lol. Have fun with Boss 1 /* - FieldInfo swapMusicField = typeof(Main).GetField("swapMusic", BindingFlags.Static | BindingFlags.NonPublic); - bool musicSwapped = (bool)swapMusicField.GetValue(null); - bool playingOtherworld = (!Main.drunkWorld && musicSwapped) || (Main.drunkWorld && !musicSwapped); - // Main.swapMusic is private. Todo: bug tmod devs to avoid reflection - return playingOtherworld ? OtherworldMusic : VanillaMusic; - */ + FieldInfo swapMusicField = typeof(Main).GetField("swapMusic", BindingFlags.Static | BindingFlags.NonPublic); + bool musicSwapped = (bool)swapMusicField.GetValue(null); + bool playingOtherworld = (!Main.drunkWorld && musicSwapped) || (Main.drunkWorld && !musicSwapped); + // Main.swapMusic is private. Todo: bug tmod devs to avoid reflection + return playingOtherworld ? OtherworldMusic : VanillaMusic; + */ } public virtual bool SetSceneEffect(Player player) @@ -55,28 +55,24 @@ namespace CalamityMod.Systems return false; /* - // You can't even edit music if the game has Otherworld toggle on lol. - // Theoretically, reflection would only occur if the music mod is disabled - if (MusicModMusic is null) - { - FieldInfo swapMusicField = typeof(Main).GetField("swapMusic", BindingFlags.Static | BindingFlags.NonPublic); - bool musicSwapped = (bool)swapMusicField.GetValue(null); - bool playingOtherworld = (!Main.drunkWorld && musicSwapped) || (Main.drunkWorld && !musicSwapped); - if (VanillaMusic == -1 && !playingOtherworld) - return false; - if (OtherworldMusic == -1 && playingOtherworld) - return false; - } - */ + // You can't even edit music if the game has Otherworld toggle on lol. + // Theoretically, reflection would only occur if the music mod is disabled + if (MusicModMusic is null) + { + FieldInfo swapMusicField = typeof(Main).GetField("swapMusic", BindingFlags.Static | BindingFlags.NonPublic); + bool musicSwapped = (bool)swapMusicField.GetValue(null); + bool playingOtherworld = (!Main.drunkWorld && musicSwapped) || (Main.drunkWorld && !musicSwapped); + if (VanillaMusic == -1 && !playingOtherworld) + return false; + if (OtherworldMusic == -1 && playingOtherworld) + return false; + } + */ Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight); int musicDistance = MusicDistance * 2; - for (int j = 0; j < Main.maxNPCs; j++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[j]; - if (!npc.active) - continue; - bool inList = false; if (npc.type == NPCType) { diff --git a/Skies/AstralDesertSurfaceClose.png b/Skies/AstralDesertSurfaceClose.png deleted file mode 100644 index c96ebe2cfd..0000000000 Binary files a/Skies/AstralDesertSurfaceClose.png and /dev/null differ diff --git a/Skies/AstralDesertSurfaceFar.png b/Skies/AstralDesertSurfaceFar.png deleted file mode 100644 index a2337a7d8f..0000000000 Binary files a/Skies/AstralDesertSurfaceFar.png and /dev/null differ diff --git a/Skies/AstralDesertSurfaceMiddle.png b/Skies/AstralDesertSurfaceMiddle.png deleted file mode 100644 index 6b5c33dee8..0000000000 Binary files a/Skies/AstralDesertSurfaceMiddle.png and /dev/null differ diff --git a/Skies/AstralSky.cs b/Skies/AstralSky.cs index c919a6f549..7290303387 100644 --- a/Skies/AstralSky.cs +++ b/Skies/AstralSky.cs @@ -6,6 +6,7 @@ using Terraria.GameContent; using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; +using System.Reflection; namespace CalamityMod.Skies { diff --git a/Skies/AstralSkyDesert.cs b/Skies/AstralSkyDesert.cs deleted file mode 100644 index f786d156da..0000000000 --- a/Skies/AstralSkyDesert.cs +++ /dev/null @@ -1,137 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Skies -{ - public class AstralSkyDesert : CustomSky - { - private bool skyActive; - private float opacity; - - private const float Scale = 2f; - - public override void Deactivate(params object[] args) - { - skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow; - } - - public override void Reset() - { - skyActive = false; - } - - public override bool IsActive() - { - return skyActive || opacity > 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - skyActive = true; - } - public override Color OnTileColor(Color inColor) - { - return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - // Small worlds, default draw height. - int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - - // Medium worlds. - if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - - // Large worlds (and anything bigger). - if (Main.maxTilesX >= 8400) - AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - - // Background from here starting from the back layer to the front layer. - float width = Main.screenWidth / 2f; - float height = Main.screenHeight / 2f; - Color color = new Color(63, 51, 90, 255) * opacity; - if (maxDepth >= 9f && minDepth < 9f) - { - float screenParralaxMultiplier = 0.16f; - Texture2D texture = CalamityMod.AstralSurfaceHorizon; - int x = (int)(Main.screenPosition.X * screenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * screenParralaxMultiplier); - y -= 1380; // 1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 8f && minDepth < 8f) - { - float screenParralaxMultiplier = 0.4f; - Texture2D texture = CalamityMod.AstralDesertSurfaceFar; - int x = (int)(Main.screenPosition.X * 0.5f * screenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); - y -= 1520; // 1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 7f && minDepth < 7f) - { - float screenParralaxMultiplier = 0.4f; - Texture2D texture = CalamityMod.AstralDesertSurfaceMiddle; - int x = (int)(Main.screenPosition.X * 0.8f * screenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); - y -= 1900; // 1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 6f && minDepth < 6f) - { - float screenParralaxMultiplier = 0.4f; - Texture2D texture = CalamityMod.AstralDesertSurfaceClose; - int x = (int)(Main.screenPosition.X * 1f * screenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); - y -= 2050; // 1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); - } - } - } - - public override void Update(GameTime gameTime) - { - if (!Main.LocalPlayer.Calamity().ZoneAstral || Main.gameMenu) - skyActive = false; - - if (skyActive && opacity < 1f) - opacity += 0.02f; - else if (!skyActive && opacity > 0f) - opacity -= 0.02f; - } - - public override float GetCloudAlpha() - { - return (1f - opacity) * 0.97f + 0.03f; - } - } -} diff --git a/Skies/AstralSkySnow.cs b/Skies/AstralSkySnow.cs deleted file mode 100644 index 277b92f4fd..0000000000 --- a/Skies/AstralSkySnow.cs +++ /dev/null @@ -1,171 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Skies -{ - public class AstralSkySnow : CustomSky - { - private bool skyActive; - private float opacity; - - private const float Scale = 2.0f; - private const float ScreenParralaxMultiplier = 0.4f; - - public override void Deactivate(params object[] args) - { - skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && Main.LocalPlayer.ZoneSnow && !Main.LocalPlayer.ZoneDesert; - } - - public override void Reset() - { - skyActive = false; - } - - public override bool IsActive() - { - return skyActive || opacity > 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - skyActive = true; - } - - public override Color OnTileColor(Color inColor) - { - return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - // Small worlds, default draw height. - int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - - // Medium worlds. - if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - - // Large worlds (and anything bigger). - if (Main.maxTilesX >= 8400) - AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - - // Background from here starting from the back layer to the front layer. - float width = Main.screenWidth / 2f; - float height = Main.screenHeight / 2f; - Color textureColor = new Color(116, 96, 164, 255) * opacity; - Vector2 origin = new Vector2(0f, AstralBiomeHeight); - if (maxDepth >= 9f && minDepth < 9f) - { - Texture2D texture = CalamityMod.AstralSurfaceHorizon; - int x = (int)(Main.screenPosition.X * 0.4f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.4f * ScreenParralaxMultiplier); - y -= 1380; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 8f && minDepth < 8f) - { - Texture2D texture = CalamityMod.AstralSurfaceFar; - int x = (int)(Main.screenPosition.X * 0.5f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.45f * ScreenParralaxMultiplier); - y -= 1520; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 7f && minDepth < 7f) - { - Texture2D texture = CalamityMod.AstralSnowSurfaceMiddle; - int x = (int)(Main.screenPosition.X * 0.8f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.5f * ScreenParralaxMultiplier); - y -= 1900; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 6f && minDepth < 6f) - { - Texture2D texture = CalamityMod.AstralSurfaceClose; - int x = (int)(Main.screenPosition.X * 0.9f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.55f * ScreenParralaxMultiplier); - y -= 1880; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - - Texture2D textureglow = CalamityMod.AstralSurfaceCloseGlow; - Color textureGlowColor = Color.White * 0.7f * opacity; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 5f && minDepth < 5f) - { - Texture2D texture = CalamityMod.AstralSurfaceFront; - int x = (int)(Main.screenPosition.X * 1.1f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.6f * ScreenParralaxMultiplier); - y -= 2100; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - - Texture2D textureglow = CalamityMod.AstralSurfaceFrontGlow; - Color textureGlowColor = Color.White * 0.9f * opacity; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - } - - public override void Update(GameTime gameTime) - { - if (!Main.LocalPlayer.Calamity().ZoneAstral || Main.gameMenu) - skyActive = false; - - if (skyActive && opacity < 1f) - opacity += 0.02f; - else if (!skyActive && opacity > 0f) - opacity -= 0.02f; - } - - public override float GetCloudAlpha() - { - return (1f - opacity) * 0.97f + 0.03f; - } - } -} diff --git a/Skies/AstralSkySurface.cs b/Skies/AstralSkySurface.cs deleted file mode 100644 index b4eead4ca8..0000000000 --- a/Skies/AstralSkySurface.cs +++ /dev/null @@ -1,179 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Skies -{ - public class AstralSkySurface : CustomSky - { - private bool skyActive; - private float opacity; - - private const float Scale = 2f; - private const float ScreenParralaxMultiplier = 0.4f; - - public override void Deactivate(params object[] args) - { - skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && !Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow; - } - - public override void Reset() - { - skyActive = false; - } - - public override bool IsActive() - { - return skyActive || opacity > 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - skyActive = true; - } - - public override Color OnTileColor(Color inColor) - { - return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - // Small worlds, default draw height. - int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - - // Medium worlds. - if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - - // Large worlds (and anything bigger). - if (Main.maxTilesX >= 8400) - AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - - // Background from here starting from the back layer to the front layer. - float width = Main.screenWidth / 2f; - float height = Main.screenHeight / 2f; - Color textureColor = new Color(63, 51, 90, 255) * opacity; - Vector2 origin = new Vector2(0f, AstralBiomeHeight); - if (maxDepth >= 9f && minDepth < 9f) - { - Texture2D texture = CalamityMod.AstralSurfaceHorizon; - int x = (int)(Main.screenPosition.X * 0.4f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.4f * ScreenParralaxMultiplier); - y -= 1380; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 8f && minDepth < 8f) - { - Texture2D texture = CalamityMod.AstralSurfaceFar; - int x = (int)(Main.screenPosition.X * 0.5f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.45f * ScreenParralaxMultiplier); - y -= 1520; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 7f && minDepth < 7f) - { - Texture2D texture = CalamityMod.AstralSurfaceMiddle; - int x = (int)(Main.screenPosition.X * 0.8f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.5f * ScreenParralaxMultiplier); - y -= 1900; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - - Texture2D textureglow = CalamityMod.AstralSurfaceMiddleGlow; - Color textureGlowColor = Color.White * 0.5f * opacity; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 6f && minDepth < 6f) - { - Texture2D texture = CalamityMod.AstralSurfaceClose; - int x = (int)(Main.screenPosition.X * 0.9f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.55f * ScreenParralaxMultiplier); - y -= 1880; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - - Texture2D textureglow = CalamityMod.AstralSurfaceCloseGlow; - Color textureGlowColor = Color.White * 0.7f * opacity; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - - if (maxDepth >= 5f && minDepth < 5f) - { - Texture2D texture = CalamityMod.AstralSurfaceFront; - int x = (int)(Main.screenPosition.X * 1.1f * ScreenParralaxMultiplier); - x %= (int)(texture.Width * Scale); - int y = (int)(Main.screenPosition.Y * 0.6f * ScreenParralaxMultiplier); - y -= 2100; // 1000 - Vector2 position = texture.Size() / 2f * Scale; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - - Texture2D textureglow = CalamityMod.AstralSurfaceFrontGlow; - Color textureGlowColor = Color.White * 0.9f * opacity; - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); - spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, origin, Scale, SpriteEffects.None, 0f); - } - } - } - - public override void Update(GameTime gameTime) - { - if (!Main.LocalPlayer.Calamity().ZoneAstral || Main.gameMenu) - skyActive = false; - - if (skyActive && opacity < 1f) - opacity += 0.02f; - else if (!skyActive && opacity > 0f) - opacity -= 0.02f; - } - - public override float GetCloudAlpha() - { - return (1f - opacity) * 0.97f + 0.03f; - } - } -} diff --git a/Skies/AstralSnowSurfaceMiddle.png b/Skies/AstralSnowSurfaceMiddle.png deleted file mode 100644 index ff4e5fc236..0000000000 Binary files a/Skies/AstralSnowSurfaceMiddle.png and /dev/null differ diff --git a/Skies/AstralSurfaceClose.png b/Skies/AstralSurfaceClose.png deleted file mode 100644 index 166e8bc48d..0000000000 Binary files a/Skies/AstralSurfaceClose.png and /dev/null differ diff --git a/Skies/AstralSurfaceFar.png b/Skies/AstralSurfaceFar.png deleted file mode 100644 index de6901e9e4..0000000000 Binary files a/Skies/AstralSurfaceFar.png and /dev/null differ diff --git a/Skies/AstralSurfaceFront.png b/Skies/AstralSurfaceFront.png deleted file mode 100644 index d9db0020e9..0000000000 Binary files a/Skies/AstralSurfaceFront.png and /dev/null differ diff --git a/Skies/AstralSurfaceHorizon.png b/Skies/AstralSurfaceHorizon.png deleted file mode 100644 index 8f448fb3b4..0000000000 Binary files a/Skies/AstralSurfaceHorizon.png and /dev/null differ diff --git a/Skies/AstralSurfaceMiddle.png b/Skies/AstralSurfaceMiddle.png deleted file mode 100644 index d3f984c001..0000000000 Binary files a/Skies/AstralSurfaceMiddle.png and /dev/null differ diff --git a/Skies/CryogenSky.cs b/Skies/CryogenSky.cs index e8d05d6677..02b5b528f5 100644 --- a/Skies/CryogenSky.cs +++ b/Skies/CryogenSky.cs @@ -108,15 +108,7 @@ namespace CalamityMod.Skies if (CryogenIndex >= 0 && Main.npc[CryogenIndex].active && Main.npc[CryogenIndex].type == cryogenType) return true; - CryogenIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == cryogenType) - { - CryogenIndex = i; - break; - } - } + CryogenIndex = NPC.FindFirstNPC(cryogenType); return CryogenIndex != -1; } diff --git a/Skies/DrunkCrabScreenShaderData.cs b/Skies/DrunkCrabScreenShaderData.cs index 6eee00117e..2d67cb7706 100644 --- a/Skies/DrunkCrabScreenShaderData.cs +++ b/Skies/DrunkCrabScreenShaderData.cs @@ -47,14 +47,7 @@ namespace CalamityMod.Skies if (!shouldForceDeactivateCirrusShader) { - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == CirrusType) - { - CirrusIndex = i; - break; - } - } + CirrusIndex = NPC.FindFirstNPC(CirrusType); } } else @@ -62,16 +55,7 @@ namespace CalamityMod.Skies if (CrabIndex >= 0 && Main.npc[CrabIndex].active && Main.npc[CrabIndex].type == CrabType) return; - CrabIndex = -1; - - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == CrabType) - { - CrabIndex = i; - break; - } - } + CrabIndex = NPC.FindFirstNPC(CrabType); } } diff --git a/Skies/SCalScreenShaderData.cs b/Skies/SCalScreenShaderData.cs index 92f0b5ca3a..1e562f1683 100644 --- a/Skies/SCalScreenShaderData.cs +++ b/Skies/SCalScreenShaderData.cs @@ -24,15 +24,7 @@ namespace CalamityMod.Skies { return; } - SCalIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == SCalType) - { - SCalIndex = i; - break; - } - } + SCalIndex = NPC.FindFirstNPC(SCalType); } public override void Update(GameTime gameTime) diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs index bb3af0b383..739d66cdee 100644 --- a/Skies/SCalSky.cs +++ b/Skies/SCalSky.cs @@ -232,15 +232,7 @@ namespace CalamityMod.Skies if (SCalIndex >= 0 && Main.npc[SCalIndex].active && Main.npc[SCalIndex].type == SCalType) return true; - SCalIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == SCalType) - { - SCalIndex = i; - break; - } - } + SCalIndex = NPC.FindFirstNPC(SCalType); return SCalIndex != -1; } diff --git a/Skies/StormWeaverFlashSky.cs b/Skies/StormWeaverFlashSky.cs index 42471c402e..82de86c339 100644 --- a/Skies/StormWeaverFlashSky.cs +++ b/Skies/StormWeaverFlashSky.cs @@ -18,15 +18,7 @@ namespace CalamityMod.Skies if (StormWeaverHeadIndex >= 0 && Main.npc[StormWeaverHeadIndex].active && Main.npc[StormWeaverHeadIndex].type == weaverType) return; - StormWeaverHeadIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == weaverType) - { - StormWeaverHeadIndex = i; - break; - } - } + StormWeaverHeadIndex = NPC.FindFirstNPC(weaverType); } public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) diff --git a/Sounds/Custom/Kickball.ogg b/Sounds/Custom/Kickball.ogg new file mode 100644 index 0000000000..f67be1f20b Binary files /dev/null and b/Sounds/Custom/Kickball.ogg differ diff --git a/Sounds/Item/EnergyRifleFire.ogg b/Sounds/Item/EnergyRifleFire.ogg new file mode 100644 index 0000000000..855a605b46 Binary files /dev/null and b/Sounds/Item/EnergyRifleFire.ogg differ diff --git a/Sounds/Item/NuhUhUh.ogg b/Sounds/Item/NuhUhUh.ogg new file mode 100644 index 0000000000..2d9dcf16c5 Binary files /dev/null and b/Sounds/Item/NuhUhUh.ogg differ diff --git a/Sounds/Item/PulseRifleFire.ogg b/Sounds/Item/PulseRifleFire.ogg index 855a605b46..3e5ef5cd27 100644 Binary files a/Sounds/Item/PulseRifleFire.ogg and b/Sounds/Item/PulseRifleFire.ogg differ diff --git a/Sounds/Item/PulseSound.ogg b/Sounds/Item/PulseSound.ogg new file mode 100644 index 0000000000..4941b20973 Binary files /dev/null and b/Sounds/Item/PulseSound.ogg differ diff --git a/Systems/BossRushDialogueSystem.cs b/Systems/BossRushDialogueSystem.cs index 71dbd2a52b..518221d65e 100644 --- a/Systems/BossRushDialogueSystem.cs +++ b/Systems/BossRushDialogueSystem.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Systems public static BossRushDialoguePhase Phase = BossRushDialoguePhase.None; private static BossRushDialogueEvent[] currentSequence = null; - private static int currentSequenceIndex = 0; + public static int currentSequenceIndex = 0; public static int CurrentDialogueDelay = 0; @@ -59,80 +59,81 @@ namespace CalamityMod.Systems { // // Dialogue times were timed by Ozzatron reading them aloud with a stopwatch. + // CIT 11MAY2024: I decided to decrease all of these dialogue delays by 30 frames, in an attempt to cut down on unnecessary waiting around. // // Dialogue that occurs the first time you start Boss Rush BossRushDialogueEvent[] startDialogues = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushStartText_1", 360), - new("Mods.CalamityMod.Events.BossRushStartText_2", 435), - new("Mods.CalamityMod.Events.BossRushStartText_3", 240), - new("Mods.CalamityMod.Events.BossRushStartText_4", 435), - new("Mods.CalamityMod.Events.BossRushStartText_5", 480), - new("Mods.CalamityMod.Events.BossRushStartText_6", 270), - new("Mods.CalamityMod.Events.BossRushStartText_7", 465), - new("Mods.CalamityMod.Events.BossRushStartText_8", 480), - new("Mods.CalamityMod.Events.BossRushStartText_9", 330), - new("Mods.CalamityMod.Events.BossRushStartText_DoG", 180, skipFunc: () => !DownedBossSystem.downedDoG), - new("Mods.CalamityMod.Events.BossRushStartText_Yharon", 240, skipFunc: () => !DownedBossSystem.downedYharon), - new("Mods.CalamityMod.Events.BossRushStartText_DraedonSCal", 315, skipFunc: () => !DownedBossSystem.downedExoMechs || !DownedBossSystem.downedCalamitas), - new("Mods.CalamityMod.Events.BossRushStartText_10", 420), - new("Mods.CalamityMod.Events.BossRushStartText_11", 420), - new("Mods.CalamityMod.Events.BossRushStartText_12", 270), + new("Mods.CalamityMod.Events.BossRushStartText_1", 330), + new("Mods.CalamityMod.Events.BossRushStartText_2", 405), + new("Mods.CalamityMod.Events.BossRushStartText_3", 210), + new("Mods.CalamityMod.Events.BossRushStartText_4", 405), + new("Mods.CalamityMod.Events.BossRushStartText_5", 450), + new("Mods.CalamityMod.Events.BossRushStartText_6", 240), + new("Mods.CalamityMod.Events.BossRushStartText_7", 435), + new("Mods.CalamityMod.Events.BossRushStartText_8", 450), + new("Mods.CalamityMod.Events.BossRushStartText_9", 300), + new("Mods.CalamityMod.Events.BossRushStartText_DoG", 150, skipFunc: () => !DownedBossSystem.downedDoG), + new("Mods.CalamityMod.Events.BossRushStartText_Yharon", 210, skipFunc: () => !DownedBossSystem.downedYharon), + new("Mods.CalamityMod.Events.BossRushStartText_DraedonSCal", 285, skipFunc: () => !DownedBossSystem.downedExoMechs || !DownedBossSystem.downedCalamitas), + new("Mods.CalamityMod.Events.BossRushStartText_10", 390), + new("Mods.CalamityMod.Events.BossRushStartText_11", 390), + new("Mods.CalamityMod.Events.BossRushStartText_12", 240), }; // Dialogue that occurs when starting Boss Rush on repeat attempts BossRushDialogueEvent[] startDialoguesShort = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushStartText_Repeat", 120), + new("Mods.CalamityMod.Events.BossRushStartText_Repeat", 90), }; // Dialogue that occurs when beating Tier 1 of Boss Rush BossRushDialogueEvent[] tierOneDialogues = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushTierOneEndText_1", 360), - new("Mods.CalamityMod.Events.BossRushTierOneEndText_2", 255), + new("Mods.CalamityMod.Events.BossRushTierOneEndText_1", 330), + new("Mods.CalamityMod.Events.BossRushTierOneEndText_2", 225), }; // Dialogue that occurs when beating Tier 2 of Boss Rush BossRushDialogueEvent[] tierTwoDialogues = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushTierTwoEndText_1", 255), - new("Mods.CalamityMod.Events.BossRushTierTwoEndText_2", 300), + new("Mods.CalamityMod.Events.BossRushTierTwoEndText_1", 225), + new("Mods.CalamityMod.Events.BossRushTierTwoEndText_2", 270), }; // Dialogue that occurs when beating Tier 3 of Boss Rush BossRushDialogueEvent[] tierThreeDialogues = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushTierThreeEndText_1", 465), - new("Mods.CalamityMod.Events.BossRushTierThreeEndText_2", 330), + new("Mods.CalamityMod.Events.BossRushTierThreeEndText_1", 435), + new("Mods.CalamityMod.Events.BossRushTierThreeEndText_2", 300), }; // Dialogue that occurs when beating Tier 4 of Boss Rush BossRushDialogueEvent[] tierFourDialogues = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushTierFourEndText_1", 165), - new("Mods.CalamityMod.Events.BossRushTierFourEndText_2", 330), - new("Mods.CalamityMod.Events.BossRushTierFourEndText_3", 300), + new("Mods.CalamityMod.Events.BossRushTierFourEndText_1", 135), + new("Mods.CalamityMod.Events.BossRushTierFourEndText_2", 300), + new("Mods.CalamityMod.Events.BossRushTierFourEndText_3", 270), }; // Dialogue that occurs the first time you beat Boss Rush BossRushDialogueEvent[] endDialogues = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushEndText_1", 540), - new("Mods.CalamityMod.Events.BossRushEndText_2", 465), - new("Mods.CalamityMod.Events.BossRushEndText_3", 360), - new("Mods.CalamityMod.Events.BossRushEndText_4", 285), - new("Mods.CalamityMod.Events.BossRushEndText_5", 420), - new("Mods.CalamityMod.Events.BossRushEndText_6", 420), - new("Mods.CalamityMod.Events.BossRushEndText_7", 225), - new("Mods.CalamityMod.Events.BossRushEndText_8", 135), + new("Mods.CalamityMod.Events.BossRushEndText_1", 510), + new("Mods.CalamityMod.Events.BossRushEndText_2", 435), + new("Mods.CalamityMod.Events.BossRushEndText_3", 330), + new("Mods.CalamityMod.Events.BossRushEndText_4", 255), + new("Mods.CalamityMod.Events.BossRushEndText_5", 390), + new("Mods.CalamityMod.Events.BossRushEndText_6", 390), + new("Mods.CalamityMod.Events.BossRushEndText_7", 195), + new("Mods.CalamityMod.Events.BossRushEndText_8", 105), }; - // Dialogue that occurs the first time you beat Boss Rush + // Dialogue that occurs on subsequent times you beat Boss Rush BossRushDialogueEvent[] endDialoguesShort = new BossRushDialogueEvent[] { - new("Mods.CalamityMod.Events.BossRushEndText_Repeat", 510), + new("Mods.CalamityMod.Events.BossRushEndText_Repeat", 480), }; BossRushDialogue = new Dictionary() @@ -207,6 +208,10 @@ namespace CalamityMod.Systems if (GottaGoFast && CurrentDialogueDelay > GottaGoFastSpeed) CurrentDialogueDelay = GottaGoFastSpeed; } + else + { + CurrentDialogueDelay = 0; + } // If the end of a sequence has been reached, stay in this state indefinitely. // Allow the boss spawn countdown to hit zero and the next boss to appear without showing any dialogue or causing any delays. diff --git a/Systems/WorldMiscUpdateSystem.cs b/Systems/WorldMiscUpdateSystem.cs index 05c4a3c2d5..074ff42332 100644 --- a/Systems/WorldMiscUpdateSystem.cs +++ b/Systems/WorldMiscUpdateSystem.cs @@ -104,12 +104,12 @@ namespace CalamityMod.Systems // Attempt to summon lab critters manually since they refuse to exist when using vanilla's spawn methods. // This needs to check all players since the method only runs server-side. - for (int i = 0; i < Main.maxPlayers; i++) + foreach (Player p in Main.ActivePlayers) { - if (!Main.player[i].active || Main.player[i].dead) + if (p.dead) continue; - CalamityGlobalNPC.AttemptToSpawnLabCritters(Main.player[i]); + CalamityGlobalNPC.AttemptToSpawnLabCritters(p); } // Make the cultist countdown happen much more quickly. diff --git a/TileEntities/TEChargingStation.cs b/TileEntities/TEChargingStation.cs index caa483d473..33ec54628d 100644 --- a/TileEntities/TEChargingStation.cs +++ b/TileEntities/TEChargingStation.cs @@ -140,10 +140,9 @@ namespace CalamityMod.TileEntities // If this charging station breaks, anyone's who's viewing it is no longer viewing it. public override void OnKill() { - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active) + if (p.dead) continue; // Use reflection to stop TML from spitting an error here. diff --git a/TileEntities/TEHostileFireTurret.cs b/TileEntities/TEHostileFireTurret.cs index 65171977ee..5f79addd68 100644 --- a/TileEntities/TEHostileFireTurret.cs +++ b/TileEntities/TEHostileFireTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TEHostileIceTurret.cs b/TileEntities/TEHostileIceTurret.cs index 7e6ff9c24d..17d4fec62d 100644 --- a/TileEntities/TEHostileIceTurret.cs +++ b/TileEntities/TEHostileIceTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TEHostileLabTurret.cs b/TileEntities/TEHostileLabTurret.cs index 22eed5f8b8..e56a00222a 100644 --- a/TileEntities/TEHostileLabTurret.cs +++ b/TileEntities/TEHostileLabTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TEHostileLaserTurret.cs b/TileEntities/TEHostileLaserTurret.cs index 694a184e10..f6957f917a 100644 --- a/TileEntities/TEHostileLaserTurret.cs +++ b/TileEntities/TEHostileLaserTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TEHostileOnyxTurret.cs b/TileEntities/TEHostileOnyxTurret.cs index 6c800d2ec8..6443c09f49 100644 --- a/TileEntities/TEHostileOnyxTurret.cs +++ b/TileEntities/TEHostileOnyxTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TEHostilePlagueTurret.cs b/TileEntities/TEHostilePlagueTurret.cs index 1969210cd5..b06e3301c5 100644 --- a/TileEntities/TEHostilePlagueTurret.cs +++ b/TileEntities/TEHostilePlagueTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TEHostileWaterTurret.cs b/TileEntities/TEHostileWaterTurret.cs index edaf987128..d89dc7c8a0 100644 --- a/TileEntities/TEHostileWaterTurret.cs +++ b/TileEntities/TEHostileWaterTurret.cs @@ -85,10 +85,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active || p.dead) + if (p.dead) continue; float distSQ = p.DistanceSQ(targetingCenter); @@ -96,7 +95,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = p.Center; - indexToSet = i; + indexToSet = p.whoAmI; } } diff --git a/TileEntities/TELabHologramProjector.cs b/TileEntities/TELabHologramProjector.cs index ea28ff6fbc..791cd49489 100644 --- a/TileEntities/TELabHologramProjector.cs +++ b/TileEntities/TELabHologramProjector.cs @@ -35,11 +35,10 @@ namespace CalamityMod.TileEntities // If one is, pop up. Vector2 projectorCenterPos = Center; float distSQ = PopupDistance * PopupDistance; - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active) // The lack of a dead check is intentional. Dead players keep hologram boxes on for amusement. - continue; + // The lack of a dead check is intentional. Dead players keep hologram boxes on for amusement. + if (p.DistanceSQ(projectorCenterPos) < distSQ) { PoppingUp = true; @@ -72,12 +71,8 @@ namespace CalamityMod.TileEntities // If this projector breaks, anyone who's viewing it is no longer viewing it. public override void OnKill() { - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active) - continue; - // Use reflection to stop TML from spitting an error here. // Try-catching will not stop this error, TML will print it to console anyway. The error is harmless. ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p); diff --git a/TileEntities/TEPlayerFireTurret.cs b/TileEntities/TEPlayerFireTurret.cs index de0a344fee..ce3485376e 100644 --- a/TileEntities/TEPlayerFireTurret.cs +++ b/TileEntities/TEPlayerFireTurret.cs @@ -88,10 +88,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -99,7 +98,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPlayerIceTurret.cs b/TileEntities/TEPlayerIceTurret.cs index 3972e8c0c9..b391d06346 100644 --- a/TileEntities/TEPlayerIceTurret.cs +++ b/TileEntities/TEPlayerIceTurret.cs @@ -88,10 +88,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -99,7 +98,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPlayerLabTurret.cs b/TileEntities/TEPlayerLabTurret.cs index 53fff521c4..df9517428b 100644 --- a/TileEntities/TEPlayerLabTurret.cs +++ b/TileEntities/TEPlayerLabTurret.cs @@ -88,10 +88,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -99,7 +98,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPlayerLaserTurret .cs b/TileEntities/TEPlayerLaserTurret .cs index 543d48156d..0360e32168 100644 --- a/TileEntities/TEPlayerLaserTurret .cs +++ b/TileEntities/TEPlayerLaserTurret .cs @@ -88,10 +88,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -99,7 +98,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPlayerOnyxTurret.cs b/TileEntities/TEPlayerOnyxTurret.cs index 249773f018..997b04959c 100644 --- a/TileEntities/TEPlayerOnyxTurret.cs +++ b/TileEntities/TEPlayerOnyxTurret.cs @@ -88,10 +88,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -99,7 +98,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPlayerPlagueTurret.cs b/TileEntities/TEPlayerPlagueTurret.cs index eac6772413..764f0c8ed8 100644 --- a/TileEntities/TEPlayerPlagueTurret.cs +++ b/TileEntities/TEPlayerPlagueTurret.cs @@ -69,10 +69,9 @@ namespace CalamityMod.TileEntities //This turret can switch targets at any time - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -80,7 +79,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPlayerWaterTurret.cs b/TileEntities/TEPlayerWaterTurret.cs index 50da41de03..924f72e22c 100644 --- a/TileEntities/TEPlayerWaterTurret.cs +++ b/TileEntities/TEPlayerWaterTurret.cs @@ -88,10 +88,9 @@ namespace CalamityMod.TileEntities Vector2 ret = InvalidTarget; float distSQToBeat = MaxRange * MaxRange; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.CountsAsACritter) + if (npc.friendly || npc.CountsAsACritter) continue; float distSQ = npc.DistanceSQ(targetingCenter); @@ -99,7 +98,7 @@ namespace CalamityMod.TileEntities { distSQToBeat = distSQ; ret = npc.Center; - indexToSet = i; + indexToSet = npc.whoAmI; } } diff --git a/TileEntities/TEPowerCellFactory.cs b/TileEntities/TEPowerCellFactory.cs index 7b1482be3a..93bdce0481 100644 --- a/TileEntities/TEPowerCellFactory.cs +++ b/TileEntities/TEPowerCellFactory.cs @@ -103,12 +103,8 @@ namespace CalamityMod.TileEntities // If this factory breaks, anyone who's viewing it is no longer viewing it. public override void OnKill() { - for (int i = 0; i < Main.maxPlayers; ++i) + foreach (Player p in Main.ActivePlayers) { - Player p = Main.player[i]; - if (!p.active) - continue; - // Use reflection to stop TML from spitting an error here. // Try-catching will not stop this error, TML will print it to console anyway. The error is harmless. ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p); diff --git a/Tiles/Abyss/AbyssGravel.cs b/Tiles/Abyss/AbyssGravel.cs index 8544a7dcce..1754b7fc58 100644 --- a/Tiles/Abyss/AbyssGravel.cs +++ b/Tiles/Abyss/AbyssGravel.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Abyss.AbyssAmbient; +using System.Collections.Generic; +using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,14 +9,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class AbyssGravel : ModTile + public class AbyssGravel : ModTile, IMergeableTile { int animationFrameWidth = 234; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); + + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -31,8 +31,8 @@ namespace CalamityMod.Tiles.Abyss HitSound = MineSound; DustType = 33; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override bool CanExplode(int i, int j) @@ -157,18 +157,5 @@ namespace CalamityMod.Tiles.Abyss } frameXOffset = uniqueAnimationFrameX * animationFrameWidth; } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index c8becd91c8..e7f7eeb788 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -1,4 +1,5 @@ -using CalamityMod.World; +using System.Collections.Generic; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,11 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class HardenedSulphurousSandstone : ModTile + public class HardenedSulphurousSandstone : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -24,9 +23,9 @@ namespace CalamityMod.Tiles.Abyss DustType = 32; AddMapEntry(new Color(76, 58, 59)); HitSound = SoundID.Dig; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/SulphurousShaleMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -43,21 +42,6 @@ namespace CalamityMod.Tiles.Abyss } } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SulphurousShaleMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; - } - public override void RandomUpdate(int i, int j) { int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index bb9c985a8a..f80d61113a 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Abyss.AbyssAmbient; +using System.Collections.Generic; +using CalamityMod.Tiles.Abyss.AbyssAmbient; using CalamityMod.Walls; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,13 +14,11 @@ namespace CalamityMod.Tiles.Abyss { // Transforms any and all Tenebris in old worlds into planty mush. [LegacyName("Tenebris")] - public class PlantyMush : ModTile + public class PlantyMush : ModTile, IMergeableTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/PlantyMushMine", 3); - - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -35,9 +34,9 @@ namespace CalamityMod.Tiles.Abyss AddMapEntry(new Color(84, 102, 39), CalamityUtils.GetItemName()); HitSound = MineSound; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); } int animationFrameWidth = 234; @@ -201,20 +200,5 @@ namespace CalamityMod.Tiles.Abyss } } } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AbyssGravelMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Abyss/PyreMantle.cs b/Tiles/Abyss/PyreMantle.cs index 7531b8f91c..12d1cd6f9c 100644 --- a/Tiles/Abyss/PyreMantle.cs +++ b/Tiles/Abyss/PyreMantle.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,13 +11,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class PyreMantle : ModTile + public class PyreMantle : ModTile, IMergeableTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -33,9 +32,9 @@ namespace CalamityMod.Tiles.Abyss MinPick = 180; AddMapEntry(new Color(19, 20, 32)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -70,20 +69,5 @@ namespace CalamityMod.Tiles.Abyss NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); } } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AbyssGravelMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Abyss/PyreMantleMolten.cs b/Tiles/Abyss/PyreMantleMolten.cs index c14d9aae02..74c659b73f 100644 --- a/Tiles/Abyss/PyreMantleMolten.cs +++ b/Tiles/Abyss/PyreMantleMolten.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,15 +11,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class PyreMantleMolten : ModTile + public class PyreMantleMolten : ModTile, IMergeableTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; internal static Texture2D GlowTexture; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -39,10 +37,10 @@ namespace CalamityMod.Tiles.Abyss MinPick = 180; AddMapEntry(new Color(113, 49, 16)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out fourthTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/PyreMantleMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -97,11 +95,6 @@ namespace CalamityMod.Tiles.Abyss TileFraming.SlopedGlowmask(i, j, 0, GlowTexture, drawOffset, null, GetDrawColour(i, j, drawColour), default); glowbrightness += 0.3f; - - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/PyreMantleMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AbyssGravelMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -118,15 +111,6 @@ namespace CalamityMod.Tiles.Abyss b *= brightness; } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out fourthTileAdjacency[i, j]); - return true; - } - private Color GetDrawColour(int i, int j, Color colour) { int colType = Main.tile[i, j].TileColor; diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index 6fb2c179e3..c0e83d585a 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -1,4 +1,5 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -15,12 +16,9 @@ namespace CalamityMod.Tiles.Abyss // It would create block swap issues with regular sulphurous sand and was rendered obsolete with the removal of this tile's water emission mechanic. // For compatibility reasons (including with schematics), however, that tile is converted into this one. [LegacyName("SulphurousSandNoWater")] - public class SulphurousSand : ModTile + public class SulphurousSand : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -37,10 +35,10 @@ namespace CalamityMod.Tiles.Abyss AddMapEntry(new Color(150, 100, 50)); HitSound = SoundID.Dig; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out fourthTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/SulphurousSandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -175,23 +173,5 @@ namespace CalamityMod.Tiles.Abyss } } } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SulphurousSandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sand, out fourthTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index a619209223..5b2c948dfe 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -1,4 +1,5 @@ -using CalamityMod.World; +using System.Collections.Generic; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,11 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class SulphurousSandstone : ModTile + public class SulphurousSandstone : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -25,9 +24,9 @@ namespace CalamityMod.Tiles.Abyss AddMapEntry(new Color(113, 90, 71)); HitSound = SoundID.Dig; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/HardenedSulphurousSandstoneMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -44,21 +43,6 @@ namespace CalamityMod.Tiles.Abyss } } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSulphurousSandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; - } - public override void RandomUpdate(int i, int j) { int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); diff --git a/Tiles/Abyss/SulphurousShale.cs b/Tiles/Abyss/SulphurousShale.cs index a76fb75138..c4652868ac 100644 --- a/Tiles/Abyss/SulphurousShale.cs +++ b/Tiles/Abyss/SulphurousShale.cs @@ -1,5 +1,6 @@ //using CalamityMod.Tiles.Abyss.AbyssAmbient; using System; +using System.Collections.Generic; using CalamityMod.Tiles.Abyss.AbyssAmbient; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -12,15 +13,14 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class SulphurousShale : ModTile + public class SulphurousShale : ModTile, IMergeableTile { int animationFrameWidth = 234; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); - + + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -35,9 +35,17 @@ namespace CalamityMod.Tiles.Abyss MinPick = 65; HitSound = MineSound; DustType = 33; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) + { + Main.SceneMetrics.ActiveFountainColor = ModContent.Find("CalamityMod/SulphuricDepthsWater").Slot; + } } public override bool CanExplode(int i, int j) @@ -217,20 +225,5 @@ namespace CalamityMod.Tiles.Abyss } frameXOffset = uniqueAnimationFrameX * animationFrameWidth; } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AbyssGravelMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Abyss/Voidstone.cs b/Tiles/Abyss/Voidstone.cs index 4c47acb550..45f6f30719 100644 --- a/Tiles/Abyss/Voidstone.cs +++ b/Tiles/Abyss/Voidstone.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,13 +11,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class Voidstone : ModTile + public class Voidstone : ModTile, IMergeableTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; internal static Texture2D GlowTexture; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -36,9 +36,9 @@ namespace CalamityMod.Tiles.Abyss MinPick = 180; AddMapEntry(new Color(15, 15, 15)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/PyreMantleMerge"); } int animationFrameWidth = 234; @@ -276,17 +276,6 @@ namespace CalamityMod.Tiles.Abyss drawColour *= brightness; TileFraming.SlopedGlowmask(i, j, 0, GlowTexture, drawOffset, null, GetDrawColour(i, j, drawColour), default); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/PyreMantleMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; } private Color GetDrawColour(int i, int j, Color colour) diff --git a/Tiles/AerialiteBrick.cs b/Tiles/AerialiteBrick.cs index 87b06b2cc6..73a3990d3f 100644 --- a/Tiles/AerialiteBrick.cs +++ b/Tiles/AerialiteBrick.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -6,10 +7,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AerialiteBrick : ModTile + public class AerialiteBrick : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -17,19 +18,12 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(68, 58, 145)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); return TileFraming.BetterGemsparkFraming(i, j, resetFrame); } diff --git a/Tiles/Astral/AstralClay.cs b/Tiles/Astral/AstralClay.cs index 4d43e6e647..d5afdd919e 100644 --- a/Tiles/Astral/AstralClay.cs +++ b/Tiles/Astral/AstralClay.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -8,9 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralClay : ModTile + public class AstralClay : ModTile, IMergeableTile { - public byte[,] tileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -29,17 +31,7 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.CanBeDugByShovel[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - return true; + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Astral/AstralDirt.cs b/Tiles/Astral/AstralDirt.cs index 6ea70a8551..4cd269dab8 100644 --- a/Tiles/Astral/AstralDirt.cs +++ b/Tiles/Astral/AstralDirt.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using System.Collections.Generic; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,10 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralDirt : ModTile + public class AstralDirt : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -35,21 +36,8 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - return true; + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override void RandomUpdate(int i, int j) diff --git a/Tiles/Astral/AstralMonolith.cs b/Tiles/Astral/AstralMonolith.cs index 6650ec3613..9724660bfb 100644 --- a/Tiles/Astral/AstralMonolith.cs +++ b/Tiles/Astral/AstralMonolith.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,12 +10,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralMonolith : ModTile + public class AstralMonolith : ModTile, IMergeableTile { private static int sheetWidth = 216; private static int sheetHeight = 72; - public byte[,] tileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -31,7 +32,7 @@ namespace CalamityMod.Tiles.Astral AddMapEntry(new Color(45, 36, 63)); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -86,14 +87,10 @@ namespace CalamityMod.Tiles.Astral { Main.spriteBatch.Draw(glowmask, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); TileFraming.CompactFraming(i, j, resetFrame); return false; } diff --git a/Tiles/Astral/AstralStone.cs b/Tiles/Astral/AstralStone.cs index 8516bb4c0d..5d4eb9f993 100644 --- a/Tiles/Astral/AstralStone.cs +++ b/Tiles/Astral/AstralStone.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -8,11 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralStone : ModTile + public class AstralStone : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -33,24 +33,9 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.Conversion.Stone[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); - } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Astral/AstralTree.cs b/Tiles/Astral/AstralTree.cs index 37d8204aae..9bc4e6c1d6 100644 --- a/Tiles/Astral/AstralTree.cs +++ b/Tiles/Astral/AstralTree.cs @@ -115,7 +115,7 @@ namespace CalamityMod.Tiles.Astral else if (Main.rand.NextBool(15)) { createLeaves = true; - int type = ModContent.ItemType(); + int type = ModContent.ItemType(); if (!Main.dayTime && Main.rand.NextBool()) type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); diff --git a/Tiles/Astral/NovaeSlag.cs b/Tiles/Astral/NovaeSlag.cs index 51265047de..60fd932b1d 100644 --- a/Tiles/Astral/NovaeSlag.cs +++ b/Tiles/Astral/NovaeSlag.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using System.Collections.Generic; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,11 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { [LegacyName("AstralSilt")] - public class NovaeSlag : ModTile + public class NovaeSlag : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -33,9 +33,9 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -45,21 +45,6 @@ namespace CalamityMod.Tiles.Astral return false; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - return true; - } - public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; diff --git a/Tiles/AstralBrick.cs b/Tiles/AstralBrick.cs index 8fe7e2c801..3af5cfe613 100644 --- a/Tiles/AstralBrick.cs +++ b/Tiles/AstralBrick.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using System.Collections.Generic; +using CalamityMod.Dusts; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -8,13 +9,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AstralBrick : ModTile + public class AstralBrick : ModTile, IMergeableTile { private const short subsheetWidth = 324; private const short subsheetHeight = 90; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -22,8 +23,8 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(128, 128, 158)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -34,8 +35,6 @@ namespace CalamityMod.Tiles public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); return TileFraming.BetterGemsparkFraming(i, j, resetFrame); } @@ -64,9 +63,6 @@ namespace CalamityMod.Tiles Tile trackTile = Main.tile[i, j]; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); - - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); } private Color GetDrawColour(int i, int j, Color colour) diff --git a/Tiles/AstralDesert/AstralPalmTree.cs b/Tiles/AstralDesert/AstralPalmTree.cs index c5b9c46c13..4ccdbe2be0 100644 --- a/Tiles/AstralDesert/AstralPalmTree.cs +++ b/Tiles/AstralDesert/AstralPalmTree.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Tiles.AstralDesert else if (Main.rand.NextBool(15)) { createLeaves = true; - int type = ModContent.ItemType(); + int type = ModContent.ItemType(); if (!Main.dayTime && Main.rand.NextBool()) type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs index 56e1f6fb34..b93e3e27db 100644 --- a/Tiles/AstralDesert/AstralSand.cs +++ b/Tiles/AstralDesert/AstralSand.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Typeless; +using System.Collections.Generic; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,12 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class AstralSand : ModTile + public class AstralSand : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -39,31 +38,16 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.Falling[Type] = true; TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out fourthTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sand, out fourthTileAdjacency[i, j]); - return true; - } public override bool HasWalkDust() { diff --git a/Tiles/AstralDesert/AstralSandstone.cs b/Tiles/AstralDesert/AstralSandstone.cs index c64c5bb851..026c0bf2df 100644 --- a/Tiles/AstralDesert/AstralSandstone.cs +++ b/Tiles/AstralDesert/AstralSandstone.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -8,12 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class AstralSandstone : ModTile + public class AstralSandstone : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -30,25 +29,10 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.Conversion.Sandstone[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.HardenedSand, out fourthTileAdjacency); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/SandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSandMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/SandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSandMerge"); - return true; + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandMerge"); + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/AstralDesert/CelestialRemains.cs b/Tiles/AstralDesert/CelestialRemains.cs index 03db9266b1..515e549546 100644 --- a/Tiles/AstralDesert/CelestialRemains.cs +++ b/Tiles/AstralDesert/CelestialRemains.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using System.Collections.Generic; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,10 +10,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { [LegacyName("AstralFossil")] - public class CelestialRemains : ModTile + public class CelestialRemains : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -28,19 +29,8 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AstralSandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralSandMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); - return true; + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandstoneMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/AstralDesert/HardenedAstralSand.cs b/Tiles/AstralDesert/HardenedAstralSand.cs index 452b866c98..0918cabd0a 100644 --- a/Tiles/AstralDesert/HardenedAstralSand.cs +++ b/Tiles/AstralDesert/HardenedAstralSand.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,13 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class HardenedAstralSand : ModTile + public class HardenedAstralSand : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; - public byte[,] fifthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -31,29 +29,11 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.Conversion.HardenedSand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.HardenedSand, out fourthTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out fifthTileAdjacency); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AstralSandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fifthTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sandstone, out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.HardenedSand, out fourthTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sand, out fifthTileAdjacency[i, j]); - return true; + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/AstralSnow/AstralIce.cs b/Tiles/AstralSnow/AstralIce.cs index ed69e681c5..a339f14e98 100644 --- a/Tiles/AstralSnow/AstralIce.cs +++ b/Tiles/AstralSnow/AstralIce.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Astral; +using System.Collections.Generic; +using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,10 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralIce : ModTile + public class AstralIce : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -36,8 +37,8 @@ namespace CalamityMod.Tiles.AstralSnow TileID.Sets.Conversion.Ice[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSnowMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -51,19 +52,6 @@ namespace CalamityMod.Tiles.AstralSnow base.FloorVisuals(player); } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralSnowMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); - return true; - } - public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) { sightColor = Color.Cyan; diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index 517e16d03d..6ab01d8390 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Astral; +using System.Collections.Generic; +using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,10 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralSnow : ModTile + public class AstralSnow : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -33,26 +34,14 @@ namespace CalamityMod.Tiles.AstralSnow TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.SnowBlock, out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); + this.RegisterUniversalMerge(TileID.SnowBlock, "CalamityMod/Tiles/Merges/SnowMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/SnowMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.SnowBlock, out secondTileAdjacency[i, j]); - return true; - } public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) { diff --git a/Tiles/AstralSnow/AstralSnowTree.cs b/Tiles/AstralSnow/AstralSnowTree.cs index b9d738433f..f36ecac3c4 100644 --- a/Tiles/AstralSnow/AstralSnowTree.cs +++ b/Tiles/AstralSnow/AstralSnowTree.cs @@ -117,7 +117,7 @@ namespace CalamityMod.Tiles.AstralSnow else if (Main.rand.NextBool(15)) { createLeaves = true; - int type = ModContent.ItemType(); + int type = ModContent.ItemType(); if (!Main.dayTime && Main.rand.NextBool()) type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); diff --git a/Tiles/Crags/BrimstoneSlab.cs b/Tiles/Crags/BrimstoneSlab.cs index 34af2e0fef..04d2cd4666 100644 --- a/Tiles/Crags/BrimstoneSlab.cs +++ b/Tiles/Crags/BrimstoneSlab.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Crags; +using System.Collections.Generic; +using CalamityMod.Tiles.Crags; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,13 +9,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlab : ModTile + public class BrimstoneSlab : ModTile, IMergeableTile { private int subsheetWidth = 450; private int subsheetHeight = 198; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -30,8 +30,8 @@ namespace CalamityMod.Tiles.Crags HitSound = SoundID.Tink; DustType = 235; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Ash, out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); + this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); } public override bool CanExplode(int i, int j) @@ -49,15 +49,9 @@ namespace CalamityMod.Tiles.Crags frameXOffset = i % 2 * subsheetWidth; frameYOffset = j % 2 * subsheetHeight; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AshMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Ash, out secondTileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } } diff --git a/Tiles/Crags/BrimstoneSlag.cs b/Tiles/Crags/BrimstoneSlag.cs index a76237ed86..3a1a485968 100644 --- a/Tiles/Crags/BrimstoneSlag.cs +++ b/Tiles/Crags/BrimstoneSlag.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Ores; +using System.Collections.Generic; +using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,11 +8,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlag : ModTile + public class BrimstoneSlag : ModTile, IMergeableTile { private const short subsheetWidth = 450; private const short subsheetHeight = 198; - public byte[,] TileAdjacency; + + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -25,7 +28,7 @@ namespace CalamityMod.Tiles.Crags MineResist = 2f; MinPick = 100; AddMapEntry(new Color(53, 33, 56)); - TileFraming.SetUpUniversalMerge(Type, TileID.Ash, out TileAdjacency); + this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -45,14 +48,8 @@ namespace CalamityMod.Tiles.Crags frameXOffset = i % 2 * subsheetWidth; frameYOffset = j % 2 * subsheetHeight; } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, TileAdjacency, "CalamityMod/Tiles/Merges/AshMerge"); - } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Ash, out TileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } diff --git a/Tiles/Crags/ScorchedBone.cs b/Tiles/Crags/ScorchedBone.cs index 9f45f7b514..9a875a0ff7 100644 --- a/Tiles/Crags/ScorchedBone.cs +++ b/Tiles/Crags/ScorchedBone.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Ores; +using System.Collections.Generic; +using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,13 +8,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedBone : ModTile + public class ScorchedBone : ModTile, IMergeableTile { private int sheetWidth = 450; private int sheetHeight = 198; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -28,8 +29,8 @@ namespace CalamityMod.Tiles.Crags MinPick = 100; AddMapEntry(new Color(87, 62, 67)); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Ash, out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); + this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); } public override bool CanExplode(int i, int j) @@ -42,15 +43,9 @@ namespace CalamityMod.Tiles.Crags frameXOffset = i % 3 * sheetWidth; frameYOffset = j % 3 * sheetHeight; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AshMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Ash, out secondTileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } } diff --git a/Tiles/Crags/ScorchedRemains.cs b/Tiles/Crags/ScorchedRemains.cs index addfd5e85a..74f47d6744 100644 --- a/Tiles/Crags/ScorchedRemains.cs +++ b/Tiles/Crags/ScorchedRemains.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Ores; +using System.Collections.Generic; +using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,13 +8,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedRemains : ModTile + public class ScorchedRemains : ModTile, IMergeableTile { private int sheetWidth = 234; private int sheetHeight = 90; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -28,8 +29,8 @@ namespace CalamityMod.Tiles.Crags MinPick = 100; AddMapEntry(new Color(57, 52, 72)); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Ash, out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); + this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); } public override void RandomUpdate(int i, int j) @@ -61,16 +62,5 @@ namespace CalamityMod.Tiles.Crags frameXOffset = i % 3 * sheetWidth; frameYOffset = j % 3 * sheetHeight; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AshMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Ash, out secondTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Crags/ScorchedRemainsGrass.cs b/Tiles/Crags/ScorchedRemainsGrass.cs index 827664346e..a83fa18de3 100644 --- a/Tiles/Crags/ScorchedRemainsGrass.cs +++ b/Tiles/Crags/ScorchedRemainsGrass.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using System.Collections.Generic; +using CalamityMod.Dusts; using CalamityMod.Tiles.Crags.Lily; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,15 +10,14 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedRemainsGrass : ModTile + public class ScorchedRemainsGrass : ModTile, IMergeableTile { private const short subsheetWidth = 234; private const short subsheetHeight = 90; private int extraFrameHeight = 36; private int extraFrameWidth = 90; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -34,8 +34,8 @@ namespace CalamityMod.Tiles.Crags RegisterItemDrop(ModContent.ItemType()); AddMapEntry(new Color(212, 82, 227)); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Ash, out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); + this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -158,17 +158,6 @@ namespace CalamityMod.Tiles.Crags DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour); DrawExtraDrapes(i, j, leaves, drawOffset, drawColour); } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AshMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Ash, out secondTileAdjacency[i, j]); - return true; - } #region 'Extra Drapes' Drawing private void DrawExtraTop(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) diff --git a/Tiles/CryonicBrick.cs b/Tiles/CryonicBrick.cs index 5c8fae2e15..96c010298a 100644 --- a/Tiles/CryonicBrick.cs +++ b/Tiles/CryonicBrick.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -6,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class CryonicBrick : ModTile + public class CryonicBrick : ModTile, IMergeableTile { int subsheetHeight = 90; int subsheetWidth = 234; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -24,8 +25,8 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(99, 131, 199)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.SnowBlock, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.SnowBlock, "CalamityMod/Tiles/Merges/SnowMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -34,13 +35,6 @@ namespace CalamityMod.Tiles return false; } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.SnowBlock, out secondTileAdjacency[i, j]); - return true; - } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { int xPos = i % 2; @@ -48,11 +42,5 @@ namespace CalamityMod.Tiles frameXOffset = xPos * subsheetWidth; frameYOffset = yPos * subsheetHeight; } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/SnowMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } } } diff --git a/Tiles/DraedonStructures/LaboratoryPanels.cs b/Tiles/DraedonStructures/LaboratoryPanels.cs index c51ba3ebb3..61724a0d54 100644 --- a/Tiles/DraedonStructures/LaboratoryPanels.cs +++ b/Tiles/DraedonStructures/LaboratoryPanels.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -7,12 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPanels : ModTile + public class LaboratoryPanels : ModTile, IMergeableTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -26,23 +27,10 @@ namespace CalamityMod.Tiles.DraedonStructures MinPick = 30; AddMapEntry(new Color(36, 35, 37)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override bool CanExplode(int i, int j) => false; - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/DraedonStructures/LaboratoryPipePlating.cs b/Tiles/DraedonStructures/LaboratoryPipePlating.cs index a9eff7d263..963d4ed162 100644 --- a/Tiles/DraedonStructures/LaboratoryPipePlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPipePlating.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -7,12 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPipePlating : ModTile + public class LaboratoryPipePlating : ModTile, IMergeableTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -25,22 +26,14 @@ namespace CalamityMod.Tiles.DraedonStructures MinPick = 30; AddMapEntry(new Color(91, 64, 56)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override bool CanExplode(int i, int j) => false; - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); TileFraming.CustomMergeFrame(i, j, Type, ModContent.TileType(), false, false, false); return false; } diff --git a/Tiles/DraedonStructures/LaboratoryPlating.cs b/Tiles/DraedonStructures/LaboratoryPlating.cs index f6bcdb2f40..9f6e1c8f72 100644 --- a/Tiles/DraedonStructures/LaboratoryPlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPlating.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -7,12 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPlating : ModTile + public class LaboratoryPlating : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); + + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -25,22 +26,14 @@ namespace CalamityMod.Tiles.DraedonStructures MinPick = 30; AddMapEntry(new Color(162, 157, 150)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override bool CanExplode(int i, int j) => false; - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); return TileFraming.BetterGemsparkFraming(i, j, resetFrame); } } diff --git a/Tiles/DraedonStructures/RustedPlating.cs b/Tiles/DraedonStructures/RustedPlating.cs index 475200035e..44eff8e23b 100644 --- a/Tiles/DraedonStructures/RustedPlating.cs +++ b/Tiles/DraedonStructures/RustedPlating.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -7,12 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class RustedPlating : ModTile + public class RustedPlating : ModTile, IMergeableTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -26,21 +26,14 @@ namespace CalamityMod.Tiles.DraedonStructures MinPick = 30; AddMapEntry(new Color(128, 90, 77)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override bool CanExplode(int i, int j) => false; public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); return TileFraming.BetterGemsparkFraming(i, j, resetFrame); } } diff --git a/Tiles/Furniture/Monoliths/AstralProjectorTile.cs b/Tiles/Furniture/Monoliths/AstralProjectorTile.cs index a13d71494f..d44aa7b562 100644 --- a/Tiles/Furniture/Monoliths/AstralProjectorTile.cs +++ b/Tiles/Furniture/Monoliths/AstralProjectorTile.cs @@ -18,12 +18,12 @@ namespace CalamityMod.Tiles.Furniture.Monoliths { public class AstralProjectorTile : ModTile { - public static Texture2D Glow; + public static Asset Glow; public override void SetStaticDefaults() { if (!Main.dedServ) { - Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/AstralProjectorTile_Glow", AssetRequestMode.AsyncLoad).Value; + Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/AstralProjectorTile_Glow", AssetRequestMode.AsyncLoad); } RegisterItemDrop(ModContent.ItemType()); Main.tileFrameImportant[Type] = true; @@ -95,7 +95,7 @@ namespace CalamityMod.Tiles.Furniture.Monoliths { int x = i - Main.tile[i, j].TileFrameX / 18 % 2; int y = j - Main.tile[i, j].TileFrameY / 18 % 3; - int tileXX18 = 54; + int tileXX18 = 56; for (int l = x; l < x + 2; l++) { for (int m = y; m < y + 3; m++) @@ -140,7 +140,7 @@ namespace CalamityMod.Tiles.Furniture.Monoliths } Main.spriteBatch.Draw(texture, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Lighting.GetColor(i, j), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); if (Glow != null) - Main.spriteBatch.Draw(Glow, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(Glow.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); return false; } } diff --git a/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs b/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs index 37a929204c..9abede9eaa 100644 --- a/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs +++ b/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs @@ -18,12 +18,12 @@ namespace CalamityMod.Tiles.Furniture.Monoliths { public class BossRushMonolithTile : ModTile { - public static Texture2D Glow; + public static Asset Glow; public override void SetStaticDefaults() { if (!Main.dedServ) { - Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/BossRushMonolithTile_Glow", AssetRequestMode.AsyncLoad).Value; + Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/BossRushMonolithTile_Glow", AssetRequestMode.AsyncLoad); } RegisterItemDrop(ModContent.ItemType()); Main.tileFrameImportant[Type] = true; @@ -140,7 +140,7 @@ namespace CalamityMod.Tiles.Furniture.Monoliths } Main.spriteBatch.Draw(texture, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Lighting.GetColor(i, j), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); if (Glow != null) - Main.spriteBatch.Draw(Glow, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(Glow.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); return false; } } diff --git a/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs b/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs index 1537d8e7d6..d598a4f1bf 100644 --- a/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs +++ b/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Tiles.Furniture.Monoliths { public class DraconicIncenseTile : ModTile { - public static Texture2D Glow; + public static Asset Glow; public override void SetStaticDefaults() { if (!Main.dedServ) { - Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/DraconicIncenseTile_Glow", AssetRequestMode.AsyncLoad).Value; + Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/DraconicIncenseTile_Glow", AssetRequestMode.AsyncLoad); } RegisterItemDrop(ModContent.ItemType()); Main.tileFrameImportant[Type] = true; @@ -138,7 +138,7 @@ namespace CalamityMod.Tiles.Furniture.Monoliths } Main.spriteBatch.Draw(texture, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Lighting.GetColor(i, j), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); if (Glow != null) - Main.spriteBatch.Draw(Glow, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(Glow.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); return false; } } diff --git a/Tiles/Furniture/Monoliths/ExoObeliskTile.cs b/Tiles/Furniture/Monoliths/ExoObeliskTile.cs index 90c6b4a01e..9712a5da57 100644 --- a/Tiles/Furniture/Monoliths/ExoObeliskTile.cs +++ b/Tiles/Furniture/Monoliths/ExoObeliskTile.cs @@ -20,14 +20,14 @@ namespace CalamityMod.Tiles.Furniture.Monoliths { public class ExoObeliskTile : ModTile { - public static Texture2D Glow; - public static Texture2D Numbers; + public static Asset Glow; + public static Asset Numbers; public override void SetStaticDefaults() { if (!Main.dedServ) { - Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/ExoObeliskTile_Glow", AssetRequestMode.AsyncLoad).Value; - Numbers = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/ExoObeliskText", AssetRequestMode.AsyncLoad).Value; + Glow = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/ExoObeliskTile_Glow", AssetRequestMode.AsyncLoad); + Numbers = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/ExoObeliskText", AssetRequestMode.AsyncLoad); } RegisterItemDrop(ModContent.ItemType()); Main.tileFrameImportant[Type] = true; @@ -144,7 +144,7 @@ namespace CalamityMod.Tiles.Furniture.Monoliths } Main.spriteBatch.Draw(texture, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Lighting.GetColor(i, j), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); if (Glow != null) - Main.spriteBatch.Draw(Glow, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(Glow.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); ; if (Numbers != null) { int colorIndex = (int)(Main.GlobalTimeWrappedHourly / 0.5 % CalamityUtils.ExoPalette.Length); @@ -152,7 +152,7 @@ namespace CalamityMod.Tiles.Furniture.Monoliths Color nextColor = CalamityUtils.ExoPalette[(colorIndex + 1) % CalamityUtils.ExoPalette.Length]; Color exoColors = Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 0.5f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f); - Main.spriteBatch.Draw(Numbers, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), exoColors, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(Numbers.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animate, 16, height), exoColors, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } return false; diff --git a/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs b/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs index 72d25b9ae3..2a52e46a60 100644 --- a/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs +++ b/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs @@ -17,6 +17,7 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public override void SetStaticDefaults() { + RegisterItemDrop(ModContent.ItemType()); Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; diff --git a/Tiles/IMergeableTile.cs b/Tiles/IMergeableTile.cs new file mode 100644 index 0000000000..9455c50bcc --- /dev/null +++ b/Tiles/IMergeableTile.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles +{ + /// + /// Interface for tiles that specify custom universal merge data. + /// + internal interface IMergeableTile + { + List TileAdjacencies { get; } + } + + internal static class MergeableTile + { + private sealed class MergeableTileGlobalTile : GlobalTile + { + public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) + { + if (!TryGetMergeableTile(type, out var mergeableTile)) + return; + + TileFraming.DrawUniversalMergeFrames(i, j, mergeableTile.TileAdjacencies); + } + + public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) + { + if (!TryGetMergeableTile(type, out var mergeableTile)) + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); + + foreach (var adjacency in mergeableTile.TileAdjacencies) + TileFraming.GetAdjacencyData(i, j, adjacency); + + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); + } + + private static bool TryGetMergeableTile(int type, [NotNullWhen(returnValue: true)] out IMergeableTile mergeableTile) + { + if (TileLoader.GetTile(type) is IMergeableTile theMergeableTile) + { + mergeableTile = theMergeableTile; + return true; + } + + mergeableTile = null; + return false; + } + } + + public static void RegisterUniversalMerge(this IMergeableTile mergeableTile, int tileId, string blendSheetPath) + { + if (mergeableTile is not ModTile tile) + throw new InvalidCastException($"{nameof(IMergeableTile)} is implemented on type {mergeableTile.GetType().FullName}; said type should inherit from {nameof(ModTile)}"); + + TileFraming.SetUpUniversalMerge(tile.Type, tileId, blendSheetPath, out var data); + mergeableTile.TileAdjacencies.Add(data); + } + } +} diff --git a/Tiles/Ores/AerialiteOre.cs b/Tiles/Ores/AerialiteOre.cs index 7b151a6aba..427c90d2b2 100644 --- a/Tiles/Ores/AerialiteOre.cs +++ b/Tiles/Ores/AerialiteOre.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -10,15 +11,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AerialiteOre : ModTile + public class AerialiteOre : ModTile, IMergeableTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/MagicalRockMine", 3); internal static Texture2D GlowTexture; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { if (!Main.dedServ) @@ -47,10 +46,10 @@ namespace CalamityMod.Tiles.Ores HitSound = MineSound; Main.tileSpelunker[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Cloud, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.RainCloud, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.SnowCloud, out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out fourthTileAdjacency); + this.RegisterUniversalMerge(TileID.Cloud, "CalamityMod/Tiles/Merges/CloudMerge"); + this.RegisterUniversalMerge(TileID.RainCloud, "CalamityMod/Tiles/Merges/RainCloudMerge"); + this.RegisterUniversalMerge(TileID.SnowCloud, "CalamityMod/Tiles/Merges/SnowCloudMerge"); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); } public override void PostSetDefaults() { @@ -63,14 +62,7 @@ namespace CalamityMod.Tiles.Ores { num = fail ? 1 : 3; } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Cloud, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.RainCloud, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.SnowCloud, out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out fourthTileAdjacency[i, j]); - return true; - } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { r = 0.14f; @@ -275,11 +267,6 @@ namespace CalamityMod.Tiles.Ores { Main.spriteBatch.Draw(GlowTexture, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/CloudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/RainCloudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SnowCloudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); } private Color GetDrawColour(int i, int j, Color colour) { diff --git a/Tiles/Ores/AerialiteOreDisenchanted.cs b/Tiles/Ores/AerialiteOreDisenchanted.cs index e8c281a20b..4780b063e0 100644 --- a/Tiles/Ores/AerialiteOreDisenchanted.cs +++ b/Tiles/Ores/AerialiteOreDisenchanted.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -6,14 +7,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AerialiteOreDisenchanted : ModTile + public class AerialiteOreDisenchanted : ModTile, IMergeableTile { private const int AnimationFrameWidth = 234; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -41,10 +39,10 @@ namespace CalamityMod.Tiles.Ores HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Cloud, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.RainCloud, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.SnowCloud, out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out fourthTileAdjacency); + this.RegisterUniversalMerge(TileID.Cloud, "CalamityMod/Tiles/Merges/CloudMerge"); + this.RegisterUniversalMerge(TileID.RainCloud, "CalamityMod/Tiles/Merges/RainCloudMerge"); + this.RegisterUniversalMerge(TileID.SnowCloud, "CalamityMod/Tiles/Merges/SnowCloudMerge"); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); } public override void PostSetDefaults() { @@ -60,15 +58,7 @@ namespace CalamityMod.Tiles.Ores { return false; } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Cloud, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.RainCloud, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.SnowCloud, out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out fourthTileAdjacency[i, j]); - return true; - } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { int uniqueAnimationFrameX = 0; @@ -159,12 +149,5 @@ namespace CalamityMod.Tiles.Ores } frameXOffset = uniqueAnimationFrameX * AnimationFrameWidth; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/CloudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/RainCloudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SnowCloudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } } } diff --git a/Tiles/Ores/AstralOre.cs b/Tiles/Ores/AstralOre.cs index 6e3c1d1153..c2e220d120 100644 --- a/Tiles/Ores/AstralOre.cs +++ b/Tiles/Ores/AstralOre.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Dusts; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; @@ -9,9 +10,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AstralOre : ModTile + public class AstralOre : ModTile, IMergeableTile { - public byte[,] TileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -37,7 +39,7 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.DoesntGetReplacedWithTileReplacement[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out TileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); } public override void NearbyEffects(int i, int j, bool closer) { @@ -85,15 +87,5 @@ namespace CalamityMod.Tiles.Ores g *= brightness; b *= brightness; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, TileAdjacency, "CalamityMod/Tiles/Merges/AstralDirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out TileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Ores/AuricOre.cs b/Tiles/Ores/AuricOre.cs index 9a8ee4c3e2..8d5facedb2 100644 --- a/Tiles/Ores/AuricOre.cs +++ b/Tiles/Ores/AuricOre.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,14 +14,14 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Ores { - public class AuricOre : ModTile + public class AuricOre : ModTile, IMergeableTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AuricMine", 3); public static bool Animate; internal static Texture2D GlowTexture; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { if (!Main.dedServ) @@ -44,9 +45,9 @@ namespace CalamityMod.Tiles.Ores MineResist = 5f; MinPick = 250; HitSound = MineSound; - - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override bool CanExplode(int i, int j) @@ -95,16 +96,8 @@ namespace CalamityMod.Tiles.Ores Tile trackTile = Main.tile[i, j]; double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); + } - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - return true; - } private Color GetDrawColour(int i, int j, Color colour) { int colType = Main.tile[i, j].TileColor; diff --git a/Tiles/Ores/ExodiumOre.cs b/Tiles/Ores/ExodiumOre.cs index 214713bca4..41fc92d67f 100644 --- a/Tiles/Ores/ExodiumOre.cs +++ b/Tiles/Ores/ExodiumOre.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,10 +10,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class ExodiumOre : ModTile + public class ExodiumOre : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -35,20 +36,8 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.ChecksForMerge[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.LunarOre, out secondTileAdjacency); - } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/LuminiteMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.LunarOre, out secondTileAdjacency[i, j]); - return true; + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.LunarOre, "CalamityMod/Tiles/Merges/LuminiteMerge"); } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/Ores/HallowedOre.cs b/Tiles/Ores/HallowedOre.cs index 366aa12c8a..049ca594f2 100644 --- a/Tiles/Ores/HallowedOre.cs +++ b/Tiles/Ores/HallowedOre.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,9 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class HallowedOre : ModTile + public class HallowedOre : ModTile, IMergeableTile { - public byte[,] tileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -32,7 +34,7 @@ namespace CalamityMod.Tiles.Ores HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Pearlstone, out tileAdjacency); + this.RegisterUniversalMerge(TileID.Pearlstone, "CalamityMod/Tiles/Merges/PearlstoneMerge"); } public override bool CanExplode(int i, int j) @@ -44,15 +46,6 @@ namespace CalamityMod.Tiles.Ores { num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/PearlstoneMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Pearlstone, out tileAdjacency[i, j]); - return true; - } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { diff --git a/Tiles/Ores/InfernalSuevite.cs b/Tiles/Ores/InfernalSuevite.cs index 55134067c2..4d00e3d10c 100644 --- a/Tiles/Ores/InfernalSuevite.cs +++ b/Tiles/Ores/InfernalSuevite.cs @@ -1,4 +1,5 @@ -using CalamityMod.Tiles.Crags; +using System.Collections.Generic; +using CalamityMod.Tiles.Crags; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,13 +10,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { [LegacyName("CharredOre")] - public class InfernalSuevite : ModTile + public class InfernalSuevite : ModTile, IMergeableTile { private int sheetWidth = 234; private int sheetHeight = 90; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -36,8 +36,8 @@ namespace CalamityMod.Tiles.Ores DustType = 235; Main.tileSpelunker[Type] = true; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Ash, out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); + this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); } public override bool CanExplode(int i, int j) @@ -62,18 +62,5 @@ namespace CalamityMod.Tiles.Ores g = 0f; b = 0f; } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/AshMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Ash, out secondTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/Ores/PerennialOre.cs b/Tiles/Ores/PerennialOre.cs index e21b28eba0..08d732e51e 100644 --- a/Tiles/Ores/PerennialOre.cs +++ b/Tiles/Ores/PerennialOre.cs @@ -1,5 +1,6 @@  using System; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -10,13 +11,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class PerennialOre : ModTile + public class PerennialOre : ModTile, IMergeableTile { internal static Texture2D GlowTexture; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -41,9 +40,9 @@ namespace CalamityMod.Tiles.Ores HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Mud, out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); } int animationFrameWidth = 234; @@ -297,18 +296,6 @@ namespace CalamityMod.Tiles.Ores Color drawColour = GetDrawColour(i, j, new Color(175, 175, 175, 175)); Tile trackTile = Main.tile[i, j]; TileFraming.SlopedGlowmask(i, j, 0, GlowTexture, drawOffset, null, GetDrawColour(i, j, drawColour), default); - - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/MudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Mud, out thirdTileAdjacency[i, j]); - return true; } private Color GetDrawColour(int i, int j, Color colour) diff --git a/Tiles/Ores/ScoriaOre.cs b/Tiles/Ores/ScoriaOre.cs index c5473a9310..238f5f1cd4 100644 --- a/Tiles/Ores/ScoriaOre.cs +++ b/Tiles/Ores/ScoriaOre.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Environment; +using System.Collections.Generic; +using CalamityMod.Projectiles.Environment; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -11,10 +12,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { [LegacyName("ChaoticOre")] - public class ScoriaOre : ModTile + public class ScoriaOre : ModTile, IMergeableTile { - public byte[,] TileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -34,8 +34,8 @@ namespace CalamityMod.Tiles.Ores MinPick = 210; HitSound = SoundID.Tink; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out TileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/PyreMantleMerge"); } public override void NearbyEffects(int i, int j, bool closer) @@ -88,15 +88,7 @@ namespace CalamityMod.Tiles.Ores g = 0.00f; b = 0.00f; } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out TileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); - return true; - } - - + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { int xPos = Main.tile[i, j].TileFrameX; @@ -108,9 +100,6 @@ namespace CalamityMod.Tiles.Ores Tile trackTile = Main.tile[i, j]; double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); - - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/PyreMantleMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, TileAdjacency, "CalamityMod/Tiles/Merges/AbyssGravelMerge"); } private Color GetDrawColour(int i, int j, Color colour) diff --git a/Tiles/Ores/UelibloomOre.cs b/Tiles/Ores/UelibloomOre.cs index 71546e0505..14ab406efd 100644 --- a/Tiles/Ores/UelibloomOre.cs +++ b/Tiles/Ores/UelibloomOre.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,11 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class UelibloomOre : ModTile + public class UelibloomOre : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -31,9 +31,9 @@ namespace CalamityMod.Tiles.Ores Main.tileSpelunker[Type] = true; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Mud, out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); } public override bool CanExplode(int i, int j) @@ -45,19 +45,5 @@ namespace CalamityMod.Tiles.Ores { num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/MudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Mud, out thirdTileAdjacency[i, j]); - return true; - } } } diff --git a/Tiles/PerennialBrick.cs b/Tiles/PerennialBrick.cs index 06851d630d..9133c5f6cb 100644 --- a/Tiles/PerennialBrick.cs +++ b/Tiles/PerennialBrick.cs @@ -1,4 +1,5 @@  +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -7,11 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class PerennialBrick : ModTile + public class PerennialBrick : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles AddMapEntry(new Color(17, 133, 46)); AnimationFrameHeight = 90; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Mud, out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -36,19 +36,6 @@ namespace CalamityMod.Tiles Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); return false; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/MudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Mud, out thirdTileAdjacency[i, j]); - return true; - } public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { diff --git a/Tiles/Pylons/AstralPylonTile.cs b/Tiles/Pylons/AstralPylonTile.cs index 9a95f6053f..1aeac063ef 100644 --- a/Tiles/Pylons/AstralPylonTile.cs +++ b/Tiles/Pylons/AstralPylonTile.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Tiles.Pylons public override NPCShop.Entry GetNPCShopEntry() { - Condition biomeCondition = new Condition(CalamityUtils.GetText("Condition.InAstral"), () => Main.LocalPlayer.Calamity().ZoneAstral); - return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, biomeCondition); + return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, CalamityConditions.InAstral); } diff --git a/Tiles/Pylons/CragsPylonTile.cs b/Tiles/Pylons/CragsPylonTile.cs index fa711e50a6..a4987d44d6 100644 --- a/Tiles/Pylons/CragsPylonTile.cs +++ b/Tiles/Pylons/CragsPylonTile.cs @@ -19,8 +19,7 @@ namespace CalamityMod.Tiles.Pylons public override NPCShop.Entry GetNPCShopEntry() { - Condition biomeCondition = new Condition(CalamityUtils.GetText("Condition.InCrag"), () => Main.LocalPlayer.Calamity().ZoneCalamity); - return new NPCShop.Entry(AssociatedItem, biomeCondition); + return new NPCShop.Entry(AssociatedItem, CalamityConditions.InCrag); } //Doesnt require npcs to function diff --git a/Tiles/Pylons/SulphurPylonTile.cs b/Tiles/Pylons/SulphurPylonTile.cs index 825e594738..39f2718703 100644 --- a/Tiles/Pylons/SulphurPylonTile.cs +++ b/Tiles/Pylons/SulphurPylonTile.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Tiles.Pylons public override NPCShop.Entry GetNPCShopEntry() { - Condition biomeCondition = new Condition(CalamityUtils.GetText("Condition.InSulph"), () => Main.LocalPlayer.Calamity().ZoneSulphur); - return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, biomeCondition); + return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, CalamityConditions.InSulph); } public override bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) => BiomeTileCounterSystem.SulphurTiles >= 100; diff --git a/Tiles/Pylons/SunkenPylonTile.cs b/Tiles/Pylons/SunkenPylonTile.cs index 74dc1115c1..8f48db51bf 100644 --- a/Tiles/Pylons/SunkenPylonTile.cs +++ b/Tiles/Pylons/SunkenPylonTile.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Tiles.Pylons public override NPCShop.Entry GetNPCShopEntry() { - Condition biomeCondition = new Condition(CalamityUtils.GetText("Condition.InSunken"), () => Main.LocalPlayer.Calamity().ZoneSunkenSea); - return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, biomeCondition); + return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, CalamityConditions.InSunken); } public override bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) => BiomeTileCounterSystem.SunkenSeaTiles >= 100; diff --git a/Tiles/ScoriaBrick.cs b/Tiles/ScoriaBrick.cs index f06c246f7b..800e5d6d57 100644 --- a/Tiles/ScoriaBrick.cs +++ b/Tiles/ScoriaBrick.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; @@ -9,13 +10,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { [LegacyName("ChaoticBrick")] - public class ScoriaBrick : ModTile + public class ScoriaBrick : ModTile, IMergeableTile { int subsheetHeight = 72; internal static Texture2D GlowTexture; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { if (!Main.dedServ) @@ -29,8 +30,8 @@ namespace CalamityMod.Tiles AddMapEntry(new Color(85, 87, 101)); HitSound = SoundID.Tink; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -53,8 +54,6 @@ namespace CalamityMod.Tiles public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); TileFraming.CompactFraming(i, j, resetFrame); return false; } @@ -73,8 +72,6 @@ namespace CalamityMod.Tiles Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset; TileFraming.SlopedGlowmask(i, j, 0, GlowTexture, drawPosition + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), GetDrawColour(i, j, drawColour), default); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); } private Color GetDrawColour(int i, int j, Color colour) { diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index 9956357a86..c9ef48f1f5 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Placeables; +using System.Collections.Generic; +using CalamityMod.Items.Placeables; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,11 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class EutrophicSand : ModTile + public class EutrophicSand : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -33,9 +32,9 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 108; AddMapEntry(new Color(92, 145, 167)); - TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.HardenedSand, out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); } public override void RandomUpdate(int i, int j) @@ -65,18 +64,8 @@ namespace CalamityMod.Tiles.SunkenSea num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/SandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSandMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Sandstone, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sand, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.HardenedSand, out thirdTileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } } diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.cs b/Tiles/SunkenSea/HardenedEutrophicSand.cs index 575f9bb7c8..209e0a22cd 100644 --- a/Tiles/SunkenSea/HardenedEutrophicSand.cs +++ b/Tiles/SunkenSea/HardenedEutrophicSand.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -7,13 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class HardenedEutrophicSand : ModTile + public class HardenedEutrophicSand : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; - public byte[,] fifthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -32,11 +29,11 @@ namespace CalamityMod.Tiles.SunkenSea DustType = 108; AddMapEntry(new Color(67, 107, 143)); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.HardenedSand, out fourthTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out fifthTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -44,22 +41,8 @@ namespace CalamityMod.Tiles.SunkenSea num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/NavystoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fifthTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sandstone, out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.HardenedSand, out fourthTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sand, out fifthTileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } } diff --git a/Tiles/SunkenSea/Navystone.cs b/Tiles/SunkenSea/Navystone.cs index 74044959e9..8799172e30 100644 --- a/Tiles/SunkenSea/Navystone.cs +++ b/Tiles/SunkenSea/Navystone.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -7,12 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class Navystone : ModTile + public class Navystone : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -27,10 +25,10 @@ namespace CalamityMod.Tiles.SunkenSea AddMapEntry(new Color(31, 92, 114)); HitSound = SoundID.Tink; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sandstone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Sand, out thirdTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.HardenedSand, out fourthTileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -38,20 +36,8 @@ namespace CalamityMod.Tiles.SunkenSea num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/SandstoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/SandMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, fourthTileAdjacency, "CalamityMod/Tiles/Merges/HardenedSandMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sandstone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Sand, out thirdTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.HardenedSand, out thirdTileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } } diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index 0b027a5498..83d6da7082 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -7,13 +8,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class SeaPrism : ModTile + public class SeaPrism : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - private const short subsheetWidth = 450; - private const short subsheetHeight = 198; - + private const short subsheetHeight = 198; + + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -32,7 +33,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileSpelunker[Type] = true; MinPick = 55; - TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -45,15 +46,9 @@ namespace CalamityMod.Tiles.SunkenSea frameXOffset = i % 2 * subsheetWidth; frameYOffset = j % 2 * subsheetHeight; } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/NavystoneMerge"); - } - + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, ModContent.TileType(), out tileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } } diff --git a/Tiles/UelibloomBrick.cs b/Tiles/UelibloomBrick.cs index 654fb1b1b5..ee453b6ab0 100644 --- a/Tiles/UelibloomBrick.cs +++ b/Tiles/UelibloomBrick.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts.Furniture; +using System.Collections.Generic; +using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,14 +10,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class UelibloomBrick : ModTile + public class UelibloomBrick : ModTile, IMergeableTile { private int extraFrameHeight = 36; private int extraFrameWidth = 90; - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { @@ -32,9 +31,9 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(174, 108, 46)); - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Mud, out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); } public override bool CreateDust(int i, int j, ref int type) @@ -69,18 +68,8 @@ namespace CalamityMod.Tiles DrawExtraDrapes(i, j, leaves, drawOffset, drawColour); } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/MudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Mud, out thirdTileAdjacency[i, j]); return TileFraming.BrimstoneFraming(i, j, resetFrame); } diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index 145e6acf38..eb4e766460 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -10,11 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class VernalSoil : ModTile + public class VernalSoil : ModTile, IMergeableTile { - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; + List IMergeableTile.TileAdjacencies { get; } = []; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -29,9 +29,9 @@ namespace CalamityMod.Tiles AddMapEntry(new Color(80, 120, 0)); HitSound = SoundID.Dig; - TileFraming.SetUpUniversalMerge(Type, TileID.Dirt, out tileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Stone, out secondTileAdjacency); - TileFraming.SetUpUniversalMerge(Type, TileID.Mud, out thirdTileAdjacency); + this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); + this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); } public override void RandomUpdate(int i, int j) @@ -150,21 +150,6 @@ namespace CalamityMod.Tiles } } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - TileFraming.DrawUniversalMergeFrames(i, j, thirdTileAdjacency, "CalamityMod/Tiles/Merges/MudMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, secondTileAdjacency, "CalamityMod/Tiles/Merges/StoneMerge"); - TileFraming.DrawUniversalMergeFrames(i, j, tileAdjacency, "CalamityMod/Tiles/Merges/DirtMerge"); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFraming.GetAdjacencyData(i, j, TileID.Dirt, out tileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Stone, out secondTileAdjacency[i, j]); - TileFraming.GetAdjacencyData(i, j, TileID.Mud, out thirdTileAdjacency[i, j]); - return true; - } - public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 66a703bbc1..a7a0ad791c 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -330,17 +330,17 @@ namespace CalamityMod.UI if (npc.ai[0] == 2f) life = 0L; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - bool isMoonLordPiece = Main.npc[i].type == NPCID.MoonLordHand || Main.npc[i].type == NPCID.MoonLordHead; - if (!Main.npc[i].active || !isMoonLordPiece || Main.npc[i].ai[3] != npc.whoAmI) + bool isMoonLordPiece = n.type == NPCID.MoonLordHand || n.type == NPCID.MoonLordHead; + if (!isMoonLordPiece || n.ai[3] != npc.whoAmI) continue; // Don't count HP towards the total if the NPC is in its dead state. - if (Main.npc[i].Calamity().newAI[0] == 1f) + if (n.Calamity().newAI[0] == 1f) continue; - life += checkingForMaxLife ? Main.npc[i].lifeMax : Main.npc[i].life; + life += checkingForMaxLife ? n.lifeMax : n.life; } return life; @@ -364,15 +364,15 @@ namespace CalamityMod.UI public override void Update(IBigProgressBar currentBar, ref BigProgressBarInfo info) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - // Ignore inactive NPCs and NPCs that should not be given a bar, even if it meets other criteria. - if (!Main.npc[i].active || BossExclusionList.Contains(Main.npc[i].type)) + // Ignore NPCs that should not be given a bar, even if it meets other criteria. + if (BossExclusionList.Contains(n.type)) continue; - bool isEoWSegment = Main.npc[i].type == NPCID.EaterofWorldsBody || Main.npc[i].type == NPCID.EaterofWorldsTail; - if ((Main.npc[i].IsABoss() && !isEoWSegment) || MinibossHPBarList.Contains(Main.npc[i].type) || Main.npc[i].Calamity().CanHaveBossHealthBar) - AttemptToAddBar(i); + bool isEoWSegment = n.type == NPCID.EaterofWorldsBody || n.type == NPCID.EaterofWorldsTail; + if ((n.IsABoss() && !isEoWSegment) || MinibossHPBarList.Contains(n.type) || n.Calamity().CanHaveBossHealthBar) + AttemptToAddBar(n.whoAmI); } for (int i = 0; i < Bars.Count; i++) @@ -466,12 +466,12 @@ namespace CalamityMod.UI return life; // Otherwise, check if any of said relationship NPCs are enraged. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].active || Main.npc[i].life <= 0 || !OneToMany[NPCType].Contains(Main.npc[i].type)) + if (n.life <= 0 || !OneToMany[NPCType].Contains(n.type)) continue; - life += Main.npc[i].life; + life += n.life; } return life; @@ -498,12 +498,12 @@ namespace CalamityMod.UI return maxLife; // Otherwise, check if any of said relationship NPCs are enraged. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].active || Main.npc[i].life <= 0 || !OneToMany[NPCType].Contains(Main.npc[i].type)) + if (n.life <= 0 || !OneToMany[NPCType].Contains(n.type)) continue; - maxLife += Main.npc[i].lifeMax; + maxLife += n.lifeMax; } return maxLife; @@ -524,12 +524,12 @@ namespace CalamityMod.UI return false; // Otherwise, check if any of said relationship NPCs are enraged. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].active || Main.npc[i].life <= 0 || !OneToMany[NPCType].Contains(Main.npc[i].type)) + if (n.life <= 0 || !OneToMany[NPCType].Contains(n.type)) continue; - if (Main.npc[i].Calamity().CurrentlyEnraged) + if (n.Calamity().CurrentlyEnraged) return true; } return false; @@ -550,12 +550,12 @@ namespace CalamityMod.UI return false; // Otherwise, check if any of said relationship NPCs are increasing their defense or DR. - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].active || Main.npc[i].life <= 0 || !OneToMany[NPCType].Contains(Main.npc[i].type)) + if (n.life <= 0 || !OneToMany[NPCType].Contains(n.type)) continue; - if (Main.npc[i].Calamity().CurrentlyIncreasingDefenseOrDR) + if (n.Calamity().CurrentlyIncreasingDefenseOrDR) return true; } return false; diff --git a/UI/BossRushUI.cs b/UI/BossRushUI.cs index 8b3ae93b96..b431ca9ff2 100644 --- a/UI/BossRushUI.cs +++ b/UI/BossRushUI.cs @@ -39,14 +39,12 @@ namespace CalamityMod.UI { int totalLife = 0; int totalLifeMax = 0; - for (int i = 0; i < Main.npc.Length; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!Main.npc[i].active) - continue; - if (types.Contains(Main.npc[i].type)) + if (types.Contains(n.type)) { - totalLife += Main.npc[i].life; - totalLifeMax += Main.npc[i].lifeMax; + totalLife += n.life; + totalLifeMax += n.lifeMax; } } diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index 8b66952b06..afbb994bc5 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -222,9 +222,9 @@ namespace CalamityMod.UI.CalamitasEnchants player.Calamity().bladeArmEnchant = true; bool armsArePresent = false; int armType = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type != armType || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) + if (p.type != armType || p.owner != player.whoAmI) continue; armsArePresent = true; @@ -282,9 +282,9 @@ namespace CalamityMod.UI.CalamitasEnchants bool orbIsPresent = false; int orbType = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].type != orbType || Main.npc[i].target != player.whoAmI || !Main.npc[i].active) + if (n.type != orbType || n.target != player.whoAmI) continue; orbIsPresent = true; diff --git a/UI/DraedonSummoning/CodebreakerUI.Communication.cs b/UI/DraedonSummoning/CodebreakerUI.Communication.cs index 09d52baba0..bfaa365107 100644 --- a/UI/DraedonSummoning/CodebreakerUI.Communication.cs +++ b/UI/DraedonSummoning/CodebreakerUI.Communication.cs @@ -5,11 +5,13 @@ using CalamityMod.NPCs.ExoMechs; using log4net; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; using ReLogic.Content; using ReLogic.Graphics; using Terraria; using Terraria.Audio; using Terraria.GameContent; +using Terraria.GameInput; using Terraria.Graphics.Shaders; using Terraria.ModLoader; using Terraria.UI.Chat; @@ -110,6 +112,8 @@ namespace CalamityMod.UI.DraedonSummoning set; } + public static float DialogOffYCache = 0; + /// /// The vertical offset as a result of scrolling for the topic options. /// @@ -182,7 +186,15 @@ namespace CalamityMod.UI.DraedonSummoning /// /// The text Draedon starts off with when you interact with the codebreaker. The first time you see him he says nothing, but in successive calls he asks what your inquiry is. /// - public static string InquiryText => Main.LocalPlayer.Calamity().HasTalkedAtCodebreaker ? "State your inquiry." : "..."; + public static string InquiryText + { + get + { + var mp = Main.LocalPlayer.Calamity(); + string key = mp.HasTalkedAtCodebreaker ? (mp.HasCraftedDraedonsForge ? "UI.CommunicationStartNormal" : "UI.CommunicationStartNoForge") : "UI.CommunicationStartInitial"; + return CalamityUtils.GetTextValue(key); + } + } /// /// The text of the previously hovered topic option. This is used to ensure hover clicking sounds only play if the sound type changes. @@ -373,6 +385,8 @@ namespace CalamityMod.UI.DraedonSummoning float cutoffDistance = OptionsTextHeight / GeneralScale - selectionOutline.Height; if (cutoffDistance > 0f && OptionsTextOpacity > 0f) { + if (MouseScreenArea.Intersects(selectionArea)) + OptionsTextVerticalOffset += PlayerInput.ScrollWheelDeltaForUI * 0.1f; TopicOptionsScroller.PositionYInterpolant = MathHelper.Clamp(OptionsTextVerticalOffset / -cutoffDistance, 0f, 1f); TopicOptionsScroller.Draw(selectionArea.Top + GeneralScale * 62f, selectionArea.Bottom - GeneralScale * 62f, selectionArea.Right - GeneralScale * 12f, GeneralScale * 0.8f, OptionsTextOpacity); OptionsTextVerticalOffset = TopicOptionsScroller.PositionYInterpolant * -cutoffDistance; @@ -486,7 +500,7 @@ namespace CalamityMod.UI.DraedonSummoning // Ensure that the player starts at the bottom of the scoller, now that new text is generating there. Texture2D dialogOutline = ModContent.Request("CalamityMod/UI/DraedonSummoning/DraedonDialogOutline").Value; Rectangle dialogArea = Utils.CenteredRectangle(selectionCenter, dialogOutline.Size() * panelScale); - DialogVerticalOffset = dialogArea.Height - DialogHeight * GeneralScale; + DialogVerticalOffset = -DialogHeight * GeneralScale; DialogScroller.PositionYInterpolant = 1f; if (DialogVerticalOffset > 0f) DialogVerticalOffset = 0f; @@ -555,7 +569,12 @@ namespace CalamityMod.UI.DraedonSummoning // Shift the text downward if it exceeds the current bottom. if (DialogHeight * 1.2f >= textCutoffRegion.Height && !string.IsNullOrEmpty(nextLetter.ToString()) && LatestDialogHeightIncrease > 0f) + { DialogVerticalOffset -= LatestDialogHeightIncrease; + DialogVerticalOffset += DialogOffYCache; + DialogHeight -= DialogOffYCache; + DialogOffYCache = 0; + } // Move to the next index in the dialog history once Draedon is finished speaking. if (WrittenDraedonText.Length >= FullDraedonText.Length) @@ -566,12 +585,19 @@ namespace CalamityMod.UI.DraedonSummoning } // Play a small dialog sound, similar to that of Undertale. - if (DialogSoundDelay <= 0 && nextLetter != ' ' && nextLetter != '\n') + if (DialogSoundDelay <= 0 && nextLetter != ' ') { - SoundStyle playThisSound = Main.rand.Next(DraedonTalks); - SoundEngine.PlaySound(playThisSound with { Volume = 0.4f }, Main.LocalPlayer.Center); + if (nextLetter != '\n') + { + DialogHeight -= DialogOffYCache; + DialogOffYCache = 0; + SoundStyle playThisSound = Main.rand.Next(DraedonTalks); + SoundEngine.PlaySound(playThisSound with { Volume = 0.4f }, Main.LocalPlayer.Center); - DialogSoundDelay = 4; + DialogSoundDelay = 4; + } + else if (WrittenDraedonText.Length < FullDraedonText.Length - 1 && FullDraedonText[WrittenDraedonText.Length] == '\n') + DialogOffYCache += panelScale.Y * 10f; } } @@ -580,6 +606,8 @@ namespace CalamityMod.UI.DraedonSummoning float cutoffDistance = DialogHeight - dialogOutline.Height; if (cutoffDistance > 0f && OptionsTextOpacity > 0f) { + if (MouseScreenArea.Intersects(dialogArea)) + DialogVerticalOffset += PlayerInput.ScrollWheelDeltaForUI * 0.2f; DialogScroller.PositionYInterpolant = MathHelper.Clamp(DialogVerticalOffset / -cutoffDistance, 0f, 1f); DialogScroller.Draw(dialogArea.Top + GeneralScale * 66f, dialogArea.Bottom - GeneralScale * 66f, dialogArea.Right - GeneralScale * 12f, GeneralScale * 0.8f, OptionsTextOpacity); DialogVerticalOffset = DialogScroller.PositionYInterpolant * -cutoffDistance; @@ -604,7 +632,7 @@ namespace CalamityMod.UI.DraedonSummoning foreach (var entry in dialogEntries) { int lineIndex = 0; - foreach (string line in Utils.WordwrapString(entry.Dialog, DialogFont, 336, 100, out _)) + foreach (string line in Utils.WordwrapString(entry.Dialog, DialogFont, 336, 1000, out _)) { if (string.IsNullOrEmpty(line)) continue; diff --git a/UI/DraedonSummoning/CodebreakerUI.cs b/UI/DraedonSummoning/CodebreakerUI.cs index a5052a90e3..5468ec11de 100644 --- a/UI/DraedonSummoning/CodebreakerUI.cs +++ b/UI/DraedonSummoning/CodebreakerUI.cs @@ -102,7 +102,7 @@ namespace CalamityMod.UI.DraedonSummoning { // If not viewing the specific tile entity's interface anymore, if the ID is for some reason invalid, or if the player is not equipped to continue viewing the UI // don't do anything other than resetting necessary data. - if (!TileEntity.ByID.ContainsKey(ViewedTileEntityID) || TileEntity.ByID[ViewedTileEntityID] is not TECodebreaker codebreakerTileEntity || !Main.LocalPlayer.WithinRange(codebreakerTileEntity.Center, 270f) || !Main.playerInventory) + if (!TileEntity.ByID.ContainsKey(ViewedTileEntityID) || TileEntity.ByID[ViewedTileEntityID] is not TECodebreaker codebreakerTileEntity || !Main.LocalPlayer.WithinRange(codebreakerTileEntity.Center, 270f) || !Main.playerInventory || Main.LocalPlayer.channel) { VerificationButtonScale = 1f; CancelButtonScale = 0.75f; @@ -117,6 +117,7 @@ namespace CalamityMod.UI.DraedonSummoning DialogScroller.Reset(); TopicOptionsScroller.Reset(); DialogVerticalOffset = 0f; + DialogOffYCache = 0; OptionsTextVerticalOffset = 0f; DialogHeight = 0f; LatestDialogHeightIncrease = 0f; diff --git a/UI/DraedonsArsenal/ChargingStationUI.cs b/UI/DraedonsArsenal/ChargingStationUI.cs index e3d298967d..f207c629b2 100644 --- a/UI/DraedonsArsenal/ChargingStationUI.cs +++ b/UI/DraedonsArsenal/ChargingStationUI.cs @@ -46,8 +46,8 @@ namespace CalamityMod.UI.DraedonsArsenal return; } - // If the player's inventory isn't open, or they have a chest open, immediately destroy this UI. - if (!Main.playerInventory || p.chest != -1) + // If the player's inventory isn't open, or they have a chest open, OR they are using a channelled item, immediately destroy this UI. + if (!Main.playerInventory || p.chest != -1 || p.channel) { mp.CurrentlyViewedChargerID = -1; return; diff --git a/UI/DraedonsArsenal/PowerCellFactoryUI.cs b/UI/DraedonsArsenal/PowerCellFactoryUI.cs index 2f3bcfd6d6..d769d5ff55 100644 --- a/UI/DraedonsArsenal/PowerCellFactoryUI.cs +++ b/UI/DraedonsArsenal/PowerCellFactoryUI.cs @@ -41,8 +41,8 @@ namespace CalamityMod.UI.DraedonsArsenal return; } - // If the player's inventory isn't open, or they have a chest open, immediately destroy this UI. - if (!Main.playerInventory || p.chest != -1) + // If the player's inventory isn't open, or they have a chest open, OR they are using a channelled item, immediately destroy this UI. + if (!Main.playerInventory || p.chest != -1 || p.channel) { mp.CurrentlyViewedFactoryID = -1; return; diff --git a/UI/FlightBar/FlightBar.cs b/UI/FlightBar/FlightBar.cs index 40c5d6bf8c..b78ed67fcd 100644 --- a/UI/FlightBar/FlightBar.cs +++ b/UI/FlightBar/FlightBar.cs @@ -53,9 +53,10 @@ namespace CalamityMod.UI else { bool ridingLimitedFlightMount = player.mount.Active && player.mount._data.flightTimeMax > 0; + bool ridingCarpet = player.carpet && !player.canCarpet; - int currentFlight = ridingLimitedFlightMount ? player.mount._flyTime + (int)(player.mount._data.fatigueMax - player.mount._fatigue) : (int)player.wingTime; - int maxFlight = ridingLimitedFlightMount ? player.mount._data.flightTimeMax + (int)player.mount._data.fatigueMax : player.wingTimeMax; + int currentFlight = ridingCarpet ? player.carpetTime : ridingLimitedFlightMount ? player.mount._flyTime + (int)(player.mount._data.fatigueMax - player.mount._fatigue) : (int)player.wingTime; + int maxFlight = ridingCarpet ? 300 : ridingLimitedFlightMount ? player.mount._data.flightTimeMax + (int)player.mount._data.fatigueMax : player.wingTimeMax; return (Math.Min(100f * currentFlight / maxFlight, 100f)).ToString("0.00"); // why the FUCK can wingtime be higher than max wingtime????????? } @@ -105,7 +106,7 @@ namespace CalamityMod.UI CalamityPlayer modPlayer = player.Calamity(); // If not drawing the flight bar, save its latest position to config and leave. - if (CalamityConfig.Instance.FlightBar && (player.wingsLogic > 0 || (player.mount.Active && player.mount._data.flightTimeMax > 0))) + if (CalamityConfig.Instance.FlightBar && (player.wingsLogic > 0 || (player.mount.Active && player.mount._data.flightTimeMax > 0) || player.carpet && !player.canCarpet)) { DrawFlightBar(spriteBatch, modPlayer, screenPos); } @@ -140,7 +141,7 @@ namespace CalamityMod.UI if (!CalamityConfig.Instance.MeterPosLock) Main.LocalPlayer.mouseInterface = true; - if (modPlayer.Player.equippedWings != null && modPlayer.Player.wingTimeMax > 0 || (player.mount.Active && modPlayer.Player.mount._data.flightTimeMax > 0)) //equipped wings or riding a flying mount and max wingtime/flighttime above 0 (so not disabled bar) + if (modPlayer.Player.equippedWings != null && modPlayer.Player.wingTimeMax > 0 || (player.mount.Active && modPlayer.Player.mount._data.flightTimeMax > 0) || player.carpet && !player.canCarpet) //equipped wings or riding a flying mount and max wingtime/flighttime above 0 (so not disabled bar) { string textToDisplay = CalamityUtils.GetText("UI.Flight").Format((GetFlightTime(modPlayer).ToString() + (modPlayer.infiniteFlight ? "" : "%"))); //the percent is here and not in localisation otherwise it looks like a dick when it's infinite flight Main.instance.MouseText(textToDisplay, 0, 0, -1, -1, -1, -1); @@ -192,7 +193,7 @@ namespace CalamityMod.UI Player player = modPlayer.Player; float flightRatio = 1; if (!modPlayer.infiniteFlight && !RidingInfiniteFlightMount(player)) - flightRatio = player.mount.Active && player.mount._data.flightTimeMax > 0 ? Math.Min((float)(player.mount._flyTime + (player.mount._data.fatigueMax - player.mount._fatigue)) / (player.mount._data.flightTimeMax + player.mount._data.fatigueMax), 1f) : Math.Min(player.wingTime / player.wingTimeMax, 1f); // why the FUCK can wingtime be higher than max wingtime????????? + flightRatio = player.carpet && !player.canCarpet ? Math.Min((float)player.carpetTime / 300f, 1f) : player.mount.Active && player.mount._data.flightTimeMax > 0 ? Math.Min((float)(player.mount._flyTime + (player.mount._data.fatigueMax - player.mount._fatigue)) / (player.mount._data.flightTimeMax + player.mount._data.fatigueMax), 1f) : Math.Min(player.wingTime / player.wingTimeMax, 1f); // why the FUCK can wingtime be higher than max wingtime????????? if (!completedAnimation && FlightAnimFrame == -1 && (modPlayer.infiniteFlight || RidingInfiniteFlightMount(modPlayer.Player))) FlightAnimFrame++; if (FlightAnimFrame > -1) //animation started, complete it. diff --git a/UI/MiscTextures/StealthMeterBar.png b/UI/MiscTextures/StealthMeterBar.png index 36d0552574..64a040088c 100644 Binary files a/UI/MiscTextures/StealthMeterBar.png and b/UI/MiscTextures/StealthMeterBar.png differ diff --git a/UI/MiscTextures/StealthMeterBarFull.png b/UI/MiscTextures/StealthMeterBarFull.png index 86048fd097..92f0fe7dc6 100644 Binary files a/UI/MiscTextures/StealthMeterBarFull.png and b/UI/MiscTextures/StealthMeterBarFull.png differ diff --git a/UI/VanillaBossBars/AstrumDeusBossBar.cs b/UI/VanillaBossBars/AstrumDeusBossBar.cs index 24e3b77c0a..3513f1cbc7 100644 --- a/UI/VanillaBossBars/AstrumDeusBossBar.cs +++ b/UI/VanillaBossBars/AstrumDeusBossBar.cs @@ -29,10 +29,9 @@ namespace CalamityMod.UI.VanillaBossBars lifeMax = 0f; // Determine the real health by finding more of itself - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC worm in Main.ActiveNPCs) { - NPC worm = Main.npc[i]; - if (worm.active && worm.type == target.type) + if (worm.type == target.type) { // In Death Mode, every worm must be killed if (CalamityWorld.death) @@ -57,16 +56,8 @@ namespace CalamityMod.UI.VanillaBossBars public bool FindMoreWorms(ref BigProgressBarInfo info) { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC target = Main.npc[i]; - if (target.active && target.type == NPCType()) - { - info.npcIndexToAimAt = i; - return true; - } - } - return false; + info.npcIndexToAimAt = NPC.FindFirstNPC(ModContent.NPCType()); + return info.npcIndexToAimAt != -1; } } } diff --git a/UI/VanillaBossBars/CeaselessVoidBossBar.cs b/UI/VanillaBossBars/CeaselessVoidBossBar.cs index d472836584..29fb7c446c 100644 --- a/UI/VanillaBossBars/CeaselessVoidBossBar.cs +++ b/UI/VanillaBossBars/CeaselessVoidBossBar.cs @@ -51,10 +51,9 @@ namespace CalamityMod.UI.VanillaBossBars shieldMax = (int)(FalseNPCSegment.lifeMax * ExpectedBallsCounter * (1 - RatioToCombust)); shield -= (int)(FalseNPCSegment.lifeMax * ExpectedBallsCounter * RatioToCombust); - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC part in Main.ActiveNPCs) { - NPC part = Main.npc[i]; - if (part.active && part.type == NPCType()) + if (part.type == NPCType()) shield += part.life; } } diff --git a/UI/VanillaBossBars/CryogenBossBar.cs b/UI/VanillaBossBars/CryogenBossBar.cs index 5202e40a2b..7342cd1913 100644 --- a/UI/VanillaBossBars/CryogenBossBar.cs +++ b/UI/VanillaBossBars/CryogenBossBar.cs @@ -39,10 +39,9 @@ namespace CalamityMod.UI.VanillaBossBars shieldMax = 0f; // Determine the shield health - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC part in Main.ActiveNPCs) { - NPC part = Main.npc[i]; - if (part.active && part.type == NPCType()) + if (part.type == NPCType()) { shield += part.life; shieldMax += part.lifeMax; diff --git a/UI/VanillaBossBars/ExoMechsBossBar.cs b/UI/VanillaBossBars/ExoMechsBossBar.cs index f808cc93fa..2c3a0d0986 100644 --- a/UI/VanillaBossBars/ExoMechsBossBar.cs +++ b/UI/VanillaBossBars/ExoMechsBossBar.cs @@ -79,16 +79,15 @@ namespace CalamityMod.UI.VanillaBossBars lifeMax += FalseNPCSegment.lifeMax; // Find the others - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC ecco in Main.ActiveNPCs) { - NPC ecco = Main.npc[i]; - if (ecco.active && ecco.type == NPCType() && target.type != NPCType()) + if (ecco.type == NPCType() && target.type != NPCType()) life += ecco.life; - if (ecco.active && ecco.type == NPCType() && target.type != NPCType()) + if (ecco.type == NPCType() && target.type != NPCType()) life += ecco.life; - if (ecco.active && ecco.type == NPCType() && target.type != NPCType()) + if (ecco.type == NPCType() && target.type != NPCType()) life += ecco.life; } } @@ -97,9 +96,8 @@ namespace CalamityMod.UI.VanillaBossBars public void ValidateAllMechs(ref BigProgressBarInfo info) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; // Find out first whether or not each of the mechs are in hiding if (target.type == NPCType()) HideAres = target.Opacity < 0.5f; diff --git a/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs b/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs index f0dc0a389c..070058dcf8 100644 --- a/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs +++ b/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs @@ -36,11 +36,10 @@ namespace CalamityMod.UI.VanillaBossBars lifeMax = target.lifeMax; // Find the partner in question - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC wife in Main.ActiveNPCs) { - NPC wife = Main.npc[i]; int targetCouple = target.type == NPCType() ? NPCType() : NPCType(); - if (wife.active && wife.type == targetCouple) + if (wife.type == targetCouple) { life += wife.life; lifeMax += wife.lifeMax; @@ -54,10 +53,9 @@ namespace CalamityMod.UI.VanillaBossBars // Determine Anahita's shield health only if she's solo (she can't just block Leviathan out of existence) if (target.type == NPCType() && !NPC.AnyNPCs(NPCType())) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC part in Main.ActiveNPCs) { - NPC part = Main.npc[i]; - if (part.active && part.type == NPCType()) + if (part.type == NPCType()) { shield += part.life; shieldMax += part.lifeMax; @@ -69,17 +67,16 @@ namespace CalamityMod.UI.VanillaBossBars public bool FindTheRightFish(ref BigProgressBarInfo info) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC target in Main.ActiveNPCs) { - NPC target = Main.npc[i]; if (target.active && target.type == NPCType()) { - info.npcIndexToAimAt = i; + info.npcIndexToAimAt = target.whoAmI; return true; } else if (target.active && target.type == NPCType()) { - info.npcIndexToAimAt = i; + info.npcIndexToAimAt = target.whoAmI; return true; } } diff --git a/UI/VanillaBossBars/RavagerBossBar.cs b/UI/VanillaBossBars/RavagerBossBar.cs index 39028612e5..eabbef027c 100644 --- a/UI/VanillaBossBars/RavagerBossBar.cs +++ b/UI/VanillaBossBars/RavagerBossBar.cs @@ -46,10 +46,9 @@ namespace CalamityMod.UI.VanillaBossBars } // Determine the current health of the parts - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC part in Main.ActiveNPCs) { - NPC part = Main.npc[i]; - if (part.active && RavagerParts.Contains(part.type)) + if (RavagerParts.Contains(part.type)) { life += part.life; } @@ -59,16 +58,8 @@ namespace CalamityMod.UI.VanillaBossBars public bool FindRavagerBody(ref BigProgressBarInfo info) { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC target = Main.npc[i]; - if (target.active && target.type == NPCType()) - { - info.npcIndexToAimAt = i; - return true; - } - } - return false; + info.npcIndexToAimAt = NPC.FindFirstNPC(ModContent.NPCType()); + return info.npcIndexToAimAt != -1; } } } diff --git a/UI/VanillaBossBars/SlimeGodBossBar.cs b/UI/VanillaBossBars/SlimeGodBossBar.cs index 33f8670457..fb329da1ff 100644 --- a/UI/VanillaBossBars/SlimeGodBossBar.cs +++ b/UI/VanillaBossBars/SlimeGodBossBar.cs @@ -44,10 +44,9 @@ namespace CalamityMod.UI.VanillaBossBars lifeMax += FalseNPCSegment.lifeMax; // Determine the current health of each slime - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC part in Main.ActiveNPCs) { - NPC part = Main.npc[i]; - if (part.active && SlimeGodSlimes.Contains(part.type)) + if (SlimeGodSlimes.Contains(part.type)) { life += part.life; } diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index b309b9055d..81a27225f2 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -528,7 +528,7 @@ namespace CalamityMod // Fallen Stars from Stardust Recipe.Create(ItemID.FallenStar). - AddIngredient(5). + AddIngredient(5). AddTile(TileID.Anvils). Register() .DisableDecraft(); @@ -545,14 +545,14 @@ namespace CalamityMod AddRecipeGroup("IronBar"). AddIngredient(ItemID.EmptyBullet, 100). AddIngredient(ItemID.ExplosivePowder, 4). - AddTile(TileID.MythrilAnvil). + AddTile(TileID.Anvils). Register(); // and Rocket IIs (requires slightly more explosive powder) Recipe.Create(ItemID.RocketII, 100). AddRecipeGroup("IronBar"). AddIngredient(ItemID.EmptyBullet, 100). AddIngredient(ItemID.ExplosivePowder, 5). - AddTile(TileID.MythrilAnvil). + AddTile(TileID.Anvils). Register(); // Life Crystal @@ -839,6 +839,7 @@ namespace CalamityMod { r => r.HasResult(ItemID.HorseshoeBundle) && !r.HasIngredient(ItemID.BundleofBalloons), AddIngredient(ModContent.ItemType(), 3) }, { Vanilla(ItemID.NightsEdge), AddIngredient(ModContent.ItemType(), 5) }, { Vanilla(ItemID.FairyBoots), AddIngredient(ItemID.SoulofLight, 5) }, + { Vanilla(ItemID.HellfireTreads), AddIngredient(ModContent.ItemType(), 4) }, { Vanilla(ItemID.SpiritFlame), AddGroup(AnyAdamantiteBar, 2) }, { Vanilla(ItemID.TerraBlade), AddIngredient(ModContent.ItemType(), 12) }, { Vanilla(ItemID.FireGauntlet), AddIngredient(ModContent.ItemType(), 5) }, @@ -1593,8 +1594,9 @@ namespace CalamityMod // Flame Waker Boots r = Recipe.Create(ItemID.FlameWakerBoots); r.AddIngredient(ItemID.Silk, 8); - r.AddIngredient(ItemID.Obsidian, 2); - r.AddTile(TileID.Loom); + r.AddIngredient(ItemID.HellstoneBar, 5); + r.AddIngredient(ItemID.Obsidian, 4); + r.AddTile(TileID.Anvils); r.Register(); r.DisableDecraft(); diff --git a/Utilities/DropHelper.cs b/Utilities/DropHelper.cs index 5cbc22d183..88a518df31 100644 --- a/Utilities/DropHelper.cs +++ b/Utilities/DropHelper.cs @@ -212,16 +212,15 @@ namespace CalamityMod int r = wormHead.whoAmI; float minDist = 1E+06f; - for (int i = 0; i < Main.npc.Length; ++i) + foreach (NPC n in Main.ActiveNPCs) { - NPC n = Main.npc[i]; - if (n != null && n.active && idsToCheck.Contains(n.type)) + if (idsToCheck.Contains(n.type)) { float dist = (n.Center - playerPos).Length(); if (dist < minDist) { minDist = dist; - r = i; + r = n.whoAmI; } } } @@ -545,10 +544,9 @@ namespace CalamityMod public static IItemDropRuleCondition AnglerFedToTrasherCondition = If((info) => { bool trasherNearby = false; - for (int i = 0; i < Main.maxNPCs; ++i) + foreach (NPC nearby in Main.ActiveNPCs) { - NPC nearby = Main.npc[i]; - if (nearby is null || !nearby.active || nearby.type != ModContent.NPCType()) + if (nearby.type != ModContent.NPCType()) continue; if (info.npc.Distance(nearby.Center) < TrasherEatDistance) { @@ -559,71 +557,69 @@ namespace CalamityMod return trasherNearby; }); // The text is a separate rule so it doesn't show up on the non-Trasher Fishing Rod drop which only occurs if the Angler is not fed to a Trasher - public static IItemDropRuleCondition TrasherText = If((info) => true, true, CalamityUtils.GetTextValue("Condition.Drops.TrasherKill")); + public static IItemDropRuleCondition TrasherText => CalamityConditions.TrasherTextCondition.ToDropCondition(ShowItemDropInUI.Always); // Get Fixed Boi seed drop rule - public static IItemDropRuleCondition GFB = If((info) => Main.zenithWorld, () => Main.zenithWorld, CalamityUtils.GetTextValue("Condition.Drops.IsGFB")); + public static IItemDropRuleCondition GFB => Condition.ZenithWorld.ToDropCondition(ShowItemDropInUI.WhenConditionSatisfied); - public static IItemDropRuleCondition RevNoMaster = If((info) => !Main.masterMode && CalamityWorld.revenge, () => !Main.masterMode && CalamityWorld.revenge, CalamityUtils.GetTextValue("Condition.Drops.IsRev")); - public static IItemDropRuleCondition RevAndMaster = If((info) => Main.masterMode || CalamityWorld.revenge, () => Main.masterMode || CalamityWorld.revenge, () => - { - return Main.masterMode ? Language.GetTextValue("Bestiary_ItemDropConditions.IsMasterMode") : CalamityUtils.GetTextValue("Condition.Drops.IsRev"); - }); + public static IItemDropRuleCondition RevNoMaster => CalamityConditions.InRevengeanceModeNotMasterMode.ToDropCondition(ShowItemDropInUI.WhenConditionSatisfied); + public static IItemDropRuleCondition RevAndMaster => CalamityConditions.InRevengeanceModeOrMasterMode.ToDropCondition(ShowItemDropInUI.WhenConditionSatisfied); #region Boss Defeat Conditionals - public static IItemDropRuleCondition PostKS(bool ui = true) => If(() => NPC.downedSlimeKing, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedKS")); - public static IItemDropRuleCondition PostDS(bool ui = true) => If(() => DownedBossSystem.downedDesertScourge, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedDS")); - public static IItemDropRuleCondition PostEoC(bool ui = true) => If(() => NPC.downedBoss1, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedEoC")); - public static IItemDropRuleCondition PostCrab(bool ui = true) => If(() => DownedBossSystem.downedCrabulon, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedCrab")); - public static IItemDropRuleCondition PostEvil1(bool ui = true) => If(() => NPC.downedBoss2, ui, CalamityUtils.GetTextValue("Condition.Drops.Downed" + (WorldGen.crimson ? "BoC" : "EoW"))); - public static IItemDropRuleCondition PostHM(bool ui = true) => If(() => DownedBossSystem.downedHiveMind, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedHM")); - public static IItemDropRuleCondition PostPerfs(bool ui = true) => If(() => DownedBossSystem.downedPerforator, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedPerfs")); - public static IItemDropRuleCondition PostEvil2(bool ui = true) => If(() => DownedBossSystem.downedHiveMind || DownedBossSystem.downedPerforator, ui, CalamityUtils.GetTextValue("Condition.Drops.Downed" + (WorldGen.crimson ? "Perfs" : "HM"))); - public static IItemDropRuleCondition PostQB(bool ui = true) => If(() => NPC.downedQueenBee, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedQB")); - public static IItemDropRuleCondition PostDeer(bool ui = true) => If(() => NPC.downedDeerclops, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedDeer")); - public static IItemDropRuleCondition PostSkele(bool ui = true) => If(() => NPC.downedBoss3, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedSkele")); - public static IItemDropRuleCondition PostSG(bool ui = true) => If(() => DownedBossSystem.downedSlimeGod, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedSG")); - public static IItemDropRuleCondition Hardmode(bool ui = true) => If(() => Main.hardMode, ui, CalamityUtils.GetTextValue("Condition.Drops.Hardmode")); - public static IItemDropRuleCondition PostQS(bool ui = true) => If(() => NPC.downedQueenSlime, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedQS")); - public static IItemDropRuleCondition PostCryo(bool ui = true) => If(() => DownedBossSystem.downedCryogen, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedCryo")); - public static IItemDropRuleCondition PostAS(bool ui = true) => If(() => DownedBossSystem.downedAquaticScourge, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedAS")); - public static IItemDropRuleCondition PostBrim(bool ui = true) => If(() => DownedBossSystem.downedBrimstoneElemental, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedBrim")); - public static IItemDropRuleCondition PostDest(bool ui = true) => If(() => NPC.downedMechBoss1, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedDest")); - public static IItemDropRuleCondition PostTwins(bool ui = true) => If(() => NPC.downedMechBoss2, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedTwins")); - public static IItemDropRuleCondition PostSP(bool ui = true) => If(() => NPC.downedMechBoss3, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedSP")); - public static IItemDropRuleCondition Post1Mech(bool ui = true) => If(() => NPC.downedMechBossAny, ui, CalamityUtils.GetTextValue("Condition.Drops.Downed1Mech")); - public static IItemDropRuleCondition Post3Mechs(bool ui = true) => If(() => NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3, ui, CalamityUtils.GetTextValue("Condition.Drops.Downed3Mechs")); - public static IItemDropRuleCondition PostCal(bool ui = true) => If(() => DownedBossSystem.downedCalamitasClone, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedCal")); - public static IItemDropRuleCondition PostPlant(bool ui = true) => If(() => NPC.downedPlantBoss, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedPlant")); - public static IItemDropRuleCondition PostLevi(bool ui = true) => If(() => DownedBossSystem.downedLeviathan, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedLebi")); - public static IItemDropRuleCondition PostAureus(bool ui = true) => If(() => DownedBossSystem.downedAstrumAureus, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedAureus")); - public static IItemDropRuleCondition PostGolem(bool ui = true) => If(() => NPC.downedGolemBoss, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedGolem")); - public static IItemDropRuleCondition PostPBG(bool ui = true) => If(() => DownedBossSystem.downedPlaguebringer, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedPBG")); - public static IItemDropRuleCondition PostEoL(bool ui = true) => If(() => NPC.downedEmpressOfLight, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedEoL")); - public static IItemDropRuleCondition PostFish(bool ui = true) => If(() => NPC.downedFishron, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedFish")); - public static IItemDropRuleCondition PostRav(bool ui = true) => If(() => DownedBossSystem.downedRavager, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedRav")); - public static IItemDropRuleCondition PostLC(bool ui = true) => If(() => NPC.downedAncientCultist, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedLC")); - public static IItemDropRuleCondition PostAD(bool ui = true) => If(() => DownedBossSystem.downedAstrumDeus, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedAD")); - public static IItemDropRuleCondition PostML(bool ui = true) => If(() => NPC.downedMoonlord, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedML")); - public static IItemDropRuleCondition PostGuard(bool ui = true) => If(() => DownedBossSystem.downedGuardians, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedGuard")); - public static IItemDropRuleCondition PostBirb(bool ui = true) => If(() => DownedBossSystem.downedDragonfolly, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedBirb")); - public static IItemDropRuleCondition PostProv(bool ui = true) => If(() => DownedBossSystem.downedProvidence, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedProv")); - public static IItemDropRuleCondition PostSig(bool ui = true) => If(() => DownedBossSystem.downedSignus, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedSig")); - public static IItemDropRuleCondition PostSW(bool ui = true) => If(() => DownedBossSystem.downedStormWeaver, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedSW")); - public static IItemDropRuleCondition PostCV(bool ui = true) => If(() => DownedBossSystem.downedCeaselessVoid, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedCV")); - public static IItemDropRuleCondition PostPolter(bool ui = true) => If(() => DownedBossSystem.downedPolterghast, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedPolter")); - public static IItemDropRuleCondition PostOD(bool ui = true) => If(() => DownedBossSystem.downedBoomerDuke, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedOD")); - public static IItemDropRuleCondition PostDoG(bool ui = true) => If(() => DownedBossSystem.downedDoG, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedDoG")); - public static IItemDropRuleCondition PostYharon(bool ui = true) => If(() => DownedBossSystem.downedYharon, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedYharon")); - public static IItemDropRuleCondition PostExos(bool ui = true) => If(() => DownedBossSystem.downedExoMechs, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedExos")); - public static IItemDropRuleCondition PostSCal(bool ui = true) => If(() => DownedBossSystem.downedCalamitas, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedSCal")); - public static IItemDropRuleCondition PostAEW(bool ui = true) => If(() => DownedBossSystem.downedPrimordialWyrm, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedAEW")); - public static IItemDropRuleCondition PostClam(bool ui = true) => If(() => DownedBossSystem.downedCLAM, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedClam")); - public static IItemDropRuleCondition PostClamHM(bool ui = true) => If(() => DownedBossSystem.downedCLAMHardMode, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedClamHM")); - public static IItemDropRuleCondition PostGSS(bool ui = true) => If(() => DownedBossSystem.downedGSS, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedGSS")); - public static IItemDropRuleCondition PostBetsy(bool ui = true) => If(() => DownedBossSystem.downedBetsy, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedBetsy")); - public static IItemDropRuleCondition PostT1AR(bool ui = true) => If(() => DownedBossSystem.downedEoCAcidRain, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedT1AR")); - public static IItemDropRuleCondition PostT2AR(bool ui = true) => If(() => DownedBossSystem.downedAquaticScourgeAcidRain, ui, CalamityUtils.GetTextValue("Condition.Drops.DownedT2AR")); + public static IItemDropRuleCondition PostKS(bool ui = true) => Condition.DownedKingSlime.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostDS(bool ui = true) => CalamityConditions.DownedDesertScourge.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostEoC(bool ui = true) => Condition.DownedEyeOfCthulhu.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostCrab(bool ui = true) => CalamityConditions.DownedCrabulon.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostEvil1(bool ui = true) => Condition.DownedEowOrBoc.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostHM(bool ui = true) => CalamityConditions.DownedHiveMind.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostPerfs(bool ui = true) => CalamityConditions.DownedPerforator.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostEvil2(bool ui = true) => CalamityConditions.DownedHiveMindOrPerforator.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostQB(bool ui = true) => Condition.DownedQueenBee.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostDeer(bool ui = true) => Condition.DownedDeerclops.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostSkele(bool ui = true) => Condition.DownedSkeletron.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostSG(bool ui = true) => CalamityConditions.DownedSlimeGod.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition Hardmode(bool ui = true) => Condition.Hardmode.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostQS(bool ui = true) => Condition.DownedQueenSlime.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostCryo(bool ui = true) => CalamityConditions.DownedCryogen.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostAS(bool ui = true) => CalamityConditions.DownedAquaticScourge.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostBrim(bool ui = true) => CalamityConditions.DownedBrimstoneElemental.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostDest(bool ui = true) => Condition.DownedDestroyer.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostTwins(bool ui = true) => Condition.DownedTwins.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostSP(bool ui = true) => Condition.DownedSkeletronPrime.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition Post1Mech(bool ui = true) => Condition.DownedMechBossAny.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition Post3Mechs(bool ui = true) => Condition.DownedMechBossAll.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostCal(bool ui = true) => CalamityConditions.DownedCalamitasClone.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostPlant(bool ui = true) => Condition.DownedPlantera.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostCalPlant(bool ui = true) => CalamityConditions.DownedCalamitasCloneOrPlantera.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostLevi(bool ui = true) => CalamityConditions.DownedLeviathan.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostAureus(bool ui = true) => CalamityConditions.DownedAstrumAureus.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostGolem(bool ui = true) => Condition.DownedGolem.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostPBG(bool ui = true) => CalamityConditions.DownedPlaguebringer.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostEoL(bool ui = true) => Condition.DownedEmpressOfLight.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostFish(bool ui = true) => Condition.DownedDukeFishron.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostRav(bool ui = true) => CalamityConditions.DownedRavager.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostLC(bool ui = true) => Condition.DownedCultist.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostAD(bool ui = true) => CalamityConditions.DownedAstrumDeus.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostML(bool ui = true) => Condition.DownedMoonLord.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostGuard(bool ui = true) => CalamityConditions.DownedGuardians.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostBirb(bool ui = true) => CalamityConditions.DownedBumblebird.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostProv(bool ui = true) => CalamityConditions.DownedProvidence.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostSig(bool ui = true) => CalamityConditions.DownedSignus.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostSW(bool ui = true) => CalamityConditions.DownedStormWeaver.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostCV(bool ui = true) => CalamityConditions.DownedCeaselessVoid.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostPolter(bool ui = true) => CalamityConditions.DownedPolterghast.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostOD(bool ui = true) => CalamityConditions.DownedOldDuke.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostDoG(bool ui = true) => CalamityConditions.DownedDevourerOfGods.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostYharon(bool ui = true) => CalamityConditions.DownedYharon.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostExos(bool ui = true) => CalamityConditions.DownedExoMechs.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostSCal(bool ui = true) => CalamityConditions.DownedSupremeCalamitas.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostAEW(bool ui = true) => CalamityConditions.DownedPrimordialWyrm.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostClam(bool ui = true) => CalamityConditions.DownedClam.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostClamHM(bool ui = true) => CalamityConditions.DownedBuffedClam.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostGSS(bool ui = true) => CalamityConditions.DownedGreatSandShark.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostBetsy(bool ui = true) => CalamityConditions.DownedBetsy.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostT1AR(bool ui = true) => CalamityConditions.DownedAcidRainT1.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); + public static IItemDropRuleCondition PostT2AR(bool ui = true) => CalamityConditions.DownedAcidRainT2.ToDropCondition(ui ? ShowItemDropInUI.Always : ShowItemDropInUI.Never); #endregion #endregion @@ -1163,9 +1159,8 @@ namespace CalamityMod NPC npc = info.npc; int idx = Item.NewItem(npc.GetSource_Loot(), npc.Center, itemId, stack, true, -1); Main.timeItemSlotCannotBeReusedFor[idx] = protectionTime; - for (int i = 0; i < Main.maxPlayers; ++i) - if (Main.player[i].active) - NetMessage.SendData(MessageID.InstancedItem, i, -1, null, idx); + foreach (Player player in Main.ActivePlayers) + NetMessage.SendData(MessageID.InstancedItem, player.whoAmI, -1, null, idx); Main.item[idx].active = false; } diff --git a/Utilities/FurnitureSetupUtils.cs b/Utilities/FurnitureSetupUtils.cs index 78a2fe683f..61898018c4 100644 --- a/Utilities/FurnitureSetupUtils.cs +++ b/Utilities/FurnitureSetupUtils.cs @@ -1396,8 +1396,8 @@ namespace CalamityMod Main.tileLavaDeath[mt.Type] = !lavaImmune; Main.tileWaterDeath[mt.Type] = false; TileID.Sets.CountsAsWaterSource[mt.Type] = water; - TileID.Sets.CountsAsHoneySource[mt.Type] = lava; - TileID.Sets.CountsAsLavaSource[mt.Type] = honey; + TileID.Sets.CountsAsLavaSource[mt.Type] = lava; + TileID.Sets.CountsAsHoneySource[mt.Type] = honey; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = !lavaImmune; TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index b738d34df0..88bb34ef06 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -153,7 +153,8 @@ namespace CalamityMod // Rapiers, whips, and other specific vanilla weapons (ie. Zenith or Excalibur) are specifically excluded from this, so they get broadsword reforges despite not scaling with melee speed. // // 18FEB2024: Ozzatron: removed the (item.channel || item.noMelee) because vanilla lets Burning Sky get Legendary - else if (item.channel && item.useStyle != ItemUseStyleID.Rapier && !item.CountsAsClass() && !PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type]) + // 12MAY2024: Shade: added item.useStyle != ItemUseStyleID.Shoot because vanilla lets Sahara Slicers and Death's Ascension get Legendary + else if (item.channel && item.useStyle != ItemUseStyleID.Rapier && !item.CountsAsClass() && !PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] && item.useStyle != ItemUseStyleID.Shoot) { int[][] meleeNoSpeedReforgeTiers = new int[][] { diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 84aa4a19d2..08c4955552 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -38,9 +38,9 @@ namespace CalamityMod return 0; int count = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (!typesToCheck.Contains(Main.npc[i].type) || !Main.npc[i].active) + if (!typesToCheck.Contains(n.type)) continue; count++; @@ -147,7 +147,7 @@ namespace CalamityMod // "Non-enemies" (e.g. butterflies or projectile enemies) with near zero max health, // or anything but the strongest enemies with no contact damage (e.g. Celestial Pillars, Providence) // do not generate rage. - if (npc.lifeMax <= BalancingConstants.TinyHealthThreshold || (npc.damage <= BalancingConstants.TinyDamageThreshold && npc.lifeMax <= BalancingConstants.NoContactDamageHealthThreshold)) + if (npc.lifeMax <= BalancingConstants.TinyHealthThreshold || (npc.defDamage <= BalancingConstants.TinyDamageThreshold && npc.lifeMax <= BalancingConstants.NoContactDamageHealthThreshold)) return false; // Also explicitly exclude dummies and anything with a ridiculous health pool (dummies from Fargo's for example). if (npc.type == NPCID.TargetDummy || npc.type == NPCType() || npc.lifeMax > BalancingConstants.UnreasonableHealthThreshold) @@ -174,18 +174,14 @@ namespace CalamityMod public static bool AnyBossNPCS(bool checkForMechs = false) { - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - if (Main.npc[i] != null) + if (npc.IsABoss()) { - NPC npc = Main.npc[i]; - if (npc.IsABoss()) - { - // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. - if (checkForMechs) - return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; - return true; - } + // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. + if (checkForMechs) + return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; + return true; } } return FindFirstProjectile(ProjectileType()) != -1; @@ -267,6 +263,7 @@ namespace CalamityMod // If we've found a valid boss target, ignore ALL targets which aren't bosses. if (bossFound && !(Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye)) continue; + if (Main.npc[index].CanBeChasedBy(null, false)) { float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); @@ -275,10 +272,11 @@ namespace CalamityMod if (extraDistance < distance && !ignoreTiles) canHit = Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1); - if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && canHit) + if (Vector2.Distance(origin, Main.npc[index].Center) < distance && canHit) { if (Main.npc[index].boss || Main.npc[index].type == NPCID.WallofFleshEye) bossFound = true; + distance = Vector2.Distance(origin, Main.npc[index].Center); closestTarget = Main.npc[index]; } @@ -297,7 +295,7 @@ namespace CalamityMod if (extraDistance < distance && !ignoreTiles) canHit = Collision.CanHit(origin, 1, 1, Main.npc[index].Center, 1, 1); - if (Vector2.Distance(origin, Main.npc[index].Center) < (distance + extraDistance) && canHit) + if (Vector2.Distance(origin, Main.npc[index].Center) < distance && canHit) { distance = Vector2.Distance(origin, Main.npc[index].Center); closestTarget = Main.npc[index]; @@ -495,12 +493,11 @@ namespace CalamityMod return; Projectile projectile = null; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - projectile = Main.projectile[i]; - if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == playerIndex) + if (p.bobber && p.owner == playerIndex) { - projectile = Main.projectile[i]; + projectile = p; break; } } diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 0a34629ef5..8d3a596706 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -22,10 +22,9 @@ namespace CalamityMod { // Efficiently loop through all projectiles, using a specially designed continue continue that attempts to minimize the amount of OR // checks per iteration. - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p.type != projectileID || !p.active) + if (p.type != projectileID) continue; return true; @@ -34,19 +33,6 @@ namespace CalamityMod return false; } - public static IEnumerable AllProjectilesByID(int projectileID) - { - // This uses the same efficient loop idea as AnyProjectiles. - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile p = Main.projectile[i]; - if (p.type != projectileID || !p.active) - continue; - - yield return p; - } - } - public static int CountProjectiles(int projectileID) => Main.projectile.Count(proj => proj.type == projectileID && proj.active); public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); @@ -71,12 +57,12 @@ namespace CalamityMod if (Main.netMode == NetmodeID.SinglePlayer) return Main.projectile[identity]; - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].identity != identity || Main.projectile[i].owner != ownerIndex || !Main.projectile[i].active) + if (p.identity != identity || p.owner != ownerIndex) continue; - return Main.projectile[i]; + return p; } return null; } @@ -109,17 +95,17 @@ namespace CalamityMod // Find the closest target. float npcDistCompare = 25000f; // Initializing the value to a large number so the first entry is basically guaranteed to replace it. int index = -1; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); - if (!Main.npc[i].CanBeChasedBy(projectile, false) || !projectile.WithinRange(Main.npc[i].Center, maxDistance + extraDistance)) + float extraDistance = (n.width / 2) + (n.height / 2); + if (!n.CanBeChasedBy(projectile, false) || !projectile.WithinRange(n.Center, maxDistance + extraDistance)) continue; - float currentNPCDist = Vector2.Distance(Main.npc[i].Center, projectile.Center); - if ((currentNPCDist < npcDistCompare) && (ignoreTiles || Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1))) + float currentNPCDist = Vector2.Distance(n.Center, projectile.Center); + if ((currentNPCDist < npcDistCompare) && (ignoreTiles || Collision.CanHit(projectile.Center, 1, 1, n.Center, 1, 1))) { npcDistCompare = currentNPCDist; - index = i; + index = n.whoAmI; } } // If the index was never changed, don't do anything. Otherwise, tell the projectile where to home. @@ -276,9 +262,8 @@ namespace CalamityMod int[] array = new int[Main.maxNPCs]; int targetArrayA = 0; int targetArrayB = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC npc in Main.ActiveNPCs) { - NPC npc = Main.npc[i]; if (npc.CanBeChasedBy(projectile, false)) { float enemyDist = Vector2.Distance(projectile.Center, npc.Center); @@ -286,12 +271,12 @@ namespace CalamityMod { if (Collision.CanHit(projectile.position, 1, 1, npc.position, npc.width, npc.height) && enemyDist > 50f) { - array[targetArrayB] = i; + array[targetArrayB] = npc.whoAmI; targetArrayB++; } else if (targetArrayB == 0) { - array[targetArrayA] = i; + array[targetArrayA] = npc.whoAmI; targetArrayA++; } } @@ -322,21 +307,21 @@ namespace CalamityMod int[] targetArray = new int[maxTargets]; int targetArrayIndex = 0; - for (int i = 0; i < Main.maxNPCs; i++) + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[i].CanBeChasedBy(projectile, false)) + if (n.CanBeChasedBy(projectile, false)) { - float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + float extraDistance = (n.width / 2) + (n.height / 2); bool canHit = true; if (extraDistance < maxDistance) - canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); + canHit = Collision.CanHit(projectile.Center, 1, 1, n.Center, 1, 1); - if (projectile.WithinRange(Main.npc[i].Center, maxDistance + extraDistance) && canHit) + if (projectile.WithinRange(n.Center, maxDistance + extraDistance) && canHit) { if (targetArrayIndex < maxTargets) { - targetArray[targetArrayIndex] = i; + targetArray[targetArrayIndex] = n.whoAmI; targetArrayIndex++; homeIn = true; } @@ -575,13 +560,12 @@ namespace CalamityMod int existingTurrets = player.ownedProjectileCounts[Type]; if (existingTurrets > 0) { - for (int i = 0; i < Main.maxProjectiles; i++) + foreach (Projectile p in Main.ActiveProjectiles) { - if (Main.projectile[i].type == Type && - Main.projectile[i].owner == player.whoAmI && - Main.projectile[i].active) + if (p.type == Type && + p.owner == player.whoAmI) { - Main.projectile[i].Kill(); + p.Kill(); existingTurrets--; if (existingTurrets <= 0) break; diff --git a/Utilities/RicoshotUtils.cs b/Utilities/RicoshotUtils.cs index f79a060cc9..697fba3fc1 100644 --- a/Utilities/RicoshotUtils.cs +++ b/Utilities/RicoshotUtils.cs @@ -32,10 +32,9 @@ namespace CalamityMod int count = 0; int id = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile p = Main.projectile[i]; - if (p is null || !p.active || p.owner != player.whoAmI) + if (p.owner != player.whoAmI) continue; if (p.type == id) ++count; @@ -98,10 +97,9 @@ namespace CalamityMod // Search for all nearby coins. // Coins do not necessarily have to be owned by the same player as the searching projectile! int coinID = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (!proj.active || proj.ModProjectile is null || proj.type != coinID) + if (proj.ModProjectile is null || proj.type != coinID) continue; // Coins that have already been struck are ignored. @@ -173,10 +171,9 @@ namespace CalamityMod bool foundAnyBullseye = false; float closestBullseyeDistance = DaawnlightSpiritOrigin.RicoshotSearchDistance; int bullseyeID = ModContent.ProjectileType(); - for (int i = 0; i < Main.maxProjectiles; ++i) + foreach (Projectile proj in Main.ActiveProjectiles) { - Projectile proj = Main.projectile[i]; - if (proj is null || !proj.active || proj.ModProjectile is null || proj.type != bullseyeID || proj.owner != theShot.owner) + if (proj.ModProjectile is null || proj.type != bullseyeID || proj.owner != theShot.owner) continue; // Do a distance check. diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index 74c5cee36f..a657958050 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Abyss.AbyssAmbient; @@ -11,6 +12,7 @@ using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -21,12 +23,42 @@ namespace CalamityMod // OnModLoad is guaranteed to be run after all content has autoloaded. public static class TileFraming { + public sealed class MergeFrameData + { + public byte[,] AdjacencyData { get; } + + public int TileID { get; } + + public int FrameOffsetX { get; } + + public int FrameOffsetY { get; } + + public Asset BlendSheet { get; } + + public MergeFrameData(byte[,] adjacencyData, int tileId, string blendSheetPath, int frameOffsetX = 0, int frameOffsetY = 0) + { + AdjacencyData = adjacencyData; + TileID = tileId; + FrameOffsetX = frameOffsetX; + FrameOffsetY = frameOffsetY; + + if (!cachedBlendSheets.TryGetValue(blendSheetPath, out var blendSheet)) + { + blendSheet = cachedBlendSheets[blendSheetPath] = ModContent.Request(blendSheetPath); + } + + BlendSheet = blendSheet; + } + } + private static int[][] PlantCheckAgainst; private static Dictionary VineToGrass; // CONSIDER -- This is a triangle array, but does it need to be? Main.tileMerge is a triangle array as well public static bool[][] tileMergeTypes; + private static Dictionary> cachedBlendSheets = new(); + #region Similarity Enum private enum Similarity { @@ -1927,23 +1959,37 @@ namespace CalamityMod /// /// Call this in SetStaticDefaults. Used to set up the adjacency data array with the correct dimensions. /// - internal static void SetUpUniversalMerge(int myType, int mergeType, out byte[,] adjacencyData) + internal static void SetUpUniversalMerge(int myType, int mergeType, string blendSheetPath, out MergeFrameData adjacencyData) { CalamityUtils.SetMerge(myType, mergeType, true); - adjacencyData = new byte[Main.tile.Width, Main.tile.Height]; + adjacencyData = new MergeFrameData(new byte[Main.tile.Width, Main.tile.Height], mergeType, blendSheetPath); } /// /// Call this in PostDraw. Uses adjacency data generated by GetAdjacencyData to draw the correct blend state over a given tile, regardless of what tile frame that tile is using /// - internal static void DrawUniversalMergeFrames(int x, int y, byte[,] adjacencyData, string blendSheetPath, int frameOffsetX = 0, int frameOffsetY = 0) + internal static void DrawUniversalMergeFrames(int x, int y, List mergeFrames) { - // 02OCT2023: MishiroUsui: The below code resulted in 30 fps drops in sulph sea, and general performance issues across the board in cal biomes - // DO NOT RE-ENABLE UNTIL THE ISSUE IS RESOLVED AND VERIFIED. - return; -#pragma warning disable CS0162 // Disable unreachable code errors while this code is disabled - - Texture2D blendLayer = ModContent.Request(blendSheetPath).Value; + Color shadingColour = Lighting.GetColor(x, y); + Tile myTile = Main.tile[x, y]; + + foreach (var frame in mergeFrames) + { + // If it hasn't yet been initialized somehow... for some reason. + if (frame is null) + continue; + + DrawUniversalMergeFrames(x, y, frame, shadingColour, myTile); + } + } + + internal static void DrawUniversalMergeFrames(int x, int y, MergeFrameData mergeFrameData, Color shadingColour, Tile myTile) + { + byte[,] adjacencyData = mergeFrameData.AdjacencyData; + var blendLayer = mergeFrameData.BlendSheet.Value; + int frameOffsetX = mergeFrameData.FrameOffsetX; + int frameOffsetY = mergeFrameData.FrameOffsetY; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(x * 16 - Main.screenPosition.X, y * 16 - Main.screenPosition.Y) + zero; @@ -1951,10 +1997,6 @@ namespace CalamityMod int subFrameX = frameOffsetX * 270; int subFrameY = frameOffsetY * 198; - Color shadingColour = Lighting.GetColor(x, y); - - Tile myTile = Main.tile[x, y]; - byte thisTileData = adjacencyData[x, y]; // Get tile variant number @@ -2301,19 +2343,21 @@ namespace CalamityMod Main.spriteBatch.Draw(blendLayer, drawOffset, new Rectangle?(new Rectangle(18 + randomFrameX36 + subFrameX, 54 + subFrameY, 18, 18)), shadingColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } #endregion -#pragma warning restore CS0162 // Disable unreachable code errors while this code is disabled } /// /// Call this in TileFrame. Used to generate adjacency data used in DrawUniversalMergeFrames. Tiles using this need a 2d byte array /// - internal static void GetAdjacencyData(int x, int y, int blendType, out byte adjacencyData) + internal static void GetAdjacencyData(int x, int y, MergeFrameData data) { + int blendType = data.TileID; + // bit to relative tile pos for reference // 4 0 5 // 3 X 1 // 7 2 6 // 01234567 + ref byte adjacencyData = ref data.AdjacencyData[x, y]; adjacencyData = 0b00000000; if (x < 0 || x >= Main.maxTilesX) diff --git a/Walls/IVisibleThroughWater.cs b/Walls/IVisibleThroughWater.cs new file mode 100644 index 0000000000..0affafae66 --- /dev/null +++ b/Walls/IVisibleThroughWater.cs @@ -0,0 +1,60 @@ +using System; +using System.Diagnostics; +using Microsoft.Xna.Framework; +using Terraria.Localization; +using Terraria.Map; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + /// + /// Walls that implement this interface may be revealed on the map through + /// water. This allows them to show on the map despite always being + /// submerged. + /// + public interface IVisibleThroughWater : ILoadable + { + int WaterMapEntry { get; set; } + } + + internal static class VisibleThroughWater + { + [Autoload(Side = ModSide.Client)] + private sealed class VisibleThroughWaterSystem : ModSystem + { + public override void AddRecipes() + { + InitializeWaterMapEntryLookups(); + } + } + + public const float WaterTransparency = 0.5f; + public static readonly Color WaterColor = new Color(9, 61, 191); + + public static void AddMapEntryWithWaterVisibility(this IVisibleThroughWater visibleThroughWater, Color baseColor, LocalizedText text = null) + { + AssertIsWall(visibleThroughWater, out var wall); + wall.AddMapEntry(baseColor, text); + wall.AddMapEntry(Color.Lerp(baseColor, WaterColor, WaterTransparency), text); + } + + public static void InitializeWaterMapEntryLookups() + { + foreach (var visibleThroughWater in CalamityMod.Instance.GetContent()) + { + AssertIsWall(visibleThroughWater, out var wall); + visibleThroughWater.WaterMapEntry = MapHelper.wallLookup[wall.Type] + 1; + } + } + + [DebuggerStepThrough] + [StackTraceHidden] + private static void AssertIsWall(IVisibleThroughWater visibleThroughWater, out ModWall wall) + { + if (visibleThroughWater is not ModWall theWall) + throw new InvalidCastException($"{nameof(IVisibleThroughWater)} is implemented on type {visibleThroughWater.GetType().FullName}; said type should inherit from {nameof(ModWall)}"); + + wall = theWall; + } + } +} diff --git a/Walls/NavystoneWall.cs b/Walls/NavystoneWall.cs index 80c3b49708..500df762c1 100644 --- a/Walls/NavystoneWall.cs +++ b/Walls/NavystoneWall.cs @@ -2,12 +2,14 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { - public class NavystoneWall : ModWall + public class NavystoneWall : ModWall, IVisibleThroughWater { + int IVisibleThroughWater.WaterMapEntry { get; set; } + public override void SetStaticDefaults() { DustType = 96; - AddMapEntry(new Color(16, 45, 48)); + this.AddMapEntryWithWaterVisibility(new Color(16, 45, 48)); } public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; diff --git a/Walls/NavystoneWallSafe.cs b/Walls/NavystoneWallSafe.cs index 4690d5bddf..ef276c3a45 100644 --- a/Walls/NavystoneWallSafe.cs +++ b/Walls/NavystoneWallSafe.cs @@ -4,13 +4,15 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { - public class NavystoneWallSafe : ModWall + public class NavystoneWallSafe : ModWall, IVisibleThroughWater { + int IVisibleThroughWater.WaterMapEntry { get; set; } + public override void SetStaticDefaults() { Main.wallHouse[Type] = true; DustType = 96; - AddMapEntry(new Color(0, 50, 50)); + this.AddMapEntryWithWaterVisibility(new Color(0, 50, 50)); } public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; diff --git a/Walls/SmoothNavystoneWall.cs b/Walls/SmoothNavystoneWall.cs index efffbffede..09dcbd2e6d 100644 --- a/Walls/SmoothNavystoneWall.cs +++ b/Walls/SmoothNavystoneWall.cs @@ -5,13 +5,15 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { - public class SmoothNavystoneWall : ModWall + public class SmoothNavystoneWall : ModWall, IVisibleThroughWater { + int IVisibleThroughWater.WaterMapEntry { get; set; } + public override void SetStaticDefaults() { Main.wallHouse[Type] = true; - AddMapEntry(new Color(27, 35, 36)); + this.AddMapEntryWithWaterVisibility(new Color(27, 35, 36)); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Walls/SulphurousSandWall.png b/Walls/SulphurousSandWall.png index 8f7a554dc5..e8e9ea87e6 100644 Binary files a/Walls/SulphurousSandWall.png and b/Walls/SulphurousSandWall.png differ diff --git a/Walls/SulphurousSandWallSafe.png b/Walls/SulphurousSandWallSafe.png index 8f7a554dc5..e8e9ea87e6 100644 Binary files a/Walls/SulphurousSandWallSafe.png and b/Walls/SulphurousSandWallSafe.png differ diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index dd83cb6b9d..bc1389ee03 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -83,13 +83,10 @@ namespace CalamityMod.World // Clients in multiplayer don't drop meteors. if (Main.netMode == NetmodeID.MultiplayerClient) return; - for (int i = 0; i < 255; i++) + foreach (Player _ in Main.ActivePlayers) { - if (Main.player[i].active) - { - meteorDropped = false; - break; - } + meteorDropped = false; + break; } // Check whether there is already too much ore. @@ -277,11 +274,11 @@ namespace CalamityMod.World } int avoidRectangleSize = 35; Rectangle rectangle = new Rectangle((i - avoidRectangleSize) * 16, (j - avoidRectangleSize) * 16, avoidRectangleSize * 2 * 16, avoidRectangleSize * 2 * 16); - for (int k = 0; k < Main.maxPlayers; k++) + foreach (Player player in Main.ActivePlayers) { - if (Main.player[k].active) + if (player.active) { - Rectangle value = new Rectangle((int)(Main.player[k].position.X + (float)(Main.player[k].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.player[k].position.Y + (float)(Main.player[k].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2); + Rectangle value = new Rectangle((int)(player.position.X + (float)(player.width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(player.position.Y + (float)(player.height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2); if (rectangle.Intersects(value)) { return false; diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index cb1e3dd3ea..f413f99e1e 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -77,7 +77,7 @@ namespace CalamityMod.World // Astral Chest has completely different loot in it if (type == ModContent.TileType()) { - PutItemInChest(ref chest, ModContent.ItemType(), 30, 80); + PutItemInChest(ref chest, ModContent.ItemType(), 30, 80); PutItemInChest(ref chest, ModContent.ItemType(), 10, 14); PutItemInChest(ref chest, ModContent.ItemType(), 8); PutItemInChest(ref chest, ModContent.ItemType(), 3, 5); diff --git a/build.txt b/build.txt index 4ae2df0d93..f6d015e792 100644 --- a/build.txt +++ b/build.txt @@ -1,6 +1,7 @@ author = Fabsol and the Dev Team -version = 2.0.3.011 +version = 2.0.4.001 displayName = Calamity Mod +modReferences = CalamityModMusic homepage = https://discord.gg/calamity buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*, .github\*, LICENSE, README.md, .editorconfig, .gitignore, .gitattributes, Effects\Compiler\* hideCode = false diff --git a/description.txt b/description.txt index 85d9d9d4bc..e72ac9e99c 100644 --- a/description.txt +++ b/description.txt @@ -20,5 +20,5 @@ A more detailed breakdown of the content available in Calamity: - 450+ tweaks and improvements to vanilla items - Cross-mod support for the Thorium Mod -PLEASE NOTE THAT THIS MOD DOES NOT INCLUDE THE CALAMITY SOUNDTRACK. -You need to install the Calamity Music Mod if you want Calamity music. +PLEASE NOTE THAT THIS MOD REQUIRES THE CALAMITY MUSIC MOD. +You will need to install "Calamity Mod Music" from the Mod Browser or the Workshop. diff --git a/description_workshop.txt b/description_workshop.txt index 0c12ea169a..172d508e9c 100644 --- a/description_workshop.txt +++ b/description_workshop.txt @@ -1,5 +1,6 @@ [h1]Calamity Mod[/h1] [url=https://discord.gg/calamity]Discord[/url] [url=https://calamitymod.wiki.gg]Official Wiki[/url] +[b]LIMITED TIME![/b] [url=https://calamitymod.com/plush]Gimme Swag Plushie Campaign[/url] The Calamity Mod is a vast content mod that creates a new and refreshing experience for Terraria! @@ -13,7 +14,7 @@ The mod additionally tweaks tons of vanilla features whilst adding new ones to a [*] Dozens more quality of life and balance changes! [/olist] -[i]Please note that this mod does [b]NOT[/b] include Calamity's soundtrack! You will need to download the music mod for the full intended experience![/i] +[i]Please note that this mod [b]REQUIRES[/b] Calamity's soundtrack! You will need to download the music mod to be able to play![/i] https://steamcommunity.com/sharedfiles/filedetails/?id=2824688266 [b]Be sure to join our Discord server linked above to keep up with the latest news about upcoming updates and features.[/b]